code
stringlengths
4
991k
repo_name
stringlengths
6
116
path
stringlengths
4
249
language
stringclasses
30 values
license
stringclasses
15 values
size
int64
4
991k
input_ids
listlengths
502
502
token_type_ids
listlengths
502
502
attention_mask
listlengths
502
502
labels
listlengths
502
502
<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> </head> <body> <h1>購入完了</h1> <p>ご購入ありがとうございました。</p> <p><a href="./index.html">トップに戻る</a> </body> </html>
smizy/DemoWebviewApsalar_android
app/src/main/assets/www2/thanks.html
HTML
mit
253
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 25869, 13462, 1027, 1000, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 1013, 2132, 1028, 1026, 2303, 1028, 1026, 1044, 2487, 1028, 100, 100, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Code generated by protoc-gen-go. DO NOT EDIT. // source: xds/core/v3/context_params.proto package xds_core_v3 import ( fmt "fmt" _ "github.com/cncf/udpa/go/udpa/annotations" proto "github.com/golang/protobuf/proto" math "math" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type ContextParams struct { Params map[string]string `protobuf:"bytes,1,rep,name=params,proto3" json:"params,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` } func (m *ContextParams) Reset() { *m = ContextParams{} } func (m *ContextParams) String() string { return proto.CompactTextString(m) } func (*ContextParams) ProtoMessage() {} func (*ContextParams) Descriptor() ([]byte, []int) { return fileDescriptor_a77d5b5f2f15aa7c, []int{0} } func (m *ContextParams) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ContextParams.Unmarshal(m, b) } func (m *ContextParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_ContextParams.Marshal(b, m, deterministic) } func (m *ContextParams) XXX_Merge(src proto.Message) { xxx_messageInfo_ContextParams.Merge(m, src) } func (m *ContextParams) XXX_Size() int { return xxx_messageInfo_ContextParams.Size(m) } func (m *ContextParams) XXX_DiscardUnknown() { xxx_messageInfo_ContextParams.DiscardUnknown(m) } var xxx_messageInfo_ContextParams proto.InternalMessageInfo func (m *ContextParams) GetParams() map[string]string { if m != nil { return m.Params } return nil } func init() { proto.RegisterType((*ContextParams)(nil), "xds.core.v3.ContextParams") proto.RegisterMapType((map[string]string)(nil), "xds.core.v3.ContextParams.ParamsEntry") } func init() { proto.RegisterFile("xds/core/v3/context_params.proto", fileDescriptor_a77d5b5f2f15aa7c) } var fileDescriptor_a77d5b5f2f15aa7c = []byte{ // 221 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xa8, 0x48, 0x29, 0xd6, 0x4f, 0xce, 0x2f, 0x4a, 0xd5, 0x2f, 0x33, 0xd6, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xad, 0x28, 0x89, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xae, 0x48, 0x29, 0xd6, 0x03, 0xa9, 0xd0, 0x2b, 0x33, 0x96, 0x92, 0x2d, 0x4d, 0x29, 0x48, 0xd4, 0x4f, 0xcc, 0xcb, 0xcb, 0x2f, 0x49, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x2f, 0x2e, 0x49, 0x2c, 0x29, 0x85, 0xaa, 0x55, 0xea, 0x62, 0xe4, 0xe2, 0x75, 0x86, 0x18, 0x12, 0x00, 0x36, 0x43, 0xc8, 0x8e, 0x8b, 0x0d, 0x62, 0x9a, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x9a, 0x1e, 0x92, 0x71, 0x7a, 0x28, 0x6a, 0xf5, 0x20, 0x94, 0x6b, 0x5e, 0x49, 0x51, 0x65, 0x10, 0x54, 0x97, 0x94, 0x25, 0x17, 0x37, 0x92, 0xb0, 0x90, 0x00, 0x17, 0x73, 0x76, 0x6a, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x88, 0x29, 0x24, 0xc2, 0xc5, 0x5a, 0x96, 0x98, 0x53, 0x9a, 0x2a, 0xc1, 0x04, 0x16, 0x83, 0x70, 0xac, 0x98, 0x2c, 0x18, 0x9d, 0xac, 0x77, 0x35, 0x9c, 0xb8, 0xc8, 0xc6, 0xc4, 0xc1, 0xc8, 0x25, 0x9d, 0x9c, 0x9f, 0xab, 0x97, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x07, 0xf2, 0x00, 0xb2, 0x1b, 0x9c, 0x84, 0x50, 0x1c, 0x11, 0x00, 0xf2, 0x47, 0x00, 0x63, 0x12, 0x1b, 0xd8, 0x43, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x4e, 0x2e, 0x13, 0x20, 0x01, 0x00, 0x00, }
tgraf/cilium
vendor/github.com/cncf/udpa/go/xds/core/v3/context_params.pb.go
GO
apache-2.0
3,805
[ 30522, 1013, 1013, 3642, 7013, 2011, 15053, 2278, 1011, 8991, 1011, 2175, 1012, 2079, 2025, 10086, 1012, 1013, 1013, 3120, 1024, 1060, 5104, 1013, 4563, 1013, 1058, 2509, 1013, 6123, 1035, 11498, 5244, 1012, 15053, 7427, 1060, 5104, 1035, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package es.uvigo.esei.sing.bdbm.gui.configuration; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.EventListener; import java.util.EventObject; import java.util.concurrent.Callable; import javax.swing.AbstractAction; import javax.swing.GroupLayout; import javax.swing.GroupLayout.Alignment; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import es.uvigo.esei.sing.bdbm.gui.BDBMGUIController; public class ConfigurationPanel extends JPanel { private static final long serialVersionUID = 1L; private final BDBMGUIController controller; private final JTextField txtRepository; private final JTextField txtBLAST; private final JTextField txtEMBOSS; private final JTextField txtBedTools; private final JTextField txtSplign; private final JTextField txtCompart; private final JButton btnBuildRepository; public ConfigurationPanel(BDBMGUIController controller) { super(); this.controller = controller; // this.setPreferredSize(new Dimension(600, 140)); final GroupLayout layout = new GroupLayout(this); layout.setAutoCreateContainerGaps(true); layout.setAutoCreateGaps(true); this.setLayout(layout); final JLabel lblRepository = new JLabel("Repository Path"); final JLabel lblBLAST = new JLabel("BLAST Path"); final JLabel lblEMBOSS = new JLabel("EMBOSS Path"); final JLabel lblBedTools = new JLabel("BedTools Path"); final JLabel lblSplign = new JLabel("Splign Path"); final JLabel lblCompart = new JLabel("Compart Path"); final File repositoryPath = this.controller.getEnvironment() .getRepositoryPaths().getBaseDirectory(); final File blastBD = this.controller.getEnvironment() .getBLASTBinaries().getBaseDirectory(); final File embossBD = this.controller.getEnvironment() .getEMBOSSBinaries().getBaseDirectory(); final File bedToolsBD = this.controller.getEnvironment() .getBedToolsBinaries().getBaseDirectory(); final File splignBD = this.controller.getEnvironment() .getSplignBinaries().getBaseDirectory(); final File compartBD = this.controller.getEnvironment() .getCompartBinaries().getBaseDirectory(); this.txtRepository = new JTextField(repositoryPath.getAbsolutePath()); this.txtBLAST = new JTextField(blastBD == null ? "" : blastBD.getAbsolutePath()); this.txtEMBOSS = new JTextField(embossBD == null ? "" : embossBD.getAbsolutePath()); this.txtBedTools = new JTextField(bedToolsBD == null ? "" : bedToolsBD.getAbsolutePath()); this.txtSplign = new JTextField(splignBD == null ? "" : splignBD.getAbsolutePath()); this.txtCompart = new JTextField(compartBD == null ? "" : compartBD.getAbsolutePath()); this.txtRepository.setEditable(false); this.txtBLAST.setEditable(false); this.txtEMBOSS.setEditable(false); this.txtBedTools.setEditable(false); this.txtSplign.setEditable(false); this.txtCompart.setEditable(false); final JButton btnRepository = new JButton("Select..."); final JButton btnBLASTSelect = new JButton("Select..."); final JButton btnEMBOSSSelect = new JButton("Select..."); final JButton btnBedToolsSelect = new JButton("Select..."); final JButton btnSplignSelect = new JButton("Select..."); final JButton btnCompartSelect = new JButton("Select..."); final JButton btnBLASTInPath = new JButton("In system path"); final JButton btnEMBOSSInPath = new JButton("In system path"); final JButton btnBedToolsInPath = new JButton("In system path"); final JButton btnSplignInPath = new JButton("In system path"); final JButton btnCompartInPath = new JButton("In system path"); this.btnBuildRepository = new JButton(new AbstractAction("Build") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { ConfigurationPanel.this.buildRepository(); } }); this.btnBuildRepository.setEnabled(false); layout.setVerticalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(lblRepository, Alignment.CENTER) .addComponent(this.txtRepository) .addComponent(btnRepository) .addComponent(this.btnBuildRepository) ) .addGroup(layout.createParallelGroup() .addComponent(lblBLAST, Alignment.CENTER) .addComponent(this.txtBLAST) .addComponent(btnBLASTSelect) .addComponent(btnBLASTInPath) ) .addGroup(layout.createParallelGroup() .addComponent(lblEMBOSS, Alignment.CENTER) .addComponent(this.txtEMBOSS) .addComponent(btnEMBOSSSelect) .addComponent(btnEMBOSSInPath) ) .addGroup(layout.createParallelGroup() .addComponent(lblBedTools, Alignment.CENTER) .addComponent(this.txtBedTools) .addComponent(btnBedToolsSelect) .addComponent(btnBedToolsInPath) ) .addGroup(layout.createParallelGroup() .addComponent(lblSplign, Alignment.CENTER) .addComponent(this.txtSplign) .addComponent(btnSplignSelect) .addComponent(btnSplignInPath) ) .addGroup(layout.createParallelGroup() .addComponent(lblCompart, Alignment.CENTER) .addComponent(this.txtCompart) .addComponent(btnCompartSelect) .addComponent(btnCompartInPath) ) ); layout.setHorizontalGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup() .addComponent(lblRepository) .addComponent(lblBLAST) .addComponent(lblEMBOSS) .addComponent(lblBedTools) .addComponent(lblSplign) .addComponent(lblCompart) ) .addGroup(layout.createParallelGroup() .addComponent(this.txtRepository) .addComponent(this.txtBLAST) .addComponent(this.txtEMBOSS) .addComponent(this.txtBedTools) .addComponent(this.txtSplign) .addComponent(this.txtCompart) ) .addGroup(layout.createParallelGroup() .addComponent(btnRepository) .addComponent(btnBLASTSelect) .addComponent(btnEMBOSSSelect) .addComponent(btnBedToolsSelect) .addComponent(btnSplignSelect) .addComponent(btnCompartSelect) ) .addGroup(layout.createParallelGroup() .addComponent(this.btnBuildRepository) .addComponent(btnBLASTInPath) .addComponent(btnEMBOSSInPath) .addComponent(btnBedToolsInPath) .addComponent(btnSplignInPath) .addComponent(btnCompartInPath) ) ); final Callable<Boolean> callbackRepositorySelection = new Callable<Boolean>() { @Override public Boolean call() { if (ConfigurationPanel.this.isValidRepositoryPath()) { btnBuildRepository.setEnabled(false); } else { btnBuildRepository.setEnabled(true); if (JOptionPane.showConfirmDialog( ConfigurationPanel.this, "Repository path does not exist or its structure is incomplete. Do you wish to build repository structure?", "Invalid Repository", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE ) == JOptionPane.YES_OPTION) { ConfigurationPanel.this.buildRepository(); } } return true; } }; btnRepository.addActionListener( new PathSelectionActionListener(this.txtRepository, callbackRepositorySelection) ); final Callable<Boolean> callbackCheckBLAST = new Callable<Boolean>() { @Override public Boolean call() { if (ConfigurationPanel.this.isValidBLASTPath()) { return true; } else { JOptionPane.showMessageDialog( ConfigurationPanel.this, "Invalid BLAST binaries path. Please, change the selected path", "Invalid Path", JOptionPane.ERROR_MESSAGE ); return false; } } }; btnBLASTSelect.addActionListener( new PathSelectionActionListener(this.txtBLAST, callbackCheckBLAST) ); btnBLASTInPath.addActionListener( new SystemPathSelectionActionListener(this.txtBLAST, callbackCheckBLAST) ); final Callable<Boolean> callbackCheckEMBOSS = new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (ConfigurationPanel.this.isValidEMBOSSPath()) { return true; } else { JOptionPane.showMessageDialog( ConfigurationPanel.this, "Invalid EMBOSS binaries path. Please, change the selected path", "Invalid Path", JOptionPane.ERROR_MESSAGE ); return false; } } }; btnEMBOSSSelect.addActionListener( new PathSelectionActionListener(this.txtEMBOSS, callbackCheckEMBOSS) ); btnEMBOSSInPath.addActionListener( new SystemPathSelectionActionListener(this.txtEMBOSS, callbackCheckEMBOSS) ); final Callable<Boolean> callbackCheckBedTools = new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (ConfigurationPanel.this.isValidBedToolsPath()) { return true; } else { JOptionPane.showMessageDialog( ConfigurationPanel.this, "Invalid bedtools binaries path. Please, change the selected path", "Invalid Path", JOptionPane.ERROR_MESSAGE ); return false; } } }; btnBedToolsSelect.addActionListener( new PathSelectionActionListener(this.txtBedTools, callbackCheckBedTools) ); btnBedToolsInPath.addActionListener( new SystemPathSelectionActionListener(this.txtBedTools, callbackCheckBedTools) ); final Callable<Boolean> callbackCheckSplign = new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (ConfigurationPanel.this.isValidSplignPath()) { return true; } else { JOptionPane.showMessageDialog( ConfigurationPanel.this, "Invalid splign binaries path. Please, change the selected path", "Invalid Path", JOptionPane.ERROR_MESSAGE ); return false; } } }; btnSplignSelect.addActionListener( new PathSelectionActionListener(this.txtSplign, callbackCheckSplign) ); btnSplignInPath.addActionListener( new SystemPathSelectionActionListener(this.txtSplign, callbackCheckSplign) ); final Callable<Boolean> callbackCheckCompart = new Callable<Boolean>() { @Override public Boolean call() throws Exception { if (ConfigurationPanel.this.isValidCompartPath()) { return true; } else { JOptionPane.showMessageDialog( ConfigurationPanel.this, "Invalid compart binaries path. Please, change the selected path", "Invalid Path", JOptionPane.ERROR_MESSAGE ); return false; } } }; btnCompartSelect.addActionListener( new PathSelectionActionListener(this.txtCompart, callbackCheckCompart) ); btnCompartInPath.addActionListener( new SystemPathSelectionActionListener(this.txtCompart, callbackCheckCompart) ); } public void addConfigurationChangeListener(ConfigurationChangeEventListener listener) { this.listenerList.add(ConfigurationChangeEventListener.class, listener); } public void removeConfigurationChangeListener(ConfigurationChangeEventListener listener) { this.listenerList.remove(ConfigurationChangeEventListener.class, listener); } protected void fireChangeEvent(ConfigurationChangeEvent event) { final ConfigurationChangeEventListener[] listeners = this.listenerList.getListeners(ConfigurationChangeEventListener.class); for (ConfigurationChangeEventListener listener : listeners) { listener.configurationChanged(event); } } protected void fireChange() { this.fireChangeEvent(new ConfigurationChangeEvent(this)); } protected File getRepositoryDirectory() { return new File(this.txtRepository.getText()); } protected String getBLASTPath() { return this.txtBLAST.getText().isEmpty() ? null : new File(this.txtBLAST.getText()).getAbsolutePath(); } protected String getEMBOSSPath() { return this.txtEMBOSS.getText().isEmpty() ? null : new File(this.txtEMBOSS.getText()).getAbsolutePath(); } protected String getBedToolsPath() { return this.txtBedTools.getText().isEmpty() ? null : new File(this.txtBedTools.getText()).getAbsolutePath(); } protected String getSplignPath() { return this.txtSplign.getText().isEmpty() ? null : new File(this.txtSplign.getText()).getAbsolutePath(); } protected String getCompartPath() { return this.txtCompart.getText().isEmpty() ? null : new File(this.txtCompart.getText()).getAbsolutePath(); } public boolean isValidRepositoryPath() { return this.controller.getEnvironment() .getRepositoryPaths() .checkBaseDirectory(getRepositoryDirectory()); } public boolean isValidBLASTPath() { return this.controller.getManager().checkBLASTPath(getBLASTPath()); } protected boolean isValidEMBOSSPath() { return this.controller.getManager().checkEMBOSSPath(getEMBOSSPath()); } protected boolean isValidBedToolsPath() { return this.controller.getManager().checkBedToolsPath(getBedToolsPath()); } protected boolean isValidSplignPath() { return this.controller.getManager().checkSplignPath(getSplignPath()); } protected boolean isValidCompartPath() { return this.controller.getManager().checkCompartPath(getCompartPath()); } protected void buildRepository() { try { this.controller.getEnvironment() .getRepositoryPaths() .buildBaseDirectory(this.getRepositoryDirectory()); this.btnBuildRepository.setEnabled(false); JOptionPane.showMessageDialog( ConfigurationPanel.this, "Repository structure was correctly built.", "Repository Built", JOptionPane.INFORMATION_MESSAGE ); this.fireChange(); } catch (Exception e) { this.btnBuildRepository.setEnabled(true); JOptionPane.showMessageDialog( ConfigurationPanel.this, "Error building repository. Please, check path and press 'Build' or change path", "Repository Building Error", JOptionPane.ERROR_MESSAGE ); } } public PathsConfiguration getConfiguration() { if (this.isValidRepositoryPath() && this.isValidBLASTPath()) { final String blastPath = this.getBLASTPath(); final String embossPath = this.getEMBOSSPath(); final String bedToolsPath = this.getBedToolsPath(); final String splignPath = this.getSplignPath(); final String compartPath = this.getCompartPath(); return new PathsConfiguration( this.getRepositoryDirectory(), blastPath == null ? null : new File(blastPath), embossPath == null ? null : new File(embossPath), bedToolsPath == null ? null : new File(bedToolsPath), splignPath == null ? null : new File(splignPath), compartPath == null ? null : new File(compartPath) ); } else { return null; } } private final class SystemPathSelectionActionListener implements ActionListener { private final JTextField txtAssociated; private final Callable<Boolean> callback; private SystemPathSelectionActionListener(JTextField txtAssociated, Callable<Boolean> callback) { this.txtAssociated = txtAssociated; this.callback = callback; } @Override public void actionPerformed(ActionEvent e) { final String previousPath = this.txtAssociated.getText(); this.txtAssociated.setText(""); try { if (this.callback.call()) { ConfigurationPanel.this.fireChange(); } else { txtAssociated.setText(previousPath); } } catch (Exception ex) { throw new RuntimeException(ex); } } } private final class PathSelectionActionListener implements ActionListener { private final JTextField txtAssociated; private final Callable<Boolean> callback; private PathSelectionActionListener(JTextField txtAssociated, Callable<Boolean> callback) { this.txtAssociated = txtAssociated; this.callback = callback; } @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser = new JFileChooser( new File(txtAssociated.getText()) ); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); if (chooser.showOpenDialog(ConfigurationPanel.this) == JFileChooser.APPROVE_OPTION) { final String previousPath = txtAssociated.getText(); txtAssociated.setText(chooser.getSelectedFile().getAbsolutePath()); try { if (this.callback.call()) { ConfigurationPanel.this.fireChange(); } else { txtAssociated.setText(previousPath); } } catch (Exception e1) { throw new RuntimeException(e1); } } } } public static class ConfigurationChangeEvent extends EventObject { private static final long serialVersionUID = 1L; private final PathsConfiguration configuration; protected ConfigurationChangeEvent(ConfigurationPanel panel) { this(panel, panel.getConfiguration()); } public ConfigurationChangeEvent(Object source, PathsConfiguration configuration) { super(source); this.configuration = configuration; } public PathsConfiguration getConfiguration() { return configuration; } } public static interface ConfigurationChangeEventListener extends EventListener { public void configurationChanged(ConfigurationChangeEvent event); } }
mrjato/BDBM
gui/es/uvigo/esei/sing/bdbm/gui/configuration/ConfigurationPanel.java
Java
lgpl-3.0
16,988
[ 30522, 7427, 9686, 1012, 23068, 14031, 1012, 9686, 7416, 1012, 6170, 1012, 1038, 18939, 2213, 1012, 26458, 1012, 9563, 1025, 12324, 9262, 1012, 22091, 2102, 1012, 2724, 1012, 2895, 18697, 3372, 1025, 12324, 9262, 1012, 22091, 2102, 1012, 27...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"29027050","logradouro":"Escadaria Desembargador Faria Santos","bairro":"Ariovaldo Favalessa","cidade":"Vit\u00f3ria","uf":"ES","estado":"Esp\u00edrito Santo"});
lfreneda/cepdb
api/v1/29027050.jsonp.js
JavaScript
cc0-1.0
175
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 17222, 22907, 2692, 12376, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 9686, 3540, 7662, 2401, 4078, 6633, 8237, 3654, 7983, 2521, 2401, 11053, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using System; namespace TheUnacademicPortfolio.Commons.Dtos { public class BaseDto { public Guid Id { get; set; } } }
pichardoJ/TheUnacademicPortfolio
src/TheUnacademicPortfolio.Commons/Dtos/BaseDto.cs
C#
apache-2.0
141
[ 30522, 2478, 2291, 1025, 3415, 15327, 1996, 9521, 21869, 7712, 6442, 14876, 12798, 1012, 7674, 1012, 26718, 2891, 1063, 2270, 2465, 2241, 3406, 1063, 2270, 26458, 2094, 8909, 1063, 2131, 1025, 2275, 1025, 1065, 1065, 1065, 102, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * @param parseObject [ParseObject] * @return [Object] * */ export const convertBrand = (parseObject) => { const ret = {}; const object = parseObject.toJSON(); ret.id = object.objectId; ret.name = object.name; ret.description = object.description; ret.images = (object.images || []).map(image => ({ id: image.objectId, url: image.file.url })); return ret; }; /* * @param parseObject [ParseObject] * @return [Object] * */ export const convertProduct = (parseObject) => { const ret = {}; const object = parseObject.toJSON(); ret.id = object.objectId; ret.brand_id = object.brand.objectId; ret.name = object.name; ret.description = object.description; ret.images = object.images.map(image => ({ id: image.objectId, url: image.file.url })); ret.size = object.size; ret.color = object.color; ret.cost = object.cost; ret.price = object.price; ret.quantity = object.quantity; return ret; };
ihenvyr/react-parse
src/utils.js
JavaScript
mit
934
[ 30522, 1013, 1008, 1008, 1030, 11498, 2213, 11968, 3366, 16429, 20614, 1031, 11968, 3366, 16429, 20614, 1033, 1008, 1030, 2709, 1031, 4874, 1033, 1008, 1008, 1013, 9167, 9530, 3367, 10463, 23544, 1027, 1006, 11968, 3366, 16429, 20614, 1007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML> <!-- Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ --> <html><head> <meta charset="utf-8"> <title>Reference: Masonry layout with multiple `align-tracks` values</title> <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com"> <style> html,body { color:black; background-color:white; font:15px/1 "Courier New", monospace; padding:0; margin:0; } grid { display: inline-grid; grid-template-rows: auto; grid-template-columns: repeat(8,50px); /*intentionally one more than align-tracks values*/ gap: 3px 5px; padding: 10px 3px 1px 7px; border: solid; border-width: 1px 7px 3px 5px; background: lightgrey content-box; height: 500px; vertical-align: top; } .fallback { grid-template-columns:3px; padding:0; border:0; } item { background: grey; height: 2em; position: relative; border: 1px solid; } .purple { background:purple; height:auto; border-top:3px solid; } z { display: block; background: yellow; height: 0; width:80%; } a { position: absolute; inset: 0; top: auto; border: 2px solid lime; } masonry-track { display: grid; gap: 3px 5px; } masonry-track:nth-child(1) { align-content:start } masonry-track:nth-child(2) { align-content:end } masonry-track:nth-child(3) { align-content:center } masonry-track:nth-child(4) { align-content:stretch; grid-template-rows: auto auto repeat(3,max-content) } masonry-track:nth-child(5) { align-content:space-between } masonry-track:nth-child(6) { align-content:space-around } masonry-track:nth-child(7) { align-content:space-evenly } masonry-track:nth-child(8) { align-content:space-evenly } </style> </head> <body> <grid> <masonry-track> <item style="width:25px">1</item> <item>11</item> <item class="purple">20</item> <item class="purple">24</item> <item>29</item> </masonry-track> <masonry-track> <item class="purple" style="height:50px">2</item> <item class="purple" style="writing-mode:vertical-rl">16 vertical-rl</item> </masonry-track> <masonry-track> <item style="margin-left:5px">3</item> <item class="purple">12<z></z></item> <item>17</item> <item>25</item> <item>33</item> </masonry-track> <masonry-track> <item class="purple" style="margin-top:5px">4</item> <item class="purple">10</item> <item>15</item> <item>23</item> <item>31</item> </masonry-track> <masonry-track> <item>5</item> <item>13</item> <item>21</item> <item class="purple">28</item> </masonry-track> <masonry-track> <item class="purple">6<a></a></item> <item>9<a></a></item> <item class="purple">18</item> <item class="purple">22</item> <item>27</item> </masonry-track> <masonry-track> <item>7</item> <item class="purple">14<z></z><a></a></item> <item>19</item> <item class="purple">26</item> <item class="purple">30</item> </masonry-track> <masonry-track> <item class="purple" style="writing-mode:vertical-lr">8 vertical-lr</item> <item class="purple">32</item> </masonry-track> </grid> <grid class="fallback" style="align-content:start"> <item></item> </grid> <grid class="fallback" style="align-content:center"> <item></item> </grid> <grid class="fallback" style="align-content:center"> <item></item> </grid> </body></html>
chromium/chromium
third_party/blink/web_tests/external/wpt/css/css-grid/masonry/tentative/masonry-align-tracks-multi-001-ref.html
HTML
bsd-3-clause
3,268
[ 30522, 1026, 999, 9986, 13874, 16129, 1028, 1026, 999, 1011, 1011, 2151, 9385, 2003, 4056, 2000, 1996, 2270, 5884, 1012, 8299, 1024, 1013, 1013, 5541, 9006, 16563, 1012, 8917, 1013, 2270, 9527, 8113, 1013, 5717, 1013, 1015, 1012, 1014, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*jslint browser: true*/ /*global Tangram, gui */ map = (function () { 'use strict'; var locations = { 'Yangon': [16.8313077,96.2187007,7] }; var map_start_location = locations['Yangon']; /*** Map ***/ var map = L.map('map', {"keyboardZoomOffset" : .05, maxZoom: 20 } ); var layer = Tangram.leafletLayer({ scene: 'cinnabar-style-more-labels.yaml?r=2', attribution: '<a href="https://mapzen.com/tangram" target="_blank">Tangram</a> | &copy; OSM contributors | <a href="https://mapzen.com/" target="_blank">Mapzen</a>' }); window.layer = layer; var scene = layer.scene; window.scene = scene; // setView expects format ([lat, long], zoom) map.setView(map_start_location.slice(0, 3), map_start_location[2]); function long2tile(lon,zoom) { return (Math.floor((lon+180)/360*Math.pow(2,zoom))); } function lat2tile(lat,zoom) { return (Math.floor((1-Math.log(Math.tan(lat*Math.PI/180) + 1/Math.cos(lat*Math.PI/180))/Math.PI)/2 *Math.pow(2,zoom))); } /***** Render loop *****/ function addGUI () { // Link to edit in OSM - hold 'e' and click } // Feature selection function initFeatureSelection () { // Selection info shown on hover var selection_info = document.createElement('div'); selection_info.setAttribute('class', 'label'); selection_info.style.display = 'block'; // Show selected feature on hover scene.container.addEventListener('mousemove', function (event) { var pixel = { x: event.clientX, y: event.clientY }; scene.getFeatureAt(pixel).then(function(selection) { if (!selection) { return; } var feature = selection.feature; if (feature != null) { // console.log("selection map: " + JSON.stringify(feature)); var label = ''; if (feature.properties.name != null) { label = feature.properties.name; } if (label != '') { selection_info.style.left = (pixel.x + 5) + 'px'; selection_info.style.top = (pixel.y + 15) + 'px'; selection_info.innerHTML = '<span class="labelInner">' + label + '</span>'; scene.container.appendChild(selection_info); } else if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } } else if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } }); // Don't show labels while panning if (scene.panning == true) { if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } } }); // Show selected feature on hover scene.container.addEventListener('click', function (event) { var pixel = { x: event.clientX, y: event.clientY }; scene.getFeatureAt(pixel).then(function(selection) { if (!selection) { return; } var feature = selection.feature; if (feature != null) { // console.log("selection map: " + JSON.stringify(feature)); var label = ''; if (feature.properties != null) { // console.log(feature.properties); var obj = JSON.parse(JSON.stringify(feature.properties)); for (var x in feature.properties) { var val = feature.properties[x] label += "<span class='labelLine' key="+x+" value="+val+" onclick='setValuesFromSpan(this)'>"+x+" : "+val+"</span><br>" } } if (label != '') { selection_info.style.left = (pixel.x + 5) + 'px'; selection_info.style.top = (pixel.y + 15) + 'px'; selection_info.innerHTML = '<span class="labelInner">' + label + '</span>'; scene.container.appendChild(selection_info); } else if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } } else if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } }); // Don't show labels while panning if (scene.panning == true) { if (selection_info.parentNode != null) { selection_info.parentNode.removeChild(selection_info); } } }); } window.addEventListener('load', function () { // Scene initialized layer.on('init', function() { addGUI(); //initFeatureSelection(); }); layer.addTo(map); }); return map; }());
mapmeld/mvoter-usage
main.js
JavaScript
mit
4,919
[ 30522, 1013, 1008, 1046, 22908, 2102, 16602, 1024, 2995, 1008, 1013, 1013, 1008, 3795, 9745, 6444, 1010, 26458, 1008, 1013, 4949, 1027, 1006, 3853, 1006, 1007, 1063, 1005, 2224, 9384, 1005, 1025, 13075, 5269, 1027, 1063, 1005, 8675, 2239, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Created file "tmp\src\dxguid\dxguid" typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ extern const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } DEFINE_GUID(IID_IDirect3DDevice, 0x64108800, 0x957d, 0x11d0, 0x89, 0xab, 0x00, 0xa0, 0xc9, 0x05, 0x41, 0x29);
Frankie-PellesC/fSDK
Lib/src/dxguid8/dxguid000001EC.c
C
lgpl-3.0
452
[ 30522, 1013, 1013, 2580, 5371, 1000, 1056, 8737, 1032, 5034, 2278, 1032, 1040, 2595, 25698, 2094, 1032, 1040, 2595, 25698, 2094, 1000, 21189, 12879, 2358, 6820, 6593, 1035, 26458, 2094, 1063, 27121, 2146, 2951, 2487, 1025, 27121, 2460, 2951...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 1999 - 2006 Intel Corporation. */ #include "e1000.h" #include <net/ip6_checksum.h> #include <linux/io.h> #include <linux/prefetch.h> #include <linux/bitops.h> #include <linux/if_vlan.h> char e1000_driver_name[] = "e1000"; static char e1000_driver_string[] = "Intel(R) PRO/1000 Network Driver"; static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation."; /* e1000_pci_tbl - PCI Device ID Table * * Last entry must be all 0s * * Macro expands to... * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} */ static const struct pci_device_id e1000_pci_tbl[] = { INTEL_E1000_ETHERNET_DEVICE(0x1000), INTEL_E1000_ETHERNET_DEVICE(0x1001), INTEL_E1000_ETHERNET_DEVICE(0x1004), INTEL_E1000_ETHERNET_DEVICE(0x1008), INTEL_E1000_ETHERNET_DEVICE(0x1009), INTEL_E1000_ETHERNET_DEVICE(0x100C), INTEL_E1000_ETHERNET_DEVICE(0x100D), INTEL_E1000_ETHERNET_DEVICE(0x100E), INTEL_E1000_ETHERNET_DEVICE(0x100F), INTEL_E1000_ETHERNET_DEVICE(0x1010), INTEL_E1000_ETHERNET_DEVICE(0x1011), INTEL_E1000_ETHERNET_DEVICE(0x1012), INTEL_E1000_ETHERNET_DEVICE(0x1013), INTEL_E1000_ETHERNET_DEVICE(0x1014), INTEL_E1000_ETHERNET_DEVICE(0x1015), INTEL_E1000_ETHERNET_DEVICE(0x1016), INTEL_E1000_ETHERNET_DEVICE(0x1017), INTEL_E1000_ETHERNET_DEVICE(0x1018), INTEL_E1000_ETHERNET_DEVICE(0x1019), INTEL_E1000_ETHERNET_DEVICE(0x101A), INTEL_E1000_ETHERNET_DEVICE(0x101D), INTEL_E1000_ETHERNET_DEVICE(0x101E), INTEL_E1000_ETHERNET_DEVICE(0x1026), INTEL_E1000_ETHERNET_DEVICE(0x1027), INTEL_E1000_ETHERNET_DEVICE(0x1028), INTEL_E1000_ETHERNET_DEVICE(0x1075), INTEL_E1000_ETHERNET_DEVICE(0x1076), INTEL_E1000_ETHERNET_DEVICE(0x1077), INTEL_E1000_ETHERNET_DEVICE(0x1078), INTEL_E1000_ETHERNET_DEVICE(0x1079), INTEL_E1000_ETHERNET_DEVICE(0x107A), INTEL_E1000_ETHERNET_DEVICE(0x107B), INTEL_E1000_ETHERNET_DEVICE(0x107C), INTEL_E1000_ETHERNET_DEVICE(0x108A), INTEL_E1000_ETHERNET_DEVICE(0x1099), INTEL_E1000_ETHERNET_DEVICE(0x10B5), INTEL_E1000_ETHERNET_DEVICE(0x2E6E), /* required last entry */ {0,} }; MODULE_DEVICE_TABLE(pci, e1000_pci_tbl); int e1000_up(struct e1000_adapter *adapter); void e1000_down(struct e1000_adapter *adapter); void e1000_reinit_locked(struct e1000_adapter *adapter); void e1000_reset(struct e1000_adapter *adapter); int e1000_setup_all_tx_resources(struct e1000_adapter *adapter); int e1000_setup_all_rx_resources(struct e1000_adapter *adapter); void e1000_free_all_tx_resources(struct e1000_adapter *adapter); void e1000_free_all_rx_resources(struct e1000_adapter *adapter); static int e1000_setup_tx_resources(struct e1000_adapter *adapter, struct e1000_tx_ring *txdr); static int e1000_setup_rx_resources(struct e1000_adapter *adapter, struct e1000_rx_ring *rxdr); static void e1000_free_tx_resources(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring); static void e1000_free_rx_resources(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring); void e1000_update_stats(struct e1000_adapter *adapter); static int e1000_init_module(void); static void e1000_exit_module(void); static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent); static void e1000_remove(struct pci_dev *pdev); static int e1000_alloc_queues(struct e1000_adapter *adapter); static int e1000_sw_init(struct e1000_adapter *adapter); int e1000_open(struct net_device *netdev); int e1000_close(struct net_device *netdev); static void e1000_configure_tx(struct e1000_adapter *adapter); static void e1000_configure_rx(struct e1000_adapter *adapter); static void e1000_setup_rctl(struct e1000_adapter *adapter); static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter); static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter); static void e1000_clean_tx_ring(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring); static void e1000_clean_rx_ring(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring); static void e1000_set_rx_mode(struct net_device *netdev); static void e1000_update_phy_info_task(struct work_struct *work); static void e1000_watchdog(struct work_struct *work); static void e1000_82547_tx_fifo_stall_task(struct work_struct *work); static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev); static int e1000_change_mtu(struct net_device *netdev, int new_mtu); static int e1000_set_mac(struct net_device *netdev, void *p); static irqreturn_t e1000_intr(int irq, void *data); static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring); static int e1000_clean(struct napi_struct *napi, int budget); static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int *work_done, int work_to_do); static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int *work_done, int work_to_do); static void e1000_alloc_dummy_rx_buffers(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int cleaned_count) { } static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int cleaned_count); static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int cleaned_count); static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); static void e1000_enter_82542_rst(struct e1000_adapter *adapter); static void e1000_leave_82542_rst(struct e1000_adapter *adapter); static void e1000_tx_timeout(struct net_device *dev, unsigned int txqueue); static void e1000_reset_task(struct work_struct *work); static void e1000_smartspeed(struct e1000_adapter *adapter); static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb); static bool e1000_vlan_used(struct e1000_adapter *adapter); static void e1000_vlan_mode(struct net_device *netdev, netdev_features_t features); static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter, bool filter_on); static int e1000_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid); static int e1000_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid); static void e1000_restore_vlan(struct e1000_adapter *adapter); static int __maybe_unused e1000_suspend(struct device *dev); static int __maybe_unused e1000_resume(struct device *dev); static void e1000_shutdown(struct pci_dev *pdev); #ifdef CONFIG_NET_POLL_CONTROLLER /* for netdump / net console */ static void e1000_netpoll (struct net_device *netdev); #endif #define COPYBREAK_DEFAULT 256 static unsigned int copybreak __read_mostly = COPYBREAK_DEFAULT; module_param(copybreak, uint, 0644); MODULE_PARM_DESC(copybreak, "Maximum size of packet that is copied to a new buffer on receive"); static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state); static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev); static void e1000_io_resume(struct pci_dev *pdev); static const struct pci_error_handlers e1000_err_handler = { .error_detected = e1000_io_error_detected, .slot_reset = e1000_io_slot_reset, .resume = e1000_io_resume, }; static SIMPLE_DEV_PM_OPS(e1000_pm_ops, e1000_suspend, e1000_resume); static struct pci_driver e1000_driver = { .name = e1000_driver_name, .id_table = e1000_pci_tbl, .probe = e1000_probe, .remove = e1000_remove, .driver = { .pm = &e1000_pm_ops, }, .shutdown = e1000_shutdown, .err_handler = &e1000_err_handler }; MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver"); MODULE_LICENSE("GPL v2"); #define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK) static int debug = -1; module_param(debug, int, 0); MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); /** * e1000_get_hw_dev - helper function for getting netdev * @hw: pointer to HW struct * * return device used by hardware layer to print debugging information * **/ struct net_device *e1000_get_hw_dev(struct e1000_hw *hw) { struct e1000_adapter *adapter = hw->back; return adapter->netdev; } /** * e1000_init_module - Driver Registration Routine * * e1000_init_module is the first routine called when the driver is * loaded. All it does is register with the PCI subsystem. **/ static int __init e1000_init_module(void) { int ret; pr_info("%s\n", e1000_driver_string); pr_info("%s\n", e1000_copyright); ret = pci_register_driver(&e1000_driver); if (copybreak != COPYBREAK_DEFAULT) { if (copybreak == 0) pr_info("copybreak disabled\n"); else pr_info("copybreak enabled for " "packets <= %u bytes\n", copybreak); } return ret; } module_init(e1000_init_module); /** * e1000_exit_module - Driver Exit Cleanup Routine * * e1000_exit_module is called just before the driver is removed * from memory. **/ static void __exit e1000_exit_module(void) { pci_unregister_driver(&e1000_driver); } module_exit(e1000_exit_module); static int e1000_request_irq(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; irq_handler_t handler = e1000_intr; int irq_flags = IRQF_SHARED; int err; err = request_irq(adapter->pdev->irq, handler, irq_flags, netdev->name, netdev); if (err) { e_err(probe, "Unable to allocate interrupt Error: %d\n", err); } return err; } static void e1000_free_irq(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; free_irq(adapter->pdev->irq, netdev); } /** * e1000_irq_disable - Mask off interrupt generation on the NIC * @adapter: board private structure **/ static void e1000_irq_disable(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; ew32(IMC, ~0); E1000_WRITE_FLUSH(); synchronize_irq(adapter->pdev->irq); } /** * e1000_irq_enable - Enable default interrupt generation settings * @adapter: board private structure **/ static void e1000_irq_enable(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; ew32(IMS, IMS_ENABLE_MASK); E1000_WRITE_FLUSH(); } static void e1000_update_mng_vlan(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; u16 vid = hw->mng_cookie.vlan_id; u16 old_vid = adapter->mng_vlan_id; if (!e1000_vlan_used(adapter)) return; if (!test_bit(vid, adapter->active_vlans)) { if (hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) { e1000_vlan_rx_add_vid(netdev, htons(ETH_P_8021Q), vid); adapter->mng_vlan_id = vid; } else { adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; } if ((old_vid != (u16)E1000_MNG_VLAN_NONE) && (vid != old_vid) && !test_bit(old_vid, adapter->active_vlans)) e1000_vlan_rx_kill_vid(netdev, htons(ETH_P_8021Q), old_vid); } else { adapter->mng_vlan_id = vid; } } static void e1000_init_manageability(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; if (adapter->en_mng_pt) { u32 manc = er32(MANC); /* disable hardware interception of ARP */ manc &= ~(E1000_MANC_ARP_EN); ew32(MANC, manc); } } static void e1000_release_manageability(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; if (adapter->en_mng_pt) { u32 manc = er32(MANC); /* re-enable hardware interception of ARP */ manc |= E1000_MANC_ARP_EN; ew32(MANC, manc); } } /** * e1000_configure - configure the hardware for RX and TX * @adapter: private board structure **/ static void e1000_configure(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; int i; e1000_set_rx_mode(netdev); e1000_restore_vlan(adapter); e1000_init_manageability(adapter); e1000_configure_tx(adapter); e1000_setup_rctl(adapter); e1000_configure_rx(adapter); /* call E1000_DESC_UNUSED which always leaves * at least 1 descriptor unused to make sure * next_to_use != next_to_clean */ for (i = 0; i < adapter->num_rx_queues; i++) { struct e1000_rx_ring *ring = &adapter->rx_ring[i]; adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring)); } } int e1000_up(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; /* hardware has been reset, we need to reload some things */ e1000_configure(adapter); clear_bit(__E1000_DOWN, &adapter->flags); napi_enable(&adapter->napi); e1000_irq_enable(adapter); netif_wake_queue(adapter->netdev); /* fire a link change interrupt to start the watchdog */ ew32(ICS, E1000_ICS_LSC); return 0; } /** * e1000_power_up_phy - restore link in case the phy was powered down * @adapter: address of board private structure * * The phy may be powered down to save power and turn off link when the * driver is unloaded and wake on lan is not enabled (among others) * *** this routine MUST be followed by a call to e1000_reset *** **/ void e1000_power_up_phy(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u16 mii_reg = 0; /* Just clear the power down bit to wake the phy back up */ if (hw->media_type == e1000_media_type_copper) { /* according to the manual, the phy will retain its * settings across a power-down/up cycle */ e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg); mii_reg &= ~MII_CR_POWER_DOWN; e1000_write_phy_reg(hw, PHY_CTRL, mii_reg); } } static void e1000_power_down_phy(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; /* Power down the PHY so no link is implied when interface is down * * The PHY cannot be powered down if any of the following is true * * (a) WoL is enabled * (b) AMT is active * (c) SoL/IDER session is active */ if (!adapter->wol && hw->mac_type >= e1000_82540 && hw->media_type == e1000_media_type_copper) { u16 mii_reg = 0; switch (hw->mac_type) { case e1000_82540: case e1000_82545: case e1000_82545_rev_3: case e1000_82546: case e1000_ce4100: case e1000_82546_rev_3: case e1000_82541: case e1000_82541_rev_2: case e1000_82547: case e1000_82547_rev_2: if (er32(MANC) & E1000_MANC_SMBUS_EN) goto out; break; default: goto out; } e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg); mii_reg |= MII_CR_POWER_DOWN; e1000_write_phy_reg(hw, PHY_CTRL, mii_reg); msleep(1); } out: return; } static void e1000_down_and_stop(struct e1000_adapter *adapter) { set_bit(__E1000_DOWN, &adapter->flags); cancel_delayed_work_sync(&adapter->watchdog_task); /* * Since the watchdog task can reschedule other tasks, we should cancel * it first, otherwise we can run into the situation when a work is * still running after the adapter has been turned down. */ cancel_delayed_work_sync(&adapter->phy_info_task); cancel_delayed_work_sync(&adapter->fifo_stall_task); /* Only kill reset task if adapter is not resetting */ if (!test_bit(__E1000_RESETTING, &adapter->flags)) cancel_work_sync(&adapter->reset_task); } void e1000_down(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; u32 rctl, tctl; /* disable receives in the hardware */ rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); /* flush and sleep below */ netif_tx_disable(netdev); /* disable transmits in the hardware */ tctl = er32(TCTL); tctl &= ~E1000_TCTL_EN; ew32(TCTL, tctl); /* flush both disables and wait for them to finish */ E1000_WRITE_FLUSH(); msleep(10); /* Set the carrier off after transmits have been disabled in the * hardware, to avoid race conditions with e1000_watchdog() (which * may be running concurrently to us, checking for the carrier * bit to decide whether it should enable transmits again). Such * a race condition would result into transmission being disabled * in the hardware until the next IFF_DOWN+IFF_UP cycle. */ netif_carrier_off(netdev); napi_disable(&adapter->napi); e1000_irq_disable(adapter); /* Setting DOWN must be after irq_disable to prevent * a screaming interrupt. Setting DOWN also prevents * tasks from rescheduling. */ e1000_down_and_stop(adapter); adapter->link_speed = 0; adapter->link_duplex = 0; e1000_reset(adapter); e1000_clean_all_tx_rings(adapter); e1000_clean_all_rx_rings(adapter); } void e1000_reinit_locked(struct e1000_adapter *adapter) { while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) msleep(1); /* only run the task if not already down */ if (!test_bit(__E1000_DOWN, &adapter->flags)) { e1000_down(adapter); e1000_up(adapter); } clear_bit(__E1000_RESETTING, &adapter->flags); } void e1000_reset(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u32 pba = 0, tx_space, min_tx_space, min_rx_space; bool legacy_pba_adjust = false; u16 hwm; /* Repartition Pba for greater than 9k mtu * To take effect CTRL.RST is required. */ switch (hw->mac_type) { case e1000_82542_rev2_0: case e1000_82542_rev2_1: case e1000_82543: case e1000_82544: case e1000_82540: case e1000_82541: case e1000_82541_rev_2: legacy_pba_adjust = true; pba = E1000_PBA_48K; break; case e1000_82545: case e1000_82545_rev_3: case e1000_82546: case e1000_ce4100: case e1000_82546_rev_3: pba = E1000_PBA_48K; break; case e1000_82547: case e1000_82547_rev_2: legacy_pba_adjust = true; pba = E1000_PBA_30K; break; case e1000_undefined: case e1000_num_macs: break; } if (legacy_pba_adjust) { if (hw->max_frame_size > E1000_RXBUFFER_8192) pba -= 8; /* allocate more FIFO for Tx */ if (hw->mac_type == e1000_82547) { adapter->tx_fifo_head = 0; adapter->tx_head_addr = pba << E1000_TX_HEAD_ADDR_SHIFT; adapter->tx_fifo_size = (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; atomic_set(&adapter->tx_fifo_stall, 0); } } else if (hw->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) { /* adjust PBA for jumbo frames */ ew32(PBA, pba); /* To maintain wire speed transmits, the Tx FIFO should be * large enough to accommodate two full transmit packets, * rounded up to the next 1KB and expressed in KB. Likewise, * the Rx FIFO should be large enough to accommodate at least * one full receive packet and is similarly rounded up and * expressed in KB. */ pba = er32(PBA); /* upper 16 bits has Tx packet buffer allocation size in KB */ tx_space = pba >> 16; /* lower 16 bits has Rx packet buffer allocation size in KB */ pba &= 0xffff; /* the Tx fifo also stores 16 bytes of information about the Tx * but don't include ethernet FCS because hardware appends it */ min_tx_space = (hw->max_frame_size + sizeof(struct e1000_tx_desc) - ETH_FCS_LEN) * 2; min_tx_space = ALIGN(min_tx_space, 1024); min_tx_space >>= 10; /* software strips receive CRC, so leave room for it */ min_rx_space = hw->max_frame_size; min_rx_space = ALIGN(min_rx_space, 1024); min_rx_space >>= 10; /* If current Tx allocation is less than the min Tx FIFO size, * and the min Tx FIFO size is less than the current Rx FIFO * allocation, take space away from current Rx allocation */ if (tx_space < min_tx_space && ((min_tx_space - tx_space) < pba)) { pba = pba - (min_tx_space - tx_space); /* PCI/PCIx hardware has PBA alignment constraints */ switch (hw->mac_type) { case e1000_82545 ... e1000_82546_rev_3: pba &= ~(E1000_PBA_8K - 1); break; default: break; } /* if short on Rx space, Rx wins and must trump Tx * adjustment or use Early Receive if available */ if (pba < min_rx_space) pba = min_rx_space; } } ew32(PBA, pba); /* flow control settings: * The high water mark must be low enough to fit one full frame * (or the size used for early receive) above it in the Rx FIFO. * Set it to the lower of: * - 90% of the Rx FIFO size, and * - the full Rx FIFO size minus the early receive size (for parts * with ERT support assuming ERT set to E1000_ERT_2048), or * - the full Rx FIFO size minus one full frame */ hwm = min(((pba << 10) * 9 / 10), ((pba << 10) - hw->max_frame_size)); hw->fc_high_water = hwm & 0xFFF8; /* 8-byte granularity */ hw->fc_low_water = hw->fc_high_water - 8; hw->fc_pause_time = E1000_FC_PAUSE_TIME; hw->fc_send_xon = 1; hw->fc = hw->original_fc; /* Allow time for pending master requests to run */ e1000_reset_hw(hw); if (hw->mac_type >= e1000_82544) ew32(WUC, 0); if (e1000_init_hw(hw)) e_dev_err("Hardware Error\n"); e1000_update_mng_vlan(adapter); /* if (adapter->hwflags & HWFLAGS_PHY_PWR_BIT) { */ if (hw->mac_type >= e1000_82544 && hw->autoneg == 1 && hw->autoneg_advertised == ADVERTISE_1000_FULL) { u32 ctrl = er32(CTRL); /* clear phy power management bit if we are in gig only mode, * which if enabled will attempt negotiation to 100Mb, which * can cause a loss of link at power off or driver unload */ ctrl &= ~E1000_CTRL_SWDPIN3; ew32(CTRL, ctrl); } /* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */ ew32(VET, ETHERNET_IEEE_VLAN_TYPE); e1000_reset_adaptive(hw); e1000_phy_get_info(hw, &adapter->phy_info); e1000_release_manageability(adapter); } /* Dump the eeprom for users having checksum issues */ static void e1000_dump_eeprom(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; struct ethtool_eeprom eeprom; const struct ethtool_ops *ops = netdev->ethtool_ops; u8 *data; int i; u16 csum_old, csum_new = 0; eeprom.len = ops->get_eeprom_len(netdev); eeprom.offset = 0; data = kmalloc(eeprom.len, GFP_KERNEL); if (!data) return; ops->get_eeprom(netdev, &eeprom, data); csum_old = (data[EEPROM_CHECKSUM_REG * 2]) + (data[EEPROM_CHECKSUM_REG * 2 + 1] << 8); for (i = 0; i < EEPROM_CHECKSUM_REG * 2; i += 2) csum_new += data[i] + (data[i + 1] << 8); csum_new = EEPROM_SUM - csum_new; pr_err("/*********************/\n"); pr_err("Current EEPROM Checksum : 0x%04x\n", csum_old); pr_err("Calculated : 0x%04x\n", csum_new); pr_err("Offset Values\n"); pr_err("======== ======\n"); print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 16, 1, data, 128, 0); pr_err("Include this output when contacting your support provider.\n"); pr_err("This is not a software error! Something bad happened to\n"); pr_err("your hardware or EEPROM image. Ignoring this problem could\n"); pr_err("result in further problems, possibly loss of data,\n"); pr_err("corruption or system hangs!\n"); pr_err("The MAC Address will be reset to 00:00:00:00:00:00,\n"); pr_err("which is invalid and requires you to set the proper MAC\n"); pr_err("address manually before continuing to enable this network\n"); pr_err("device. Please inspect the EEPROM dump and report the\n"); pr_err("issue to your hardware vendor or Intel Customer Support.\n"); pr_err("/*********************/\n"); kfree(data); } /** * e1000_is_need_ioport - determine if an adapter needs ioport resources or not * @pdev: PCI device information struct * * Return true if an adapter needs ioport resources **/ static int e1000_is_need_ioport(struct pci_dev *pdev) { switch (pdev->device) { case E1000_DEV_ID_82540EM: case E1000_DEV_ID_82540EM_LOM: case E1000_DEV_ID_82540EP: case E1000_DEV_ID_82540EP_LOM: case E1000_DEV_ID_82540EP_LP: case E1000_DEV_ID_82541EI: case E1000_DEV_ID_82541EI_MOBILE: case E1000_DEV_ID_82541ER: case E1000_DEV_ID_82541ER_LOM: case E1000_DEV_ID_82541GI: case E1000_DEV_ID_82541GI_LF: case E1000_DEV_ID_82541GI_MOBILE: case E1000_DEV_ID_82544EI_COPPER: case E1000_DEV_ID_82544EI_FIBER: case E1000_DEV_ID_82544GC_COPPER: case E1000_DEV_ID_82544GC_LOM: case E1000_DEV_ID_82545EM_COPPER: case E1000_DEV_ID_82545EM_FIBER: case E1000_DEV_ID_82546EB_COPPER: case E1000_DEV_ID_82546EB_FIBER: case E1000_DEV_ID_82546EB_QUAD_COPPER: return true; default: return false; } } static netdev_features_t e1000_fix_features(struct net_device *netdev, netdev_features_t features) { /* Since there is no support for separate Rx/Tx vlan accel * enable/disable make sure Tx flag is always in same state as Rx. */ if (features & NETIF_F_HW_VLAN_CTAG_RX) features |= NETIF_F_HW_VLAN_CTAG_TX; else features &= ~NETIF_F_HW_VLAN_CTAG_TX; return features; } static int e1000_set_features(struct net_device *netdev, netdev_features_t features) { struct e1000_adapter *adapter = netdev_priv(netdev); netdev_features_t changed = features ^ netdev->features; if (changed & NETIF_F_HW_VLAN_CTAG_RX) e1000_vlan_mode(netdev, features); if (!(changed & (NETIF_F_RXCSUM | NETIF_F_RXALL))) return 0; netdev->features = features; adapter->rx_csum = !!(features & NETIF_F_RXCSUM); if (netif_running(netdev)) e1000_reinit_locked(adapter); else e1000_reset(adapter); return 1; } static const struct net_device_ops e1000_netdev_ops = { .ndo_open = e1000_open, .ndo_stop = e1000_close, .ndo_start_xmit = e1000_xmit_frame, .ndo_set_rx_mode = e1000_set_rx_mode, .ndo_set_mac_address = e1000_set_mac, .ndo_tx_timeout = e1000_tx_timeout, .ndo_change_mtu = e1000_change_mtu, .ndo_eth_ioctl = e1000_ioctl, .ndo_validate_addr = eth_validate_addr, .ndo_vlan_rx_add_vid = e1000_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = e1000_vlan_rx_kill_vid, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = e1000_netpoll, #endif .ndo_fix_features = e1000_fix_features, .ndo_set_features = e1000_set_features, }; /** * e1000_init_hw_struct - initialize members of hw struct * @adapter: board private struct * @hw: structure used by e1000_hw.c * * Factors out initialization of the e1000_hw struct to its own function * that can be called very early at init (just after struct allocation). * Fields are initialized based on PCI device information and * OS network device settings (MTU size). * Returns negative error codes if MAC type setup fails. */ static int e1000_init_hw_struct(struct e1000_adapter *adapter, struct e1000_hw *hw) { struct pci_dev *pdev = adapter->pdev; /* PCI config space info */ hw->vendor_id = pdev->vendor; hw->device_id = pdev->device; hw->subsystem_vendor_id = pdev->subsystem_vendor; hw->subsystem_id = pdev->subsystem_device; hw->revision_id = pdev->revision; pci_read_config_word(pdev, PCI_COMMAND, &hw->pci_cmd_word); hw->max_frame_size = adapter->netdev->mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; hw->min_frame_size = MINIMUM_ETHERNET_FRAME_SIZE; /* identify the MAC */ if (e1000_set_mac_type(hw)) { e_err(probe, "Unknown MAC Type\n"); return -EIO; } switch (hw->mac_type) { default: break; case e1000_82541: case e1000_82547: case e1000_82541_rev_2: case e1000_82547_rev_2: hw->phy_init_script = 1; break; } e1000_set_media_type(hw); e1000_get_bus_info(hw); hw->wait_autoneg_complete = false; hw->tbi_compatibility_en = true; hw->adaptive_ifs = true; /* Copper options */ if (hw->media_type == e1000_media_type_copper) { hw->mdix = AUTO_ALL_MODES; hw->disable_polarity_correction = false; hw->master_slave = E1000_MASTER_SLAVE; } return 0; } /** * e1000_probe - Device Initialization Routine * @pdev: PCI device information struct * @ent: entry in e1000_pci_tbl * * Returns 0 on success, negative on failure * * e1000_probe initializes an adapter identified by a pci_dev structure. * The OS initialization, configuring of the adapter private structure, * and a hardware reset occur. **/ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct net_device *netdev; struct e1000_adapter *adapter = NULL; struct e1000_hw *hw; static int cards_found; static int global_quad_port_a; /* global ksp3 port a indication */ int i, err, pci_using_dac; u16 eeprom_data = 0; u16 tmp = 0; u16 eeprom_apme_mask = E1000_EEPROM_APME; int bars, need_ioport; bool disable_dev = false; /* do not allocate ioport bars when not needed */ need_ioport = e1000_is_need_ioport(pdev); if (need_ioport) { bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); err = pci_enable_device(pdev); } else { bars = pci_select_bars(pdev, IORESOURCE_MEM); err = pci_enable_device_mem(pdev); } if (err) return err; err = pci_request_selected_regions(pdev, bars, e1000_driver_name); if (err) goto err_pci_reg; pci_set_master(pdev); err = pci_save_state(pdev); if (err) goto err_alloc_etherdev; err = -ENOMEM; netdev = alloc_etherdev(sizeof(struct e1000_adapter)); if (!netdev) goto err_alloc_etherdev; SET_NETDEV_DEV(netdev, &pdev->dev); pci_set_drvdata(pdev, netdev); adapter = netdev_priv(netdev); adapter->netdev = netdev; adapter->pdev = pdev; adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); adapter->bars = bars; adapter->need_ioport = need_ioport; hw = &adapter->hw; hw->back = adapter; err = -EIO; hw->hw_addr = pci_ioremap_bar(pdev, BAR_0); if (!hw->hw_addr) goto err_ioremap; if (adapter->need_ioport) { for (i = BAR_1; i < PCI_STD_NUM_BARS; i++) { if (pci_resource_len(pdev, i) == 0) continue; if (pci_resource_flags(pdev, i) & IORESOURCE_IO) { hw->io_base = pci_resource_start(pdev, i); break; } } } /* make ready for any if (hw->...) below */ err = e1000_init_hw_struct(adapter, hw); if (err) goto err_sw_init; /* there is a workaround being applied below that limits * 64-bit DMA addresses to 64-bit hardware. There are some * 32-bit adapters that Tx hang when given 64-bit DMA addresses */ pci_using_dac = 0; if ((hw->bus_type == e1000_bus_type_pcix) && !dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) { pci_using_dac = 1; } else { err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); if (err) { pr_err("No usable DMA config, aborting\n"); goto err_dma; } } netdev->netdev_ops = &e1000_netdev_ops; e1000_set_ethtool_ops(netdev); netdev->watchdog_timeo = 5 * HZ; netif_napi_add(netdev, &adapter->napi, e1000_clean, 64); strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1); adapter->bd_number = cards_found; /* setup the private structure */ err = e1000_sw_init(adapter); if (err) goto err_sw_init; err = -EIO; if (hw->mac_type == e1000_ce4100) { hw->ce4100_gbe_mdio_base_virt = ioremap(pci_resource_start(pdev, BAR_1), pci_resource_len(pdev, BAR_1)); if (!hw->ce4100_gbe_mdio_base_virt) goto err_mdio_ioremap; } if (hw->mac_type >= e1000_82543) { netdev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_RX; netdev->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_FILTER; } if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_82547)) netdev->hw_features |= NETIF_F_TSO; netdev->priv_flags |= IFF_SUPP_NOFCS; netdev->features |= netdev->hw_features; netdev->hw_features |= (NETIF_F_RXCSUM | NETIF_F_RXALL | NETIF_F_RXFCS); if (pci_using_dac) { netdev->features |= NETIF_F_HIGHDMA; netdev->vlan_features |= NETIF_F_HIGHDMA; } netdev->vlan_features |= (NETIF_F_TSO | NETIF_F_HW_CSUM | NETIF_F_SG); /* Do not set IFF_UNICAST_FLT for VMWare's 82545EM */ if (hw->device_id != E1000_DEV_ID_82545EM_COPPER || hw->subsystem_vendor_id != PCI_VENDOR_ID_VMWARE) netdev->priv_flags |= IFF_UNICAST_FLT; /* MTU range: 46 - 16110 */ netdev->min_mtu = ETH_ZLEN - ETH_HLEN; netdev->max_mtu = MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN); adapter->en_mng_pt = e1000_enable_mng_pass_thru(hw); /* initialize eeprom parameters */ if (e1000_init_eeprom_params(hw)) { e_err(probe, "EEPROM initialization failed\n"); goto err_eeprom; } /* before reading the EEPROM, reset the controller to * put the device in a known good starting state */ e1000_reset_hw(hw); /* make sure the EEPROM is good */ if (e1000_validate_eeprom_checksum(hw) < 0) { e_err(probe, "The EEPROM Checksum Is Not Valid\n"); e1000_dump_eeprom(adapter); /* set MAC address to all zeroes to invalidate and temporary * disable this device for the user. This blocks regular * traffic while still permitting ethtool ioctls from reaching * the hardware as well as allowing the user to run the * interface after manually setting a hw addr using * `ip set address` */ memset(hw->mac_addr, 0, netdev->addr_len); } else { /* copy the MAC address out of the EEPROM */ if (e1000_read_mac_addr(hw)) e_err(probe, "EEPROM Read Error\n"); } /* don't block initialization here due to bad MAC address */ eth_hw_addr_set(netdev, hw->mac_addr); if (!is_valid_ether_addr(netdev->dev_addr)) e_err(probe, "Invalid MAC Address\n"); INIT_DELAYED_WORK(&adapter->watchdog_task, e1000_watchdog); INIT_DELAYED_WORK(&adapter->fifo_stall_task, e1000_82547_tx_fifo_stall_task); INIT_DELAYED_WORK(&adapter->phy_info_task, e1000_update_phy_info_task); INIT_WORK(&adapter->reset_task, e1000_reset_task); e1000_check_options(adapter); /* Initial Wake on LAN setting * If APM wake is enabled in the EEPROM, * enable the ACPI Magic Packet filter */ switch (hw->mac_type) { case e1000_82542_rev2_0: case e1000_82542_rev2_1: case e1000_82543: break; case e1000_82544: e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data); eeprom_apme_mask = E1000_EEPROM_82544_APM; break; case e1000_82546: case e1000_82546_rev_3: if (er32(STATUS) & E1000_STATUS_FUNC_1) { e1000_read_eeprom(hw, EEPROM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); break; } fallthrough; default: e1000_read_eeprom(hw, EEPROM_INIT_CONTROL3_PORT_A, 1, &eeprom_data); break; } if (eeprom_data & eeprom_apme_mask) adapter->eeprom_wol |= E1000_WUFC_MAG; /* now that we have the eeprom settings, apply the special cases * where the eeprom may be wrong or the board simply won't support * wake on lan on a particular port */ switch (pdev->device) { case E1000_DEV_ID_82546GB_PCIE: adapter->eeprom_wol = 0; break; case E1000_DEV_ID_82546EB_FIBER: case E1000_DEV_ID_82546GB_FIBER: /* Wake events only supported on port A for dual fiber * regardless of eeprom setting */ if (er32(STATUS) & E1000_STATUS_FUNC_1) adapter->eeprom_wol = 0; break; case E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3: /* if quad port adapter, disable WoL on all but port A */ if (global_quad_port_a != 0) adapter->eeprom_wol = 0; else adapter->quad_port_a = true; /* Reset for multiple quad port adapters */ if (++global_quad_port_a == 4) global_quad_port_a = 0; break; } /* initialize the wol settings based on the eeprom settings */ adapter->wol = adapter->eeprom_wol; device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); /* Auto detect PHY address */ if (hw->mac_type == e1000_ce4100) { for (i = 0; i < 32; i++) { hw->phy_addr = i; e1000_read_phy_reg(hw, PHY_ID2, &tmp); if (tmp != 0 && tmp != 0xFF) break; } if (i >= 32) goto err_eeprom; } /* reset the hardware with the new settings */ e1000_reset(adapter); strcpy(netdev->name, "eth%d"); err = register_netdev(netdev); if (err) goto err_register; e1000_vlan_filter_on_off(adapter, false); /* print bus type/speed/width info */ e_info(probe, "(PCI%s:%dMHz:%d-bit) %pM\n", ((hw->bus_type == e1000_bus_type_pcix) ? "-X" : ""), ((hw->bus_speed == e1000_bus_speed_133) ? 133 : (hw->bus_speed == e1000_bus_speed_120) ? 120 : (hw->bus_speed == e1000_bus_speed_100) ? 100 : (hw->bus_speed == e1000_bus_speed_66) ? 66 : 33), ((hw->bus_width == e1000_bus_width_64) ? 64 : 32), netdev->dev_addr); /* carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off(netdev); e_info(probe, "Intel(R) PRO/1000 Network Connection\n"); cards_found++; return 0; err_register: err_eeprom: e1000_phy_hw_reset(hw); if (hw->flash_address) iounmap(hw->flash_address); kfree(adapter->tx_ring); kfree(adapter->rx_ring); err_dma: err_sw_init: err_mdio_ioremap: iounmap(hw->ce4100_gbe_mdio_base_virt); iounmap(hw->hw_addr); err_ioremap: disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags); free_netdev(netdev); err_alloc_etherdev: pci_release_selected_regions(pdev, bars); err_pci_reg: if (!adapter || disable_dev) pci_disable_device(pdev); return err; } /** * e1000_remove - Device Removal Routine * @pdev: PCI device information struct * * e1000_remove is called by the PCI subsystem to alert the driver * that it should release a PCI device. That could be caused by a * Hot-Plug event, or because the driver is going to be removed from * memory. **/ static void e1000_remove(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; bool disable_dev; e1000_down_and_stop(adapter); e1000_release_manageability(adapter); unregister_netdev(netdev); e1000_phy_hw_reset(hw); kfree(adapter->tx_ring); kfree(adapter->rx_ring); if (hw->mac_type == e1000_ce4100) iounmap(hw->ce4100_gbe_mdio_base_virt); iounmap(hw->hw_addr); if (hw->flash_address) iounmap(hw->flash_address); pci_release_selected_regions(pdev, adapter->bars); disable_dev = !test_and_set_bit(__E1000_DISABLED, &adapter->flags); free_netdev(netdev); if (disable_dev) pci_disable_device(pdev); } /** * e1000_sw_init - Initialize general software structures (struct e1000_adapter) * @adapter: board private structure to initialize * * e1000_sw_init initializes the Adapter private data structure. * e1000_init_hw_struct MUST be called before this function **/ static int e1000_sw_init(struct e1000_adapter *adapter) { adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; adapter->num_tx_queues = 1; adapter->num_rx_queues = 1; if (e1000_alloc_queues(adapter)) { e_err(probe, "Unable to allocate memory for queues\n"); return -ENOMEM; } /* Explicitly disable IRQ since the NIC can be in any state. */ e1000_irq_disable(adapter); spin_lock_init(&adapter->stats_lock); set_bit(__E1000_DOWN, &adapter->flags); return 0; } /** * e1000_alloc_queues - Allocate memory for all rings * @adapter: board private structure to initialize * * We allocate one ring per queue at run-time since we don't know the * number of queues at compile-time. **/ static int e1000_alloc_queues(struct e1000_adapter *adapter) { adapter->tx_ring = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL); if (!adapter->tx_ring) return -ENOMEM; adapter->rx_ring = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL); if (!adapter->rx_ring) { kfree(adapter->tx_ring); return -ENOMEM; } return E1000_SUCCESS; } /** * e1000_open - Called when a network interface is made active * @netdev: network interface device structure * * Returns 0 on success, negative value on failure * * The open entry point is called when a network interface is made * active by the system (IFF_UP). At this point all resources needed * for transmit and receive operations are allocated, the interrupt * handler is registered with the OS, the watchdog task is started, * and the stack is notified that the interface is ready. **/ int e1000_open(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; int err; /* disallow open during test */ if (test_bit(__E1000_TESTING, &adapter->flags)) return -EBUSY; netif_carrier_off(netdev); /* allocate transmit descriptors */ err = e1000_setup_all_tx_resources(adapter); if (err) goto err_setup_tx; /* allocate receive descriptors */ err = e1000_setup_all_rx_resources(adapter); if (err) goto err_setup_rx; e1000_power_up_phy(adapter); adapter->mng_vlan_id = E1000_MNG_VLAN_NONE; if ((hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) { e1000_update_mng_vlan(adapter); } /* before we allocate an interrupt, we must be ready to handle it. * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt * as soon as we call pci_request_irq, so we have to setup our * clean_rx handler before we do so. */ e1000_configure(adapter); err = e1000_request_irq(adapter); if (err) goto err_req_irq; /* From here on the code is the same as e1000_up() */ clear_bit(__E1000_DOWN, &adapter->flags); napi_enable(&adapter->napi); e1000_irq_enable(adapter); netif_start_queue(netdev); /* fire a link status change interrupt to start the watchdog */ ew32(ICS, E1000_ICS_LSC); return E1000_SUCCESS; err_req_irq: e1000_power_down_phy(adapter); e1000_free_all_rx_resources(adapter); err_setup_rx: e1000_free_all_tx_resources(adapter); err_setup_tx: e1000_reset(adapter); return err; } /** * e1000_close - Disables a network interface * @netdev: network interface device structure * * Returns 0, this is not allowed to fail * * The close entry point is called when an interface is de-activated * by the OS. The hardware is still under the drivers control, but * needs to be disabled. A global MAC reset is issued to stop the * hardware, and all transmit and receive resources are freed. **/ int e1000_close(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; int count = E1000_CHECK_RESET_COUNT; while (test_and_set_bit(__E1000_RESETTING, &adapter->flags) && count--) usleep_range(10000, 20000); WARN_ON(count < 0); /* signal that we're down so that the reset task will no longer run */ set_bit(__E1000_DOWN, &adapter->flags); clear_bit(__E1000_RESETTING, &adapter->flags); e1000_down(adapter); e1000_power_down_phy(adapter); e1000_free_irq(adapter); e1000_free_all_tx_resources(adapter); e1000_free_all_rx_resources(adapter); /* kill manageability vlan ID if supported, but not if a vlan with * the same ID is registered on the host OS (let 8021q kill it) */ if ((hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) { e1000_vlan_rx_kill_vid(netdev, htons(ETH_P_8021Q), adapter->mng_vlan_id); } return 0; } /** * e1000_check_64k_bound - check that memory doesn't cross 64kB boundary * @adapter: address of board private structure * @start: address of beginning of memory * @len: length of memory **/ static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start, unsigned long len) { struct e1000_hw *hw = &adapter->hw; unsigned long begin = (unsigned long)start; unsigned long end = begin + len; /* First rev 82545 and 82546 need to not allow any memory * write location to cross 64k boundary due to errata 23 */ if (hw->mac_type == e1000_82545 || hw->mac_type == e1000_ce4100 || hw->mac_type == e1000_82546) { return ((begin ^ (end - 1)) >> 16) == 0; } return true; } /** * e1000_setup_tx_resources - allocate Tx resources (Descriptors) * @adapter: board private structure * @txdr: tx descriptor ring (for a specific queue) to setup * * Return 0 on success, negative on failure **/ static int e1000_setup_tx_resources(struct e1000_adapter *adapter, struct e1000_tx_ring *txdr) { struct pci_dev *pdev = adapter->pdev; int size; size = sizeof(struct e1000_tx_buffer) * txdr->count; txdr->buffer_info = vzalloc(size); if (!txdr->buffer_info) return -ENOMEM; /* round up to nearest 4K */ txdr->size = txdr->count * sizeof(struct e1000_tx_desc); txdr->size = ALIGN(txdr->size, 4096); txdr->desc = dma_alloc_coherent(&pdev->dev, txdr->size, &txdr->dma, GFP_KERNEL); if (!txdr->desc) { setup_tx_desc_die: vfree(txdr->buffer_info); return -ENOMEM; } /* Fix for errata 23, can't cross 64kB boundary */ if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { void *olddesc = txdr->desc; dma_addr_t olddma = txdr->dma; e_err(tx_err, "txdr align check failed: %u bytes at %p\n", txdr->size, txdr->desc); /* Try again, without freeing the previous */ txdr->desc = dma_alloc_coherent(&pdev->dev, txdr->size, &txdr->dma, GFP_KERNEL); /* Failed allocation, critical failure */ if (!txdr->desc) { dma_free_coherent(&pdev->dev, txdr->size, olddesc, olddma); goto setup_tx_desc_die; } if (!e1000_check_64k_bound(adapter, txdr->desc, txdr->size)) { /* give up */ dma_free_coherent(&pdev->dev, txdr->size, txdr->desc, txdr->dma); dma_free_coherent(&pdev->dev, txdr->size, olddesc, olddma); e_err(probe, "Unable to allocate aligned memory " "for the transmit descriptor ring\n"); vfree(txdr->buffer_info); return -ENOMEM; } else { /* Free old allocation, new allocation was successful */ dma_free_coherent(&pdev->dev, txdr->size, olddesc, olddma); } } memset(txdr->desc, 0, txdr->size); txdr->next_to_use = 0; txdr->next_to_clean = 0; return 0; } /** * e1000_setup_all_tx_resources - wrapper to allocate Tx resources * (Descriptors) for all queues * @adapter: board private structure * * Return 0 on success, negative on failure **/ int e1000_setup_all_tx_resources(struct e1000_adapter *adapter) { int i, err = 0; for (i = 0; i < adapter->num_tx_queues; i++) { err = e1000_setup_tx_resources(adapter, &adapter->tx_ring[i]); if (err) { e_err(probe, "Allocation for Tx Queue %u failed\n", i); for (i-- ; i >= 0; i--) e1000_free_tx_resources(adapter, &adapter->tx_ring[i]); break; } } return err; } /** * e1000_configure_tx - Configure 8254x Transmit Unit after Reset * @adapter: board private structure * * Configure the Tx unit of the MAC after a reset. **/ static void e1000_configure_tx(struct e1000_adapter *adapter) { u64 tdba; struct e1000_hw *hw = &adapter->hw; u32 tdlen, tctl, tipg; u32 ipgr1, ipgr2; /* Setup the HW Tx Head and Tail descriptor pointers */ switch (adapter->num_tx_queues) { case 1: default: tdba = adapter->tx_ring[0].dma; tdlen = adapter->tx_ring[0].count * sizeof(struct e1000_tx_desc); ew32(TDLEN, tdlen); ew32(TDBAH, (tdba >> 32)); ew32(TDBAL, (tdba & 0x00000000ffffffffULL)); ew32(TDT, 0); ew32(TDH, 0); adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH); adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT); break; } /* Set the default values for the Tx Inter Packet Gap timer */ if ((hw->media_type == e1000_media_type_fiber || hw->media_type == e1000_media_type_internal_serdes)) tipg = DEFAULT_82543_TIPG_IPGT_FIBER; else tipg = DEFAULT_82543_TIPG_IPGT_COPPER; switch (hw->mac_type) { case e1000_82542_rev2_0: case e1000_82542_rev2_1: tipg = DEFAULT_82542_TIPG_IPGT; ipgr1 = DEFAULT_82542_TIPG_IPGR1; ipgr2 = DEFAULT_82542_TIPG_IPGR2; break; default: ipgr1 = DEFAULT_82543_TIPG_IPGR1; ipgr2 = DEFAULT_82543_TIPG_IPGR2; break; } tipg |= ipgr1 << E1000_TIPG_IPGR1_SHIFT; tipg |= ipgr2 << E1000_TIPG_IPGR2_SHIFT; ew32(TIPG, tipg); /* Set the Tx Interrupt Delay register */ ew32(TIDV, adapter->tx_int_delay); if (hw->mac_type >= e1000_82540) ew32(TADV, adapter->tx_abs_int_delay); /* Program the Transmit Control Register */ tctl = er32(TCTL); tctl &= ~E1000_TCTL_CT; tctl |= E1000_TCTL_PSP | E1000_TCTL_RTLC | (E1000_COLLISION_THRESHOLD << E1000_CT_SHIFT); e1000_config_collision_dist(hw); /* Setup Transmit Descriptor Settings for eop descriptor */ adapter->txd_cmd = E1000_TXD_CMD_EOP | E1000_TXD_CMD_IFCS; /* only set IDE if we are delaying interrupts using the timers */ if (adapter->tx_int_delay) adapter->txd_cmd |= E1000_TXD_CMD_IDE; if (hw->mac_type < e1000_82543) adapter->txd_cmd |= E1000_TXD_CMD_RPS; else adapter->txd_cmd |= E1000_TXD_CMD_RS; /* Cache if we're 82544 running in PCI-X because we'll * need this to apply a workaround later in the send path. */ if (hw->mac_type == e1000_82544 && hw->bus_type == e1000_bus_type_pcix) adapter->pcix_82544 = true; ew32(TCTL, tctl); } /** * e1000_setup_rx_resources - allocate Rx resources (Descriptors) * @adapter: board private structure * @rxdr: rx descriptor ring (for a specific queue) to setup * * Returns 0 on success, negative on failure **/ static int e1000_setup_rx_resources(struct e1000_adapter *adapter, struct e1000_rx_ring *rxdr) { struct pci_dev *pdev = adapter->pdev; int size, desc_len; size = sizeof(struct e1000_rx_buffer) * rxdr->count; rxdr->buffer_info = vzalloc(size); if (!rxdr->buffer_info) return -ENOMEM; desc_len = sizeof(struct e1000_rx_desc); /* Round up to nearest 4K */ rxdr->size = rxdr->count * desc_len; rxdr->size = ALIGN(rxdr->size, 4096); rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, &rxdr->dma, GFP_KERNEL); if (!rxdr->desc) { setup_rx_desc_die: vfree(rxdr->buffer_info); return -ENOMEM; } /* Fix for errata 23, can't cross 64kB boundary */ if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { void *olddesc = rxdr->desc; dma_addr_t olddma = rxdr->dma; e_err(rx_err, "rxdr align check failed: %u bytes at %p\n", rxdr->size, rxdr->desc); /* Try again, without freeing the previous */ rxdr->desc = dma_alloc_coherent(&pdev->dev, rxdr->size, &rxdr->dma, GFP_KERNEL); /* Failed allocation, critical failure */ if (!rxdr->desc) { dma_free_coherent(&pdev->dev, rxdr->size, olddesc, olddma); goto setup_rx_desc_die; } if (!e1000_check_64k_bound(adapter, rxdr->desc, rxdr->size)) { /* give up */ dma_free_coherent(&pdev->dev, rxdr->size, rxdr->desc, rxdr->dma); dma_free_coherent(&pdev->dev, rxdr->size, olddesc, olddma); e_err(probe, "Unable to allocate aligned memory for " "the Rx descriptor ring\n"); goto setup_rx_desc_die; } else { /* Free old allocation, new allocation was successful */ dma_free_coherent(&pdev->dev, rxdr->size, olddesc, olddma); } } memset(rxdr->desc, 0, rxdr->size); rxdr->next_to_clean = 0; rxdr->next_to_use = 0; rxdr->rx_skb_top = NULL; return 0; } /** * e1000_setup_all_rx_resources - wrapper to allocate Rx resources * (Descriptors) for all queues * @adapter: board private structure * * Return 0 on success, negative on failure **/ int e1000_setup_all_rx_resources(struct e1000_adapter *adapter) { int i, err = 0; for (i = 0; i < adapter->num_rx_queues; i++) { err = e1000_setup_rx_resources(adapter, &adapter->rx_ring[i]); if (err) { e_err(probe, "Allocation for Rx Queue %u failed\n", i); for (i-- ; i >= 0; i--) e1000_free_rx_resources(adapter, &adapter->rx_ring[i]); break; } } return err; } /** * e1000_setup_rctl - configure the receive control registers * @adapter: Board private structure **/ static void e1000_setup_rctl(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u32 rctl; rctl = er32(RCTL); rctl &= ~(3 << E1000_RCTL_MO_SHIFT); rctl |= E1000_RCTL_BAM | E1000_RCTL_LBM_NO | E1000_RCTL_RDMTS_HALF | (hw->mc_filter_type << E1000_RCTL_MO_SHIFT); if (hw->tbi_compatibility_on == 1) rctl |= E1000_RCTL_SBP; else rctl &= ~E1000_RCTL_SBP; if (adapter->netdev->mtu <= ETH_DATA_LEN) rctl &= ~E1000_RCTL_LPE; else rctl |= E1000_RCTL_LPE; /* Setup buffer sizes */ rctl &= ~E1000_RCTL_SZ_4096; rctl |= E1000_RCTL_BSEX; switch (adapter->rx_buffer_len) { case E1000_RXBUFFER_2048: default: rctl |= E1000_RCTL_SZ_2048; rctl &= ~E1000_RCTL_BSEX; break; case E1000_RXBUFFER_4096: rctl |= E1000_RCTL_SZ_4096; break; case E1000_RXBUFFER_8192: rctl |= E1000_RCTL_SZ_8192; break; case E1000_RXBUFFER_16384: rctl |= E1000_RCTL_SZ_16384; break; } /* This is useful for sniffing bad packets. */ if (adapter->netdev->features & NETIF_F_RXALL) { /* UPE and MPE will be handled by normal PROMISC logic * in e1000e_set_rx_mode */ rctl |= (E1000_RCTL_SBP | /* Receive bad packets */ E1000_RCTL_BAM | /* RX All Bcast Pkts */ E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */ rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */ E1000_RCTL_DPF | /* Allow filtered pause */ E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */ /* Do not mess with E1000_CTRL_VME, it affects transmit as well, * and that breaks VLANs. */ } ew32(RCTL, rctl); } /** * e1000_configure_rx - Configure 8254x Receive Unit after Reset * @adapter: board private structure * * Configure the Rx unit of the MAC after a reset. **/ static void e1000_configure_rx(struct e1000_adapter *adapter) { u64 rdba; struct e1000_hw *hw = &adapter->hw; u32 rdlen, rctl, rxcsum; if (adapter->netdev->mtu > ETH_DATA_LEN) { rdlen = adapter->rx_ring[0].count * sizeof(struct e1000_rx_desc); adapter->clean_rx = e1000_clean_jumbo_rx_irq; adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers; } else { rdlen = adapter->rx_ring[0].count * sizeof(struct e1000_rx_desc); adapter->clean_rx = e1000_clean_rx_irq; adapter->alloc_rx_buf = e1000_alloc_rx_buffers; } /* disable receives while setting up the descriptors */ rctl = er32(RCTL); ew32(RCTL, rctl & ~E1000_RCTL_EN); /* set the Receive Delay Timer Register */ ew32(RDTR, adapter->rx_int_delay); if (hw->mac_type >= e1000_82540) { ew32(RADV, adapter->rx_abs_int_delay); if (adapter->itr_setting != 0) ew32(ITR, 1000000000 / (adapter->itr * 256)); } /* Setup the HW Rx Head and Tail Descriptor Pointers and * the Base and Length of the Rx Descriptor Ring */ switch (adapter->num_rx_queues) { case 1: default: rdba = adapter->rx_ring[0].dma; ew32(RDLEN, rdlen); ew32(RDBAH, (rdba >> 32)); ew32(RDBAL, (rdba & 0x00000000ffffffffULL)); ew32(RDT, 0); ew32(RDH, 0); adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH); adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT); break; } /* Enable 82543 Receive Checksum Offload for TCP and UDP */ if (hw->mac_type >= e1000_82543) { rxcsum = er32(RXCSUM); if (adapter->rx_csum) rxcsum |= E1000_RXCSUM_TUOFL; else /* don't need to clear IPPCSE as it defaults to 0 */ rxcsum &= ~E1000_RXCSUM_TUOFL; ew32(RXCSUM, rxcsum); } /* Enable Receives */ ew32(RCTL, rctl | E1000_RCTL_EN); } /** * e1000_free_tx_resources - Free Tx Resources per Queue * @adapter: board private structure * @tx_ring: Tx descriptor ring for a specific queue * * Free all transmit software resources **/ static void e1000_free_tx_resources(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring) { struct pci_dev *pdev = adapter->pdev; e1000_clean_tx_ring(adapter, tx_ring); vfree(tx_ring->buffer_info); tx_ring->buffer_info = NULL; dma_free_coherent(&pdev->dev, tx_ring->size, tx_ring->desc, tx_ring->dma); tx_ring->desc = NULL; } /** * e1000_free_all_tx_resources - Free Tx Resources for All Queues * @adapter: board private structure * * Free all transmit software resources **/ void e1000_free_all_tx_resources(struct e1000_adapter *adapter) { int i; for (i = 0; i < adapter->num_tx_queues; i++) e1000_free_tx_resources(adapter, &adapter->tx_ring[i]); } static void e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter, struct e1000_tx_buffer *buffer_info) { if (buffer_info->dma) { if (buffer_info->mapped_as_page) dma_unmap_page(&adapter->pdev->dev, buffer_info->dma, buffer_info->length, DMA_TO_DEVICE); else dma_unmap_single(&adapter->pdev->dev, buffer_info->dma, buffer_info->length, DMA_TO_DEVICE); buffer_info->dma = 0; } if (buffer_info->skb) { dev_kfree_skb_any(buffer_info->skb); buffer_info->skb = NULL; } buffer_info->time_stamp = 0; /* buffer_info must be completely set up in the transmit path */ } /** * e1000_clean_tx_ring - Free Tx Buffers * @adapter: board private structure * @tx_ring: ring to be cleaned **/ static void e1000_clean_tx_ring(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring) { struct e1000_hw *hw = &adapter->hw; struct e1000_tx_buffer *buffer_info; unsigned long size; unsigned int i; /* Free all the Tx ring sk_buffs */ for (i = 0; i < tx_ring->count; i++) { buffer_info = &tx_ring->buffer_info[i]; e1000_unmap_and_free_tx_resource(adapter, buffer_info); } netdev_reset_queue(adapter->netdev); size = sizeof(struct e1000_tx_buffer) * tx_ring->count; memset(tx_ring->buffer_info, 0, size); /* Zero out the descriptor ring */ memset(tx_ring->desc, 0, tx_ring->size); tx_ring->next_to_use = 0; tx_ring->next_to_clean = 0; tx_ring->last_tx_tso = false; writel(0, hw->hw_addr + tx_ring->tdh); writel(0, hw->hw_addr + tx_ring->tdt); } /** * e1000_clean_all_tx_rings - Free Tx Buffers for all queues * @adapter: board private structure **/ static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter) { int i; for (i = 0; i < adapter->num_tx_queues; i++) e1000_clean_tx_ring(adapter, &adapter->tx_ring[i]); } /** * e1000_free_rx_resources - Free Rx Resources * @adapter: board private structure * @rx_ring: ring to clean the resources from * * Free all receive software resources **/ static void e1000_free_rx_resources(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring) { struct pci_dev *pdev = adapter->pdev; e1000_clean_rx_ring(adapter, rx_ring); vfree(rx_ring->buffer_info); rx_ring->buffer_info = NULL; dma_free_coherent(&pdev->dev, rx_ring->size, rx_ring->desc, rx_ring->dma); rx_ring->desc = NULL; } /** * e1000_free_all_rx_resources - Free Rx Resources for All Queues * @adapter: board private structure * * Free all receive software resources **/ void e1000_free_all_rx_resources(struct e1000_adapter *adapter) { int i; for (i = 0; i < adapter->num_rx_queues; i++) e1000_free_rx_resources(adapter, &adapter->rx_ring[i]); } #define E1000_HEADROOM (NET_SKB_PAD + NET_IP_ALIGN) static unsigned int e1000_frag_len(const struct e1000_adapter *a) { return SKB_DATA_ALIGN(a->rx_buffer_len + E1000_HEADROOM) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)); } static void *e1000_alloc_frag(const struct e1000_adapter *a) { unsigned int len = e1000_frag_len(a); u8 *data = netdev_alloc_frag(len); if (likely(data)) data += E1000_HEADROOM; return data; } /** * e1000_clean_rx_ring - Free Rx Buffers per Queue * @adapter: board private structure * @rx_ring: ring to free buffers from **/ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring) { struct e1000_hw *hw = &adapter->hw; struct e1000_rx_buffer *buffer_info; struct pci_dev *pdev = adapter->pdev; unsigned long size; unsigned int i; /* Free all the Rx netfrags */ for (i = 0; i < rx_ring->count; i++) { buffer_info = &rx_ring->buffer_info[i]; if (adapter->clean_rx == e1000_clean_rx_irq) { if (buffer_info->dma) dma_unmap_single(&pdev->dev, buffer_info->dma, adapter->rx_buffer_len, DMA_FROM_DEVICE); if (buffer_info->rxbuf.data) { skb_free_frag(buffer_info->rxbuf.data); buffer_info->rxbuf.data = NULL; } } else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq) { if (buffer_info->dma) dma_unmap_page(&pdev->dev, buffer_info->dma, adapter->rx_buffer_len, DMA_FROM_DEVICE); if (buffer_info->rxbuf.page) { put_page(buffer_info->rxbuf.page); buffer_info->rxbuf.page = NULL; } } buffer_info->dma = 0; } /* there also may be some cached data from a chained receive */ napi_free_frags(&adapter->napi); rx_ring->rx_skb_top = NULL; size = sizeof(struct e1000_rx_buffer) * rx_ring->count; memset(rx_ring->buffer_info, 0, size); /* Zero out the descriptor ring */ memset(rx_ring->desc, 0, rx_ring->size); rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0; writel(0, hw->hw_addr + rx_ring->rdh); writel(0, hw->hw_addr + rx_ring->rdt); } /** * e1000_clean_all_rx_rings - Free Rx Buffers for all queues * @adapter: board private structure **/ static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter) { int i; for (i = 0; i < adapter->num_rx_queues; i++) e1000_clean_rx_ring(adapter, &adapter->rx_ring[i]); } /* The 82542 2.0 (revision 2) needs to have the receive unit in reset * and memory write and invalidate disabled for certain operations */ static void e1000_enter_82542_rst(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; u32 rctl; e1000_pci_clear_mwi(hw); rctl = er32(RCTL); rctl |= E1000_RCTL_RST; ew32(RCTL, rctl); E1000_WRITE_FLUSH(); mdelay(5); if (netif_running(netdev)) e1000_clean_all_rx_rings(adapter); } static void e1000_leave_82542_rst(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; u32 rctl; rctl = er32(RCTL); rctl &= ~E1000_RCTL_RST; ew32(RCTL, rctl); E1000_WRITE_FLUSH(); mdelay(5); if (hw->pci_cmd_word & PCI_COMMAND_INVALIDATE) e1000_pci_set_mwi(hw); if (netif_running(netdev)) { /* No need to loop, because 82542 supports only 1 queue */ struct e1000_rx_ring *ring = &adapter->rx_ring[0]; e1000_configure_rx(adapter); adapter->alloc_rx_buf(adapter, ring, E1000_DESC_UNUSED(ring)); } } /** * e1000_set_mac - Change the Ethernet Address of the NIC * @netdev: network interface device structure * @p: pointer to an address structure * * Returns 0 on success, negative on failure **/ static int e1000_set_mac(struct net_device *netdev, void *p) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; struct sockaddr *addr = p; if (!is_valid_ether_addr(addr->sa_data)) return -EADDRNOTAVAIL; /* 82542 2.0 needs to be in reset to write receive address registers */ if (hw->mac_type == e1000_82542_rev2_0) e1000_enter_82542_rst(adapter); eth_hw_addr_set(netdev, addr->sa_data); memcpy(hw->mac_addr, addr->sa_data, netdev->addr_len); e1000_rar_set(hw, hw->mac_addr, 0); if (hw->mac_type == e1000_82542_rev2_0) e1000_leave_82542_rst(adapter); return 0; } /** * e1000_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set * @netdev: network interface device structure * * The set_rx_mode entry point is called whenever the unicast or multicast * address lists or the network interface flags are updated. This routine is * responsible for configuring the hardware for proper unicast, multicast, * promiscuous mode, and all-multi behavior. **/ static void e1000_set_rx_mode(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; struct netdev_hw_addr *ha; bool use_uc = false; u32 rctl; u32 hash_value; int i, rar_entries = E1000_RAR_ENTRIES; int mta_reg_count = E1000_NUM_MTA_REGISTERS; u32 *mcarray = kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC); if (!mcarray) return; /* Check for Promiscuous and All Multicast modes */ rctl = er32(RCTL); if (netdev->flags & IFF_PROMISC) { rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE); rctl &= ~E1000_RCTL_VFE; } else { if (netdev->flags & IFF_ALLMULTI) rctl |= E1000_RCTL_MPE; else rctl &= ~E1000_RCTL_MPE; /* Enable VLAN filter if there is a VLAN */ if (e1000_vlan_used(adapter)) rctl |= E1000_RCTL_VFE; } if (netdev_uc_count(netdev) > rar_entries - 1) { rctl |= E1000_RCTL_UPE; } else if (!(netdev->flags & IFF_PROMISC)) { rctl &= ~E1000_RCTL_UPE; use_uc = true; } ew32(RCTL, rctl); /* 82542 2.0 needs to be in reset to write receive address registers */ if (hw->mac_type == e1000_82542_rev2_0) e1000_enter_82542_rst(adapter); /* load the first 14 addresses into the exact filters 1-14. Unicast * addresses take precedence to avoid disabling unicast filtering * when possible. * * RAR 0 is used for the station MAC address * if there are not 14 addresses, go ahead and clear the filters */ i = 1; if (use_uc) netdev_for_each_uc_addr(ha, netdev) { if (i == rar_entries) break; e1000_rar_set(hw, ha->addr, i++); } netdev_for_each_mc_addr(ha, netdev) { if (i == rar_entries) { /* load any remaining addresses into the hash table */ u32 hash_reg, hash_bit, mta; hash_value = e1000_hash_mc_addr(hw, ha->addr); hash_reg = (hash_value >> 5) & 0x7F; hash_bit = hash_value & 0x1F; mta = (1 << hash_bit); mcarray[hash_reg] |= mta; } else { e1000_rar_set(hw, ha->addr, i++); } } for (; i < rar_entries; i++) { E1000_WRITE_REG_ARRAY(hw, RA, i << 1, 0); E1000_WRITE_FLUSH(); E1000_WRITE_REG_ARRAY(hw, RA, (i << 1) + 1, 0); E1000_WRITE_FLUSH(); } /* write the hash table completely, write from bottom to avoid * both stupid write combining chipsets, and flushing each write */ for (i = mta_reg_count - 1; i >= 0 ; i--) { /* If we are on an 82544 has an errata where writing odd * offsets overwrites the previous even offset, but writing * backwards over the range solves the issue by always * writing the odd offset first */ E1000_WRITE_REG_ARRAY(hw, MTA, i, mcarray[i]); } E1000_WRITE_FLUSH(); if (hw->mac_type == e1000_82542_rev2_0) e1000_leave_82542_rst(adapter); kfree(mcarray); } /** * e1000_update_phy_info_task - get phy info * @work: work struct contained inside adapter struct * * Need to wait a few seconds after link up to get diagnostic information from * the phy */ static void e1000_update_phy_info_task(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, phy_info_task.work); e1000_phy_get_info(&adapter->hw, &adapter->phy_info); } /** * e1000_82547_tx_fifo_stall_task - task to complete work * @work: work struct contained inside adapter struct **/ static void e1000_82547_tx_fifo_stall_task(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, fifo_stall_task.work); struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; u32 tctl; if (atomic_read(&adapter->tx_fifo_stall)) { if ((er32(TDT) == er32(TDH)) && (er32(TDFT) == er32(TDFH)) && (er32(TDFTS) == er32(TDFHS))) { tctl = er32(TCTL); ew32(TCTL, tctl & ~E1000_TCTL_EN); ew32(TDFT, adapter->tx_head_addr); ew32(TDFH, adapter->tx_head_addr); ew32(TDFTS, adapter->tx_head_addr); ew32(TDFHS, adapter->tx_head_addr); ew32(TCTL, tctl); E1000_WRITE_FLUSH(); adapter->tx_fifo_head = 0; atomic_set(&adapter->tx_fifo_stall, 0); netif_wake_queue(netdev); } else if (!test_bit(__E1000_DOWN, &adapter->flags)) { schedule_delayed_work(&adapter->fifo_stall_task, 1); } } } bool e1000_has_link(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; bool link_active = false; /* get_link_status is set on LSC (link status) interrupt or rx * sequence error interrupt (except on intel ce4100). * get_link_status will stay false until the * e1000_check_for_link establishes link for copper adapters * ONLY */ switch (hw->media_type) { case e1000_media_type_copper: if (hw->mac_type == e1000_ce4100) hw->get_link_status = 1; if (hw->get_link_status) { e1000_check_for_link(hw); link_active = !hw->get_link_status; } else { link_active = true; } break; case e1000_media_type_fiber: e1000_check_for_link(hw); link_active = !!(er32(STATUS) & E1000_STATUS_LU); break; case e1000_media_type_internal_serdes: e1000_check_for_link(hw); link_active = hw->serdes_has_link; break; default: break; } return link_active; } /** * e1000_watchdog - work function * @work: work struct contained inside adapter struct **/ static void e1000_watchdog(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, watchdog_task.work); struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; struct e1000_tx_ring *txdr = adapter->tx_ring; u32 link, tctl; link = e1000_has_link(adapter); if ((netif_carrier_ok(netdev)) && link) goto link_up; if (link) { if (!netif_carrier_ok(netdev)) { u32 ctrl; /* update snapshot of PHY registers on LSC */ e1000_get_speed_and_duplex(hw, &adapter->link_speed, &adapter->link_duplex); ctrl = er32(CTRL); pr_info("%s NIC Link is Up %d Mbps %s, " "Flow Control: %s\n", netdev->name, adapter->link_speed, adapter->link_duplex == FULL_DUPLEX ? "Full Duplex" : "Half Duplex", ((ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE)) ? "RX/TX" : ((ctrl & E1000_CTRL_RFCE) ? "RX" : ((ctrl & E1000_CTRL_TFCE) ? "TX" : "None"))); /* adjust timeout factor according to speed/duplex */ adapter->tx_timeout_factor = 1; switch (adapter->link_speed) { case SPEED_10: adapter->tx_timeout_factor = 16; break; case SPEED_100: /* maybe add some timeout factor ? */ break; } /* enable transmits in the hardware */ tctl = er32(TCTL); tctl |= E1000_TCTL_EN; ew32(TCTL, tctl); netif_carrier_on(netdev); if (!test_bit(__E1000_DOWN, &adapter->flags)) schedule_delayed_work(&adapter->phy_info_task, 2 * HZ); adapter->smartspeed = 0; } } else { if (netif_carrier_ok(netdev)) { adapter->link_speed = 0; adapter->link_duplex = 0; pr_info("%s NIC Link is Down\n", netdev->name); netif_carrier_off(netdev); if (!test_bit(__E1000_DOWN, &adapter->flags)) schedule_delayed_work(&adapter->phy_info_task, 2 * HZ); } e1000_smartspeed(adapter); } link_up: e1000_update_stats(adapter); hw->tx_packet_delta = adapter->stats.tpt - adapter->tpt_old; adapter->tpt_old = adapter->stats.tpt; hw->collision_delta = adapter->stats.colc - adapter->colc_old; adapter->colc_old = adapter->stats.colc; adapter->gorcl = adapter->stats.gorcl - adapter->gorcl_old; adapter->gorcl_old = adapter->stats.gorcl; adapter->gotcl = adapter->stats.gotcl - adapter->gotcl_old; adapter->gotcl_old = adapter->stats.gotcl; e1000_update_adaptive(hw); if (!netif_carrier_ok(netdev)) { if (E1000_DESC_UNUSED(txdr) + 1 < txdr->count) { /* We've lost link, so the controller stops DMA, * but we've got queued Tx work that's never going * to get done, so reset controller to flush Tx. * (Do the reset outside of interrupt context). */ adapter->tx_timeout_count++; schedule_work(&adapter->reset_task); /* exit immediately since reset is imminent */ return; } } /* Simple mode for Interrupt Throttle Rate (ITR) */ if (hw->mac_type >= e1000_82540 && adapter->itr_setting == 4) { /* Symmetric Tx/Rx gets a reduced ITR=2000; * Total asymmetrical Tx or Rx gets ITR=8000; * everyone else is between 2000-8000. */ u32 goc = (adapter->gotcl + adapter->gorcl) / 10000; u32 dif = (adapter->gotcl > adapter->gorcl ? adapter->gotcl - adapter->gorcl : adapter->gorcl - adapter->gotcl) / 10000; u32 itr = goc > 0 ? (dif * 6000 / goc + 2000) : 8000; ew32(ITR, 1000000000 / (itr * 256)); } /* Cause software interrupt to ensure rx ring is cleaned */ ew32(ICS, E1000_ICS_RXDMT0); /* Force detection of hung controller every watchdog period */ adapter->detect_tx_hung = true; /* Reschedule the task */ if (!test_bit(__E1000_DOWN, &adapter->flags)) schedule_delayed_work(&adapter->watchdog_task, 2 * HZ); } enum latency_range { lowest_latency = 0, low_latency = 1, bulk_latency = 2, latency_invalid = 255 }; /** * e1000_update_itr - update the dynamic ITR value based on statistics * @adapter: pointer to adapter * @itr_setting: current adapter->itr * @packets: the number of packets during this measurement interval * @bytes: the number of bytes during this measurement interval * * Stores a new ITR value based on packets and byte * counts during the last interrupt. The advantage of per interrupt * computation is faster updates and more accurate ITR for the current * traffic pattern. Constants in this function were computed * based on theoretical maximum wire speed and thresholds were set based * on testing data as well as attempting to minimize response time * while increasing bulk throughput. * this functionality is controlled by the InterruptThrottleRate module * parameter (see e1000_param.c) **/ static unsigned int e1000_update_itr(struct e1000_adapter *adapter, u16 itr_setting, int packets, int bytes) { unsigned int retval = itr_setting; struct e1000_hw *hw = &adapter->hw; if (unlikely(hw->mac_type < e1000_82540)) goto update_itr_done; if (packets == 0) goto update_itr_done; switch (itr_setting) { case lowest_latency: /* jumbo frames get bulk treatment*/ if (bytes/packets > 8000) retval = bulk_latency; else if ((packets < 5) && (bytes > 512)) retval = low_latency; break; case low_latency: /* 50 usec aka 20000 ints/s */ if (bytes > 10000) { /* jumbo frames need bulk latency setting */ if (bytes/packets > 8000) retval = bulk_latency; else if ((packets < 10) || ((bytes/packets) > 1200)) retval = bulk_latency; else if ((packets > 35)) retval = lowest_latency; } else if (bytes/packets > 2000) retval = bulk_latency; else if (packets <= 2 && bytes < 512) retval = lowest_latency; break; case bulk_latency: /* 250 usec aka 4000 ints/s */ if (bytes > 25000) { if (packets > 35) retval = low_latency; } else if (bytes < 6000) { retval = low_latency; } break; } update_itr_done: return retval; } static void e1000_set_itr(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u16 current_itr; u32 new_itr = adapter->itr; if (unlikely(hw->mac_type < e1000_82540)) return; /* for non-gigabit speeds, just fix the interrupt rate at 4000 */ if (unlikely(adapter->link_speed != SPEED_1000)) { new_itr = 4000; goto set_itr_now; } adapter->tx_itr = e1000_update_itr(adapter, adapter->tx_itr, adapter->total_tx_packets, adapter->total_tx_bytes); /* conservative mode (itr 3) eliminates the lowest_latency setting */ if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency) adapter->tx_itr = low_latency; adapter->rx_itr = e1000_update_itr(adapter, adapter->rx_itr, adapter->total_rx_packets, adapter->total_rx_bytes); /* conservative mode (itr 3) eliminates the lowest_latency setting */ if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency) adapter->rx_itr = low_latency; current_itr = max(adapter->rx_itr, adapter->tx_itr); switch (current_itr) { /* counts and packets in update_itr are dependent on these numbers */ case lowest_latency: new_itr = 70000; break; case low_latency: new_itr = 20000; /* aka hwitr = ~200 */ break; case bulk_latency: new_itr = 4000; break; default: break; } set_itr_now: if (new_itr != adapter->itr) { /* this attempts to bias the interrupt rate towards Bulk * by adding intermediate steps when interrupt rate is * increasing */ new_itr = new_itr > adapter->itr ? min(adapter->itr + (new_itr >> 2), new_itr) : new_itr; adapter->itr = new_itr; ew32(ITR, 1000000000 / (new_itr * 256)); } } #define E1000_TX_FLAGS_CSUM 0x00000001 #define E1000_TX_FLAGS_VLAN 0x00000002 #define E1000_TX_FLAGS_TSO 0x00000004 #define E1000_TX_FLAGS_IPV4 0x00000008 #define E1000_TX_FLAGS_NO_FCS 0x00000010 #define E1000_TX_FLAGS_VLAN_MASK 0xffff0000 #define E1000_TX_FLAGS_VLAN_SHIFT 16 static int e1000_tso(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, struct sk_buff *skb, __be16 protocol) { struct e1000_context_desc *context_desc; struct e1000_tx_buffer *buffer_info; unsigned int i; u32 cmd_length = 0; u16 ipcse = 0, tucse, mss; u8 ipcss, ipcso, tucss, tucso, hdr_len; if (skb_is_gso(skb)) { int err; err = skb_cow_head(skb, 0); if (err < 0) return err; hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); mss = skb_shinfo(skb)->gso_size; if (protocol == htons(ETH_P_IP)) { struct iphdr *iph = ip_hdr(skb); iph->tot_len = 0; iph->check = 0; tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, IPPROTO_TCP, 0); cmd_length = E1000_TXD_CMD_IP; ipcse = skb_transport_offset(skb) - 1; } else if (skb_is_gso_v6(skb)) { tcp_v6_gso_csum_prep(skb); ipcse = 0; } ipcss = skb_network_offset(skb); ipcso = (void *)&(ip_hdr(skb)->check) - (void *)skb->data; tucss = skb_transport_offset(skb); tucso = (void *)&(tcp_hdr(skb)->check) - (void *)skb->data; tucse = 0; cmd_length |= (E1000_TXD_CMD_DEXT | E1000_TXD_CMD_TSE | E1000_TXD_CMD_TCP | (skb->len - (hdr_len))); i = tx_ring->next_to_use; context_desc = E1000_CONTEXT_DESC(*tx_ring, i); buffer_info = &tx_ring->buffer_info[i]; context_desc->lower_setup.ip_fields.ipcss = ipcss; context_desc->lower_setup.ip_fields.ipcso = ipcso; context_desc->lower_setup.ip_fields.ipcse = cpu_to_le16(ipcse); context_desc->upper_setup.tcp_fields.tucss = tucss; context_desc->upper_setup.tcp_fields.tucso = tucso; context_desc->upper_setup.tcp_fields.tucse = cpu_to_le16(tucse); context_desc->tcp_seg_setup.fields.mss = cpu_to_le16(mss); context_desc->tcp_seg_setup.fields.hdr_len = hdr_len; context_desc->cmd_and_length = cpu_to_le32(cmd_length); buffer_info->time_stamp = jiffies; buffer_info->next_to_watch = i; if (++i == tx_ring->count) i = 0; tx_ring->next_to_use = i; return true; } return false; } static bool e1000_tx_csum(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, struct sk_buff *skb, __be16 protocol) { struct e1000_context_desc *context_desc; struct e1000_tx_buffer *buffer_info; unsigned int i; u8 css; u32 cmd_len = E1000_TXD_CMD_DEXT; if (skb->ip_summed != CHECKSUM_PARTIAL) return false; switch (protocol) { case cpu_to_be16(ETH_P_IP): if (ip_hdr(skb)->protocol == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; break; case cpu_to_be16(ETH_P_IPV6): /* XXX not handling all IPV6 headers */ if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) cmd_len |= E1000_TXD_CMD_TCP; break; default: if (unlikely(net_ratelimit())) e_warn(drv, "checksum_partial proto=%x!\n", skb->protocol); break; } css = skb_checksum_start_offset(skb); i = tx_ring->next_to_use; buffer_info = &tx_ring->buffer_info[i]; context_desc = E1000_CONTEXT_DESC(*tx_ring, i); context_desc->lower_setup.ip_config = 0; context_desc->upper_setup.tcp_fields.tucss = css; context_desc->upper_setup.tcp_fields.tucso = css + skb->csum_offset; context_desc->upper_setup.tcp_fields.tucse = 0; context_desc->tcp_seg_setup.data = 0; context_desc->cmd_and_length = cpu_to_le32(cmd_len); buffer_info->time_stamp = jiffies; buffer_info->next_to_watch = i; if (unlikely(++i == tx_ring->count)) i = 0; tx_ring->next_to_use = i; return true; } #define E1000_MAX_TXD_PWR 12 #define E1000_MAX_DATA_PER_TXD (1<<E1000_MAX_TXD_PWR) static int e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, struct sk_buff *skb, unsigned int first, unsigned int max_per_txd, unsigned int nr_frags, unsigned int mss) { struct e1000_hw *hw = &adapter->hw; struct pci_dev *pdev = adapter->pdev; struct e1000_tx_buffer *buffer_info; unsigned int len = skb_headlen(skb); unsigned int offset = 0, size, count = 0, i; unsigned int f, bytecount, segs; i = tx_ring->next_to_use; while (len) { buffer_info = &tx_ring->buffer_info[i]; size = min(len, max_per_txd); /* Workaround for Controller erratum -- * descriptor for non-tso packet in a linear SKB that follows a * tso gets written back prematurely before the data is fully * DMA'd to the controller */ if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb)) { tx_ring->last_tx_tso = false; size -= 4; } /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ if (unlikely(mss && !nr_frags && size == len && size > 8)) size -= 4; /* work-around for errata 10 and it applies * to all controllers in PCI-X mode * The fix is to make sure that the first descriptor of a * packet is smaller than 2048 - 16 - 16 (or 2016) bytes */ if (unlikely((hw->bus_type == e1000_bus_type_pcix) && (size > 2015) && count == 0)) size = 2015; /* Workaround for potential 82544 hang in PCI-X. Avoid * terminating buffers within evenly-aligned dwords. */ if (unlikely(adapter->pcix_82544 && !((unsigned long)(skb->data + offset + size - 1) & 4) && size > 4)) size -= 4; buffer_info->length = size; /* set time_stamp *before* dma to help avoid a possible race */ buffer_info->time_stamp = jiffies; buffer_info->mapped_as_page = false; buffer_info->dma = dma_map_single(&pdev->dev, skb->data + offset, size, DMA_TO_DEVICE); if (dma_mapping_error(&pdev->dev, buffer_info->dma)) goto dma_error; buffer_info->next_to_watch = i; len -= size; offset += size; count++; if (len) { i++; if (unlikely(i == tx_ring->count)) i = 0; } } for (f = 0; f < nr_frags; f++) { const skb_frag_t *frag = &skb_shinfo(skb)->frags[f]; len = skb_frag_size(frag); offset = 0; while (len) { unsigned long bufend; i++; if (unlikely(i == tx_ring->count)) i = 0; buffer_info = &tx_ring->buffer_info[i]; size = min(len, max_per_txd); /* Workaround for premature desc write-backs * in TSO mode. Append 4-byte sentinel desc */ if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8)) size -= 4; /* Workaround for potential 82544 hang in PCI-X. * Avoid terminating buffers within evenly-aligned * dwords. */ bufend = (unsigned long) page_to_phys(skb_frag_page(frag)); bufend += offset + size - 1; if (unlikely(adapter->pcix_82544 && !(bufend & 4) && size > 4)) size -= 4; buffer_info->length = size; buffer_info->time_stamp = jiffies; buffer_info->mapped_as_page = true; buffer_info->dma = skb_frag_dma_map(&pdev->dev, frag, offset, size, DMA_TO_DEVICE); if (dma_mapping_error(&pdev->dev, buffer_info->dma)) goto dma_error; buffer_info->next_to_watch = i; len -= size; offset += size; count++; } } segs = skb_shinfo(skb)->gso_segs ?: 1; /* multiply data chunks by size of headers */ bytecount = ((segs - 1) * skb_headlen(skb)) + skb->len; tx_ring->buffer_info[i].skb = skb; tx_ring->buffer_info[i].segs = segs; tx_ring->buffer_info[i].bytecount = bytecount; tx_ring->buffer_info[first].next_to_watch = i; return count; dma_error: dev_err(&pdev->dev, "TX DMA map failed\n"); buffer_info->dma = 0; if (count) count--; while (count--) { if (i == 0) i += tx_ring->count; i--; buffer_info = &tx_ring->buffer_info[i]; e1000_unmap_and_free_tx_resource(adapter, buffer_info); } return 0; } static void e1000_tx_queue(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring, int tx_flags, int count) { struct e1000_tx_desc *tx_desc = NULL; struct e1000_tx_buffer *buffer_info; u32 txd_upper = 0, txd_lower = E1000_TXD_CMD_IFCS; unsigned int i; if (likely(tx_flags & E1000_TX_FLAGS_TSO)) { txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D | E1000_TXD_CMD_TSE; txd_upper |= E1000_TXD_POPTS_TXSM << 8; if (likely(tx_flags & E1000_TX_FLAGS_IPV4)) txd_upper |= E1000_TXD_POPTS_IXSM << 8; } if (likely(tx_flags & E1000_TX_FLAGS_CSUM)) { txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; txd_upper |= E1000_TXD_POPTS_TXSM << 8; } if (unlikely(tx_flags & E1000_TX_FLAGS_VLAN)) { txd_lower |= E1000_TXD_CMD_VLE; txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK); } if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) txd_lower &= ~(E1000_TXD_CMD_IFCS); i = tx_ring->next_to_use; while (count--) { buffer_info = &tx_ring->buffer_info[i]; tx_desc = E1000_TX_DESC(*tx_ring, i); tx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); tx_desc->lower.data = cpu_to_le32(txd_lower | buffer_info->length); tx_desc->upper.data = cpu_to_le32(txd_upper); if (unlikely(++i == tx_ring->count)) i = 0; } tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd); /* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */ if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS)) tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS)); /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, * such as IA-64). */ dma_wmb(); tx_ring->next_to_use = i; } /* 82547 workaround to avoid controller hang in half-duplex environment. * The workaround is to avoid queuing a large packet that would span * the internal Tx FIFO ring boundary by notifying the stack to resend * the packet at a later time. This gives the Tx FIFO an opportunity to * flush all packets. When that occurs, we reset the Tx FIFO pointers * to the beginning of the Tx FIFO. */ #define E1000_FIFO_HDR 0x10 #define E1000_82547_PAD_LEN 0x3E0 static int e1000_82547_fifo_workaround(struct e1000_adapter *adapter, struct sk_buff *skb) { u32 fifo_space = adapter->tx_fifo_size - adapter->tx_fifo_head; u32 skb_fifo_len = skb->len + E1000_FIFO_HDR; skb_fifo_len = ALIGN(skb_fifo_len, E1000_FIFO_HDR); if (adapter->link_duplex != HALF_DUPLEX) goto no_fifo_stall_required; if (atomic_read(&adapter->tx_fifo_stall)) return 1; if (skb_fifo_len >= (E1000_82547_PAD_LEN + fifo_space)) { atomic_set(&adapter->tx_fifo_stall, 1); return 1; } no_fifo_stall_required: adapter->tx_fifo_head += skb_fifo_len; if (adapter->tx_fifo_head >= adapter->tx_fifo_size) adapter->tx_fifo_head -= adapter->tx_fifo_size; return 0; } static int __e1000_maybe_stop_tx(struct net_device *netdev, int size) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_tx_ring *tx_ring = adapter->tx_ring; netif_stop_queue(netdev); /* Herbert's original patch had: * smp_mb__after_netif_stop_queue(); * but since that doesn't exist yet, just open code it. */ smp_mb(); /* We need to check again in a case another CPU has just * made room available. */ if (likely(E1000_DESC_UNUSED(tx_ring) < size)) return -EBUSY; /* A reprieve! */ netif_start_queue(netdev); ++adapter->restart_queue; return 0; } static int e1000_maybe_stop_tx(struct net_device *netdev, struct e1000_tx_ring *tx_ring, int size) { if (likely(E1000_DESC_UNUSED(tx_ring) >= size)) return 0; return __e1000_maybe_stop_tx(netdev, size); } #define TXD_USE_COUNT(S, X) (((S) + ((1 << (X)) - 1)) >> (X)) static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; struct e1000_tx_ring *tx_ring; unsigned int first, max_per_txd = E1000_MAX_DATA_PER_TXD; unsigned int max_txd_pwr = E1000_MAX_TXD_PWR; unsigned int tx_flags = 0; unsigned int len = skb_headlen(skb); unsigned int nr_frags; unsigned int mss; int count = 0; int tso; unsigned int f; __be16 protocol = vlan_get_protocol(skb); /* This goes back to the question of how to logically map a Tx queue * to a flow. Right now, performance is impacted slightly negatively * if using multiple Tx queues. If the stack breaks away from a * single qdisc implementation, we can look at this again. */ tx_ring = adapter->tx_ring; /* On PCI/PCI-X HW, if packet size is less than ETH_ZLEN, * packets may get corrupted during padding by HW. * To WA this issue, pad all small packets manually. */ if (eth_skb_pad(skb)) return NETDEV_TX_OK; mss = skb_shinfo(skb)->gso_size; /* The controller does a simple calculation to * make sure there is enough room in the FIFO before * initiating the DMA for each buffer. The calc is: * 4 = ceil(buffer len/mss). To make sure we don't * overrun the FIFO, adjust the max buffer len if mss * drops. */ if (mss) { u8 hdr_len; max_per_txd = min(mss << 2, max_per_txd); max_txd_pwr = fls(max_per_txd) - 1; hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb); if (skb->data_len && hdr_len == len) { switch (hw->mac_type) { case e1000_82544: { unsigned int pull_size; /* Make sure we have room to chop off 4 bytes, * and that the end alignment will work out to * this hardware's requirements * NOTE: this is a TSO only workaround * if end byte alignment not correct move us * into the next dword */ if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4) break; pull_size = min((unsigned int)4, skb->data_len); if (!__pskb_pull_tail(skb, pull_size)) { e_err(drv, "__pskb_pull_tail " "failed.\n"); dev_kfree_skb_any(skb); return NETDEV_TX_OK; } len = skb_headlen(skb); break; } default: /* do nothing */ break; } } } /* reserve a descriptor for the offload context */ if ((mss) || (skb->ip_summed == CHECKSUM_PARTIAL)) count++; count++; /* Controller Erratum workaround */ if (!skb->data_len && tx_ring->last_tx_tso && !skb_is_gso(skb)) count++; count += TXD_USE_COUNT(len, max_txd_pwr); if (adapter->pcix_82544) count++; /* work-around for errata 10 and it applies to all controllers * in PCI-X mode, so add one more descriptor to the count */ if (unlikely((hw->bus_type == e1000_bus_type_pcix) && (len > 2015))) count++; nr_frags = skb_shinfo(skb)->nr_frags; for (f = 0; f < nr_frags; f++) count += TXD_USE_COUNT(skb_frag_size(&skb_shinfo(skb)->frags[f]), max_txd_pwr); if (adapter->pcix_82544) count += nr_frags; /* need: count + 2 desc gap to keep tail from touching * head, otherwise try next time */ if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2))) return NETDEV_TX_BUSY; if (unlikely((hw->mac_type == e1000_82547) && (e1000_82547_fifo_workaround(adapter, skb)))) { netif_stop_queue(netdev); if (!test_bit(__E1000_DOWN, &adapter->flags)) schedule_delayed_work(&adapter->fifo_stall_task, 1); return NETDEV_TX_BUSY; } if (skb_vlan_tag_present(skb)) { tx_flags |= E1000_TX_FLAGS_VLAN; tx_flags |= (skb_vlan_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT); } first = tx_ring->next_to_use; tso = e1000_tso(adapter, tx_ring, skb, protocol); if (tso < 0) { dev_kfree_skb_any(skb); return NETDEV_TX_OK; } if (likely(tso)) { if (likely(hw->mac_type != e1000_82544)) tx_ring->last_tx_tso = true; tx_flags |= E1000_TX_FLAGS_TSO; } else if (likely(e1000_tx_csum(adapter, tx_ring, skb, protocol))) tx_flags |= E1000_TX_FLAGS_CSUM; if (protocol == htons(ETH_P_IP)) tx_flags |= E1000_TX_FLAGS_IPV4; if (unlikely(skb->no_fcs)) tx_flags |= E1000_TX_FLAGS_NO_FCS; count = e1000_tx_map(adapter, tx_ring, skb, first, max_per_txd, nr_frags, mss); if (count) { /* The descriptors needed is higher than other Intel drivers * due to a number of workarounds. The breakdown is below: * Data descriptors: MAX_SKB_FRAGS + 1 * Context Descriptor: 1 * Keep head from touching tail: 2 * Workarounds: 3 */ int desc_needed = MAX_SKB_FRAGS + 7; netdev_sent_queue(netdev, skb->len); skb_tx_timestamp(skb); e1000_tx_queue(adapter, tx_ring, tx_flags, count); /* 82544 potentially requires twice as many data descriptors * in order to guarantee buffers don't end on evenly-aligned * dwords */ if (adapter->pcix_82544) desc_needed += MAX_SKB_FRAGS + 1; /* Make sure there is space in the ring for the next send. */ e1000_maybe_stop_tx(netdev, tx_ring, desc_needed); if (!netdev_xmit_more() || netif_xmit_stopped(netdev_get_tx_queue(netdev, 0))) { writel(tx_ring->next_to_use, hw->hw_addr + tx_ring->tdt); } } else { dev_kfree_skb_any(skb); tx_ring->buffer_info[first].time_stamp = 0; tx_ring->next_to_use = first; } return NETDEV_TX_OK; } #define NUM_REGS 38 /* 1 based count */ static void e1000_regdump(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u32 regs[NUM_REGS]; u32 *regs_buff = regs; int i = 0; static const char * const reg_name[] = { "CTRL", "STATUS", "RCTL", "RDLEN", "RDH", "RDT", "RDTR", "TCTL", "TDBAL", "TDBAH", "TDLEN", "TDH", "TDT", "TIDV", "TXDCTL", "TADV", "TARC0", "TDBAL1", "TDBAH1", "TDLEN1", "TDH1", "TDT1", "TXDCTL1", "TARC1", "CTRL_EXT", "ERT", "RDBAL", "RDBAH", "TDFH", "TDFT", "TDFHS", "TDFTS", "TDFPC", "RDFH", "RDFT", "RDFHS", "RDFTS", "RDFPC" }; regs_buff[0] = er32(CTRL); regs_buff[1] = er32(STATUS); regs_buff[2] = er32(RCTL); regs_buff[3] = er32(RDLEN); regs_buff[4] = er32(RDH); regs_buff[5] = er32(RDT); regs_buff[6] = er32(RDTR); regs_buff[7] = er32(TCTL); regs_buff[8] = er32(TDBAL); regs_buff[9] = er32(TDBAH); regs_buff[10] = er32(TDLEN); regs_buff[11] = er32(TDH); regs_buff[12] = er32(TDT); regs_buff[13] = er32(TIDV); regs_buff[14] = er32(TXDCTL); regs_buff[15] = er32(TADV); regs_buff[16] = er32(TARC0); regs_buff[17] = er32(TDBAL1); regs_buff[18] = er32(TDBAH1); regs_buff[19] = er32(TDLEN1); regs_buff[20] = er32(TDH1); regs_buff[21] = er32(TDT1); regs_buff[22] = er32(TXDCTL1); regs_buff[23] = er32(TARC1); regs_buff[24] = er32(CTRL_EXT); regs_buff[25] = er32(ERT); regs_buff[26] = er32(RDBAL0); regs_buff[27] = er32(RDBAH0); regs_buff[28] = er32(TDFH); regs_buff[29] = er32(TDFT); regs_buff[30] = er32(TDFHS); regs_buff[31] = er32(TDFTS); regs_buff[32] = er32(TDFPC); regs_buff[33] = er32(RDFH); regs_buff[34] = er32(RDFT); regs_buff[35] = er32(RDFHS); regs_buff[36] = er32(RDFTS); regs_buff[37] = er32(RDFPC); pr_info("Register dump\n"); for (i = 0; i < NUM_REGS; i++) pr_info("%-15s %08x\n", reg_name[i], regs_buff[i]); } /* * e1000_dump: Print registers, tx ring and rx ring */ static void e1000_dump(struct e1000_adapter *adapter) { /* this code doesn't handle multiple rings */ struct e1000_tx_ring *tx_ring = adapter->tx_ring; struct e1000_rx_ring *rx_ring = adapter->rx_ring; int i; if (!netif_msg_hw(adapter)) return; /* Print Registers */ e1000_regdump(adapter); /* transmit dump */ pr_info("TX Desc ring0 dump\n"); /* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended) * * Legacy Transmit Descriptor * +--------------------------------------------------------------+ * 0 | Buffer Address [63:0] (Reserved on Write Back) | * +--------------------------------------------------------------+ * 8 | Special | CSS | Status | CMD | CSO | Length | * +--------------------------------------------------------------+ * 63 48 47 36 35 32 31 24 23 16 15 0 * * Extended Context Descriptor (DTYP=0x0) for TSO or checksum offload * 63 48 47 40 39 32 31 16 15 8 7 0 * +----------------------------------------------------------------+ * 0 | TUCSE | TUCS0 | TUCSS | IPCSE | IPCS0 | IPCSS | * +----------------------------------------------------------------+ * 8 | MSS | HDRLEN | RSV | STA | TUCMD | DTYP | PAYLEN | * +----------------------------------------------------------------+ * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 * * Extended Data Descriptor (DTYP=0x1) * +----------------------------------------------------------------+ * 0 | Buffer Address [63:0] | * +----------------------------------------------------------------+ * 8 | VLAN tag | POPTS | Rsvd | Status | Command | DTYP | DTALEN | * +----------------------------------------------------------------+ * 63 48 47 40 39 36 35 32 31 24 23 20 19 0 */ pr_info("Tc[desc] [Ce CoCsIpceCoS] [MssHlRSCm0Plen] [bi->dma ] leng ntw timestmp bi->skb\n"); pr_info("Td[desc] [address 63:0 ] [VlaPoRSCm1Dlen] [bi->dma ] leng ntw timestmp bi->skb\n"); if (!netif_msg_tx_done(adapter)) goto rx_ring_summary; for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { struct e1000_tx_desc *tx_desc = E1000_TX_DESC(*tx_ring, i); struct e1000_tx_buffer *buffer_info = &tx_ring->buffer_info[i]; struct my_u { __le64 a; __le64 b; }; struct my_u *u = (struct my_u *)tx_desc; const char *type; if (i == tx_ring->next_to_use && i == tx_ring->next_to_clean) type = "NTC/U"; else if (i == tx_ring->next_to_use) type = "NTU"; else if (i == tx_ring->next_to_clean) type = "NTC"; else type = ""; pr_info("T%c[0x%03X] %016llX %016llX %016llX %04X %3X %016llX %p %s\n", ((le64_to_cpu(u->b) & (1<<20)) ? 'd' : 'c'), i, le64_to_cpu(u->a), le64_to_cpu(u->b), (u64)buffer_info->dma, buffer_info->length, buffer_info->next_to_watch, (u64)buffer_info->time_stamp, buffer_info->skb, type); } rx_ring_summary: /* receive dump */ pr_info("\nRX Desc ring dump\n"); /* Legacy Receive Descriptor Format * * +-----------------------------------------------------+ * | Buffer Address [63:0] | * +-----------------------------------------------------+ * | VLAN Tag | Errors | Status 0 | Packet csum | Length | * +-----------------------------------------------------+ * 63 48 47 40 39 32 31 16 15 0 */ pr_info("R[desc] [address 63:0 ] [vl er S cks ln] [bi->dma ] [bi->skb]\n"); if (!netif_msg_rx_status(adapter)) goto exit; for (i = 0; rx_ring->desc && (i < rx_ring->count); i++) { struct e1000_rx_desc *rx_desc = E1000_RX_DESC(*rx_ring, i); struct e1000_rx_buffer *buffer_info = &rx_ring->buffer_info[i]; struct my_u { __le64 a; __le64 b; }; struct my_u *u = (struct my_u *)rx_desc; const char *type; if (i == rx_ring->next_to_use) type = "NTU"; else if (i == rx_ring->next_to_clean) type = "NTC"; else type = ""; pr_info("R[0x%03X] %016llX %016llX %016llX %p %s\n", i, le64_to_cpu(u->a), le64_to_cpu(u->b), (u64)buffer_info->dma, buffer_info->rxbuf.data, type); } /* for */ /* dump the descriptor caches */ /* rx */ pr_info("Rx descriptor cache in 64bit format\n"); for (i = 0x6000; i <= 0x63FF ; i += 0x10) { pr_info("R%04X: %08X|%08X %08X|%08X\n", i, readl(adapter->hw.hw_addr + i+4), readl(adapter->hw.hw_addr + i), readl(adapter->hw.hw_addr + i+12), readl(adapter->hw.hw_addr + i+8)); } /* tx */ pr_info("Tx descriptor cache in 64bit format\n"); for (i = 0x7000; i <= 0x73FF ; i += 0x10) { pr_info("T%04X: %08X|%08X %08X|%08X\n", i, readl(adapter->hw.hw_addr + i+4), readl(adapter->hw.hw_addr + i), readl(adapter->hw.hw_addr + i+12), readl(adapter->hw.hw_addr + i+8)); } exit: return; } /** * e1000_tx_timeout - Respond to a Tx Hang * @netdev: network interface device structure * @txqueue: number of the Tx queue that hung (unused) **/ static void e1000_tx_timeout(struct net_device *netdev, unsigned int __always_unused txqueue) { struct e1000_adapter *adapter = netdev_priv(netdev); /* Do the reset outside of interrupt context */ adapter->tx_timeout_count++; schedule_work(&adapter->reset_task); } static void e1000_reset_task(struct work_struct *work) { struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, reset_task); e_err(drv, "Reset adapter\n"); e1000_reinit_locked(adapter); } /** * e1000_change_mtu - Change the Maximum Transfer Unit * @netdev: network interface device structure * @new_mtu: new value for maximum frame size * * Returns 0 on success, negative on failure **/ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN; /* Adapter-specific max frame size limits. */ switch (hw->mac_type) { case e1000_undefined ... e1000_82542_rev2_1: if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) { e_err(probe, "Jumbo Frames not supported.\n"); return -EINVAL; } break; default: /* Capable of supporting up to MAX_JUMBO_FRAME_SIZE limit. */ break; } while (test_and_set_bit(__E1000_RESETTING, &adapter->flags)) msleep(1); /* e1000_down has a dependency on max_frame_size */ hw->max_frame_size = max_frame; if (netif_running(netdev)) { /* prevent buffers from being reallocated */ adapter->alloc_rx_buf = e1000_alloc_dummy_rx_buffers; e1000_down(adapter); } /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN * means we reserve 2 more, this pushes us to allocate from the next * larger slab size. * i.e. RXBUFFER_2048 --> size-4096 slab * however with the new *_jumbo_rx* routines, jumbo receives will use * fragmented skbs */ if (max_frame <= E1000_RXBUFFER_2048) adapter->rx_buffer_len = E1000_RXBUFFER_2048; else #if (PAGE_SIZE >= E1000_RXBUFFER_16384) adapter->rx_buffer_len = E1000_RXBUFFER_16384; #elif (PAGE_SIZE >= E1000_RXBUFFER_4096) adapter->rx_buffer_len = PAGE_SIZE; #endif /* adjust allocation if LPE protects us, and we aren't using SBP */ if (!hw->tbi_compatibility_on && ((max_frame == (ETH_FRAME_LEN + ETH_FCS_LEN)) || (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; netdev_dbg(netdev, "changing MTU from %d to %d\n", netdev->mtu, new_mtu); netdev->mtu = new_mtu; if (netif_running(netdev)) e1000_up(adapter); else e1000_reset(adapter); clear_bit(__E1000_RESETTING, &adapter->flags); return 0; } /** * e1000_update_stats - Update the board statistics counters * @adapter: board private structure **/ void e1000_update_stats(struct e1000_adapter *adapter) { struct net_device *netdev = adapter->netdev; struct e1000_hw *hw = &adapter->hw; struct pci_dev *pdev = adapter->pdev; unsigned long flags; u16 phy_tmp; #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF /* Prevent stats update while adapter is being reset, or if the pci * connection is down. */ if (adapter->link_speed == 0) return; if (pci_channel_offline(pdev)) return; spin_lock_irqsave(&adapter->stats_lock, flags); /* these counters are modified from e1000_tbi_adjust_stats, * called from the interrupt context, so they must only * be written while holding adapter->stats_lock */ adapter->stats.crcerrs += er32(CRCERRS); adapter->stats.gprc += er32(GPRC); adapter->stats.gorcl += er32(GORCL); adapter->stats.gorch += er32(GORCH); adapter->stats.bprc += er32(BPRC); adapter->stats.mprc += er32(MPRC); adapter->stats.roc += er32(ROC); adapter->stats.prc64 += er32(PRC64); adapter->stats.prc127 += er32(PRC127); adapter->stats.prc255 += er32(PRC255); adapter->stats.prc511 += er32(PRC511); adapter->stats.prc1023 += er32(PRC1023); adapter->stats.prc1522 += er32(PRC1522); adapter->stats.symerrs += er32(SYMERRS); adapter->stats.mpc += er32(MPC); adapter->stats.scc += er32(SCC); adapter->stats.ecol += er32(ECOL); adapter->stats.mcc += er32(MCC); adapter->stats.latecol += er32(LATECOL); adapter->stats.dc += er32(DC); adapter->stats.sec += er32(SEC); adapter->stats.rlec += er32(RLEC); adapter->stats.xonrxc += er32(XONRXC); adapter->stats.xontxc += er32(XONTXC); adapter->stats.xoffrxc += er32(XOFFRXC); adapter->stats.xofftxc += er32(XOFFTXC); adapter->stats.fcruc += er32(FCRUC); adapter->stats.gptc += er32(GPTC); adapter->stats.gotcl += er32(GOTCL); adapter->stats.gotch += er32(GOTCH); adapter->stats.rnbc += er32(RNBC); adapter->stats.ruc += er32(RUC); adapter->stats.rfc += er32(RFC); adapter->stats.rjc += er32(RJC); adapter->stats.torl += er32(TORL); adapter->stats.torh += er32(TORH); adapter->stats.totl += er32(TOTL); adapter->stats.toth += er32(TOTH); adapter->stats.tpr += er32(TPR); adapter->stats.ptc64 += er32(PTC64); adapter->stats.ptc127 += er32(PTC127); adapter->stats.ptc255 += er32(PTC255); adapter->stats.ptc511 += er32(PTC511); adapter->stats.ptc1023 += er32(PTC1023); adapter->stats.ptc1522 += er32(PTC1522); adapter->stats.mptc += er32(MPTC); adapter->stats.bptc += er32(BPTC); /* used for adaptive IFS */ hw->tx_packet_delta = er32(TPT); adapter->stats.tpt += hw->tx_packet_delta; hw->collision_delta = er32(COLC); adapter->stats.colc += hw->collision_delta; if (hw->mac_type >= e1000_82543) { adapter->stats.algnerrc += er32(ALGNERRC); adapter->stats.rxerrc += er32(RXERRC); adapter->stats.tncrs += er32(TNCRS); adapter->stats.cexterr += er32(CEXTERR); adapter->stats.tsctc += er32(TSCTC); adapter->stats.tsctfc += er32(TSCTFC); } /* Fill out the OS statistics structure */ netdev->stats.multicast = adapter->stats.mprc; netdev->stats.collisions = adapter->stats.colc; /* Rx Errors */ /* RLEC on some newer hardware can be incorrect so build * our own version based on RUC and ROC */ netdev->stats.rx_errors = adapter->stats.rxerrc + adapter->stats.crcerrs + adapter->stats.algnerrc + adapter->stats.ruc + adapter->stats.roc + adapter->stats.cexterr; adapter->stats.rlerrc = adapter->stats.ruc + adapter->stats.roc; netdev->stats.rx_length_errors = adapter->stats.rlerrc; netdev->stats.rx_crc_errors = adapter->stats.crcerrs; netdev->stats.rx_frame_errors = adapter->stats.algnerrc; netdev->stats.rx_missed_errors = adapter->stats.mpc; /* Tx Errors */ adapter->stats.txerrc = adapter->stats.ecol + adapter->stats.latecol; netdev->stats.tx_errors = adapter->stats.txerrc; netdev->stats.tx_aborted_errors = adapter->stats.ecol; netdev->stats.tx_window_errors = adapter->stats.latecol; netdev->stats.tx_carrier_errors = adapter->stats.tncrs; if (hw->bad_tx_carr_stats_fd && adapter->link_duplex == FULL_DUPLEX) { netdev->stats.tx_carrier_errors = 0; adapter->stats.tncrs = 0; } /* Tx Dropped needs to be maintained elsewhere */ /* Phy Stats */ if (hw->media_type == e1000_media_type_copper) { if ((adapter->link_speed == SPEED_1000) && (!e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_tmp))) { phy_tmp &= PHY_IDLE_ERROR_COUNT_MASK; adapter->phy_stats.idle_errors += phy_tmp; } if ((hw->mac_type <= e1000_82546) && (hw->phy_type == e1000_phy_m88) && !e1000_read_phy_reg(hw, M88E1000_RX_ERR_CNTR, &phy_tmp)) adapter->phy_stats.receive_errors += phy_tmp; } /* Management Stats */ if (hw->has_smbus) { adapter->stats.mgptc += er32(MGTPTC); adapter->stats.mgprc += er32(MGTPRC); adapter->stats.mgpdc += er32(MGTPDC); } spin_unlock_irqrestore(&adapter->stats_lock, flags); } /** * e1000_intr - Interrupt Handler * @irq: interrupt number * @data: pointer to a network interface device structure **/ static irqreturn_t e1000_intr(int irq, void *data) { struct net_device *netdev = data; struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 icr = er32(ICR); if (unlikely((!icr))) return IRQ_NONE; /* Not our interrupt */ /* we might have caused the interrupt, but the above * read cleared it, and just in case the driver is * down there is nothing to do so return handled */ if (unlikely(test_bit(__E1000_DOWN, &adapter->flags))) return IRQ_HANDLED; if (unlikely(icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC))) { hw->get_link_status = 1; /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->flags)) schedule_delayed_work(&adapter->watchdog_task, 1); } /* disable interrupts, without the synchronize_irq bit */ ew32(IMC, ~0); E1000_WRITE_FLUSH(); if (likely(napi_schedule_prep(&adapter->napi))) { adapter->total_tx_bytes = 0; adapter->total_tx_packets = 0; adapter->total_rx_bytes = 0; adapter->total_rx_packets = 0; __napi_schedule(&adapter->napi); } else { /* this really should not happen! if it does it is basically a * bug, but not a hard error, so enable ints and continue */ if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_enable(adapter); } return IRQ_HANDLED; } /** * e1000_clean - NAPI Rx polling callback * @napi: napi struct containing references to driver info * @budget: budget given to driver for receive packets **/ static int e1000_clean(struct napi_struct *napi, int budget) { struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi); int tx_clean_complete = 0, work_done = 0; tx_clean_complete = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]); adapter->clean_rx(adapter, &adapter->rx_ring[0], &work_done, budget); if (!tx_clean_complete || work_done == budget) return budget; /* Exit the polling mode, but don't re-enable interrupts if stack might * poll us due to busy-polling */ if (likely(napi_complete_done(napi, work_done))) { if (likely(adapter->itr_setting & 3)) e1000_set_itr(adapter); if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_enable(adapter); } return work_done; } /** * e1000_clean_tx_irq - Reclaim resources after transmit completes * @adapter: board private structure * @tx_ring: ring to clean **/ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring) { struct e1000_hw *hw = &adapter->hw; struct net_device *netdev = adapter->netdev; struct e1000_tx_desc *tx_desc, *eop_desc; struct e1000_tx_buffer *buffer_info; unsigned int i, eop; unsigned int count = 0; unsigned int total_tx_bytes = 0, total_tx_packets = 0; unsigned int bytes_compl = 0, pkts_compl = 0; i = tx_ring->next_to_clean; eop = tx_ring->buffer_info[i].next_to_watch; eop_desc = E1000_TX_DESC(*tx_ring, eop); while ((eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) && (count < tx_ring->count)) { bool cleaned = false; dma_rmb(); /* read buffer_info after eop_desc */ for ( ; !cleaned; count++) { tx_desc = E1000_TX_DESC(*tx_ring, i); buffer_info = &tx_ring->buffer_info[i]; cleaned = (i == eop); if (cleaned) { total_tx_packets += buffer_info->segs; total_tx_bytes += buffer_info->bytecount; if (buffer_info->skb) { bytes_compl += buffer_info->skb->len; pkts_compl++; } } e1000_unmap_and_free_tx_resource(adapter, buffer_info); tx_desc->upper.data = 0; if (unlikely(++i == tx_ring->count)) i = 0; } eop = tx_ring->buffer_info[i].next_to_watch; eop_desc = E1000_TX_DESC(*tx_ring, eop); } /* Synchronize with E1000_DESC_UNUSED called from e1000_xmit_frame, * which will reuse the cleaned buffers. */ smp_store_release(&tx_ring->next_to_clean, i); netdev_completed_queue(netdev, pkts_compl, bytes_compl); #define TX_WAKE_THRESHOLD 32 if (unlikely(count && netif_carrier_ok(netdev) && E1000_DESC_UNUSED(tx_ring) >= TX_WAKE_THRESHOLD)) { /* Make sure that anybody stopping the queue after this * sees the new next_to_clean. */ smp_mb(); if (netif_queue_stopped(netdev) && !(test_bit(__E1000_DOWN, &adapter->flags))) { netif_wake_queue(netdev); ++adapter->restart_queue; } } if (adapter->detect_tx_hung) { /* Detect a transmit hang in hardware, this serializes the * check with the clearing of time_stamp and movement of i */ adapter->detect_tx_hung = false; if (tx_ring->buffer_info[eop].time_stamp && time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + (adapter->tx_timeout_factor * HZ)) && !(er32(STATUS) & E1000_STATUS_TXOFF)) { /* detected Tx unit hang */ e_err(drv, "Detected Tx Unit Hang\n" " Tx Queue <%lu>\n" " TDH <%x>\n" " TDT <%x>\n" " next_to_use <%x>\n" " next_to_clean <%x>\n" "buffer_info[next_to_clean]\n" " time_stamp <%lx>\n" " next_to_watch <%x>\n" " jiffies <%lx>\n" " next_to_watch.status <%x>\n", (unsigned long)(tx_ring - adapter->tx_ring), readl(hw->hw_addr + tx_ring->tdh), readl(hw->hw_addr + tx_ring->tdt), tx_ring->next_to_use, tx_ring->next_to_clean, tx_ring->buffer_info[eop].time_stamp, eop, jiffies, eop_desc->upper.fields.status); e1000_dump(adapter); netif_stop_queue(netdev); } } adapter->total_tx_bytes += total_tx_bytes; adapter->total_tx_packets += total_tx_packets; netdev->stats.tx_bytes += total_tx_bytes; netdev->stats.tx_packets += total_tx_packets; return count < tx_ring->count; } /** * e1000_rx_checksum - Receive Checksum Offload for 82543 * @adapter: board private structure * @status_err: receive descriptor status and error fields * @csum: receive descriptor csum field * @skb: socket buffer with received data **/ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, u32 csum, struct sk_buff *skb) { struct e1000_hw *hw = &adapter->hw; u16 status = (u16)status_err; u8 errors = (u8)(status_err >> 24); skb_checksum_none_assert(skb); /* 82543 or newer only */ if (unlikely(hw->mac_type < e1000_82543)) return; /* Ignore Checksum bit is set */ if (unlikely(status & E1000_RXD_STAT_IXSM)) return; /* TCP/UDP checksum error bit is set */ if (unlikely(errors & E1000_RXD_ERR_TCPE)) { /* let the stack verify checksum errors */ adapter->hw_csum_err++; return; } /* TCP/UDP Checksum has not been calculated */ if (!(status & E1000_RXD_STAT_TCPCS)) return; /* It must be a TCP or UDP packet with a valid checksum */ if (likely(status & E1000_RXD_STAT_TCPCS)) { /* TCP checksum is good */ skb->ip_summed = CHECKSUM_UNNECESSARY; } adapter->hw_csum_good++; } /** * e1000_consume_page - helper function for jumbo Rx path * @bi: software descriptor shadow data * @skb: skb being modified * @length: length of data being added **/ static void e1000_consume_page(struct e1000_rx_buffer *bi, struct sk_buff *skb, u16 length) { bi->rxbuf.page = NULL; skb->len += length; skb->data_len += length; skb->truesize += PAGE_SIZE; } /** * e1000_receive_skb - helper function to handle rx indications * @adapter: board private structure * @status: descriptor status field as written by hardware * @vlan: descriptor vlan field as written by hardware (no le/be conversion) * @skb: pointer to sk_buff to be indicated to stack */ static void e1000_receive_skb(struct e1000_adapter *adapter, u8 status, __le16 vlan, struct sk_buff *skb) { skb->protocol = eth_type_trans(skb, adapter->netdev); if (status & E1000_RXD_STAT_VP) { u16 vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK; __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid); } napi_gro_receive(&adapter->napi, skb); } /** * e1000_tbi_adjust_stats * @hw: Struct containing variables accessed by shared code * @stats: point to stats struct * @frame_len: The length of the frame in question * @mac_addr: The Ethernet destination address of the frame in question * * Adjusts the statistic counters when a frame is accepted by TBI_ACCEPT */ static void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats, u32 frame_len, const u8 *mac_addr) { u64 carry_bit; /* First adjust the frame length. */ frame_len--; /* We need to adjust the statistics counters, since the hardware * counters overcount this packet as a CRC error and undercount * the packet as a good packet */ /* This packet should not be counted as a CRC error. */ stats->crcerrs--; /* This packet does count as a Good Packet Received. */ stats->gprc++; /* Adjust the Good Octets received counters */ carry_bit = 0x80000000 & stats->gorcl; stats->gorcl += frame_len; /* If the high bit of Gorcl (the low 32 bits of the Good Octets * Received Count) was one before the addition, * AND it is zero after, then we lost the carry out, * need to add one to Gorch (Good Octets Received Count High). * This could be simplified if all environments supported * 64-bit integers. */ if (carry_bit && ((stats->gorcl & 0x80000000) == 0)) stats->gorch++; /* Is this a broadcast or multicast? Check broadcast first, * since the test for a multicast frame will test positive on * a broadcast frame. */ if (is_broadcast_ether_addr(mac_addr)) stats->bprc++; else if (is_multicast_ether_addr(mac_addr)) stats->mprc++; if (frame_len == hw->max_frame_size) { /* In this case, the hardware has overcounted the number of * oversize frames. */ if (stats->roc > 0) stats->roc--; } /* Adjust the bin counters when the extra byte put the frame in the * wrong bin. Remember that the frame_len was adjusted above. */ if (frame_len == 64) { stats->prc64++; stats->prc127--; } else if (frame_len == 127) { stats->prc127++; stats->prc255--; } else if (frame_len == 255) { stats->prc255++; stats->prc511--; } else if (frame_len == 511) { stats->prc511++; stats->prc1023--; } else if (frame_len == 1023) { stats->prc1023++; stats->prc1522--; } else if (frame_len == 1522) { stats->prc1522++; } } static bool e1000_tbi_should_accept(struct e1000_adapter *adapter, u8 status, u8 errors, u32 length, const u8 *data) { struct e1000_hw *hw = &adapter->hw; u8 last_byte = *(data + length - 1); if (TBI_ACCEPT(hw, status, errors, length, last_byte)) { unsigned long irq_flags; spin_lock_irqsave(&adapter->stats_lock, irq_flags); e1000_tbi_adjust_stats(hw, &adapter->stats, length, data); spin_unlock_irqrestore(&adapter->stats_lock, irq_flags); return true; } return false; } static struct sk_buff *e1000_alloc_rx_skb(struct e1000_adapter *adapter, unsigned int bufsz) { struct sk_buff *skb = napi_alloc_skb(&adapter->napi, bufsz); if (unlikely(!skb)) adapter->alloc_rx_buff_failed++; return skb; } /** * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy * @adapter: board private structure * @rx_ring: ring to clean * @work_done: amount of napi work completed this call * @work_to_do: max amount of work allowed for this call to do * * the return value indicates whether actual cleaning was done, there * is no guarantee that everything was cleaned */ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int *work_done, int work_to_do) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; struct e1000_rx_desc *rx_desc, *next_rxd; struct e1000_rx_buffer *buffer_info, *next_buffer; u32 length; unsigned int i; int cleaned_count = 0; bool cleaned = false; unsigned int total_rx_bytes = 0, total_rx_packets = 0; i = rx_ring->next_to_clean; rx_desc = E1000_RX_DESC(*rx_ring, i); buffer_info = &rx_ring->buffer_info[i]; while (rx_desc->status & E1000_RXD_STAT_DD) { struct sk_buff *skb; u8 status; if (*work_done >= work_to_do) break; (*work_done)++; dma_rmb(); /* read descriptor and rx_buffer_info after status DD */ status = rx_desc->status; if (++i == rx_ring->count) i = 0; next_rxd = E1000_RX_DESC(*rx_ring, i); prefetch(next_rxd); next_buffer = &rx_ring->buffer_info[i]; cleaned = true; cleaned_count++; dma_unmap_page(&pdev->dev, buffer_info->dma, adapter->rx_buffer_len, DMA_FROM_DEVICE); buffer_info->dma = 0; length = le16_to_cpu(rx_desc->length); /* errors is only valid for DD + EOP descriptors */ if (unlikely((status & E1000_RXD_STAT_EOP) && (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) { u8 *mapped = page_address(buffer_info->rxbuf.page); if (e1000_tbi_should_accept(adapter, status, rx_desc->errors, length, mapped)) { length--; } else if (netdev->features & NETIF_F_RXALL) { goto process_skb; } else { /* an error means any chain goes out the window * too */ dev_kfree_skb(rx_ring->rx_skb_top); rx_ring->rx_skb_top = NULL; goto next_desc; } } #define rxtop rx_ring->rx_skb_top process_skb: if (!(status & E1000_RXD_STAT_EOP)) { /* this descriptor is only the beginning (or middle) */ if (!rxtop) { /* this is the beginning of a chain */ rxtop = napi_get_frags(&adapter->napi); if (!rxtop) break; skb_fill_page_desc(rxtop, 0, buffer_info->rxbuf.page, 0, length); } else { /* this is the middle of a chain */ skb_fill_page_desc(rxtop, skb_shinfo(rxtop)->nr_frags, buffer_info->rxbuf.page, 0, length); } e1000_consume_page(buffer_info, rxtop, length); goto next_desc; } else { if (rxtop) { /* end of the chain */ skb_fill_page_desc(rxtop, skb_shinfo(rxtop)->nr_frags, buffer_info->rxbuf.page, 0, length); skb = rxtop; rxtop = NULL; e1000_consume_page(buffer_info, skb, length); } else { struct page *p; /* no chain, got EOP, this buf is the packet * copybreak to save the put_page/alloc_page */ p = buffer_info->rxbuf.page; if (length <= copybreak) { u8 *vaddr; if (likely(!(netdev->features & NETIF_F_RXFCS))) length -= 4; skb = e1000_alloc_rx_skb(adapter, length); if (!skb) break; vaddr = kmap_atomic(p); memcpy(skb_tail_pointer(skb), vaddr, length); kunmap_atomic(vaddr); /* re-use the page, so don't erase * buffer_info->rxbuf.page */ skb_put(skb, length); e1000_rx_checksum(adapter, status | rx_desc->errors << 24, le16_to_cpu(rx_desc->csum), skb); total_rx_bytes += skb->len; total_rx_packets++; e1000_receive_skb(adapter, status, rx_desc->special, skb); goto next_desc; } else { skb = napi_get_frags(&adapter->napi); if (!skb) { adapter->alloc_rx_buff_failed++; break; } skb_fill_page_desc(skb, 0, p, 0, length); e1000_consume_page(buffer_info, skb, length); } } } /* Receive Checksum Offload XXX recompute due to CRC strip? */ e1000_rx_checksum(adapter, (u32)(status) | ((u32)(rx_desc->errors) << 24), le16_to_cpu(rx_desc->csum), skb); total_rx_bytes += (skb->len - 4); /* don't count FCS */ if (likely(!(netdev->features & NETIF_F_RXFCS))) pskb_trim(skb, skb->len - 4); total_rx_packets++; if (status & E1000_RXD_STAT_VP) { __le16 vlan = rx_desc->special; u16 vid = le16_to_cpu(vlan) & E1000_RXD_SPC_VLAN_MASK; __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vid); } napi_gro_frags(&adapter->napi); next_desc: rx_desc->status = 0; /* return some buffers to hardware, one at a time is too slow */ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); cleaned_count = 0; } /* use prefetched values */ rx_desc = next_rxd; buffer_info = next_buffer; } rx_ring->next_to_clean = i; cleaned_count = E1000_DESC_UNUSED(rx_ring); if (cleaned_count) adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); adapter->total_rx_packets += total_rx_packets; adapter->total_rx_bytes += total_rx_bytes; netdev->stats.rx_bytes += total_rx_bytes; netdev->stats.rx_packets += total_rx_packets; return cleaned; } /* this should improve performance for small packets with large amounts * of reassembly being done in the stack */ static struct sk_buff *e1000_copybreak(struct e1000_adapter *adapter, struct e1000_rx_buffer *buffer_info, u32 length, const void *data) { struct sk_buff *skb; if (length > copybreak) return NULL; skb = e1000_alloc_rx_skb(adapter, length); if (!skb) return NULL; dma_sync_single_for_cpu(&adapter->pdev->dev, buffer_info->dma, length, DMA_FROM_DEVICE); skb_put_data(skb, data, length); return skb; } /** * e1000_clean_rx_irq - Send received data up the network stack; legacy * @adapter: board private structure * @rx_ring: ring to clean * @work_done: amount of napi work completed this call * @work_to_do: max amount of work allowed for this call to do */ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int *work_done, int work_to_do) { struct net_device *netdev = adapter->netdev; struct pci_dev *pdev = adapter->pdev; struct e1000_rx_desc *rx_desc, *next_rxd; struct e1000_rx_buffer *buffer_info, *next_buffer; u32 length; unsigned int i; int cleaned_count = 0; bool cleaned = false; unsigned int total_rx_bytes = 0, total_rx_packets = 0; i = rx_ring->next_to_clean; rx_desc = E1000_RX_DESC(*rx_ring, i); buffer_info = &rx_ring->buffer_info[i]; while (rx_desc->status & E1000_RXD_STAT_DD) { struct sk_buff *skb; u8 *data; u8 status; if (*work_done >= work_to_do) break; (*work_done)++; dma_rmb(); /* read descriptor and rx_buffer_info after status DD */ status = rx_desc->status; length = le16_to_cpu(rx_desc->length); data = buffer_info->rxbuf.data; prefetch(data); skb = e1000_copybreak(adapter, buffer_info, length, data); if (!skb) { unsigned int frag_len = e1000_frag_len(adapter); skb = build_skb(data - E1000_HEADROOM, frag_len); if (!skb) { adapter->alloc_rx_buff_failed++; break; } skb_reserve(skb, E1000_HEADROOM); dma_unmap_single(&pdev->dev, buffer_info->dma, adapter->rx_buffer_len, DMA_FROM_DEVICE); buffer_info->dma = 0; buffer_info->rxbuf.data = NULL; } if (++i == rx_ring->count) i = 0; next_rxd = E1000_RX_DESC(*rx_ring, i); prefetch(next_rxd); next_buffer = &rx_ring->buffer_info[i]; cleaned = true; cleaned_count++; /* !EOP means multiple descriptors were used to store a single * packet, if thats the case we need to toss it. In fact, we * to toss every packet with the EOP bit clear and the next * frame that _does_ have the EOP bit set, as it is by * definition only a frame fragment */ if (unlikely(!(status & E1000_RXD_STAT_EOP))) adapter->discarding = true; if (adapter->discarding) { /* All receives must fit into a single buffer */ netdev_dbg(netdev, "Receive packet consumed multiple buffers\n"); dev_kfree_skb(skb); if (status & E1000_RXD_STAT_EOP) adapter->discarding = false; goto next_desc; } if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { if (e1000_tbi_should_accept(adapter, status, rx_desc->errors, length, data)) { length--; } else if (netdev->features & NETIF_F_RXALL) { goto process_skb; } else { dev_kfree_skb(skb); goto next_desc; } } process_skb: total_rx_bytes += (length - 4); /* don't count FCS */ total_rx_packets++; if (likely(!(netdev->features & NETIF_F_RXFCS))) /* adjust length to remove Ethernet CRC, this must be * done after the TBI_ACCEPT workaround above */ length -= 4; if (buffer_info->rxbuf.data == NULL) skb_put(skb, length); else /* copybreak skb */ skb_trim(skb, length); /* Receive Checksum Offload */ e1000_rx_checksum(adapter, (u32)(status) | ((u32)(rx_desc->errors) << 24), le16_to_cpu(rx_desc->csum), skb); e1000_receive_skb(adapter, status, rx_desc->special, skb); next_desc: rx_desc->status = 0; /* return some buffers to hardware, one at a time is too slow */ if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); cleaned_count = 0; } /* use prefetched values */ rx_desc = next_rxd; buffer_info = next_buffer; } rx_ring->next_to_clean = i; cleaned_count = E1000_DESC_UNUSED(rx_ring); if (cleaned_count) adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); adapter->total_rx_packets += total_rx_packets; adapter->total_rx_bytes += total_rx_bytes; netdev->stats.rx_bytes += total_rx_bytes; netdev->stats.rx_packets += total_rx_packets; return cleaned; } /** * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers * @adapter: address of board private structure * @rx_ring: pointer to receive ring structure * @cleaned_count: number of buffers to allocate this pass **/ static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int cleaned_count) { struct pci_dev *pdev = adapter->pdev; struct e1000_rx_desc *rx_desc; struct e1000_rx_buffer *buffer_info; unsigned int i; i = rx_ring->next_to_use; buffer_info = &rx_ring->buffer_info[i]; while (cleaned_count--) { /* allocate a new page if necessary */ if (!buffer_info->rxbuf.page) { buffer_info->rxbuf.page = alloc_page(GFP_ATOMIC); if (unlikely(!buffer_info->rxbuf.page)) { adapter->alloc_rx_buff_failed++; break; } } if (!buffer_info->dma) { buffer_info->dma = dma_map_page(&pdev->dev, buffer_info->rxbuf.page, 0, adapter->rx_buffer_len, DMA_FROM_DEVICE); if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { put_page(buffer_info->rxbuf.page); buffer_info->rxbuf.page = NULL; buffer_info->dma = 0; adapter->alloc_rx_buff_failed++; break; } } rx_desc = E1000_RX_DESC(*rx_ring, i); rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); if (unlikely(++i == rx_ring->count)) i = 0; buffer_info = &rx_ring->buffer_info[i]; } if (likely(rx_ring->next_to_use != i)) { rx_ring->next_to_use = i; if (unlikely(i-- == 0)) i = (rx_ring->count - 1); /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, * such as IA-64). */ dma_wmb(); writel(i, adapter->hw.hw_addr + rx_ring->rdt); } } /** * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended * @adapter: address of board private structure * @rx_ring: pointer to ring struct * @cleaned_count: number of new Rx buffers to try to allocate **/ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, struct e1000_rx_ring *rx_ring, int cleaned_count) { struct e1000_hw *hw = &adapter->hw; struct pci_dev *pdev = adapter->pdev; struct e1000_rx_desc *rx_desc; struct e1000_rx_buffer *buffer_info; unsigned int i; unsigned int bufsz = adapter->rx_buffer_len; i = rx_ring->next_to_use; buffer_info = &rx_ring->buffer_info[i]; while (cleaned_count--) { void *data; if (buffer_info->rxbuf.data) goto skip; data = e1000_alloc_frag(adapter); if (!data) { /* Better luck next round */ adapter->alloc_rx_buff_failed++; break; } /* Fix for errata 23, can't cross 64kB boundary */ if (!e1000_check_64k_bound(adapter, data, bufsz)) { void *olddata = data; e_err(rx_err, "skb align check failed: %u bytes at " "%p\n", bufsz, data); /* Try again, without freeing the previous */ data = e1000_alloc_frag(adapter); /* Failed allocation, critical failure */ if (!data) { skb_free_frag(olddata); adapter->alloc_rx_buff_failed++; break; } if (!e1000_check_64k_bound(adapter, data, bufsz)) { /* give up */ skb_free_frag(data); skb_free_frag(olddata); adapter->alloc_rx_buff_failed++; break; } /* Use new allocation */ skb_free_frag(olddata); } buffer_info->dma = dma_map_single(&pdev->dev, data, adapter->rx_buffer_len, DMA_FROM_DEVICE); if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { skb_free_frag(data); buffer_info->dma = 0; adapter->alloc_rx_buff_failed++; break; } /* XXX if it was allocated cleanly it will never map to a * boundary crossing */ /* Fix for errata 23, can't cross 64kB boundary */ if (!e1000_check_64k_bound(adapter, (void *)(unsigned long)buffer_info->dma, adapter->rx_buffer_len)) { e_err(rx_err, "dma align check failed: %u bytes at " "%p\n", adapter->rx_buffer_len, (void *)(unsigned long)buffer_info->dma); dma_unmap_single(&pdev->dev, buffer_info->dma, adapter->rx_buffer_len, DMA_FROM_DEVICE); skb_free_frag(data); buffer_info->rxbuf.data = NULL; buffer_info->dma = 0; adapter->alloc_rx_buff_failed++; break; } buffer_info->rxbuf.data = data; skip: rx_desc = E1000_RX_DESC(*rx_ring, i); rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); if (unlikely(++i == rx_ring->count)) i = 0; buffer_info = &rx_ring->buffer_info[i]; } if (likely(rx_ring->next_to_use != i)) { rx_ring->next_to_use = i; if (unlikely(i-- == 0)) i = (rx_ring->count - 1); /* Force memory writes to complete before letting h/w * know there are new descriptors to fetch. (Only * applicable for weak-ordered memory model archs, * such as IA-64). */ dma_wmb(); writel(i, hw->hw_addr + rx_ring->rdt); } } /** * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers. * @adapter: address of board private structure **/ static void e1000_smartspeed(struct e1000_adapter *adapter) { struct e1000_hw *hw = &adapter->hw; u16 phy_status; u16 phy_ctrl; if ((hw->phy_type != e1000_phy_igp) || !hw->autoneg || !(hw->autoneg_advertised & ADVERTISE_1000_FULL)) return; if (adapter->smartspeed == 0) { /* If Master/Slave config fault is asserted twice, * we assume back-to-back */ e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status); if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status); if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return; e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl); if (phy_ctrl & CR_1000T_MS_ENABLE) { phy_ctrl &= ~CR_1000T_MS_ENABLE; e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_ctrl); adapter->smartspeed++; if (!e1000_phy_setup_autoneg(hw) && !e1000_read_phy_reg(hw, PHY_CTRL, &phy_ctrl)) { phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); e1000_write_phy_reg(hw, PHY_CTRL, phy_ctrl); } } return; } else if (adapter->smartspeed == E1000_SMARTSPEED_DOWNSHIFT) { /* If still no link, perhaps using 2/3 pair cable */ e1000_read_phy_reg(hw, PHY_1000T_CTRL, &phy_ctrl); phy_ctrl |= CR_1000T_MS_ENABLE; e1000_write_phy_reg(hw, PHY_1000T_CTRL, phy_ctrl); if (!e1000_phy_setup_autoneg(hw) && !e1000_read_phy_reg(hw, PHY_CTRL, &phy_ctrl)) { phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); e1000_write_phy_reg(hw, PHY_CTRL, phy_ctrl); } } /* Restart process after E1000_SMARTSPEED_MAX iterations */ if (adapter->smartspeed++ == E1000_SMARTSPEED_MAX) adapter->smartspeed = 0; } /** * e1000_ioctl - handle ioctl calls * @netdev: pointer to our netdev * @ifr: pointer to interface request structure * @cmd: ioctl data **/ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { switch (cmd) { case SIOCGMIIPHY: case SIOCGMIIREG: case SIOCSMIIREG: return e1000_mii_ioctl(netdev, ifr, cmd); default: return -EOPNOTSUPP; } } /** * e1000_mii_ioctl - * @netdev: pointer to our netdev * @ifr: pointer to interface request structure * @cmd: ioctl data **/ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; struct mii_ioctl_data *data = if_mii(ifr); int retval; u16 mii_reg; unsigned long flags; if (hw->media_type != e1000_media_type_copper) return -EOPNOTSUPP; switch (cmd) { case SIOCGMIIPHY: data->phy_id = hw->phy_addr; break; case SIOCGMIIREG: spin_lock_irqsave(&adapter->stats_lock, flags); if (e1000_read_phy_reg(hw, data->reg_num & 0x1F, &data->val_out)) { spin_unlock_irqrestore(&adapter->stats_lock, flags); return -EIO; } spin_unlock_irqrestore(&adapter->stats_lock, flags); break; case SIOCSMIIREG: if (data->reg_num & ~(0x1F)) return -EFAULT; mii_reg = data->val_in; spin_lock_irqsave(&adapter->stats_lock, flags); if (e1000_write_phy_reg(hw, data->reg_num, mii_reg)) { spin_unlock_irqrestore(&adapter->stats_lock, flags); return -EIO; } spin_unlock_irqrestore(&adapter->stats_lock, flags); if (hw->media_type == e1000_media_type_copper) { switch (data->reg_num) { case PHY_CTRL: if (mii_reg & MII_CR_POWER_DOWN) break; if (mii_reg & MII_CR_AUTO_NEG_EN) { hw->autoneg = 1; hw->autoneg_advertised = 0x2F; } else { u32 speed; if (mii_reg & 0x40) speed = SPEED_1000; else if (mii_reg & 0x2000) speed = SPEED_100; else speed = SPEED_10; retval = e1000_set_spd_dplx( adapter, speed, ((mii_reg & 0x100) ? DUPLEX_FULL : DUPLEX_HALF)); if (retval) return retval; } if (netif_running(adapter->netdev)) e1000_reinit_locked(adapter); else e1000_reset(adapter); break; case M88E1000_PHY_SPEC_CTRL: case M88E1000_EXT_PHY_SPEC_CTRL: if (e1000_phy_reset(hw)) return -EIO; break; } } else { switch (data->reg_num) { case PHY_CTRL: if (mii_reg & MII_CR_POWER_DOWN) break; if (netif_running(adapter->netdev)) e1000_reinit_locked(adapter); else e1000_reset(adapter); break; } } break; default: return -EOPNOTSUPP; } return E1000_SUCCESS; } void e1000_pci_set_mwi(struct e1000_hw *hw) { struct e1000_adapter *adapter = hw->back; int ret_val = pci_set_mwi(adapter->pdev); if (ret_val) e_err(probe, "Error in setting MWI\n"); } void e1000_pci_clear_mwi(struct e1000_hw *hw) { struct e1000_adapter *adapter = hw->back; pci_clear_mwi(adapter->pdev); } int e1000_pcix_get_mmrbc(struct e1000_hw *hw) { struct e1000_adapter *adapter = hw->back; return pcix_get_mmrbc(adapter->pdev); } void e1000_pcix_set_mmrbc(struct e1000_hw *hw, int mmrbc) { struct e1000_adapter *adapter = hw->back; pcix_set_mmrbc(adapter->pdev, mmrbc); } void e1000_io_write(struct e1000_hw *hw, unsigned long port, u32 value) { outl(value, port); } static bool e1000_vlan_used(struct e1000_adapter *adapter) { u16 vid; for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) return true; return false; } static void __e1000_vlan_mode(struct e1000_adapter *adapter, netdev_features_t features) { struct e1000_hw *hw = &adapter->hw; u32 ctrl; ctrl = er32(CTRL); if (features & NETIF_F_HW_VLAN_CTAG_RX) { /* enable VLAN tag insert/strip */ ctrl |= E1000_CTRL_VME; } else { /* disable VLAN tag insert/strip */ ctrl &= ~E1000_CTRL_VME; } ew32(CTRL, ctrl); } static void e1000_vlan_filter_on_off(struct e1000_adapter *adapter, bool filter_on) { struct e1000_hw *hw = &adapter->hw; u32 rctl; if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_disable(adapter); __e1000_vlan_mode(adapter, adapter->netdev->features); if (filter_on) { /* enable VLAN receive filtering */ rctl = er32(RCTL); rctl &= ~E1000_RCTL_CFIEN; if (!(adapter->netdev->flags & IFF_PROMISC)) rctl |= E1000_RCTL_VFE; ew32(RCTL, rctl); e1000_update_mng_vlan(adapter); } else { /* disable VLAN receive filtering */ rctl = er32(RCTL); rctl &= ~E1000_RCTL_VFE; ew32(RCTL, rctl); } if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_enable(adapter); } static void e1000_vlan_mode(struct net_device *netdev, netdev_features_t features) { struct e1000_adapter *adapter = netdev_priv(netdev); if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_disable(adapter); __e1000_vlan_mode(adapter, features); if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_enable(adapter); } static int e1000_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 vfta, index; if ((hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && (vid == adapter->mng_vlan_id)) return 0; if (!e1000_vlan_used(adapter)) e1000_vlan_filter_on_off(adapter, true); /* add VID to filter table */ index = (vid >> 5) & 0x7F; vfta = E1000_READ_REG_ARRAY(hw, VFTA, index); vfta |= (1 << (vid & 0x1F)); e1000_write_vfta(hw, index, vfta); set_bit(vid, adapter->active_vlans); return 0; } static int e1000_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid) { struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 vfta, index; if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_disable(adapter); if (!test_bit(__E1000_DOWN, &adapter->flags)) e1000_irq_enable(adapter); /* remove VID from filter table */ index = (vid >> 5) & 0x7F; vfta = E1000_READ_REG_ARRAY(hw, VFTA, index); vfta &= ~(1 << (vid & 0x1F)); e1000_write_vfta(hw, index, vfta); clear_bit(vid, adapter->active_vlans); if (!e1000_vlan_used(adapter)) e1000_vlan_filter_on_off(adapter, false); return 0; } static void e1000_restore_vlan(struct e1000_adapter *adapter) { u16 vid; if (!e1000_vlan_used(adapter)) return; e1000_vlan_filter_on_off(adapter, true); for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID) e1000_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); } int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx) { struct e1000_hw *hw = &adapter->hw; hw->autoneg = 0; /* Make sure dplx is at most 1 bit and lsb of speed is not set * for the switch() below to work */ if ((spd & 1) || (dplx & ~1)) goto err_inval; /* Fiber NICs only allow 1000 gbps Full duplex */ if ((hw->media_type == e1000_media_type_fiber) && spd != SPEED_1000 && dplx != DUPLEX_FULL) goto err_inval; switch (spd + dplx) { case SPEED_10 + DUPLEX_HALF: hw->forced_speed_duplex = e1000_10_half; break; case SPEED_10 + DUPLEX_FULL: hw->forced_speed_duplex = e1000_10_full; break; case SPEED_100 + DUPLEX_HALF: hw->forced_speed_duplex = e1000_100_half; break; case SPEED_100 + DUPLEX_FULL: hw->forced_speed_duplex = e1000_100_full; break; case SPEED_1000 + DUPLEX_FULL: hw->autoneg = 1; hw->autoneg_advertised = ADVERTISE_1000_FULL; break; case SPEED_1000 + DUPLEX_HALF: /* not supported */ default: goto err_inval; } /* clear MDI, MDI(-X) override is only allowed when autoneg enabled */ hw->mdix = AUTO_ALL_MODES; return 0; err_inval: e_err(probe, "Unsupported Speed/Duplex configuration\n"); return -EINVAL; } static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake) { struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 ctrl, ctrl_ext, rctl, status; u32 wufc = adapter->wol; netif_device_detach(netdev); if (netif_running(netdev)) { int count = E1000_CHECK_RESET_COUNT; while (test_bit(__E1000_RESETTING, &adapter->flags) && count--) usleep_range(10000, 20000); WARN_ON(test_bit(__E1000_RESETTING, &adapter->flags)); e1000_down(adapter); } status = er32(STATUS); if (status & E1000_STATUS_LU) wufc &= ~E1000_WUFC_LNKC; if (wufc) { e1000_setup_rctl(adapter); e1000_set_rx_mode(netdev); rctl = er32(RCTL); /* turn on all-multi mode if wake on multicast is enabled */ if (wufc & E1000_WUFC_MC) rctl |= E1000_RCTL_MPE; /* enable receives in the hardware */ ew32(RCTL, rctl | E1000_RCTL_EN); if (hw->mac_type >= e1000_82540) { ctrl = er32(CTRL); /* advertise wake from D3Cold */ #define E1000_CTRL_ADVD3WUC 0x00100000 /* phy power management enable */ #define E1000_CTRL_EN_PHY_PWR_MGMT 0x00200000 ctrl |= E1000_CTRL_ADVD3WUC | E1000_CTRL_EN_PHY_PWR_MGMT; ew32(CTRL, ctrl); } if (hw->media_type == e1000_media_type_fiber || hw->media_type == e1000_media_type_internal_serdes) { /* keep the laser running in D3 */ ctrl_ext = er32(CTRL_EXT); ctrl_ext |= E1000_CTRL_EXT_SDP7_DATA; ew32(CTRL_EXT, ctrl_ext); } ew32(WUC, E1000_WUC_PME_EN); ew32(WUFC, wufc); } else { ew32(WUC, 0); ew32(WUFC, 0); } e1000_release_manageability(adapter); *enable_wake = !!wufc; /* make sure adapter isn't asleep if manageability is enabled */ if (adapter->en_mng_pt) *enable_wake = true; if (netif_running(netdev)) e1000_free_irq(adapter); if (!test_and_set_bit(__E1000_DISABLED, &adapter->flags)) pci_disable_device(pdev); return 0; } static int __maybe_unused e1000_suspend(struct device *dev) { int retval; struct pci_dev *pdev = to_pci_dev(dev); bool wake; retval = __e1000_shutdown(pdev, &wake); device_set_wakeup_enable(dev, wake); return retval; } static int __maybe_unused e1000_resume(struct device *dev) { struct pci_dev *pdev = to_pci_dev(dev); struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 err; if (adapter->need_ioport) err = pci_enable_device(pdev); else err = pci_enable_device_mem(pdev); if (err) { pr_err("Cannot enable PCI device from suspend\n"); return err; } /* flush memory to make sure state is correct */ smp_mb__before_atomic(); clear_bit(__E1000_DISABLED, &adapter->flags); pci_set_master(pdev); pci_enable_wake(pdev, PCI_D3hot, 0); pci_enable_wake(pdev, PCI_D3cold, 0); if (netif_running(netdev)) { err = e1000_request_irq(adapter); if (err) return err; } e1000_power_up_phy(adapter); e1000_reset(adapter); ew32(WUS, ~0); e1000_init_manageability(adapter); if (netif_running(netdev)) e1000_up(adapter); netif_device_attach(netdev); return 0; } static void e1000_shutdown(struct pci_dev *pdev) { bool wake; __e1000_shutdown(pdev, &wake); if (system_state == SYSTEM_POWER_OFF) { pci_wake_from_d3(pdev, wake); pci_set_power_state(pdev, PCI_D3hot); } } #ifdef CONFIG_NET_POLL_CONTROLLER /* Polling 'interrupt' - used by things like netconsole to send skbs * without having to re-enable interrupts. It's not called while * the interrupt routine is executing. */ static void e1000_netpoll(struct net_device *netdev) { struct e1000_adapter *adapter = netdev_priv(netdev); if (disable_hardirq(adapter->pdev->irq)) e1000_intr(adapter->pdev->irq, netdev); enable_irq(adapter->pdev->irq); } #endif /** * e1000_io_error_detected - called when PCI error is detected * @pdev: Pointer to PCI device * @state: The current pci connection state * * This function is called after a PCI bus error affecting * this device has been detected. */ static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state) { struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); netif_device_detach(netdev); if (state == pci_channel_io_perm_failure) return PCI_ERS_RESULT_DISCONNECT; if (netif_running(netdev)) e1000_down(adapter); if (!test_and_set_bit(__E1000_DISABLED, &adapter->flags)) pci_disable_device(pdev); /* Request a slot reset. */ return PCI_ERS_RESULT_NEED_RESET; } /** * e1000_io_slot_reset - called after the pci bus has been reset. * @pdev: Pointer to PCI device * * Restart the card from scratch, as if from a cold-boot. Implementation * resembles the first-half of the e1000_resume routine. */ static pci_ers_result_t e1000_io_slot_reset(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; int err; if (adapter->need_ioport) err = pci_enable_device(pdev); else err = pci_enable_device_mem(pdev); if (err) { pr_err("Cannot re-enable PCI device after reset.\n"); return PCI_ERS_RESULT_DISCONNECT; } /* flush memory to make sure state is correct */ smp_mb__before_atomic(); clear_bit(__E1000_DISABLED, &adapter->flags); pci_set_master(pdev); pci_enable_wake(pdev, PCI_D3hot, 0); pci_enable_wake(pdev, PCI_D3cold, 0); e1000_reset(adapter); ew32(WUS, ~0); return PCI_ERS_RESULT_RECOVERED; } /** * e1000_io_resume - called when traffic can start flowing again. * @pdev: Pointer to PCI device * * This callback is called when the error recovery driver tells us that * its OK to resume normal operation. Implementation resembles the * second-half of the e1000_resume routine. */ static void e1000_io_resume(struct pci_dev *pdev) { struct net_device *netdev = pci_get_drvdata(pdev); struct e1000_adapter *adapter = netdev_priv(netdev); e1000_init_manageability(adapter); if (netif_running(netdev)) { if (e1000_up(adapter)) { pr_info("can't bring device back up after reset\n"); return; } } netif_device_attach(netdev); } /* e1000_main.c */
rperier/linux
drivers/net/ethernet/intel/e1000/e1000_main.c
C
gpl-2.0
148,736
[ 30522, 1013, 1013, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 14246, 2140, 1011, 1016, 1012, 1014, 1013, 1008, 9385, 1006, 1039, 1007, 2639, 1011, 2294, 13420, 3840, 1012, 1008, 1013, 1001, 2421, 1000, 1041, 18613, 2692, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<div class="slide-pane slide-pane--dark content-item-preview" ng-show="isActive" ng-class="{open: isActive, 'slide-pane--inset': mode === 'authoring'}"> <div class="slide-pane__header"> <h3 ng-show="canSendItem() && itemActions.publish" translate>Send to / Publish</h3> <h3 ng-show="canSendItem() && !itemActions.publish" translate>Send to</h3> <h3 ng-show="!canSendItem()" translate>Fetch To</h3> <div class="close" ng-click="close()"><i class="icon-close-small icon-white"></i></div> </div> <div class="slide-pane__content"> <div sd-toggle-box ng-if="showSendButtonAndDestination()" data-title="{{ :: 'Destination' | translate }}" data-open="true" data-style="dark"> <div class="dropdown dropdown-noarrow dropdown--dark" dropdown> <button class="dropdown-toggle" dropdown-toggle> <span ng-show="!selectedDesk" translate>Select desk</span> <span ng-show="selectedDesk">{{selectedDesk.name}}</span> <b class="caret white"></b> </button> <ul class="dropdown-menu"> <li ng-repeat="desk in desks._items track by desk._id"> <button ng-click="selectDesk(desk)">{{::desk.name}}</button> </li> </ul> </div> <ul class="btn-list" ng-if="stages"> <li ng-repeat="stage in stages track by stage._id"> <button class="btn__check" ng-class="{active: stage._id === selectedStage._id}" ng-disabled="stage._id === item.task.stage" ng-click="selectStage(stage)"> {{::stage.name}} </button> </li> </ul> </div> <div sd-toggle-box id="embargoTimestamp" ng-if="mode === 'authoring' && showEmbargo()" data-title="Embargo" data-open="true" data-style="dark"> <label class="label--lite" translate>Embargo</label> <ul class="btn-list"> <li class="datepicker-input--dark"> <div sd-datepicker ng-model="item.embargo_date"></div> </li> <li class="timepicker-input--dark"> <div sd-timepicker ng-model="item.embargo_time"></div> </li> </ul> </div> <div sd-toggle-box id="publishScheduleTimestamp" ng-if="mode === 'authoring' && showPublishSchedule()" data-title="{{ 'Publishing Schedule' | translate }}" data-open="true" data-style="dark"> <label class="label--lite" translate>Publish Schedule</label> <ul class="btn-list"> <li class="datepicker-input--dark"> <div sd-datepicker ng-model="item.publish_schedule_date" ng-disabled="!_editable"></div> </li> <li class="timepicker-input--dark"> <div sd-timepicker ng-model="item.publish_schedule_time" ng-disabled="!_editable"></div> </li> </ul> </div> <div sd-toggle-box id="timezoneTimestamp" ng-if="mode === 'authoring' && showTimezone()" data-title="Timezone" data-open="true" data-style="dark"> <div sd-timezone data-timezone="item.time_zone" class="timezone-input--dark"></div> </div> </div> <div class="slide-pane__footer" sd-loading="loading"> <ul class="btn-list"> <li ng-if="mode === 'authoring' && canSendAndContinue() && itemActions.send && itemActions.new_take"> <button class="btn btn-info" ng-click="sendAndContinue()" ng-disabled="item.embargo || disableSendButton()" translate> send and continue </button> </li> <li ng-if="showSendButtonAndDestination()"> <button class="btn btn-info" ng-click="send()" ng-disabled="disableSendButton()" > {{!canSendItem() ? 'fetch' : 'send' | translate}} </button> </li> <li ng-if="showSendButtonAndDestination() && !canSendItem()"> <button class="btn btn-info" ng-click="send(true)" ng-disabled="disableFetchAndOpenButton()" translate> fetch and open </button> </li> <li class="full-width" ng-if="canSendItem() && canPublishItem()"> <button type="submit" class="btn btn-info" ng-show="_editable" ng-click="publish()" > {{_action === 'edit' ? 'publish' : _action | translate}} </button> </li> </ul> </div> </div>
mscam/superdesk-client-core
scripts/superdesk-authoring/views/send-item.html
HTML
agpl-3.0
5,045
[ 30522, 1026, 4487, 2615, 2465, 1027, 1000, 7358, 1011, 6090, 2063, 7358, 1011, 6090, 2063, 1011, 1011, 2601, 4180, 1011, 8875, 1011, 19236, 1000, 12835, 1011, 2265, 1027, 1000, 18061, 15277, 1000, 12835, 1011, 2465, 1027, 1000, 1063, 2330, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package greatspacerace import ( "bufio" "fmt" "github.com/TSavo/go.firebase" "os" ) func init() { f, err := os.Open("firebase.secret") if err != nil { fmt.Printf("error opening firebase.secret: %v\n", err) } r := bufio.NewReader(f) url, e := Readln(r) if e != nil { panic(e) } secret, e := Readln(r) if e != nil { panic(e) } db = firebase.New(url, secret) } var db *firebase.FirebaseRoot; func Readln(r *bufio.Reader) (string, error) { var ( isPrefix bool = true err error = nil line, ln []byte ) for isPrefix && err == nil { line, isPrefix, err = r.ReadLine() ln = append(ln, line...) } return string(ln), err }
TSavo/FarlightRacing
database.go
GO
apache-2.0
699
[ 30522, 7427, 2307, 23058, 22903, 12324, 1006, 1000, 20934, 8873, 2080, 1000, 1000, 4718, 2102, 1000, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 24529, 11431, 2080, 1013, 2175, 1012, 2543, 15058, 1000, 1000, 9808, 1000, 1007, 4569, 2278, 19...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
from __future__ import division, print_function, absolute_import import numpy as np import scipy.interpolate as interp from numpy.testing import assert_almost_equal class TestRegression(object): def test_spalde_scalar_input(self): """Ticket #629""" x = np.linspace(0,10) y = x**3 tck = interp.splrep(x, y, k=3, t=[5]) res = interp.spalde(np.float64(1), tck) des = np.array([1., 3., 6., 6.]) assert_almost_equal(res, des)
mbayon/TFG-MachineLearning
venv/lib/python3.6/site-packages/scipy/interpolate/tests/test_regression.py
Python
mit
484
[ 30522, 2013, 1035, 1035, 2925, 1035, 1035, 12324, 2407, 1010, 6140, 1035, 3853, 1010, 7619, 1035, 12324, 12324, 16371, 8737, 2100, 2004, 27937, 12324, 16596, 7685, 1012, 6970, 18155, 3686, 2004, 6970, 2361, 2013, 16371, 8737, 2100, 1012, 56...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?xml version="1.0" ?><!DOCTYPE TS><TS language="el_GR" version="2.1"> <context> <name>AboutDialog</name> <message> <location filename="../forms/aboutdialog.ui" line="+14"/> <source>About BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+39"/> <source>&lt;b&gt;BigBang&lt;/b&gt; version</source> <translation type="unfinished"/> </message> <message> <location line="+41"/> <source>Copyright © 2009-2014 The Bitcoin developers Copyright © 2012-2014 The NovaCoin developers Copyright © 2014 The BigBang developers</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source> This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.</source> <translation> This is experimental software. Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php. This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.</translation> </message> </context> <context> <name>AddressBookPage</name> <message> <location filename="../forms/addressbookpage.ui" line="+14"/> <source>Address Book</source> <translation type="unfinished"/> </message> <message> <location line="+22"/> <source>Double-click to edit address or label</source> <translation>Διπλό-κλικ για επεξεργασία της διεύθυνσης ή της ετικέτας</translation> </message> <message> <location line="+27"/> <source>Create a new address</source> <translation>Δημιούργησε νέα διεύθυνση</translation> </message> <message> <location line="+14"/> <source>Copy the currently selected address to the system clipboard</source> <translation>Αντέγραψε την επιλεγμένη διεύθυνση στο πρόχειρο του συστήματος</translation> </message> <message> <location line="-11"/> <source>&amp;New Address</source> <translation type="unfinished"/> </message> <message> <location line="-46"/> <source>These are your BigBang addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you.</source> <translation type="unfinished"/> </message> <message> <location line="+60"/> <source>&amp;Copy Address</source> <translation>&amp;Αντιγραφή διεύθυνσης</translation> </message> <message> <location line="+11"/> <source>Show &amp;QR Code</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Sign a message to prove you own a BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Sign &amp;Message</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>Delete the currently selected address from the list</source> <translation>Αντιγραφη της επιλεγμενης διεύθυνσης στο πρόχειρο του συστηματος</translation> </message> <message> <location line="-14"/> <source>Verify a message to ensure it was signed with a specified BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Verify Message</source> <translation type="unfinished"/> </message> <message> <location line="+14"/> <source>&amp;Delete</source> <translation>&amp;Διαγραφή</translation> </message> <message> <location filename="../addressbookpage.cpp" line="+65"/> <source>Copy &amp;Label</source> <translation>Αντιγραφή &amp;επιγραφής</translation> </message> <message> <location line="+2"/> <source>&amp;Edit</source> <translation>&amp;Επεξεργασία</translation> </message> <message> <location line="+250"/> <source>Export Address Book Data</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Comma separated file (*.csv)</source> <translation>Αρχείο οριοθετημένο με κόμματα (*.csv)</translation> </message> <message> <location line="+13"/> <source>Error exporting</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Could not write to file %1.</source> <translation type="unfinished"/> </message> </context> <context> <name>AddressTableModel</name> <message> <location filename="../addresstablemodel.cpp" line="+144"/> <source>Label</source> <translation>Ετικέτα</translation> </message> <message> <location line="+0"/> <source>Address</source> <translation>Διεύθυνση</translation> </message> <message> <location line="+36"/> <source>(no label)</source> <translation>(χωρίς ετικέτα)</translation> </message> </context> <context> <name>AskPassphraseDialog</name> <message> <location filename="../forms/askpassphrasedialog.ui" line="+26"/> <source>Passphrase Dialog</source> <translation>Φράση πρόσβασης </translation> </message> <message> <location line="+21"/> <source>Enter passphrase</source> <translation>Βάλτε κωδικό πρόσβασης</translation> </message> <message> <location line="+14"/> <source>New passphrase</source> <translation>Νέος κωδικός πρόσβασης</translation> </message> <message> <location line="+14"/> <source>Repeat new passphrase</source> <translation>Επανέλαβε τον νέο κωδικό πρόσβασης</translation> </message> <message> <location line="+33"/> <source>Serves to disable the trivial sendmoney when OS account compromised. Provides no real security.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>For staking only</source> <translation type="unfinished"/> </message> <message> <location filename="../askpassphrasedialog.cpp" line="+35"/> <source>Enter the new passphrase to the wallet.&lt;br/&gt;Please use a passphrase of &lt;b&gt;10 or more random characters&lt;/b&gt;, or &lt;b&gt;eight or more words&lt;/b&gt;.</source> <translation>Εισάγετε τον νέο κωδικό πρόσβασης στον πορτοφόλι &lt;br/&gt; Παρακαλώ χρησιμοποιείστε ένα κωδικό με &lt;b&gt; 10 ή περισσότερους τυχαίους χαρακτήρες&lt;/b&gt; ή &lt;b&gt; οχτώ ή παραπάνω λέξεις&lt;/b&gt;.</translation> </message> <message> <location line="+1"/> <source>Encrypt wallet</source> <translation>Κρυπτογράφησε το πορτοφόλι</translation> </message> <message> <location line="+7"/> <source>This operation needs your wallet passphrase to unlock the wallet.</source> <translation>Αυτη η ενεργεία χρειάζεται τον κωδικό του πορτοφολιού για να ξεκλειδώσει το πορτοφόλι.</translation> </message> <message> <location line="+5"/> <source>Unlock wallet</source> <translation>Ξεκλειδωσε το πορτοφολι</translation> </message> <message> <location line="+3"/> <source>This operation needs your wallet passphrase to decrypt the wallet.</source> <translation>Αυτη η ενεργεια χρειάζεται τον κωδικο του πορτοφολιου για να αποκρυπτογραφησειι το πορτοφολι.</translation> </message> <message> <location line="+5"/> <source>Decrypt wallet</source> <translation>Αποκρυπτογράφησε το πορτοφολι</translation> </message> <message> <location line="+3"/> <source>Change passphrase</source> <translation>Άλλαξε κωδικο πρόσβασης</translation> </message> <message> <location line="+1"/> <source>Enter the old and new passphrase to the wallet.</source> <translation>Εισάγετε τον παλιό και τον νεο κωδικο στο πορτοφολι.</translation> </message> <message> <location line="+46"/> <source>Confirm wallet encryption</source> <translation>Επιβεβαίωσε την κρυπτογραφηση του πορτοφολιού</translation> </message> <message> <location line="+1"/> <source>Warning: If you encrypt your wallet and lose your passphrase, you will &lt;b&gt;LOSE ALL OF YOUR COINS&lt;/b&gt;!</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Are you sure you wish to encrypt your wallet?</source> <translation>Είστε σίγουροι ότι θέλετε να κρυπτογραφήσετε το πορτοφόλι σας;</translation> </message> <message> <location line="+15"/> <source>IMPORTANT: Any previous backups you have made of your wallet file should be replaced with the newly generated, encrypted wallet file. For security reasons, previous backups of the unencrypted wallet file will become useless as soon as you start using the new, encrypted wallet.</source> <translation>ΣΗΜΑΝΤΙΚΟ: Τα προηγούμενα αντίγραφα ασφαλείας που έχετε κάνει από το αρχείο του πορτοφόλιου σας θα πρέπει να αντικατασταθουν με το νέο που δημιουργείται, κρυπτογραφημένο αρχείο πορτοφόλιου. Για λόγους ασφαλείας, τα προηγούμενα αντίγραφα ασφαλείας του μη κρυπτογραφημένου αρχείου πορτοφόλιου θα καταστουν άχρηστα μόλις αρχίσετε να χρησιμοποιείτε το νέο κρυπτογραφημένο πορτοφόλι. </translation> </message> <message> <location line="+103"/> <location line="+24"/> <source>Warning: The Caps Lock key is on!</source> <translation>Προσοχη: το πλήκτρο Caps Lock είναι ενεργο.</translation> </message> <message> <location line="-133"/> <location line="+60"/> <source>Wallet encrypted</source> <translation>Κρυπτογραφημενο πορτοφολι</translation> </message> <message> <location line="-58"/> <source>BigBang will close now to finish the encryption process. Remember that encrypting your wallet cannot fully protect your coins from being stolen by malware infecting your computer.</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <location line="+7"/> <location line="+44"/> <location line="+6"/> <source>Wallet encryption failed</source> <translation>Η κρυπτογραφηση του πορτοφολιού απέτυχε</translation> </message> <message> <location line="-56"/> <source>Wallet encryption failed due to an internal error. Your wallet was not encrypted.</source> <translation>Η κρυπτογράφηση του πορτοφολιού απέτυχε λογω εσωτερικού σφάλματος. Το πορτοφολι δεν κρυπτογραφηθηκε.</translation> </message> <message> <location line="+7"/> <location line="+50"/> <source>The supplied passphrases do not match.</source> <translation>Οι εισαχθέντες κωδικοί δεν ταιριάζουν.</translation> </message> <message> <location line="-38"/> <source>Wallet unlock failed</source> <translation>το ξεκλείδωμα του πορτοφολιού απέτυχε</translation> </message> <message> <location line="+1"/> <location line="+12"/> <location line="+19"/> <source>The passphrase entered for the wallet decryption was incorrect.</source> <translation>Ο κωδικος που εισήχθη για την αποκρυπτογραφηση του πορτοφολιού ήταν λαθος.</translation> </message> <message> <location line="-20"/> <source>Wallet decryption failed</source> <translation>Η αποκρυπτογραφηση του πορτοφολιού απέτυχε</translation> </message> <message> <location line="+14"/> <source>Wallet passphrase was successfully changed.</source> <translation>Ο κωδικος του πορτοφολιού άλλαξε με επιτυχία.</translation> </message> </context> <context> <name>BitcoinGUI</name> <message> <location filename="../bitcoingui.cpp" line="+282"/> <source>Sign &amp;message...</source> <translation>Υπογραφή &amp;Μηνύματος...</translation> </message> <message> <location line="+251"/> <source>Synchronizing with network...</source> <translation>Συγχρονισμός με το δίκτυο...</translation> </message> <message> <location line="-319"/> <source>&amp;Overview</source> <translation>&amp;Επισκόπηση</translation> </message> <message> <location line="+1"/> <source>Show general overview of wallet</source> <translation>Εμφάνισε τη γενική εικόνα του πορτοφολιού</translation> </message> <message> <location line="+17"/> <source>&amp;Transactions</source> <translation>&amp;Συναλλαγές</translation> </message> <message> <location line="+1"/> <source>Browse transaction history</source> <translation>Περιήγηση στο ιστορικό συναλλαγών</translation> </message> <message> <location line="+5"/> <source>&amp;Address Book</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Edit the list of stored addresses and labels</source> <translation type="unfinished"/> </message> <message> <location line="-13"/> <source>&amp;Receive coins</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show the list of addresses for receiving payments</source> <translation type="unfinished"/> </message> <message> <location line="-7"/> <source>&amp;Send coins</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>E&amp;xit</source> <translation>Έ&amp;ξοδος</translation> </message> <message> <location line="+1"/> <source>Quit application</source> <translation>Εξοδος από την εφαρμογή</translation> </message> <message> <location line="+6"/> <source>Show information about BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>About &amp;Qt</source> <translation>Σχετικά με &amp;Qt</translation> </message> <message> <location line="+1"/> <source>Show information about Qt</source> <translation>Εμφάνισε πληροφορίες σχετικά με Qt</translation> </message> <message> <location line="+2"/> <source>&amp;Options...</source> <translation>&amp;Επιλογές...</translation> </message> <message> <location line="+4"/> <source>&amp;Encrypt Wallet...</source> <translation>&amp;Κρυπτογράφησε το πορτοφόλι</translation> </message> <message> <location line="+3"/> <source>&amp;Backup Wallet...</source> <translation>&amp;Αντίγραφο ασφαλείας του πορτοφολιού</translation> </message> <message> <location line="+2"/> <source>&amp;Change Passphrase...</source> <translation>&amp;Άλλαξε κωδικο πρόσβασης</translation> </message> <message numerus="yes"> <location line="+259"/> <source>~%n block(s) remaining</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+6"/> <source>Downloaded %1 of %2 blocks of transaction history (%3% done).</source> <translation type="unfinished"/> </message> <message> <location line="-256"/> <source>&amp;Export...</source> <translation type="unfinished"/> </message> <message> <location line="-64"/> <source>Send coins to a BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+47"/> <source>Modify configuration options for BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>Export the data in the current tab to a file</source> <translation type="unfinished"/> </message> <message> <location line="-14"/> <source>Encrypt or decrypt wallet</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Backup wallet to another location</source> <translation>Δημιουργία αντιγράφου ασφαλείας πορτοφολιού σε άλλη τοποθεσία</translation> </message> <message> <location line="+2"/> <source>Change the passphrase used for wallet encryption</source> <translation>Αλλαγή του κωδικού κρυπτογράφησης του πορτοφολιού</translation> </message> <message> <location line="+10"/> <source>&amp;Debug window</source> <translation>&amp;Παράθυρο αποσφαλμάτωσης</translation> </message> <message> <location line="+1"/> <source>Open debugging and diagnostic console</source> <translation>Άνοιγμα κονσόλας αποσφαλμάτωσης και διαγνωστικών</translation> </message> <message> <location line="-5"/> <source>&amp;Verify message...</source> <translation>&amp;Επιβεβαίωση μηνύματος</translation> </message> <message> <location line="-202"/> <source>BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Wallet</source> <translation>Πορτοφόλι</translation> </message> <message> <location line="+180"/> <source>&amp;About BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>&amp;Show / Hide</source> <translation>&amp;Εμφάνισε/Κρύψε</translation> </message> <message> <location line="+9"/> <source>Unlock wallet</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>&amp;Lock Wallet</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Lock wallet</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>&amp;File</source> <translation>&amp;Αρχείο</translation> </message> <message> <location line="+8"/> <source>&amp;Settings</source> <translation>&amp;Ρυθμίσεις</translation> </message> <message> <location line="+8"/> <source>&amp;Help</source> <translation>&amp;Βοήθεια</translation> </message> <message> <location line="+12"/> <source>Tabs toolbar</source> <translation>Εργαλειοθήκη καρτελών</translation> </message> <message> <location line="+8"/> <source>Actions toolbar</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <location line="+9"/> <source>[testnet]</source> <translation>[testnet]</translation> </message> <message> <location line="+0"/> <location line="+60"/> <source>BigBang client</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+75"/> <source>%n active connection(s) to BigBang network</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+40"/> <source>Downloaded %1 blocks of transaction history.</source> <translation type="unfinished"/> </message> <message> <location line="+413"/> <source>Staking.&lt;br&gt;Your weight is %1&lt;br&gt;Network weight is %2&lt;br&gt;Expected time to earn reward is %3</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Not staking because wallet is locked</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Not staking because wallet is offline</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Not staking because wallet is syncing</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Not staking because you don&apos;t have mature coins</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="-403"/> <source>%n second(s) ago</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="-312"/> <source>About BigBang card</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show information about BigBang card</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>&amp;Unlock Wallet...</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+297"/> <source>%n minute(s) ago</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n hour(s) ago</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n day(s) ago</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+6"/> <source>Up to date</source> <translation>Ενημερωμένο</translation> </message> <message> <location line="+7"/> <source>Catching up...</source> <translation>Ενημέρωση...</translation> </message> <message> <location line="+10"/> <source>Last received block was generated %1.</source> <translation type="unfinished"/> </message> <message> <location line="+59"/> <source>This transaction is over the size limit. You can still send it for a fee of %1, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Confirm transaction fee</source> <translation type="unfinished"/> </message> <message> <location line="+27"/> <source>Sent transaction</source> <translation>Η συναλλαγή απεστάλη</translation> </message> <message> <location line="+1"/> <source>Incoming transaction</source> <translation>Εισερχόμενη συναλλαγή</translation> </message> <message> <location line="+1"/> <source>Date: %1 Amount: %2 Type: %3 Address: %4 </source> <translation>Ημερομηνία: %1 Ποσό: %2 Τύπος: %3 Διεύθυνση: %4 </translation> </message> <message> <location line="+100"/> <location line="+15"/> <source>URI handling</source> <translation type="unfinished"/> </message> <message> <location line="-15"/> <location line="+15"/> <source>URI can not be parsed! This can be caused by an invalid BigBang address or malformed URI parameters.</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>Wallet is &lt;b&gt;encrypted&lt;/b&gt; and currently &lt;b&gt;unlocked&lt;/b&gt;</source> <translation>Το πορτοφόλι είναι &lt;b&gt;κρυπτογραφημένο&lt;/b&gt; και &lt;b&gt;ξεκλείδωτο&lt;/b&gt;</translation> </message> <message> <location line="+10"/> <source>Wallet is &lt;b&gt;encrypted&lt;/b&gt; and currently &lt;b&gt;locked&lt;/b&gt;</source> <translation>Το πορτοφόλι είναι &lt;b&gt;κρυπτογραφημένο&lt;/b&gt; και &lt;b&gt;κλειδωμένο&lt;/b&gt;</translation> </message> <message> <location line="+25"/> <source>Backup Wallet</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Wallet Data (*.dat)</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Backup Failed</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>There was an error trying to save the wallet data to the new location.</source> <translation type="unfinished"/> </message> <message numerus="yes"> <location line="+76"/> <source>%n second(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n minute(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n hour(s)</source> <translation><numerusform>%n ώρες </numerusform><numerusform>%n ώρες </numerusform></translation> </message> <message numerus="yes"> <location line="+4"/> <source>%n day(s)</source> <translation><numerusform>%n ημέρες </numerusform><numerusform>%n ημέρες </numerusform></translation> </message> <message> <location line="+18"/> <source>Not staking</source> <translation type="unfinished"/> </message> <message> <location filename="../bitcoin.cpp" line="+109"/> <source>A fatal error occurred. BigBang can no longer continue safely and will quit.</source> <translation type="unfinished"/> </message> </context> <context> <name>ClientModel</name> <message> <location filename="../clientmodel.cpp" line="+90"/> <source>Network Alert</source> <translation>Ειδοποίηση Δικτύου</translation> </message> </context> <context> <name>CoinControlDialog</name> <message> <location filename="../forms/coincontroldialog.ui" line="+14"/> <source>Coin Control</source> <translation type="unfinished"/> </message> <message> <location line="+31"/> <source>Quantity:</source> <translation type="unfinished"/> </message> <message> <location line="+32"/> <source>Bytes:</source> <translation type="unfinished"/> </message> <message> <location line="+48"/> <source>Amount:</source> <translation>Ποσό:</translation> </message> <message> <location line="+32"/> <source>Priority:</source> <translation type="unfinished"/> </message> <message> <location line="+48"/> <source>Fee:</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>Low Output:</source> <translation type="unfinished"/> </message> <message> <location filename="../coincontroldialog.cpp" line="+551"/> <source>no</source> <translation type="unfinished"/> </message> <message> <location filename="../forms/coincontroldialog.ui" line="+51"/> <source>After Fee:</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>Change:</source> <translation type="unfinished"/> </message> <message> <location line="+69"/> <source>(un)select all</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>Tree mode</source> <translation type="unfinished"/> </message> <message> <location line="+16"/> <source>List mode</source> <translation type="unfinished"/> </message> <message> <location line="+45"/> <source>Amount</source> <translation>Ποσό</translation> </message> <message> <location line="+5"/> <source>Label</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Address</source> <translation>Διεύθυνση</translation> </message> <message> <location line="+5"/> <source>Date</source> <translation>Ημερομηνία</translation> </message> <message> <location line="+5"/> <source>Confirmations</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Confirmed</source> <translation>Επικυρωμένες</translation> </message> <message> <location line="+5"/> <source>Priority</source> <translation type="unfinished"/> </message> <message> <location filename="../coincontroldialog.cpp" line="-515"/> <source>Copy address</source> <translation>Αντιγραφή διεύθυνσης</translation> </message> <message> <location line="+1"/> <source>Copy label</source> <translation>Αντιγραφή επιγραφής</translation> </message> <message> <location line="+1"/> <location line="+26"/> <source>Copy amount</source> <translation>Αντιγραφή ποσού</translation> </message> <message> <location line="-25"/> <source>Copy transaction ID</source> <translation>Αντιγραφη του ID Συναλλαγής</translation> </message> <message> <location line="+24"/> <source>Copy quantity</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Copy fee</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy after fee</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy bytes</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy priority</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy low output</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy change</source> <translation type="unfinished"/> </message> <message> <location line="+317"/> <source>highest</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>high</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>medium-high</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>medium</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>low-medium</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>low</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>lowest</source> <translation type="unfinished"/> </message> <message> <location line="+155"/> <source>DUST</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>yes</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>This label turns red, if the transaction size is bigger than 10000 bytes. This means a fee of at least %1 per kb is required. Can vary +/- 1 Byte per input.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Transactions with higher priority get more likely into a block. This label turns red, if the priority is smaller than &quot;medium&quot;. This means a fee of at least %1 per kb is required.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>This label turns red, if any recipient receives an amount smaller than %1. This means a fee of at least %2 is required. Amounts below 0.546 times the minimum relay fee are shown as DUST.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>This label turns red, if the change is smaller than %1. This means a fee of at least %2 is required.</source> <translation type="unfinished"/> </message> <message> <location line="+37"/> <location line="+66"/> <source>(no label)</source> <translation>(χωρίς ετικέτα)</translation> </message> <message> <location line="-9"/> <source>change from %1 (%2)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>(change)</source> <translation type="unfinished"/> </message> </context> <context> <name>EditAddressDialog</name> <message> <location filename="../forms/editaddressdialog.ui" line="+14"/> <source>Edit Address</source> <translation>Επεξεργασία Διεύθυνσης</translation> </message> <message> <location line="+11"/> <source>&amp;Label</source> <translation>&amp;Επιγραφή</translation> </message> <message> <location line="+10"/> <source>The label associated with this address book entry</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>&amp;Address</source> <translation>&amp;Διεύθυνση</translation> </message> <message> <location line="+10"/> <source>The address associated with this address book entry. This can only be modified for sending addresses.</source> <translation type="unfinished"/> </message> <message> <location filename="../editaddressdialog.cpp" line="+20"/> <source>New receiving address</source> <translation>Νέα διεύθυνση λήψης</translation> </message> <message> <location line="+4"/> <source>New sending address</source> <translation>Νέα διεύθυνση αποστολής</translation> </message> <message> <location line="+3"/> <source>Edit receiving address</source> <translation>Επεξεργασία διεύθυνσης λήψης</translation> </message> <message> <location line="+4"/> <source>Edit sending address</source> <translation>Επεξεργασία διεύθυνσης αποστολής</translation> </message> <message> <location line="+76"/> <source>The entered address &quot;%1&quot; is already in the address book.</source> <translation>Η διεύθυνση &quot;%1&quot; βρίσκεται ήδη στο βιβλίο διευθύνσεων.</translation> </message> <message> <location line="-5"/> <source>The entered address &quot;%1&quot; is not a valid BigBang address.</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>Could not unlock wallet.</source> <translation>Δεν είναι δυνατό το ξεκλείδωμα του πορτοφολιού.</translation> </message> <message> <location line="+5"/> <source>New key generation failed.</source> <translation>Η δημιουργία νέου κλειδιού απέτυχε.</translation> </message> </context> <context> <name>GUIUtil::HelpMessageBox</name> <message> <location filename="../guiutil.cpp" line="+420"/> <location line="+12"/> <source>BigBang-Qt</source> <translation type="unfinished"/> </message> <message> <location line="-12"/> <source>version</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Usage:</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>command-line options</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>UI options</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Set language, for example &quot;de_DE&quot; (default: system locale)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Start minimized</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Show splash screen on startup (default: 1)</source> <translation type="unfinished"/> </message> </context> <context> <name>OptionsDialog</name> <message> <location filename="../forms/optionsdialog.ui" line="+14"/> <source>Options</source> <translation>Ρυθμίσεις</translation> </message> <message> <location line="+16"/> <source>&amp;Main</source> <translation>&amp;Κύριο</translation> </message> <message> <location line="+6"/> <source>Optional transaction fee per kB that helps make sure your transactions are processed quickly. Most transactions are 1 kB. Fee 0.01 recommended.</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source>Pay transaction &amp;fee</source> <translation>Αμοιβή &amp;συναλλαγής</translation> </message> <message> <location line="+31"/> <source>Reserved amount does not participate in staking and is therefore spendable at any time.</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source>Reserve</source> <translation type="unfinished"/> </message> <message> <location line="+31"/> <source>Automatically start BigBang after logging in to the system.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Start BigBang on system login</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Detach databases at shutdown</source> <translation type="unfinished"/> </message> <message> <location line="+21"/> <source>&amp;Network</source> <translation>&amp;Δίκτυο</translation> </message> <message> <location line="+6"/> <source>Automatically open the BigBang client port on the router. This only works when your router supports UPnP and it is enabled.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Map port using &amp;UPnP</source> <translation>Απόδοση θυρών με χρήστη &amp;UPnP</translation> </message> <message> <location line="+7"/> <source>Connect to the BigBang network through a SOCKS proxy (e.g. when connecting through Tor).</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Connect through SOCKS proxy:</source> <translation type="unfinished"/> </message> <message> <location line="+9"/> <source>Proxy &amp;IP:</source> <translation>&amp;IP διαμεσολαβητή:</translation> </message> <message> <location line="+19"/> <source>IP address of the proxy (e.g. 127.0.0.1)</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>&amp;Port:</source> <translation>&amp;Θύρα:</translation> </message> <message> <location line="+19"/> <source>Port of the proxy (e.g. 9050)</source> <translation>Θύρα διαμεσολαβητή</translation> </message> <message> <location line="+7"/> <source>SOCKS &amp;Version:</source> <translation>SOCKS &amp;Έκδοση:</translation> </message> <message> <location line="+13"/> <source>SOCKS version of the proxy (e.g. 5)</source> <translation>SOCKS εκδοση του διαμεσολαβητη (e.g. 5)</translation> </message> <message> <location line="+36"/> <source>&amp;Window</source> <translation>&amp;Παράθυρο</translation> </message> <message> <location line="+6"/> <source>Show only a tray icon after minimizing the window.</source> <translation>Εμφάνιση μόνο εικονιδίου στην περιοχή ειδοποιήσεων κατά την ελαχιστοποίηση</translation> </message> <message> <location line="+3"/> <source>&amp;Minimize to the tray instead of the taskbar</source> <translation>&amp;Ελαχιστοποίηση στην περιοχή ειδοποιήσεων αντί της γραμμής εργασιών</translation> </message> <message> <location line="+7"/> <source>Minimize instead of exit the application when the window is closed. When this option is enabled, the application will be closed only after selecting Quit in the menu.</source> <translation>Ελαχιστοποίηση αντί για έξοδο κατά το κλείσιμο του παραθύρου</translation> </message> <message> <location line="+3"/> <source>M&amp;inimize on close</source> <translation>Ε&amp;λαχιστοποίηση κατά το κλείσιμο</translation> </message> <message> <location line="+21"/> <source>&amp;Display</source> <translation>&amp;Απεικόνιση</translation> </message> <message> <location line="+8"/> <source>User Interface &amp;language:</source> <translation>Γλώσσα περιβάλλοντος εργασίας: </translation> </message> <message> <location line="+13"/> <source>The user interface language can be set here. This setting will take effect after restarting BigBang.</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>&amp;Unit to show amounts in:</source> <translation>&amp;Μονάδα μέτρησης:</translation> </message> <message> <location line="+13"/> <source>Choose the default subdivision unit to show in the interface and when sending coins.</source> <translation>Διαλέξτε την προεπιλεγμένη υποδιαίρεση που θα εμφανίζεται όταν στέλνετε νομίσματα.</translation> </message> <message> <location line="+9"/> <source>Whether to show BigBang addresses in the transaction list or not.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Display addresses in transaction list</source> <translation>Εμφάνιση διευθύνσεων στη λίστα συναλλαγών</translation> </message> <message> <location line="+7"/> <source>Whether to show coin control features or not.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Display coin &amp;control features (experts only!)</source> <translation type="unfinished"/> </message> <message> <location line="+71"/> <source>&amp;OK</source> <translation>&amp;ΟΚ</translation> </message> <message> <location line="+7"/> <source>&amp;Cancel</source> <translation>&amp;Ακύρωση</translation> </message> <message> <location line="+10"/> <source>&amp;Apply</source> <translation type="unfinished"/> </message> <message> <location filename="../optionsdialog.cpp" line="+55"/> <source>default</source> <translation>προεπιλογή</translation> </message> <message> <location line="+149"/> <location line="+9"/> <source>Warning</source> <translation type="unfinished"/> </message> <message> <location line="-9"/> <location line="+9"/> <source>This setting will take effect after restarting BigBang.</source> <translation type="unfinished"/> </message> <message> <location line="+29"/> <source>The supplied proxy address is invalid.</source> <translation>Δεν είναι έγκυρη η διεύθυνση διαμεσολαβητή</translation> </message> </context> <context> <name>OverviewPage</name> <message> <location filename="../forms/overviewpage.ui" line="+14"/> <source>Form</source> <translation>Φόρμα</translation> </message> <message> <location line="+33"/> <location line="+231"/> <source>The displayed information may be out of date. Your wallet automatically synchronizes with the BigBang network after a connection is established, but this process has not completed yet.</source> <translation type="unfinished"/> </message> <message> <location line="-160"/> <source>Stake:</source> <translation type="unfinished"/> </message> <message> <location line="+29"/> <source>Unconfirmed:</source> <translation type="unfinished"/> </message> <message> <location line="-107"/> <source>Wallet</source> <translation>Πορτοφόλι</translation> </message> <message> <location line="+49"/> <source>Spendable:</source> <translation type="unfinished"/> </message> <message> <location line="+16"/> <source>Your current spendable balance</source> <translation>Το τρέχον διαθέσιμο υπόλοιπο</translation> </message> <message> <location line="+71"/> <source>Immature:</source> <translation>Ανώριμος</translation> </message> <message> <location line="+13"/> <source>Mined balance that has not yet matured</source> <translation>Εξορυγμενο υπόλοιπο που δεν έχει ακόμα ωριμάσει </translation> </message> <message> <location line="+20"/> <source>Total:</source> <translation>Σύνολο:</translation> </message> <message> <location line="+16"/> <source>Your current total balance</source> <translation>Το τρέχον συνολικό υπόλοιπο</translation> </message> <message> <location line="+46"/> <source>&lt;b&gt;Recent transactions&lt;/b&gt;</source> <translation>&lt;b&gt;Πρόσφατες συναλλαγές&lt;/b&gt;</translation> </message> <message> <location line="-108"/> <source>Total of transactions that have yet to be confirmed, and do not yet count toward the current balance</source> <translation type="unfinished"/> </message> <message> <location line="-29"/> <source>Total of coins that was staked, and do not yet count toward the current balance</source> <translation type="unfinished"/> </message> <message> <location filename="../overviewpage.cpp" line="+113"/> <location line="+1"/> <source>out of sync</source> <translation>εκτός συγχρονισμού</translation> </message> </context> <context> <name>QRCodeDialog</name> <message> <location filename="../forms/qrcodedialog.ui" line="+14"/> <source>QR Code Dialog</source> <translation type="unfinished"/> </message> <message> <location line="+59"/> <source>Request Payment</source> <translation type="unfinished"/> </message> <message> <location line="+56"/> <source>Amount:</source> <translation type="unfinished"/> </message> <message> <location line="-44"/> <source>Label:</source> <translation type="unfinished"/> </message> <message> <location line="+19"/> <source>Message:</source> <translation type="unfinished"/> </message> <message> <location line="+71"/> <source>&amp;Save As...</source> <translation type="unfinished"/> </message> <message> <location filename="../qrcodedialog.cpp" line="+62"/> <source>Error encoding URI into QR Code.</source> <translation type="unfinished"/> </message> <message> <location line="+40"/> <source>The entered amount is invalid, please check.</source> <translation type="unfinished"/> </message> <message> <location line="+23"/> <source>Resulting URI too long, try to reduce the text for label / message.</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>Save QR Code</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>PNG Images (*.png)</source> <translation type="unfinished"/> </message> </context> <context> <name>RPCConsole</name> <message> <location filename="../forms/rpcconsole.ui" line="+46"/> <source>Client name</source> <translation>Όνομα Πελάτη</translation> </message> <message> <location line="+10"/> <location line="+23"/> <location line="+26"/> <location line="+23"/> <location line="+23"/> <location line="+36"/> <location line="+53"/> <location line="+23"/> <location line="+23"/> <location filename="../rpcconsole.cpp" line="+348"/> <source>N/A</source> <translation>Μη διαθέσιμο</translation> </message> <message> <location line="-217"/> <source>Client version</source> <translation>Έκδοση Πελάτη</translation> </message> <message> <location line="-45"/> <source>&amp;Information</source> <translation>&amp;Πληροφορία</translation> </message> <message> <location line="+68"/> <source>Using OpenSSL version</source> <translation>Χρησιμοποιηση της OpenSSL εκδοσης</translation> </message> <message> <location line="+49"/> <source>Startup time</source> <translation>Χρόνος εκκίνησης</translation> </message> <message> <location line="+29"/> <source>Network</source> <translation>Δίκτυο</translation> </message> <message> <location line="+7"/> <source>Number of connections</source> <translation>Αριθμός συνδέσεων</translation> </message> <message> <location line="+23"/> <source>On testnet</source> <translation type="unfinished"/> </message> <message> <location line="+23"/> <source>Block chain</source> <translation>Αλυσίδα μπλοκ</translation> </message> <message> <location line="+7"/> <source>Current number of blocks</source> <translation>Τρέχον αριθμός μπλοκ</translation> </message> <message> <location line="+23"/> <source>Estimated total blocks</source> <translation>Κατ&apos; εκτίμηση συνολικά μπλοκς</translation> </message> <message> <location line="+23"/> <source>Last block time</source> <translation>Χρόνος τελευταίου μπλοκ</translation> </message> <message> <location line="+52"/> <source>&amp;Open</source> <translation>&amp;Άνοιγμα</translation> </message> <message> <location line="+16"/> <source>Command-line options</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Show the BigBang-Qt help message to get a list with possible BigBang command-line options.</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>&amp;Show</source> <translation type="unfinished"/> </message> <message> <location line="+24"/> <source>&amp;Console</source> <translation>&amp;Κονσόλα</translation> </message> <message> <location line="-260"/> <source>Build date</source> <translation>Ημερομηνία κατασκευής</translation> </message> <message> <location line="-104"/> <source>BigBang - Debug window</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>BigBang Core</source> <translation type="unfinished"/> </message> <message> <location line="+279"/> <source>Debug log file</source> <translation>Αρχείο καταγραφής εντοπισμού σφαλμάτων </translation> </message> <message> <location line="+7"/> <source>Open the BigBang debug log file from the current data directory. This can take a few seconds for large log files.</source> <translation type="unfinished"/> </message> <message> <location line="+102"/> <source>Clear console</source> <translation>Καθαρισμός κονσόλας</translation> </message> <message> <location filename="../rpcconsole.cpp" line="-33"/> <source>Welcome to the BigBang RPC console.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Use up and down arrows to navigate history, and &lt;b&gt;Ctrl-L&lt;/b&gt; to clear screen.</source> <translation>Χρησιμοποιήστε το πάνω και κάτω βέλος για να περιηγηθείτε στο ιστορικο, και &lt;b&gt;Ctrl-L&lt;/b&gt; για εκκαθαριση οθονης.</translation> </message> <message> <location line="+1"/> <source>Type &lt;b&gt;help&lt;/b&gt; for an overview of available commands.</source> <translation>Γράψτε &lt;b&gt;help&lt;/b&gt; για μια επισκόπηση των διαθέσιμων εντολών</translation> </message> </context> <context> <name>SendCoinsDialog</name> <message> <location filename="../forms/sendcoinsdialog.ui" line="+14"/> <location filename="../sendcoinsdialog.cpp" line="+182"/> <location line="+5"/> <location line="+5"/> <location line="+5"/> <location line="+6"/> <location line="+5"/> <location line="+5"/> <source>Send Coins</source> <translation>Αποστολή νομισμάτων</translation> </message> <message> <location line="+76"/> <source>Coin Control Features</source> <translation type="unfinished"/> </message> <message> <location line="+20"/> <source>Inputs...</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>automatically selected</source> <translation type="unfinished"/> </message> <message> <location line="+19"/> <source>Insufficient funds!</source> <translation type="unfinished"/> </message> <message> <location line="+77"/> <source>Quantity:</source> <translation type="unfinished"/> </message> <message> <location line="+22"/> <location line="+35"/> <source>0</source> <translation type="unfinished"/> </message> <message> <location line="-19"/> <source>Bytes:</source> <translation type="unfinished"/> </message> <message> <location line="+51"/> <source>Amount:</source> <translation>Ποσό:</translation> </message> <message> <location line="+22"/> <location line="+86"/> <location line="+86"/> <location line="+32"/> <source>0.00 BBC</source> <translation type="unfinished"/> </message> <message> <location line="-191"/> <source>Priority:</source> <translation type="unfinished"/> </message> <message> <location line="+19"/> <source>medium</source> <translation type="unfinished"/> </message> <message> <location line="+32"/> <source>Fee:</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>Low Output:</source> <translation type="unfinished"/> </message> <message> <location line="+19"/> <source>no</source> <translation type="unfinished"/> </message> <message> <location line="+32"/> <source>After Fee:</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>Change</source> <translation type="unfinished"/> </message> <message> <location line="+50"/> <source>custom change address</source> <translation type="unfinished"/> </message> <message> <location line="+106"/> <source>Send to multiple recipients at once</source> <translation>Αποστολή σε πολλούς αποδέκτες ταυτόχρονα</translation> </message> <message> <location line="+3"/> <source>Add &amp;Recipient</source> <translation>&amp;Προσθήκη αποδέκτη</translation> </message> <message> <location line="+20"/> <source>Remove all transaction fields</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Clear &amp;All</source> <translation>Καθαρισμός &amp;Όλων</translation> </message> <message> <location line="+28"/> <source>Balance:</source> <translation>Υπόλοιπο:</translation> </message> <message> <location line="+16"/> <source>123.456 BBC</source> <translation type="unfinished"/> </message> <message> <location line="+31"/> <source>Confirm the send action</source> <translation>Επιβεβαίωση αποστολής</translation> </message> <message> <location line="+3"/> <source>S&amp;end</source> <translation>Αποστολη</translation> </message> <message> <location filename="../sendcoinsdialog.cpp" line="-173"/> <source>Enter a BigBang address (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source>Copy quantity</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy amount</source> <translation>Αντιγραφή ποσού</translation> </message> <message> <location line="+1"/> <source>Copy fee</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy after fee</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy bytes</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy priority</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy low output</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Copy change</source> <translation type="unfinished"/> </message> <message> <location line="+86"/> <source>&lt;b&gt;%1&lt;/b&gt; to %2 (%3)</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Confirm send coins</source> <translation>Επιβεβαίωση αποστολής νομισμάτων</translation> </message> <message> <location line="+1"/> <source>Are you sure you want to send %1?</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source> and </source> <translation type="unfinished"/> </message> <message> <location line="+29"/> <source>The recipient address is not valid, please recheck.</source> <translation>Η διεύθυνση του αποδέκτη δεν είναι σωστή. Παρακαλώ ελέγξτε ξανά.</translation> </message> <message> <location line="+5"/> <source>The amount to pay must be larger than 0.</source> <translation>Το ποσό πληρωμής πρέπει να είναι μεγαλύτερο από 0.</translation> </message> <message> <location line="+5"/> <source>The amount exceeds your balance.</source> <translation>Το ποσό ξεπερνάει το διαθέσιμο υπόλοιπο</translation> </message> <message> <location line="+5"/> <source>The total exceeds your balance when the %1 transaction fee is included.</source> <translation>Το σύνολο υπερβαίνει το υπόλοιπό σας όταν συμπεριληφθεί και η αμοιβή %1</translation> </message> <message> <location line="+6"/> <source>Duplicate address found, can only send to each address once per send operation.</source> <translation>Βρέθηκε η ίδια διεύθυνση δύο φορές. Επιτρέπεται μία μόνο εγγραφή για κάθε διεύθυνση, σε κάθε διαδικασία αποστολής.</translation> </message> <message> <location line="+5"/> <source>Error: Transaction creation failed.</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source> <translation type="unfinished"/> </message> <message> <location line="+251"/> <source>WARNING: Invalid BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+13"/> <source>(no label)</source> <translation>(χωρίς ετικέτα)</translation> </message> <message> <location line="+4"/> <source>WARNING: unknown change address</source> <translation type="unfinished"/> </message> </context> <context> <name>SendCoinsEntry</name> <message> <location filename="../forms/sendcoinsentry.ui" line="+14"/> <source>Form</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source>A&amp;mount:</source> <translation>&amp;Ποσό:</translation> </message> <message> <location line="+13"/> <source>Pay &amp;To:</source> <translation>Πληρωμή &amp;σε:</translation> </message> <message> <location line="+24"/> <location filename="../sendcoinsentry.cpp" line="+25"/> <source>Enter a label for this address to add it to your address book</source> <translation>Εισάγετε μια επιγραφή για αυτή τη διεύθυνση ώστε να καταχωρηθεί στο βιβλίο διευθύνσεων</translation> </message> <message> <location line="+9"/> <source>&amp;Label:</source> <translation>&amp;Επιγραφή</translation> </message> <message> <location line="+18"/> <source>The address to send the payment to (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>Choose address from address book</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <source>Alt+A</source> <translation>Alt+A</translation> </message> <message> <location line="+7"/> <source>Paste address from clipboard</source> <translation>Επικόλληση διεύθυνσης από το πρόχειρο</translation> </message> <message> <location line="+10"/> <source>Alt+P</source> <translation>Alt+P</translation> </message> <message> <location line="+7"/> <source>Remove this recipient</source> <translation type="unfinished"/> </message> <message> <location filename="../sendcoinsentry.cpp" line="+1"/> <source>Enter a BigBang address (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> </context> <context> <name>SignVerifyMessageDialog</name> <message> <location filename="../forms/signverifymessagedialog.ui" line="+14"/> <source>Signatures - Sign / Verify a Message</source> <translation>Υπογραφές - Είσοδος / Επαλήθευση μήνυματος </translation> </message> <message> <location line="+13"/> <location line="+124"/> <source>&amp;Sign Message</source> <translation>&amp;Υπογραφή Μηνύματος</translation> </message> <message> <location line="-118"/> <source>You can sign messages with your addresses to prove you own them. Be careful not to sign anything vague, as phishing attacks may try to trick you into signing your identity over to them. Only sign fully-detailed statements you agree to.</source> <translation>Μπορείτε να υπογράφετε μηνύματα με τις διευθύνσεις σας, ώστε ν&apos; αποδεικνύετε πως αυτές σας ανήκουν. Αποφεύγετε να υπογράφετε κάτι αόριστο καθώς ενδέχεται να εξαπατηθείτε. Υπογράφετε μόνο πλήρης δηλώσεις με τις οποίες συμφωνείτε.</translation> </message> <message> <location line="+18"/> <source>The address to sign the message with (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> <message> <location line="+10"/> <location line="+203"/> <source>Choose an address from the address book</source> <translation type="unfinished"/> </message> <message> <location line="-193"/> <location line="+203"/> <source>Alt+A</source> <translation>Alt+A</translation> </message> <message> <location line="-193"/> <source>Paste address from clipboard</source> <translation>Επικόλληση διεύθυνσης από το βιβλίο διευθύνσεων</translation> </message> <message> <location line="+10"/> <source>Alt+P</source> <translation>Alt+P</translation> </message> <message> <location line="+12"/> <source>Enter the message you want to sign here</source> <translation>Εισάγετε εδώ το μήνυμα που θέλετε να υπογράψετε</translation> </message> <message> <location line="+24"/> <source>Copy the current signature to the system clipboard</source> <translation>Αντέγραφη της επιλεγμενης διεύθυνσης στο πρόχειρο του συστηματος</translation> </message> <message> <location line="+21"/> <source>Sign the message to prove you own this BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+17"/> <source>Reset all sign message fields</source> <translation>Επαναφορά όλων των πεδίων μήνυματος</translation> </message> <message> <location line="+3"/> <location line="+146"/> <source>Clear &amp;All</source> <translation>Καθαρισμός &amp;Όλων</translation> </message> <message> <location line="-87"/> <location line="+70"/> <source>&amp;Verify Message</source> <translation>&amp;Επιβεβαίωση μηνύματος</translation> </message> <message> <location line="-64"/> <source>Enter the signing address, message (ensure you copy line breaks, spaces, tabs, etc. exactly) and signature below to verify the message. Be careful not to read more into the signature than what is in the signed message itself, to avoid being tricked by a man-in-the-middle attack.</source> <translation>Πληκτρολογήστε την υπογραφή διεύθυνσης, μήνυμα (βεβαιωθείτε ότι έχετε αντιγράψει τις αλλαγές γραμμής, κενά, tabs, κ.λπ. ακριβώς) και την υπογραφή παρακάτω, για να ελέγξει το μήνυμα. Να είστε προσεκτικοί για να μην διαβάσετε περισσότερα στην υπογραφή ό, τι είναι στην υπογραφή ίδιο το μήνυμα , για να μην εξαπατηθούν από έναν άνθρωπο -in - the-middle επίθεση.</translation> </message> <message> <location line="+21"/> <source>The address the message was signed with (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> <message> <location line="+40"/> <source>Verify the message to ensure it was signed with the specified BigBang address</source> <translation type="unfinished"/> </message> <message> <location line="+17"/> <source>Reset all verify message fields</source> <translation>Επαναφορά όλων επαλήθευμενων πεδίων μήνυματος </translation> </message> <message> <location filename="../signverifymessagedialog.cpp" line="+27"/> <location line="+3"/> <source>Enter a BigBang address (e.g. Sjz75uKHzUQJnSdzvpiigEGxseKkDhQToX)</source> <translation type="unfinished"/> </message> <message> <location line="-2"/> <source>Click &quot;Sign Message&quot; to generate signature</source> <translation>Κάντε κλικ στο &quot;Υπογραφή Μηνύματος&quot; για να λάβετε την υπογραφή</translation> </message> <message> <location line="+3"/> <source>Enter BigBang signature</source> <translation type="unfinished"/> </message> <message> <location line="+82"/> <location line="+81"/> <source>The entered address is invalid.</source> <translation>Η διεύθυνση που εισήχθη είναι λάθος.</translation> </message> <message> <location line="-81"/> <location line="+8"/> <location line="+73"/> <location line="+8"/> <source>Please check the address and try again.</source> <translation>Παρακαλούμε ελέγξτε την διεύθυνση και δοκιμάστε ξανά.</translation> </message> <message> <location line="-81"/> <location line="+81"/> <source>The entered address does not refer to a key.</source> <translation>Η διεύθυνση που έχει εισαχθεί δεν αναφέρεται σε ένα πλήκτρο.</translation> </message> <message> <location line="-73"/> <source>Wallet unlock was cancelled.</source> <translation>το ξεκλείδωμα του πορτοφολιού απέτυχε</translation> </message> <message> <location line="+8"/> <source>Private key for the entered address is not available.</source> <translation>Το προσωπικό κλειδί εισαγμενης διευθυνσης δεν είναι διαθέσιμο.</translation> </message> <message> <location line="+12"/> <source>Message signing failed.</source> <translation>Η υπογραφή του μηνύματος απέτυχε.</translation> </message> <message> <location line="+5"/> <source>Message signed.</source> <translation>Μήνυμα υπεγράφη.</translation> </message> <message> <location line="+59"/> <source>The signature could not be decoded.</source> <translation>Η υπογραφή δεν μπόρεσε να αποκρυπτογραφηθεί.</translation> </message> <message> <location line="+0"/> <location line="+13"/> <source>Please check the signature and try again.</source> <translation>Παρακαλούμε ελέγξτε την υπογραφή και δοκιμάστε ξανά.</translation> </message> <message> <location line="+0"/> <source>The signature did not match the message digest.</source> <translation>Η υπογραφή δεν ταιριάζει με το μήνυμα. </translation> </message> <message> <location line="+7"/> <source>Message verification failed.</source> <translation>Η επιβεβαίωση του μηνύματος απέτυχε</translation> </message> <message> <location line="+5"/> <source>Message verified.</source> <translation>Μήνυμα επιβεβαιώθηκε.</translation> </message> </context> <context> <name>TransactionDesc</name> <message> <location filename="../transactiondesc.cpp" line="+19"/> <source>Open until %1</source> <translation>Ανοιχτό μέχρι %1</translation> </message> <message numerus="yes"> <location line="-2"/> <source>Open for %n block(s)</source> <translation type="unfinished"><numerusform></numerusform><numerusform></numerusform></translation> </message> <message> <location line="+8"/> <source>conflicted</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>%1/offline</source> <translation>%1/χωρίς σύνδεση;</translation> </message> <message> <location line="+2"/> <source>%1/unconfirmed</source> <translation>%1/χωρίς επιβεβαίωση</translation> </message> <message> <location line="+2"/> <source>%1 confirmations</source> <translation>%1 επιβεβαιώσεις</translation> </message> <message> <location line="+18"/> <source>Status</source> <translation>Κατάσταση</translation> </message> <message numerus="yes"> <location line="+7"/> <source>, broadcast through %n node(s)</source> <translation><numerusform>, έχει μεταδοθεί μέσω %n κόμβων</numerusform><numerusform>, έχει μεταδοθεί μέσω %n κόμβων</numerusform></translation> </message> <message> <location line="+4"/> <source>Date</source> <translation>Ημερομηνία</translation> </message> <message> <location line="+7"/> <source>Source</source> <translation>Πηγή</translation> </message> <message> <location line="+0"/> <source>Generated</source> <translation>Δημιουργία </translation> </message> <message> <location line="+5"/> <location line="+17"/> <source>From</source> <translation>Από</translation> </message> <message> <location line="+1"/> <location line="+22"/> <location line="+58"/> <source>To</source> <translation>Προς</translation> </message> <message> <location line="-77"/> <location line="+2"/> <source>own address</source> <translation> δική σας διεύθυνση </translation> </message> <message> <location line="-2"/> <source>label</source> <translation>eπιγραφή</translation> </message> <message> <location line="+37"/> <location line="+12"/> <location line="+45"/> <location line="+17"/> <location line="+30"/> <source>Credit</source> <translation>Πίστωση </translation> </message> <message numerus="yes"> <location line="-102"/> <source>matures in %n more block(s)</source> <translation><numerusform>ωρίμανση σε %n επιπλέον μπλοκ</numerusform><numerusform>ωρίμανση σε %n επιπλέον μπλοκ</numerusform></translation> </message> <message> <location line="+2"/> <source>not accepted</source> <translation>μη αποδεκτό</translation> </message> <message> <location line="+44"/> <location line="+8"/> <location line="+15"/> <location line="+30"/> <source>Debit</source> <translation>Debit</translation> </message> <message> <location line="-39"/> <source>Transaction fee</source> <translation>Τέλος συναλλαγής </translation> </message> <message> <location line="+16"/> <source>Net amount</source> <translation>Καθαρό ποσό</translation> </message> <message> <location line="+6"/> <source>Message</source> <translation>Μήνυμα</translation> </message> <message> <location line="+2"/> <source>Comment</source> <translation>Σχόλιο:</translation> </message> <message> <location line="+2"/> <source>Transaction ID</source> <translation>ID Συναλλαγής:</translation> </message> <message> <location line="+3"/> <source>Generated coins must mature 110 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to &quot;not accepted&quot; and it won&apos;t be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.</source> <translation type="unfinished"/> </message> <message> <location line="+7"/> <source>Debug information</source> <translation>Πληροφορίες αποσφαλμάτωσης</translation> </message> <message> <location line="+8"/> <source>Transaction</source> <translation>Συναλλαγή</translation> </message> <message> <location line="+5"/> <source>Inputs</source> <translation>εισροές </translation> </message> <message> <location line="+23"/> <source>Amount</source> <translation>Ποσό</translation> </message> <message> <location line="+1"/> <source>true</source> <translation>αληθής</translation> </message> <message> <location line="+0"/> <source>false</source> <translation>αναληθής </translation> </message> <message> <location line="-211"/> <source>, has not been successfully broadcast yet</source> <translation>, δεν έχει ακόμα μεταδοθεί μ&apos; επιτυχία</translation> </message> <message> <location line="+35"/> <source>unknown</source> <translation>άγνωστο</translation> </message> </context> <context> <name>TransactionDescDialog</name> <message> <location filename="../forms/transactiondescdialog.ui" line="+14"/> <source>Transaction details</source> <translation>Λεπτομέρειες συναλλαγής</translation> </message> <message> <location line="+6"/> <source>This pane shows a detailed description of the transaction</source> <translation>Αυτό το παράθυρο δείχνει μια λεπτομερή περιγραφή της συναλλαγής</translation> </message> </context> <context> <name>TransactionTableModel</name> <message> <location filename="../transactiontablemodel.cpp" line="+226"/> <source>Date</source> <translation>Ημερομηνία</translation> </message> <message> <location line="+0"/> <source>Type</source> <translation>Τύπος</translation> </message> <message> <location line="+0"/> <source>Address</source> <translation>Διεύθυνση</translation> </message> <message> <location line="+0"/> <source>Amount</source> <translation>Ποσό</translation> </message> <message> <location line="+60"/> <source>Open until %1</source> <translation>Ανοιχτό μέχρι %1</translation> </message> <message> <location line="+12"/> <source>Confirmed (%1 confirmations)</source> <translation>Επικυρωμένη (%1 επικυρώσεις)</translation> </message> <message numerus="yes"> <location line="-15"/> <source>Open for %n more block(s)</source> <translation><numerusform>Ανοιχτό για %n μπλοκ</numerusform><numerusform>Ανοιχτό για %n μπλοκ</numerusform></translation> </message> <message> <location line="+6"/> <source>Offline</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Unconfirmed</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Confirming (%1 of %2 recommended confirmations)</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Conflicted</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Immature (%1 confirmations, will be available after %2)</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>This block was not received by any other nodes and will probably not be accepted!</source> <translation>Αυτό το μπλοκ δεν έχει παραληφθεί από κανέναν άλλο κόμβο και κατά πάσα πιθανότητα θα απορριφθεί!</translation> </message> <message> <location line="+3"/> <source>Generated but not accepted</source> <translation>Δημιουργήθηκε αλλά απορρίφθηκε</translation> </message> <message> <location line="+42"/> <source>Received with</source> <translation>Παραλαβή με</translation> </message> <message> <location line="+2"/> <source>Received from</source> <translation>Ελήφθη από</translation> </message> <message> <location line="+3"/> <source>Sent to</source> <translation>Αποστολή προς</translation> </message> <message> <location line="+2"/> <source>Payment to yourself</source> <translation>Πληρωμή προς εσάς</translation> </message> <message> <location line="+2"/> <source>Mined</source> <translation>Εξόρυξη</translation> </message> <message> <location line="+38"/> <source>(n/a)</source> <translation>(δ/α)</translation> </message> <message> <location line="+190"/> <source>Transaction status. Hover over this field to show number of confirmations.</source> <translation>Κατάσταση συναλλαγής. Πηγαίνετε το ποντίκι πάνω από αυτό το πεδίο για να δείτε τον αριθμό των επικυρώσεων</translation> </message> <message> <location line="+2"/> <source>Date and time that the transaction was received.</source> <translation>Ημερομηνία κι ώρα λήψης της συναλλαγής.</translation> </message> <message> <location line="+2"/> <source>Type of transaction.</source> <translation>Είδος συναλλαγής.</translation> </message> <message> <location line="+2"/> <source>Destination address of transaction.</source> <translation>Διεύθυνση αποστολής της συναλλαγής.</translation> </message> <message> <location line="+2"/> <source>Amount removed from or added to balance.</source> <translation>Ποσό που αφαιρέθηκε ή προστέθηκε στο υπόλοιπο.</translation> </message> </context> <context> <name>TransactionView</name> <message> <location filename="../transactionview.cpp" line="+55"/> <location line="+16"/> <source>All</source> <translation>Όλα</translation> </message> <message> <location line="-15"/> <source>Today</source> <translation>Σήμερα</translation> </message> <message> <location line="+1"/> <source>This week</source> <translation>Αυτή την εβδομάδα</translation> </message> <message> <location line="+1"/> <source>This month</source> <translation>Αυτόν τον μήνα</translation> </message> <message> <location line="+1"/> <source>Last month</source> <translation>Τον προηγούμενο μήνα</translation> </message> <message> <location line="+1"/> <source>This year</source> <translation>Αυτό το έτος</translation> </message> <message> <location line="+1"/> <source>Range...</source> <translation>Έκταση...</translation> </message> <message> <location line="+11"/> <source>Received with</source> <translation>Ελήφθη με</translation> </message> <message> <location line="+2"/> <source>Sent to</source> <translation>Απεστάλη προς</translation> </message> <message> <location line="+2"/> <source>To yourself</source> <translation>Προς εσάς</translation> </message> <message> <location line="+1"/> <source>Mined</source> <translation>Εξόρυξη</translation> </message> <message> <location line="+1"/> <source>Other</source> <translation>Άλλο</translation> </message> <message> <location line="+7"/> <source>Enter address or label to search</source> <translation>Αναζήτηση με βάση τη διεύθυνση ή την επιγραφή</translation> </message> <message> <location line="+7"/> <source>Min amount</source> <translation>Ελάχιστο ποσό</translation> </message> <message> <location line="+34"/> <source>Copy address</source> <translation>Αντιγραφή διεύθυνσης</translation> </message> <message> <location line="+1"/> <source>Copy label</source> <translation>Αντιγραφή επιγραφής</translation> </message> <message> <location line="+1"/> <source>Copy amount</source> <translation>Αντιγραφή ποσού</translation> </message> <message> <location line="+1"/> <source>Copy transaction ID</source> <translation>Αντιγραφη του ID Συναλλαγής</translation> </message> <message> <location line="+1"/> <source>Edit label</source> <translation>Επεξεργασία επιγραφής</translation> </message> <message> <location line="+1"/> <source>Show transaction details</source> <translation>Εμφάνιση λεπτομερειών συναλλαγής</translation> </message> <message> <location line="+144"/> <source>Export Transaction Data</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Comma separated file (*.csv)</source> <translation>Αρχείο οριοθετημένο με κόμματα (*.csv)</translation> </message> <message> <location line="+8"/> <source>Confirmed</source> <translation>Επικυρωμένες</translation> </message> <message> <location line="+1"/> <source>Date</source> <translation>Ημερομηνία</translation> </message> <message> <location line="+1"/> <source>Type</source> <translation>Τύπος</translation> </message> <message> <location line="+1"/> <source>Label</source> <translation>Επιγραφή</translation> </message> <message> <location line="+1"/> <source>Address</source> <translation>Διεύθυνση</translation> </message> <message> <location line="+1"/> <source>Amount</source> <translation>Ποσό</translation> </message> <message> <location line="+1"/> <source>ID</source> <translation>ID</translation> </message> <message> <location line="+4"/> <source>Error exporting</source> <translation type="unfinished"/> </message> <message> <location line="+0"/> <source>Could not write to file %1.</source> <translation type="unfinished"/> </message> <message> <location line="+100"/> <source>Range:</source> <translation>Έκταση:</translation> </message> <message> <location line="+8"/> <source>to</source> <translation>έως</translation> </message> </context> <context> <name>WalletModel</name> <message> <location filename="../walletmodel.cpp" line="+206"/> <source>Sending...</source> <translation type="unfinished"/> </message> </context> <context> <name>bitcoin-core</name> <message> <location filename="../bitcoinstrings.cpp" line="+33"/> <source>BigBang version</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Usage:</source> <translation>Χρήση:</translation> </message> <message> <location line="+1"/> <source>Send command to -server or BigBangd</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>List commands</source> <translation>Λίστα εντολών</translation> </message> <message> <location line="+1"/> <source>Get help for a command</source> <translation>Επεξήγηση εντολής</translation> </message> <message> <location line="+2"/> <source>Options:</source> <translation>Επιλογές:</translation> </message> <message> <location line="+2"/> <source>Specify configuration file (default: BigBang.conf)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Specify pid file (default: BigBangd.pid)</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Specify wallet file (within data directory)</source> <translation type="unfinished"/> </message> <message> <location line="-1"/> <source>Specify data directory</source> <translation>Ορισμός φακέλου δεδομένων</translation> </message> <message> <location line="+2"/> <source>Set database cache size in megabytes (default: 25)</source> <translation>Όρισε το μέγεθος της βάσης προσωρινής αποθήκευσης σε megabytes(προεπιλογή:25)</translation> </message> <message> <location line="+1"/> <source>Set database disk log size in megabytes (default: 100)</source> <translation type="unfinished"/> </message> <message> <location line="+6"/> <source>Listen for connections on &lt;port&gt; (default: 15714 or testnet: 25714)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Maintain at most &lt;n&gt; connections to peers (default: 125)</source> <translation>Μέγιστες αριθμός συνδέσεων με τους peers &lt;n&gt; (προεπιλογή: 125)</translation> </message> <message> <location line="+3"/> <source>Connect to a node to retrieve peer addresses, and disconnect</source> <translation>Σύνδεση σε έναν κόμβο για την ανάκτηση διευθύνσεων από ομοτίμους, και αποσυνδέσh</translation> </message> <message> <location line="+1"/> <source>Specify your own public address</source> <translation>Διευκρινίστε τη δικιά σας δημόσια διεύθυνση.</translation> </message> <message> <location line="+5"/> <source>Bind to given address. Use [host]:port notation for IPv6</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Stake your coins to support network and gain reward (default: 1)</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Threshold for disconnecting misbehaving peers (default: 100)</source> <translation>Όριο αποσύνδεσης προβληματικών peers (προεπιλογή: 100)</translation> </message> <message> <location line="+1"/> <source>Number of seconds to keep misbehaving peers from reconnecting (default: 86400)</source> <translation>Δευτερόλεπτα πριν επιτραπεί ξανά η σύνδεση των προβληματικών peers (προεπιλογή: 86400)</translation> </message> <message> <location line="-44"/> <source>An error occurred while setting up the RPC port %u for listening on IPv4: %s</source> <translation>Ένα σφάλμα συνέβη καθώς προετοιμαζόταν η πόρτα RPC %u για αναμονή IPv4: %s</translation> </message> <message> <location line="+51"/> <source>Detach block and address databases. Increases shutdown time (default: 0)</source> <translation type="unfinished"/> </message> <message> <location line="+109"/> <source>Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.</source> <translation type="unfinished"/> </message> <message> <location line="-5"/> <source>Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds </source> <translation type="unfinished"/> </message> <message> <location line="-87"/> <source>Listen for JSON-RPC connections on &lt;port&gt; (default: 15715 or testnet: 25715)</source> <translation type="unfinished"/> </message> <message> <location line="-11"/> <source>Accept command line and JSON-RPC commands</source> <translation>Αποδοχή εντολών κονσόλας και JSON-RPC</translation> </message> <message> <location line="+101"/> <source>Error: Transaction creation failed </source> <translation type="unfinished"/> </message> <message> <location line="-5"/> <source>Error: Wallet locked, unable to create transaction </source> <translation type="unfinished"/> </message> <message> <location line="-8"/> <source>Importing blockchain data file.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Importing bootstrap blockchain data file.</source> <translation type="unfinished"/> </message> <message> <location line="-88"/> <source>Run in the background as a daemon and accept commands</source> <translation>Εκτέλεση στο παρασκήνιο κι αποδοχή εντολών</translation> </message> <message> <location line="+1"/> <source>Use the test network</source> <translation>Χρήση του δοκιμαστικού δικτύου</translation> </message> <message> <location line="-24"/> <source>Accept connections from outside (default: 1 if no -proxy or -connect)</source> <translation>Να δέχεσαι συνδέσεις από έξω(προεπιλογή:1)</translation> </message> <message> <location line="-38"/> <source>An error occurred while setting up the RPC port %u for listening on IPv6, falling back to IPv4: %s</source> <translation>Ένα σφάλμα συνέβη καθώς προετοιμαζόταν η υποδοχη RPC %u για αναμονη του IPv6, επεσε πισω στο IPv4:%s</translation> </message> <message> <location line="+117"/> <source>Error initializing database environment %s! To recover, BACKUP THAT DIRECTORY, then remove everything from it except for wallet.dat.</source> <translation type="unfinished"/> </message> <message> <location line="-20"/> <source>Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.</source> <translation>Προειδοποίηση: Η παράμετρος -paytxfee είναι πολύ υψηλή. Πρόκειται για την αμοιβή που θα πληρώνετε για κάθε συναλλαγή που θα στέλνετε.</translation> </message> <message> <location line="+61"/> <source>Warning: Please check that your computer&apos;s date and time are correct! If your clock is wrong BigBang will not work properly.</source> <translation type="unfinished"/> </message> <message> <location line="-31"/> <source>Warning: error reading wallet.dat! All keys read correctly, but transaction data or address book entries might be missing or incorrect.</source> <translation>Προειδοποίηση : Σφάλμα wallet.dat κατα την ανάγνωση ! Όλα τα κλειδιά αναγνωρισθηκαν σωστά, αλλά τα δεδομένα των συναλλαγών ή καταχωρήσεις στο βιβλίο διευθύνσεων μπορεί να είναι ελλιπείς ή λανθασμένα. </translation> </message> <message> <location line="-18"/> <source>Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect you should restore from a backup.</source> <translation>Προειδοποίηση : το αρχειο wallet.dat ειναι διεφθαρμένο, τα δεδομένα σώζονται ! Original wallet.dat αποθηκεύονται ως wallet.{timestamp}.bak στο %s . Αν το υπόλοιπο του ή τις συναλλαγές σας, είναι λάθος θα πρέπει να επαναφέρετε από ένα αντίγραφο ασφαλείας</translation> </message> <message> <location line="-30"/> <source>Attempt to recover private keys from a corrupt wallet.dat</source> <translation>Προσπάθεια για ανακτησει ιδιωτικων κλειδιων από ενα διεφθαρμένο αρχειο wallet.dat </translation> </message> <message> <location line="+4"/> <source>Block creation options:</source> <translation>Αποκλεισμός επιλογων δημιουργίας: </translation> </message> <message> <location line="-62"/> <source>Connect only to the specified node(s)</source> <translation>Σύνδεση μόνο με ορισμένους κόμβους</translation> </message> <message> <location line="+4"/> <source>Discover own IP address (default: 1 when listening and no -externalip)</source> <translation>Ανακαλύψτε την δικη σας IP διεύθυνση (προεπιλογή: 1 όταν ακούει και δεν - externalip) </translation> </message> <message> <location line="+94"/> <source>Failed to listen on any port. Use -listen=0 if you want this.</source> <translation>ταλαιπωρηθειτε για να ακούσετε σε οποιαδήποτε θύρα. Χρήση - ακούστε = 0 , αν θέλετε αυτό.</translation> </message> <message> <location line="-90"/> <source>Find peers using DNS lookup (default: 1)</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Sync checkpoints policy (default: strict)</source> <translation type="unfinished"/> </message> <message> <location line="+83"/> <source>Invalid -tor address: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="+4"/> <source>Invalid amount for -reservebalance=&lt;amount&gt;</source> <translation type="unfinished"/> </message> <message> <location line="-82"/> <source>Maximum per-connection receive buffer, &lt;n&gt;*1000 bytes (default: 5000)</source> <translation>Μέγιστος buffer λήψης ανά σύνδεση, &lt;n&gt;*1000 bytes (προεπιλογή: 5000)</translation> </message> <message> <location line="+1"/> <source>Maximum per-connection send buffer, &lt;n&gt;*1000 bytes (default: 1000)</source> <translation>Μέγιστος buffer αποστολής ανά σύνδεση, &lt;n&gt;*1000 bytes (προεπιλογή: 1000)</translation> </message> <message> <location line="-16"/> <source>Only connect to nodes in network &lt;net&gt; (IPv4, IPv6 or Tor)</source> <translation> Συνδέση μόνο σε κόμβους του δικτύου &lt;net&gt; (IPv4, IPv6 ή Tor) </translation> </message> <message> <location line="+28"/> <source>Output extra debugging information. Implies all other -debug* options</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Output extra network debugging information</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Prepend debug output with timestamp</source> <translation type="unfinished"/> </message> <message> <location line="+35"/> <source>SSL options: (see the Bitcoin Wiki for SSL setup instructions)</source> <translation>Ρυθμίσεις SSL: (ανατρέξτε στο Bitcoin Wiki για οδηγίες ρυθμίσεων SSL)</translation> </message> <message> <location line="-74"/> <source>Select the version of socks proxy to use (4-5, default: 5)</source> <translation type="unfinished"/> </message> <message> <location line="+41"/> <source>Send trace/debug info to console instead of debug.log file</source> <translation>Αποστολή πληροφοριών εντοπισμού σφαλμάτων στην κονσόλα αντί του αρχείου debug.log</translation> </message> <message> <location line="+1"/> <source>Send trace/debug info to debugger</source> <translation type="unfinished"/> </message> <message> <location line="+28"/> <source>Set maximum block size in bytes (default: 250000)</source> <translation type="unfinished"/> </message> <message> <location line="-1"/> <source>Set minimum block size in bytes (default: 0)</source> <translation>Ορίστε το μέγιστο μέγεθος μπλοκ σε bytes (προεπιλογή: 0)</translation> </message> <message> <location line="-29"/> <source>Shrink debug.log file on client startup (default: 1 when no -debug)</source> <translation>Συρρίκνωση του αρχείο debug.log κατα την εκκίνηση του πελάτη (προεπιλογή: 1 όταν δεν-debug)</translation> </message> <message> <location line="-42"/> <source>Specify connection timeout in milliseconds (default: 5000)</source> <translation>Ορισμός λήξης χρονικού ορίου σε χιλιοστά του δευτερολέπτου(προεπιλογή:5000)</translation> </message> <message> <location line="+109"/> <source>Unable to sign checkpoint, wrong checkpointkey? </source> <translation type="unfinished"/> </message> <message> <location line="-80"/> <source>Use UPnP to map the listening port (default: 0)</source> <translation>Χρησιμοποίηση του UPnP για την χρήση της πόρτας αναμονής (προεπιλογή:0)</translation> </message> <message> <location line="-1"/> <source>Use UPnP to map the listening port (default: 1 when listening)</source> <translation>Χρησιμοποίηση του UPnP για την χρήση της πόρτας αναμονής (προεπιλογή:1)</translation> </message> <message> <location line="-25"/> <source>Use proxy to reach tor hidden services (default: same as -proxy)</source> <translation type="unfinished"/> </message> <message> <location line="+42"/> <source>Username for JSON-RPC connections</source> <translation>Όνομα χρήστη για τις συνδέσεις JSON-RPC</translation> </message> <message> <location line="+47"/> <source>Verifying database integrity...</source> <translation type="unfinished"/> </message> <message> <location line="+57"/> <source>WARNING: syncronized checkpoint violation detected, but skipped!</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Warning: Disk space is low!</source> <translation type="unfinished"/> </message> <message> <location line="-2"/> <source>Warning: This version is obsolete, upgrade required!</source> <translation>Προειδοποίηση: Αυτή η έκδοση είναι ξεπερασμένη, απαιτείται αναβάθμιση </translation> </message> <message> <location line="-48"/> <source>wallet.dat corrupt, salvage failed</source> <translation>Το αρχειο wallet.dat ειναι διεφθαρμένο, η διάσωση απέτυχε</translation> </message> <message> <location line="-54"/> <source>Password for JSON-RPC connections</source> <translation>Κωδικός για τις συνδέσεις JSON-RPC</translation> </message> <message> <location line="-84"/> <source>%s, you must set a rpcpassword in the configuration file: %s It is recommended you use the following random password: rpcuser=BigBangrpc rpcpassword=%s (you do not need to remember this password) The username and password MUST NOT be the same. If the file does not exist, create it with owner-readable-only file permissions. It is also recommended to set alertnotify so you are notified of problems; for example: alertnotify=echo %%s | mail -s &quot;BigBang Alert&quot; admin@foo.com </source> <translation type="unfinished"/> </message> <message> <location line="+51"/> <source>Find peers using internet relay chat (default: 0)</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Sync time with other nodes. Disable if time on your system is precise e.g. syncing with NTP (default: 1)</source> <translation type="unfinished"/> </message> <message> <location line="+15"/> <source>When creating transactions, ignore inputs with value less than this (default: 0.01)</source> <translation type="unfinished"/> </message> <message> <location line="+16"/> <source>Allow JSON-RPC connections from specified IP address</source> <translation>Αποδοχή συνδέσεων JSON-RPC από συγκεκριμένη διεύθυνση IP</translation> </message> <message> <location line="+1"/> <source>Send commands to node running on &lt;ip&gt; (default: 127.0.0.1)</source> <translation>Αποστολή εντολών στον κόμβο &lt;ip&gt; (προεπιλογή: 127.0.0.1)</translation> </message> <message> <location line="+1"/> <source>Execute command when the best block changes (%s in cmd is replaced by block hash)</source> <translation>Εκτέλεσε την εντολή όταν το καλύτερο μπλοκ αλλάξει(%s στην εντολή αντικαθίσταται από το hash του μπλοκ)</translation> </message> <message> <location line="+3"/> <source>Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)</source> <translation>Εκτέλεσε την εντολή όταν το καλύτερο μπλοκ αλλάξει(%s στην εντολή αντικαθίσταται από το hash του μπλοκ)</translation> </message> <message> <location line="+3"/> <source>Require a confirmations for change (default: 0)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Enforce transaction scripts to use canonical PUSH operators (default: 1)</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Execute command when a relevant alert is received (%s in cmd is replaced by message)</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Upgrade wallet to latest format</source> <translation>Αναβάθμισε το πορτοφόλι στην τελευταία έκδοση</translation> </message> <message> <location line="+1"/> <source>Set key pool size to &lt;n&gt; (default: 100)</source> <translation>Όριο πλήθους κλειδιών pool &lt;n&gt; (προεπιλογή: 100)</translation> </message> <message> <location line="+1"/> <source>Rescan the block chain for missing wallet transactions</source> <translation>Επανέλεγχος της αλυσίδας μπλοκ για απούσες συναλλαγές</translation> </message> <message> <location line="+2"/> <source>How many blocks to check at startup (default: 2500, 0 = all)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>How thorough the block verification is (0-6, default: 1)</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Imports blocks from external blk000?.dat file</source> <translation type="unfinished"/> </message> <message> <location line="+8"/> <source>Use OpenSSL (https) for JSON-RPC connections</source> <translation>Χρήση του OpenSSL (https) για συνδέσεις JSON-RPC</translation> </message> <message> <location line="+1"/> <source>Server certificate file (default: server.cert)</source> <translation>Αρχείο πιστοποιητικού του διακομιστή (προεπιλογή: server.cert)</translation> </message> <message> <location line="+1"/> <source>Server private key (default: server.pem)</source> <translation>Προσωπικό κλειδί του διακομιστή (προεπιλογή: server.pem)</translation> </message> <message> <location line="+1"/> <source>Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)</source> <translation type="unfinished"/> </message> <message> <location line="+53"/> <source>Error: Wallet unlocked for staking only, unable to create transaction.</source> <translation type="unfinished"/> </message> <message> <location line="+18"/> <source>WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers.</source> <translation type="unfinished"/> </message> <message> <location line="-158"/> <source>This help message</source> <translation>Αυτό το κείμενο βοήθειας</translation> </message> <message> <location line="+95"/> <source>Wallet %s resides outside data directory %s.</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Cannot obtain a lock on data directory %s. BigBang is probably already running.</source> <translation type="unfinished"/> </message> <message> <location line="-98"/> <source>BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+140"/> <source>Unable to bind to %s on this computer (bind returned error %d, %s)</source> <translation>Αδύνατη η σύνδεση με τη θύρα %s αυτού του υπολογιστή (bind returned error %d, %s) </translation> </message> <message> <location line="-130"/> <source>Connect through socks proxy</source> <translation type="unfinished"/> </message> <message> <location line="+3"/> <source>Allow DNS lookups for -addnode, -seednode and -connect</source> <translation>Να επιτρέπονται οι έλεγχοι DNS για προσθήκη και σύνδεση κόμβων</translation> </message> <message> <location line="+122"/> <source>Loading addresses...</source> <translation>Φόρτωση διευθύνσεων...</translation> </message> <message> <location line="-15"/> <source>Error loading blkindex.dat</source> <translation type="unfinished"/> </message> <message> <location line="+2"/> <source>Error loading wallet.dat: Wallet corrupted</source> <translation>Σφάλμα φόρτωσης wallet.dat: Κατεστραμμένο Πορτοφόλι</translation> </message> <message> <location line="+4"/> <source>Error loading wallet.dat: Wallet requires newer version of BigBang</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Wallet needed to be rewritten: restart BigBang to complete</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Error loading wallet.dat</source> <translation>Σφάλμα φόρτωσης αρχείου wallet.dat</translation> </message> <message> <location line="-16"/> <source>Invalid -proxy address: &apos;%s&apos;</source> <translation>Δεν είναι έγκυρη η διεύθυνση διαμεσολαβητή: &apos;%s&apos;</translation> </message> <message> <location line="-1"/> <source>Unknown network specified in -onlynet: &apos;%s&apos;</source> <translation>Άγνωστo δίκτυο ορίζεται σε onlynet: &apos;%s&apos;</translation> </message> <message> <location line="-1"/> <source>Unknown -socks proxy version requested: %i</source> <translation>Άγνωστo δίκτυο ορίζεται: %i</translation> </message> <message> <location line="+4"/> <source>Cannot resolve -bind address: &apos;%s&apos;</source> <translation>Δεν μπορώ να γράψω την προεπιλεγμένη διεύθυνση: &apos;%s&apos;</translation> </message> <message> <location line="+2"/> <source>Cannot resolve -externalip address: &apos;%s&apos;</source> <translation>Δεν μπορώ να γράψω την προεπιλεγμένη διεύθυνση: &apos;%s&apos;</translation> </message> <message> <location line="-24"/> <source>Invalid amount for -paytxfee=&lt;amount&gt;: &apos;%s&apos;</source> <translation>Μη έγκυρο ποσό για την παράμετρο -paytxfee=&lt;amount&gt;: &apos;%s&apos;</translation> </message> <message> <location line="+44"/> <source>Error: could not start node</source> <translation type="unfinished"/> </message> <message> <location line="+11"/> <source>Sending...</source> <translation type="unfinished"/> </message> <message> <location line="+5"/> <source>Invalid amount</source> <translation>Λάθος ποσότητα</translation> </message> <message> <location line="+1"/> <source>Insufficient funds</source> <translation>Ανεπαρκές κεφάλαιο</translation> </message> <message> <location line="-34"/> <source>Loading block index...</source> <translation>Φόρτωση ευρετηρίου μπλοκ...</translation> </message> <message> <location line="-103"/> <source>Add a node to connect to and attempt to keep the connection open</source> <translation>Προσέθεσε ένα κόμβο για σύνδεση και προσπάθησε να κρατήσεις την σύνδεση ανοιχτή</translation> </message> <message> <location line="+122"/> <source>Unable to bind to %s on this computer. BigBang is probably already running.</source> <translation type="unfinished"/> </message> <message> <location line="-97"/> <source>Fee per KB to add to transactions you send</source> <translation type="unfinished"/> </message> <message> <location line="+55"/> <source>Invalid amount for -mininput=&lt;amount&gt;: &apos;%s&apos;</source> <translation type="unfinished"/> </message> <message> <location line="+25"/> <source>Loading wallet...</source> <translation>Φόρτωση πορτοφολιού...</translation> </message> <message> <location line="+8"/> <source>Cannot downgrade wallet</source> <translation>Δεν μπορώ να υποβαθμίσω το πορτοφόλι</translation> </message> <message> <location line="+1"/> <source>Cannot initialize keypool</source> <translation type="unfinished"/> </message> <message> <location line="+1"/> <source>Cannot write default address</source> <translation>Δεν μπορώ να γράψω την προεπιλεγμένη διεύθυνση</translation> </message> <message> <location line="+1"/> <source>Rescanning...</source> <translation>Ανίχνευση...</translation> </message> <message> <location line="+5"/> <source>Done loading</source> <translation>Η φόρτωση ολοκληρώθηκε</translation> </message> <message> <location line="-167"/> <source>To use the %s option</source> <translation>Χρήση της %s επιλογής</translation> </message> <message> <location line="+14"/> <source>Error</source> <translation>Σφάλμα</translation> </message> <message> <location line="+6"/> <source>You must set rpcpassword=&lt;password&gt; in the configuration file: %s If the file does not exist, create it with owner-readable-only file permissions.</source> <translation>Πρέπει να βάλεις ένα κωδικό στο αρχείο παραμέτρων: %s Εάν το αρχείο δεν υπάρχει, δημιούργησε το με δικαιώματα μόνο για ανάγνωση από τον δημιουργό</translation> </message> </context> </TS>
Lefter1s/BigBang
src/qt/locale/bitcoin_el_GR.ts
TypeScript
mit
128,896
[ 30522, 1026, 1029, 20950, 2544, 1027, 1000, 1015, 1012, 1014, 1000, 1029, 1028, 1026, 999, 9986, 13874, 24529, 1028, 1026, 24529, 2653, 1027, 1000, 3449, 1035, 24665, 1000, 2544, 1027, 1000, 1016, 1012, 1015, 1000, 1028, 1026, 6123, 1028, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Yeriomin\ConsoleApp; /** * Service exception * * @author yeriomin */ class ConsoleAppException extends \Exception { }
yeriomin/console-app
src/Yeriomin/ConsoleApp/ConsoleAppException.php
PHP
mit
140
[ 30522, 1026, 1029, 25718, 3415, 15327, 20416, 18994, 2378, 1032, 10122, 29098, 1025, 1013, 1008, 1008, 1008, 2326, 6453, 1008, 1008, 1030, 3166, 20416, 18994, 2378, 1008, 1013, 2465, 10122, 29098, 10288, 24422, 8908, 1032, 6453, 1063, 1065, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*BEGIN_LEGAL Intel Open Source License Copyright (c) 2002-2013 Intel Corporation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. END_LEGAL */ // // This tool demonstrates how to get the value of the application's // errno on linux in jit mode. // // There are symbols called __errno_location in both libc and libpthread. // This test captures the address of the __errno_location() function in // one of the libraries and not in the other. Today, the implementations // in libc and libpthread point to the same actual location (in a TLS), // but this assumption is fragile and may change at some time int he future. // // On FreeBSD, the function is called __error(). It suffers from the same problem // (but the threading library in FreeBSD is libthr). The problem is more severe // on FreeBSD because the function in libc and in libthr don't point to the same // location (libthr point to TLS and libc to a static variable). Also, on FreeBSD, // libc and libpthr lack symbols, so the address of the function cannot be found. // This tool is not supported on FreeBSD. #include "pin.H" #include <iostream> #include <stdlib.h> #include <errno.h> using namespace std; AFUNPTR pf_errno_location = 0; /* ===================================================================== */ VOID ToolCheckError( CONTEXT * ctxt ) { unsigned long err_loc; if ( *pf_errno_location != 0 ) { cerr << "Tool: calling __errno_location()" << endl; PIN_CallApplicationFunction( ctxt, PIN_ThreadId(), CALLINGSTD_DEFAULT, pf_errno_location, PIN_PARG(unsigned long), &err_loc, PIN_PARG_END() ); int err_value = *( reinterpret_cast< unsigned long *>(err_loc)); cerr << "Tool: errno=" << err_value << endl; } else cerr << "Tool: __errno_location not found." << endl; } /* ===================================================================== */ VOID ImageLoad(IMG img, VOID *v) { RTN errno_location_rtn = RTN_FindByName(img, "__errno_location"); if (RTN_Valid(errno_location_rtn)) { pf_errno_location = reinterpret_cast<AFUNPTR>(RTN_Address(errno_location_rtn)); cerr << "Tool: Found __errno_location() at " << hex << (ADDRINT)pf_errno_location << "." << endl; } if ( IMG_IsMainExecutable( img )) { PROTO proto = PROTO_Allocate( PIN_PARG(void), CALLINGSTD_DEFAULT, "CheckError", PIN_PARG_END() ); RTN rtn = RTN_FindByName(img, "CheckError"); if (RTN_Valid(rtn)) { cout << "Replacing " << RTN_Name(rtn) << " in " << IMG_Name(img) << endl; RTN_ReplaceSignature(rtn, AFUNPTR(ToolCheckError), IARG_PROTOTYPE, proto, IARG_CONTEXT, IARG_END); } PROTO_Free( proto ); } } /* ===================================================================== */ int main(INT32 argc, CHAR *argv[]) { PIN_InitSymbols(); PIN_Init(argc, argv); IMG_AddInstrumentFunction(ImageLoad, 0); PIN_StartProgram(); return 0; } /* ===================================================================== */ /* eof */ /* ===================================================================== */
cyjseagull/SHMA
zsim-nvmain/pin_kit/source/tools/Probes/error-lin-jit.cpp
C++
gpl-2.0
4,820
[ 30522, 1013, 1008, 4088, 1035, 3423, 13420, 2330, 3120, 6105, 9385, 1006, 1039, 1007, 2526, 1011, 2286, 13420, 3840, 1012, 2035, 2916, 9235, 1012, 25707, 1998, 2224, 1999, 3120, 1998, 12441, 3596, 1010, 2007, 2030, 2302, 14080, 1010, 2024, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_71) on Fri Jul 10 16:43:03 IST 2015 --> <title>com.ephesoft.dcma.regexvalidation.service Class Hierarchy</title> <meta name="date" content="2015-07-10"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="com.ephesoft.dcma.regexvalidation.service Class Hierarchy"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-files/index-1.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../com/ephesoft/dcma/regexvalidation/constant/package-tree.html">Prev</a></li> <li><a href="../../../../../com/ephesoft/dcma/regexvalidtaion/package-tree.html">Next</a></li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?com/ephesoft/dcma/regexvalidation/service/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 class="title">Hierarchy For Package com.ephesoft.dcma.regexvalidation.service</h1> <span class="strong">Package Hierarchies:</span> <ul class="horizontal"> <li><a href="../../../../../overview-tree.html">All Packages</a></li> </ul> </div> <div class="contentContainer"> <h2 title="Class Hierarchy">Class Hierarchy</h2> <ul> <li type="circle">java.lang.Object <ul> <li type="circle">com.ephesoft.dcma.regexvalidation.service.<a href="../../../../../com/ephesoft/dcma/regexvalidation/service/RegexValidationServiceImpl.html" title="class in com.ephesoft.dcma.regexvalidation.service"><span class="strong">RegexValidationServiceImpl</span></a> (implements com.ephesoft.dcma.regexvalidation.service.<a href="../../../../../com/ephesoft/dcma/regexvalidation/service/RegexValidationService.html" title="interface in com.ephesoft.dcma.regexvalidation.service">RegexValidationService</a>)</li> </ul> </li> </ul> <h2 title="Interface Hierarchy">Interface Hierarchy</h2> <ul> <li type="circle">com.ephesoft.dcma.regexvalidation.service.<a href="../../../../../com/ephesoft/dcma/regexvalidation/service/RegexValidationService.html" title="interface in com.ephesoft.dcma.regexvalidation.service"><span class="strong">RegexValidationService</span></a></li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li>Class</li> <li>Use</li> <li class="navBarCell1Rev">Tree</li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-files/index-1.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../com/ephesoft/dcma/regexvalidation/constant/package-tree.html">Prev</a></li> <li><a href="../../../../../com/ephesoft/dcma/regexvalidtaion/package-tree.html">Next</a></li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?com/ephesoft/dcma/regexvalidation/service/package-tree.html" target="_top">Frames</a></li> <li><a href="package-tree.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
ungerik/ephesoft
Ephesoft_Community_Release_4.0.2.0/javadocs/com/ephesoft/dcma/regexvalidation/service/package-tree.html
HTML
agpl-3.0
5,377
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, 8917, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jackrabbit.oak.jcr.tck; import junit.framework.Test; public class RetentionIT extends TCKBase { public static Test suite() { return new RetentionIT(); } public RetentionIT() { super("JCR retention tests"); } @Override protected void addTests() { addTest(org.apache.jackrabbit.test.api.retention.TestAll.suite()); } }
anchela/jackrabbit-oak
oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/tck/RetentionIT.java
Java
apache-2.0
1,195
[ 30522, 1013, 1008, 1008, 7000, 2000, 1996, 15895, 4007, 3192, 1006, 2004, 2546, 1007, 2104, 2028, 2030, 2062, 1008, 12130, 6105, 10540, 1012, 2156, 1996, 5060, 5371, 5500, 2007, 1008, 2023, 2147, 2005, 3176, 2592, 4953, 9385, 6095, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /** * File containing the RelationList FieldType Value class * * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 * @version //autogentag// */ namespace eZ\Publish\Core\FieldType\RelationList; use eZ\Publish\Core\FieldType\Value as BaseValue; /** * Value for RelationList field type */ class Value extends BaseValue { /** * Related content id's * * @var mixed[] */ public $destinationContentIds; /** * Construct a new Value object and initialize it $text * * @param mixed[] $destinationContentIds */ public function __construct( array $destinationContentIds = array() ) { $this->destinationContentIds = $destinationContentIds; } /** * @see \eZ\Publish\Core\FieldType\Value */ public function __toString() { return implode( ',', $this->destinationContentIds ); } }
gbentley/ezpublish-kernel
eZ/Publish/Core/FieldType/RelationList/Value.php
PHP
gpl-2.0
992
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 1008, 5371, 4820, 1996, 7189, 9863, 2492, 13874, 3643, 2465, 1008, 1008, 1030, 9385, 9385, 1006, 1039, 1007, 2639, 1011, 2286, 1041, 2480, 3001, 2004, 1012, 2035, 2916, 9235, 1012, 1008, 1030, 6...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Agora Agora is an open-source service that allows querying a linked data platform built on managed vocabularies. ## Requirements * Docker (Linux) * Vagrant (Windows/Mac/Linux) ## How to start? 1. Just clone this repo and ```vagrant up``` 2. Browse <http://localhost:9002/types> and you should get the following JSON object: ```{ "types": [] }```. This means the Agora Fountain is up and running. Agora is distributed under the Apache License, version 2.0.
SmartDeveloperHub/agora
README.md
Markdown
apache-2.0
463
[ 30522, 1001, 3283, 2527, 3283, 2527, 2003, 2019, 2330, 1011, 3120, 2326, 2008, 4473, 23032, 2075, 1037, 5799, 2951, 4132, 2328, 2006, 3266, 29536, 3540, 28808, 3111, 1012, 1001, 1001, 5918, 1008, 8946, 2121, 1006, 11603, 1007, 1008, 12436, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var studio_locale = {lc:{"ar":function(n){ if (n === 0) { return 'zero'; } if (n == 1) { return 'one'; } if (n == 2) { return 'two'; } if ((n % 100) >= 3 && (n % 100) <= 10 && n == Math.floor(n)) { return 'few'; } if ((n % 100) >= 11 && (n % 100) <= 99 && n == Math.floor(n)) { return 'many'; } return 'other'; },"en":function(n){return n===1?"one":"other"},"bg":function(n){return n===1?"one":"other"},"bn":function(n){return n===1?"one":"other"},"ca":function(n){return n===1?"one":"other"},"cs":function(n){ if (n == 1) { return 'one'; } if (n == 2 || n == 3 || n == 4) { return 'few'; } return 'other'; },"da":function(n){return n===1?"one":"other"},"de":function(n){return n===1?"one":"other"},"el":function(n){return n===1?"one":"other"},"es":function(n){return n===1?"one":"other"},"et":function(n){return n===1?"one":"other"},"eu":function(n){return n===1?"one":"other"},"fa":function(n){return "other"},"fi":function(n){return n===1?"one":"other"},"fil":function(n){return n===0||n==1?"one":"other"},"fr":function(n){return Math.floor(n)===0||Math.floor(n)==1?"one":"other"},"ga":function(n){return n==1?"one":(n==2?"two":"other")},"gl":function(n){return n===1?"one":"other"},"he":function(n){return n===1?"one":"other"},"hi":function(n){return n===0||n==1?"one":"other"},"hr":function(n){ if ((n % 10) == 1 && (n % 100) != 11) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 4 && ((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) { return 'few'; } if ((n % 10) === 0 || ((n % 10) >= 5 && (n % 10) <= 9) || ((n % 100) >= 11 && (n % 100) <= 14) && n == Math.floor(n)) { return 'many'; } return 'other'; },"hu":function(n){return "other"},"id":function(n){return "other"},"is":function(n){ return ((n%10) === 1 && (n%100) !== 11) ? 'one' : 'other'; },"it":function(n){return n===1?"one":"other"},"ja":function(n){return "other"},"ko":function(n){return "other"},"lt":function(n){ if ((n % 10) == 1 && ((n % 100) < 11 || (n % 100) > 19)) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 9 && ((n % 100) < 11 || (n % 100) > 19) && n == Math.floor(n)) { return 'few'; } return 'other'; },"lv":function(n){ if (n === 0) { return 'zero'; } if ((n % 10) == 1 && (n % 100) != 11) { return 'one'; } return 'other'; },"mk":function(n){return (n%10)==1&&n!=11?"one":"other"},"mr":function(n){return n===1?"one":"other"},"ms":function(n){return "other"},"mt":function(n){ if (n == 1) { return 'one'; } if (n === 0 || ((n % 100) >= 2 && (n % 100) <= 4 && n == Math.floor(n))) { return 'few'; } if ((n % 100) >= 11 && (n % 100) <= 19 && n == Math.floor(n)) { return 'many'; } return 'other'; },"nl":function(n){return n===1?"one":"other"},"no":function(n){return n===1?"one":"other"},"pl":function(n){ if (n == 1) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 4 && ((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) { return 'few'; } if ((n % 10) === 0 || n != 1 && (n % 10) == 1 || ((n % 10) >= 5 && (n % 10) <= 9 || (n % 100) >= 12 && (n % 100) <= 14) && n == Math.floor(n)) { return 'many'; } return 'other'; },"pt":function(n){return n===1?"one":"other"},"ro":function(n){ if (n == 1) { return 'one'; } if (n === 0 || n != 1 && (n % 100) >= 1 && (n % 100) <= 19 && n == Math.floor(n)) { return 'few'; } return 'other'; },"ru":function(n){ if ((n % 10) == 1 && (n % 100) != 11) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 4 && ((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) { return 'few'; } if ((n % 10) === 0 || ((n % 10) >= 5 && (n % 10) <= 9) || ((n % 100) >= 11 && (n % 100) <= 14) && n == Math.floor(n)) { return 'many'; } return 'other'; },"sk":function(n){ if (n == 1) { return 'one'; } if (n == 2 || n == 3 || n == 4) { return 'few'; } return 'other'; },"sl":function(n){ if ((n % 100) == 1) { return 'one'; } if ((n % 100) == 2) { return 'two'; } if ((n % 100) == 3 || (n % 100) == 4) { return 'few'; } return 'other'; },"sq":function(n){return n===1?"one":"other"},"sr":function(n){ if ((n % 10) == 1 && (n % 100) != 11) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 4 && ((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) { return 'few'; } if ((n % 10) === 0 || ((n % 10) >= 5 && (n % 10) <= 9) || ((n % 100) >= 11 && (n % 100) <= 14) && n == Math.floor(n)) { return 'many'; } return 'other'; },"sv":function(n){return n===1?"one":"other"},"ta":function(n){return n===1?"one":"other"},"th":function(n){return "other"},"tr":function(n){return n===1?"one":"other"},"uk":function(n){ if ((n % 10) == 1 && (n % 100) != 11) { return 'one'; } if ((n % 10) >= 2 && (n % 10) <= 4 && ((n % 100) < 12 || (n % 100) > 14) && n == Math.floor(n)) { return 'few'; } if ((n % 10) === 0 || ((n % 10) >= 5 && (n % 10) <= 9) || ((n % 100) >= 11 && (n % 100) <= 14) && n == Math.floor(n)) { return 'many'; } return 'other'; },"ur":function(n){return n===1?"one":"other"},"vi":function(n){return "other"},"zh":function(n){return "other"}}, c:function(d,k){if(!d)throw new Error("MessageFormat: Data required for '"+k+"'.")}, n:function(d,k,o){if(isNaN(d[k]))throw new Error("MessageFormat: '"+k+"' isn't a number.");return d[k]-(o||0)}, v:function(d,k){studio_locale.c(d,k);return d[k]}, p:function(d,k,o,l,p){studio_locale.c(d,k);return d[k] in p?p[d[k]]:(k=studio_locale.lc[l](d[k]-o),k in p?p[k]:p.other)}, s:function(d,k,p){studio_locale.c(d,k);return d[k] in p?p[d[k]]:p.other}}; (window.blockly = window.blockly || {}).studio_locale = { "actor":function(d){return "herec"}, "addItems1":function(d){return "přidat 1 položku typu"}, "addItems2":function(d){return "přidat 2 položky typu"}, "addItems3":function(d){return "přidat 3 položky typu"}, "addItems5":function(d){return "přidat 5 položek typu"}, "addItems10":function(d){return "přidat 10 položek typu"}, "addItemsRandom":function(d){return "přidat náhodné položky typu"}, "addItemsTooltip":function(d){return "Přidat položky na scénu."}, "alienInvasion":function(d){return "Mimozemská invaze!"}, "backgroundBlack":function(d){return "černý"}, "backgroundCave":function(d){return "jeskyně"}, "backgroundCloudy":function(d){return "zataženo"}, "backgroundHardcourt":function(d){return "tvrdé hřiště"}, "backgroundNight":function(d){return "noc"}, "backgroundUnderwater":function(d){return "pod vodou"}, "backgroundCity":function(d){return "město"}, "backgroundDesert":function(d){return "poušť"}, "backgroundRainbow":function(d){return "duha"}, "backgroundSoccer":function(d){return "fotbal"}, "backgroundSpace":function(d){return "vesmír"}, "backgroundTennis":function(d){return "tenis"}, "backgroundWinter":function(d){return "zima"}, "catActions":function(d){return "Akce"}, "catControl":function(d){return "Smyčky"}, "catEvents":function(d){return "Události"}, "catLogic":function(d){return "Logika"}, "catMath":function(d){return "Matematika"}, "catProcedures":function(d){return "Funkce"}, "catText":function(d){return "text"}, "catVariables":function(d){return "Proměnné"}, "changeScoreTooltip":function(d){return "Přidat nebo odebrat bod ze skóre."}, "changeScoreTooltipK1":function(d){return "Přidat bod."}, "continue":function(d){return "Pokračovat"}, "decrementPlayerScore":function(d){return "Odebrat bod"}, "defaultSayText":function(d){return "Piš zde"}, "dropletBlock_changeScore_description":function(d){return "Přidat nebo odebrat bod ze skóre."}, "dropletBlock_penColour_description":function(d){return "Sets the color of the line drawn behind the turtle as it moves"}, "dropletBlock_penColour_param0":function(d){return "color"}, "dropletBlock_setBackground_description":function(d){return "Nastavit obrázek pozadí"}, "dropletBlock_setSpriteEmotion_description":function(d){return "Nastaví náladu herce"}, "dropletBlock_setSpritePosition_description":function(d){return "Okamžitě přesune herce na zadané místo."}, "dropletBlock_setSpriteSpeed_description":function(d){return "Nastaví rychlost herce"}, "dropletBlock_setSprite_description":function(d){return "Nastaví obrázek herce"}, "dropletBlock_throw_description":function(d){return "Hodí střelu od zadaného herce."}, "dropletBlock_vanish_description":function(d){return "Herec zmizí."}, "emotion":function(d){return "nálada"}, "finalLevel":function(d){return "Dobrá práce! Vyřešil si poslední hádanku."}, "for":function(d){return "pro"}, "hello":function(d){return "ahoj"}, "helloWorld":function(d){return "Ahoj světe!"}, "incrementPlayerScore":function(d){return "Bod"}, "itemBlueFireball":function(d){return "modrá ohnivá koule"}, "itemPurpleFireball":function(d){return "fialová ohnivá koule"}, "itemRedFireball":function(d){return "červená ohnivá koule"}, "itemYellowHearts":function(d){return "žlutá srdce"}, "itemPurpleHearts":function(d){return "fialová srdce"}, "itemRedHearts":function(d){return "červená srdce"}, "itemRandom":function(d){return "náhodně"}, "itemAnna":function(d){return "hák"}, "itemElsa":function(d){return "jiskra"}, "itemHiro":function(d){return "mikroboti"}, "itemBaymax":function(d){return "raketa"}, "itemRapunzel":function(d){return "pánev"}, "itemCherry":function(d){return "třešeň"}, "itemIce":function(d){return "led"}, "itemDuck":function(d){return "kachna"}, "makeProjectileDisappear":function(d){return "zmizet"}, "makeProjectileBounce":function(d){return "odrazit"}, "makeProjectileBlueFireball":function(d){return "udělej modrou ohnivou kouli"}, "makeProjectilePurpleFireball":function(d){return "udělej fialovou ohnivou kouli"}, "makeProjectileRedFireball":function(d){return "udělej červenou ohnivou kouli"}, "makeProjectileYellowHearts":function(d){return "udělej žlutá srdce"}, "makeProjectilePurpleHearts":function(d){return "udělej fialová srdce"}, "makeProjectileRedHearts":function(d){return "udělej červená srdce"}, "makeProjectileTooltip":function(d){return "Nechat střelu narazit a zmizet nebo odrazit."}, "makeYourOwn":function(d){return "Vytvořit si vlastní hru v Hravé laboratoři"}, "moveDirectionDown":function(d){return "dolů"}, "moveDirectionLeft":function(d){return "vlevo"}, "moveDirectionRight":function(d){return "vpravo"}, "moveDirectionUp":function(d){return "nahoru"}, "moveDirectionRandom":function(d){return "náhodně"}, "moveDistance25":function(d){return "25 pixelů"}, "moveDistance50":function(d){return "50 pixelů"}, "moveDistance100":function(d){return "100 pixelů"}, "moveDistance200":function(d){return "200 pixelů"}, "moveDistance400":function(d){return "400 pixelů"}, "moveDistancePixels":function(d){return "pixely"}, "moveDistanceRandom":function(d){return "náhodné pixely"}, "moveDistanceTooltip":function(d){return "Přemístit herce určenou vzdálenost ve specifickém směru."}, "moveSprite":function(d){return "pohyb"}, "moveSpriteN":function(d){return "pohnout hercem "+studio_locale.v(d,"spriteIndex")}, "toXY":function(d){return "do x,y"}, "moveDown":function(d){return "pohyb dolů"}, "moveDownTooltip":function(d){return "pohnout hercem dolů."}, "moveLeft":function(d){return "pohnout vlevo"}, "moveLeftTooltip":function(d){return "pohnout hercem vlevo."}, "moveRight":function(d){return "pohnout vpravo"}, "moveRightTooltip":function(d){return "pohnout hercem vpravo."}, "moveUp":function(d){return "pohnout nahoru"}, "moveUpTooltip":function(d){return "pohnout hercem nahoru."}, "moveTooltip":function(d){return "pohnout hercem."}, "nextLevel":function(d){return "Dobrá práce! Dokončil jsi tuto hádanku."}, "no":function(d){return "Ne"}, "numBlocksNeeded":function(d){return "Tato hádanka může být vyřešena pomocí %1 bloků."}, "onEventTooltip":function(d){return "Spustit kód v reakci na konkrétní událost."}, "ouchExclamation":function(d){return "Au!"}, "playSoundCrunch":function(d){return "přehrát zvuk křupání"}, "playSoundGoal1":function(d){return "přehrát zvuk cíl 1"}, "playSoundGoal2":function(d){return "přehrát zvuk cíl 2"}, "playSoundHit":function(d){return "přehrát zvuk zásah"}, "playSoundLosePoint":function(d){return "přehrát zvuk ztráta bodu"}, "playSoundLosePoint2":function(d){return "přehrát zvuk ztráta bodu 2"}, "playSoundRetro":function(d){return "přehrát zvuk \"retro\""}, "playSoundRubber":function(d){return "přehrát zvuk guma"}, "playSoundSlap":function(d){return "přehrát zvuk plácnutí"}, "playSoundTooltip":function(d){return "Přehraj vybraný zvuk."}, "playSoundWinPoint":function(d){return "přehrát zvuk získaný bod"}, "playSoundWinPoint2":function(d){return "přehrát zvuk získaný bod 2"}, "playSoundWood":function(d){return "přehrát zvuk dřevo"}, "positionOutTopLeft":function(d){return "na pozici nad horní levou pozicí"}, "positionOutTopRight":function(d){return "na pozici nad horní pravou pozicí"}, "positionTopOutLeft":function(d){return "na horní vnější levou pozici"}, "positionTopLeft":function(d){return "na horní levou pozici"}, "positionTopCenter":function(d){return "na horní středovou pozici"}, "positionTopRight":function(d){return "na horní pravou pozici"}, "positionTopOutRight":function(d){return "na horní vnější pravou pozici"}, "positionMiddleLeft":function(d){return "na střední levou pozici"}, "positionMiddleCenter":function(d){return "na prostřední středovou pozici"}, "positionMiddleRight":function(d){return "na prostřední pravou pozici"}, "positionBottomOutLeft":function(d){return "na spodní vnější levou pozici"}, "positionBottomLeft":function(d){return "na spodní levou pozici"}, "positionBottomCenter":function(d){return "na spodní středovou pozici"}, "positionBottomRight":function(d){return "na spodní pravou pozici"}, "positionBottomOutRight":function(d){return "na spodní vnější pravou pozici"}, "positionOutBottomLeft":function(d){return "na pozici pod spodní levou pozicí"}, "positionOutBottomRight":function(d){return "na pozici pod spodní pravou pozicí"}, "positionRandom":function(d){return "na náhodnou pozici"}, "projectileBlueFireball":function(d){return "modrá ohnivá koule"}, "projectilePurpleFireball":function(d){return "fialová ohnivá koule"}, "projectileRedFireball":function(d){return "červená ohnivá koule"}, "projectileYellowHearts":function(d){return "žlutá srdce"}, "projectilePurpleHearts":function(d){return "fialová srdce"}, "projectileRedHearts":function(d){return "červená srdce"}, "projectileRandom":function(d){return "náhodně"}, "projectileAnna":function(d){return "hák"}, "projectileElsa":function(d){return "jiskra"}, "projectileHiro":function(d){return "mikroboti"}, "projectileBaymax":function(d){return "raketa"}, "projectileRapunzel":function(d){return "pánev"}, "projectileCherry":function(d){return "třešeň"}, "projectileIce":function(d){return "led"}, "projectileDuck":function(d){return "kachna"}, "reinfFeedbackMsg":function(d){return "Můžeš stisknout tlačítko \"Pokračovat v hraní\" pro návrat do hraní tvé historie."}, "repeatForever":function(d){return "opakujte navždy"}, "repeatDo":function(d){return "dělej"}, "repeatForeverTooltip":function(d){return "Provést akce v tomto bloku opakovaně dokud je spuštěn příběh."}, "saySprite":function(d){return "řekni"}, "saySpriteN":function(d){return "herec "+studio_locale.v(d,"spriteIndex")+" říká"}, "saySpriteTooltip":function(d){return "Zobrazit komiksovou bublinu s přidruženým textem od zvoleného herece."}, "saySpriteChoices_0":function(d){return "Ahoj."}, "saySpriteChoices_1":function(d){return "Ahoj všichni."}, "saySpriteChoices_2":function(d){return "Jak se máš?"}, "saySpriteChoices_3":function(d){return "Dobré ráno"}, "saySpriteChoices_4":function(d){return "Dobré odpoledne"}, "saySpriteChoices_5":function(d){return "Dobrou noc"}, "saySpriteChoices_6":function(d){return "Dobrý večer"}, "saySpriteChoices_7":function(d){return "Co je nového?"}, "saySpriteChoices_8":function(d){return "Co?"}, "saySpriteChoices_9":function(d){return "Kde?"}, "saySpriteChoices_10":function(d){return "Kdy?"}, "saySpriteChoices_11":function(d){return "Dobře."}, "saySpriteChoices_12":function(d){return "Skvělé!"}, "saySpriteChoices_13":function(d){return "Dobře."}, "saySpriteChoices_14":function(d){return "Není to zlé."}, "saySpriteChoices_15":function(d){return "Hodně štěstí."}, "saySpriteChoices_16":function(d){return "Ano"}, "saySpriteChoices_17":function(d){return "Ne"}, "saySpriteChoices_18":function(d){return "Dobře"}, "saySpriteChoices_19":function(d){return "Pěkný hod!"}, "saySpriteChoices_20":function(d){return "Hezký den."}, "saySpriteChoices_21":function(d){return "Ahoj."}, "saySpriteChoices_22":function(d){return "Hned jsem zpátky."}, "saySpriteChoices_23":function(d){return "Zítra ahoj!"}, "saySpriteChoices_24":function(d){return "Zatím se měj!"}, "saySpriteChoices_25":function(d){return "Opatruj se!"}, "saySpriteChoices_26":function(d){return "Užijte si!"}, "saySpriteChoices_27":function(d){return "Musím jít."}, "saySpriteChoices_28":function(d){return "Chcete být přátelé?"}, "saySpriteChoices_29":function(d){return "Skvělá práce!"}, "saySpriteChoices_30":function(d){return "Pane jo!"}, "saySpriteChoices_31":function(d){return "Jaj!"}, "saySpriteChoices_32":function(d){return "Těší mě."}, "saySpriteChoices_33":function(d){return "Dobře!"}, "saySpriteChoices_34":function(d){return "Děkuji"}, "saySpriteChoices_35":function(d){return "Ne, děkuji"}, "saySpriteChoices_36":function(d){return "Aaaaaah!"}, "saySpriteChoices_37":function(d){return "Nevadí"}, "saySpriteChoices_38":function(d){return "Dnes"}, "saySpriteChoices_39":function(d){return "Zítra"}, "saySpriteChoices_40":function(d){return "Včera"}, "saySpriteChoices_41":function(d){return "Našel jsem tě!"}, "saySpriteChoices_42":function(d){return "Našel si mě!"}, "saySpriteChoices_43":function(d){return "10, 9, 8, 7, 6, 5, 4, 3, 2, 1!"}, "saySpriteChoices_44":function(d){return "Jsi skvělý!"}, "saySpriteChoices_45":function(d){return "Jsi vtipný!"}, "saySpriteChoices_46":function(d){return "Jsi pošetilý! "}, "saySpriteChoices_47":function(d){return "Jsi dobrý přítel!"}, "saySpriteChoices_48":function(d){return "Dávej pozor!"}, "saySpriteChoices_49":function(d){return "Kachna!"}, "saySpriteChoices_50":function(d){return "Mám tě!"}, "saySpriteChoices_51":function(d){return "Au!"}, "saySpriteChoices_52":function(d){return "Promiň!"}, "saySpriteChoices_53":function(d){return "Opatrně!"}, "saySpriteChoices_54":function(d){return "Uau!"}, "saySpriteChoices_55":function(d){return "Ups!"}, "saySpriteChoices_56":function(d){return "Skoro si mě dostal!"}, "saySpriteChoices_57":function(d){return "Dobrý pokus!"}, "saySpriteChoices_58":function(d){return "Nemůžeš mě chytit!"}, "scoreText":function(d){return "Body: "+studio_locale.v(d,"playerScore")}, "setBackground":function(d){return "nastavit pozadí"}, "setBackgroundRandom":function(d){return "nastavit náhodné pozadí"}, "setBackgroundBlack":function(d){return "nastavit černé pozadí"}, "setBackgroundCave":function(d){return "nastavit pozadí jeskyně"}, "setBackgroundCloudy":function(d){return "nastavit pozadí mraky"}, "setBackgroundHardcourt":function(d){return "nastavit pozadí tvrdé hřiště"}, "setBackgroundNight":function(d){return "nastavit pozadí noc"}, "setBackgroundUnderwater":function(d){return "nastavit pozadí pod vodou"}, "setBackgroundCity":function(d){return "nastavit pozadí město"}, "setBackgroundDesert":function(d){return "nastavit pozadí poušť"}, "setBackgroundRainbow":function(d){return "nastavit pozadí duha"}, "setBackgroundSoccer":function(d){return "nastavit pozadí fotbal"}, "setBackgroundSpace":function(d){return "nastavit pozadí vesmír"}, "setBackgroundTennis":function(d){return "nastavit pozadí tenis"}, "setBackgroundWinter":function(d){return "nastavit pozadí zima"}, "setBackgroundLeafy":function(d){return "nastavit listnaté pozadí"}, "setBackgroundGrassy":function(d){return "nastavit travnaté pozadí"}, "setBackgroundFlower":function(d){return "nastavit květinové pozadí"}, "setBackgroundTile":function(d){return "nastavit dlaždicové pozadí"}, "setBackgroundIcy":function(d){return "nastavit ledové pozadí"}, "setBackgroundSnowy":function(d){return "nastavit zasněžené pozadí"}, "setBackgroundTooltip":function(d){return "Nastavit obrázek pozadí"}, "setEnemySpeed":function(d){return "nastavit rychlost protivníka"}, "setPlayerSpeed":function(d){return "nastavit rychlost hráče"}, "setScoreText":function(d){return "nastavit body"}, "setScoreTextTooltip":function(d){return "Nastaví text, který se má zobrazit v oblasti pro výsledek."}, "setSpriteEmotionAngry":function(d){return "na nahněvanou náladu"}, "setSpriteEmotionHappy":function(d){return "na šťastnou náladu"}, "setSpriteEmotionNormal":function(d){return "na normální náladu"}, "setSpriteEmotionRandom":function(d){return "na náhodnou náladu"}, "setSpriteEmotionSad":function(d){return "na smutnou náladu"}, "setSpriteEmotionTooltip":function(d){return "Nastaví náladu herce"}, "setSpriteAlien":function(d){return "na obrázek mimozemšťana"}, "setSpriteBat":function(d){return "na obrázek netopýra"}, "setSpriteBird":function(d){return "na obrázek ptáka"}, "setSpriteCat":function(d){return "na obrázek kočky"}, "setSpriteCaveBoy":function(d){return "na obrázek jeskynního chlapece"}, "setSpriteCaveGirl":function(d){return "na obrázek jeskynní dívky"}, "setSpriteDinosaur":function(d){return "na obrázek dinosaura"}, "setSpriteDog":function(d){return "na obrázek psa"}, "setSpriteDragon":function(d){return "na obrázek draka"}, "setSpriteGhost":function(d){return "na obrázek ducha"}, "setSpriteHidden":function(d){return "na skrytý obrázek"}, "setSpriteHideK1":function(d){return "skrýt"}, "setSpriteAnna":function(d){return "na Anin obrázek"}, "setSpriteElsa":function(d){return "na Elsin obrázek"}, "setSpriteHiro":function(d){return "na obrázek Hira"}, "setSpriteBaymax":function(d){return "na obrázek Baymaxe"}, "setSpriteRapunzel":function(d){return "na obrázek Rapunzela"}, "setSpriteKnight":function(d){return "na obrázek rytíře"}, "setSpriteMonster":function(d){return "na obrázek příšery"}, "setSpriteNinja":function(d){return "na obrázek maskovaného ninjy"}, "setSpriteOctopus":function(d){return "na obrázek chobotnice"}, "setSpritePenguin":function(d){return "na obrázek tučňáka"}, "setSpritePirate":function(d){return "na obrázek piráta"}, "setSpritePrincess":function(d){return "na obrázek princezny"}, "setSpriteRandom":function(d){return "na náhodný obrázek"}, "setSpriteRobot":function(d){return "na obrázek robota"}, "setSpriteShowK1":function(d){return "zobrazit"}, "setSpriteSpacebot":function(d){return "na obrázek vesmírného robota"}, "setSpriteSoccerGirl":function(d){return "na obrázek fotbalistky"}, "setSpriteSoccerBoy":function(d){return "na obrázek fotbalisty"}, "setSpriteSquirrel":function(d){return "na obrázek veverky"}, "setSpriteTennisGirl":function(d){return "na obrázek tenistky"}, "setSpriteTennisBoy":function(d){return "na obrázek tenisty"}, "setSpriteUnicorn":function(d){return "na obrázek jednorožce"}, "setSpriteWitch":function(d){return "na obrázek čarodějnice"}, "setSpriteWizard":function(d){return "na obrázek čaroděje"}, "setSpritePositionTooltip":function(d){return "Okamžitě přesune herce na zadané místo."}, "setSpriteK1Tooltip":function(d){return "Zobrazí nebo skryje zadaného herce."}, "setSpriteTooltip":function(d){return "Nastaví obrázek herce"}, "setSpriteSizeRandom":function(d){return "na náhodnou velikost"}, "setSpriteSizeVerySmall":function(d){return "na velmi malou velikost"}, "setSpriteSizeSmall":function(d){return "na malou velikost"}, "setSpriteSizeNormal":function(d){return "na normální velikost"}, "setSpriteSizeLarge":function(d){return "na velkou velikost"}, "setSpriteSizeVeryLarge":function(d){return "na velmi velkou velikost"}, "setSpriteSizeTooltip":function(d){return "Nastaví velikost herce"}, "setSpriteSpeedRandom":function(d){return "na náhodnou rychlost"}, "setSpriteSpeedVerySlow":function(d){return "na velmi pomalou rychlost"}, "setSpriteSpeedSlow":function(d){return "na pomalou rychlost"}, "setSpriteSpeedNormal":function(d){return "na normální rychlost"}, "setSpriteSpeedFast":function(d){return "na rychlou rychlost"}, "setSpriteSpeedVeryFast":function(d){return "na velmi rychlou rychlost"}, "setSpriteSpeedTooltip":function(d){return "Nastaví rychlost herce"}, "setSpriteZombie":function(d){return "na obrázek zombie"}, "shareStudioTwitter":function(d){return "Podívejte se na aplikaci, kterou jsem udělal. Napsal jsem to sám s @codeorg"}, "shareGame":function(d){return "Sdílej svůj příběh:"}, "showCoordinates":function(d){return "Zobrazit souřadnice"}, "showCoordinatesTooltip":function(d){return "zobrazí souřadnice hlavní postavy na obrazovce"}, "showTitleScreen":function(d){return "zobrazit úvodní obrazovku"}, "showTitleScreenTitle":function(d){return "nadpis"}, "showTitleScreenText":function(d){return "text"}, "showTSDefTitle":function(d){return "zde napiš nadpis"}, "showTSDefText":function(d){return "zde napiš text"}, "showTitleScreenTooltip":function(d){return "Zobrazit úvodní obrazovka k přidruženému názvu a textu."}, "size":function(d){return "velikost"}, "setSprite":function(d){return "nastavit"}, "setSpriteN":function(d){return "nastavit herece "+studio_locale.v(d,"spriteIndex")}, "soundCrunch":function(d){return "křupnutí"}, "soundGoal1":function(d){return "cíl 1"}, "soundGoal2":function(d){return "cíl 2"}, "soundHit":function(d){return "zásah"}, "soundLosePoint":function(d){return "ztracený bod"}, "soundLosePoint2":function(d){return "ztracený bod 2"}, "soundRetro":function(d){return "retro"}, "soundRubber":function(d){return "guma"}, "soundSlap":function(d){return "facka"}, "soundWinPoint":function(d){return "vyhraný bod"}, "soundWinPoint2":function(d){return "vyhraný bod 2"}, "soundWood":function(d){return "dřevo"}, "speed":function(d){return "rychlost"}, "startSetValue":function(d){return "start (funkce)"}, "startSetVars":function(d){return "game_vars (nadpis, podnadpis, pozadí, cíl, nebezpečí, hráč)"}, "startSetFuncs":function(d){return "game_funcs (aktualizuj-cíl, aktualizuj-nebezpečí, aktualizuj-hráče, kolize?, na-obrazovce?)"}, "stopSprite":function(d){return "zastavit"}, "stopSpriteN":function(d){return "zastavit herce "+studio_locale.v(d,"spriteIndex")}, "stopTooltip":function(d){return "Zastaví pohyb herce."}, "throwSprite":function(d){return "hoď"}, "throwSpriteN":function(d){return "herec "+studio_locale.v(d,"spriteIndex")+" hodí"}, "throwTooltip":function(d){return "Hodí střelu od zadaného herce."}, "vanish":function(d){return "zmiz"}, "vanishActorN":function(d){return "zmiz herec "+studio_locale.v(d,"spriteIndex")}, "vanishTooltip":function(d){return "Herec zmizí."}, "waitFor":function(d){return "čekat na"}, "waitSeconds":function(d){return "sekund"}, "waitForClick":function(d){return "čekat na kliknutí"}, "waitForRandom":function(d){return "čekat na náhodně"}, "waitForHalfSecond":function(d){return "čekat půl sekundy"}, "waitFor1Second":function(d){return "čekat 1 sekundu"}, "waitFor2Seconds":function(d){return "čekat 2 sekundy"}, "waitFor5Seconds":function(d){return "čekat 5 sekund"}, "waitFor10Seconds":function(d){return "čekat 10 sekund"}, "waitParamsTooltip":function(d){return "Čeká zadaný počet sekund. Použijte nulu pro čekání na kliknutí."}, "waitTooltip":function(d){return "Čeká zadané množství času nebo dokud nedojde ke kliknutí."}, "whenArrowDown":function(d){return "šipka dolů"}, "whenArrowLeft":function(d){return "šipka vlevo"}, "whenArrowRight":function(d){return "šipka vpravo"}, "whenArrowUp":function(d){return "šipka nahoru"}, "whenArrowTooltip":function(d){return "Provést zadané akce po stisknutí klávesy se šipkou."}, "whenDown":function(d){return "když šipka dolů"}, "whenDownTooltip":function(d){return "Spusť uvedené akce když je stisknutá klávesa \"dolů\"."}, "whenGameStarts":function(d){return "když se příběh začne"}, "whenGameStartsTooltip":function(d){return "Provést uvedené akce, když příběh začne."}, "whenLeft":function(d){return "když šipka vlevo"}, "whenLeftTooltip":function(d){return "Spusť uvedené akce když je stisknutá klávesa \"vlevo\"."}, "whenRight":function(d){return "když šipka vpravo"}, "whenRightTooltip":function(d){return "Spusť uvedené akce když je stisknutá klávesa \"vpravo\"."}, "whenSpriteClicked":function(d){return "po kliknutí na herce"}, "whenSpriteClickedN":function(d){return "po kliknutí na herce "+studio_locale.v(d,"spriteIndex")}, "whenSpriteClickedTooltip":function(d){return "Provést uvedené akce po kliknutí na herce."}, "whenSpriteCollidedN":function(d){return "když se herec "+studio_locale.v(d,"spriteIndex")}, "whenSpriteCollidedTooltip":function(d){return "Provést uvedené akce když se herec dotkne jiného herce."}, "whenSpriteCollidedWith":function(d){return "dotkne"}, "whenSpriteCollidedWithAnyActor":function(d){return "dotkne jiného herce"}, "whenSpriteCollidedWithAnyEdge":function(d){return "dotkne okraje"}, "whenSpriteCollidedWithAnyProjectile":function(d){return "dotkne střely"}, "whenSpriteCollidedWithAnything":function(d){return "dotkne čehokoliv"}, "whenSpriteCollidedWithN":function(d){return "dotkne herce "+studio_locale.v(d,"spriteIndex")}, "whenSpriteCollidedWithBlueFireball":function(d){return "dotkne modré ohnivé koule"}, "whenSpriteCollidedWithPurpleFireball":function(d){return "dotkne fialové ohnivé koule"}, "whenSpriteCollidedWithRedFireball":function(d){return "dotkne červené ohnivé koule"}, "whenSpriteCollidedWithYellowHearts":function(d){return "dotkne žlutých srdcí"}, "whenSpriteCollidedWithPurpleHearts":function(d){return "dotkne fialových srdcí"}, "whenSpriteCollidedWithRedHearts":function(d){return "dotkne červených srdcí"}, "whenSpriteCollidedWithBottomEdge":function(d){return "dotkne dolního okraje"}, "whenSpriteCollidedWithLeftEdge":function(d){return "dotkne levého okraje"}, "whenSpriteCollidedWithRightEdge":function(d){return "dotkne pravého okraje"}, "whenSpriteCollidedWithTopEdge":function(d){return "dotkne horního okraje"}, "whenUp":function(d){return "když šipka nahoru"}, "whenUpTooltip":function(d){return "Spusť uvedené akce když je stisknutá klávesa \"nahoru\"."}, "yes":function(d){return "Ano"}};
ty-po/code-dot-org
dashboard/public/apps-package/js/cs_cz/studio_locale-bfd0c94141f74417a2ff3e69569591ae.js
JavaScript
apache-2.0
30,817
[ 30522, 13075, 2996, 1035, 2334, 2063, 1027, 1063, 29215, 1024, 1063, 1000, 12098, 1000, 1024, 3853, 1006, 1050, 1007, 1063, 2065, 1006, 1050, 1027, 1027, 1027, 1014, 1007, 1063, 2709, 1005, 5717, 1005, 1025, 1065, 2065, 1006, 1050, 1027, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import { booleanAttributeValue, standardBooleanAttributes } from "./dom.js"; import { rendering } from "./internal.js"; // Memoized maps of attribute to property names and vice versa. // We initialize this with the special case of the tabindex (lowercase "i") // attribute, which is mapped to the tabIndex (capital "I") property. /** @type {IndexedObject<string>} */ const attributeToPropertyNames = { tabindex: "tabIndex", }; /** @type {IndexedObject<string>} */ const propertyNamesToAttributes = { tabIndex: "tabindex", }; /** * Sets properties when the corresponding attributes change * * If your component exposes a setter for a property, it's generally a good * idea to let devs using your component be able to set that property in HTML * via an element attribute. You can code that yourself by writing an * `attributeChangedCallback`, or you can use this mixin to get a degree of * automatic support. * * This mixin implements an `attributeChangedCallback` that will attempt to * convert a change in an element attribute into a call to the corresponding * property setter. Attributes typically follow hyphenated names ("foo-bar"), * whereas properties typically use camelCase names ("fooBar"). This mixin * respects that convention, automatically mapping the hyphenated attribute * name to the corresponding camelCase property name. * * Example: You define a component using this mixin: * * class MyElement extends AttributeMarshallingMixin(HTMLElement) { * get fooBar() { return this._fooBar; } * set fooBar(value) { this._fooBar = value; } * } * * If someone then instantiates your component in HTML: * * <my-element foo-bar="Hello"></my-element> * * Then, after the element has been upgraded, the `fooBar` setter will * automatically be invoked with the initial value "Hello". * * Attributes can only have string values. If you'd like to convert string * attributes to other types (numbers, booleans), you must implement parsing * yourself. * * @module AttributeMarshallingMixin * @param {Constructor<CustomElement>} Base */ export default function AttributeMarshallingMixin(Base) { // The class prototype added by the mixin. class AttributeMarshalling extends Base { /** * Handle a change to the attribute with the given name. * * @ignore * @param {string} attributeName * @param {string} oldValue * @param {string} newValue */ attributeChangedCallback(attributeName, oldValue, newValue) { if (super.attributeChangedCallback) { super.attributeChangedCallback(attributeName, oldValue, newValue); } // Sometimes this callback is invoked when there's not actually any // change, in which we skip invoking the property setter. // // We also skip setting properties if we're rendering. A component may // want to reflect property values to attributes during rendering, but // such attribute changes shouldn't trigger property updates. if (newValue !== oldValue && !this[rendering]) { const propertyName = attributeToPropertyName(attributeName); // If the attribute name corresponds to a property name, set the property. if (propertyName in this) { // Parse standard boolean attributes. const parsed = standardBooleanAttributes[attributeName] ? booleanAttributeValue(attributeName, newValue) : newValue; this[propertyName] = parsed; } } } // Because maintaining the mapping of attributes to properties is tedious, // this provides a default implementation for `observedAttributes` that // assumes that your component will want to expose all public properties in // your component's API as properties. // // You can override this default implementation of `observedAttributes`. For // example, if you have a system that can statically analyze which // properties are available to your component, you could hand-author or // programmatically generate a definition for `observedAttributes` that // avoids the minor run-time performance cost of inspecting the component // prototype to determine your component's public properties. static get observedAttributes() { return attributesForClass(this); } } return AttributeMarshalling; } /** * Return the custom attributes for the given class. * * E.g., if the supplied class defines a `fooBar` property, then the resulting * array of attribute names will include the "foo-bar" attribute. * * @private * @param {Constructor<HTMLElement>} classFn * @returns {string[]} */ function attributesForClass(classFn) { // We treat the HTMLElement base class as if it has no attributes, since we // don't want to receive attributeChangedCallback for it (or anything further // up the protoype chain). if (classFn === HTMLElement) { return []; } // Get attributes for parent class. const baseClass = Object.getPrototypeOf(classFn.prototype).constructor; // See if parent class defines observedAttributes manually. let baseAttributes = baseClass.observedAttributes; if (!baseAttributes) { // Calculate parent class attributes ourselves. baseAttributes = attributesForClass(baseClass); } // Get the properties for this particular class. const propertyNames = Object.getOwnPropertyNames(classFn.prototype); const setterNames = propertyNames.filter((propertyName) => { const descriptor = Object.getOwnPropertyDescriptor( classFn.prototype, propertyName ); return descriptor && typeof descriptor.set === "function"; }); // Map the property names to attribute names. const attributes = setterNames.map((setterName) => propertyNameToAttribute(setterName) ); // Merge the attribute for this class and its base class. const diff = attributes.filter( (attribute) => baseAttributes.indexOf(attribute) < 0 ); const result = baseAttributes.concat(diff); return result; } /** * Convert hyphenated foo-bar attribute name to camel case fooBar property name. * * @private * @param {string} attributeName */ function attributeToPropertyName(attributeName) { let propertyName = attributeToPropertyNames[attributeName]; if (!propertyName) { // Convert and memoize. const hyphenRegEx = /-([a-z])/g; propertyName = attributeName.replace(hyphenRegEx, (match) => match[1].toUpperCase() ); attributeToPropertyNames[attributeName] = propertyName; } return propertyName; } /** * Convert a camel case fooBar property name to a hyphenated foo-bar attribute. * * @private * @param {string} propertyName */ function propertyNameToAttribute(propertyName) { let attribute = propertyNamesToAttributes[propertyName]; if (!attribute) { // Convert and memoize. const uppercaseRegEx = /([A-Z])/g; attribute = propertyName.replace(uppercaseRegEx, "-$1").toLowerCase(); propertyNamesToAttributes[propertyName] = attribute; } return attribute; }
elix/elix
src/core/AttributeMarshallingMixin.js
JavaScript
mit
7,052
[ 30522, 12324, 1063, 22017, 20898, 19321, 3089, 8569, 2618, 10175, 5657, 1010, 3115, 5092, 9890, 5162, 4779, 3089, 8569, 4570, 1065, 2013, 1000, 1012, 1013, 14383, 1012, 1046, 2015, 1000, 1025, 12324, 1063, 14259, 1065, 2013, 1000, 1012, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/******************************************************************************* * Copyright (c) 2021 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package com.ibm.ws.jpa.tests.spec10.entity; import org.junit.ClassRule; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; import com.ibm.ws.jpa.tests.spec10.entity.tests.AbstractFATSuite; import com.ibm.ws.jpa.tests.spec10.entity.tests.Entity_EJB; import com.ibm.ws.jpa.tests.spec10.entity.tests.Entity_Web; import componenttest.rules.repeater.FeatureReplacementAction; import componenttest.rules.repeater.RepeatTests; @RunWith(Suite.class) @SuiteClasses({ Entity_EJB.class, Entity_Web.class, componenttest.custom.junit.runner.AlwaysPassesTest.class }) public class FATSuite extends AbstractFATSuite { @ClassRule public static RepeatTests r = RepeatTests.with(FeatureReplacementAction.EE9_FEATURES()); }
kgibm/open-liberty
dev/com.ibm.ws.jpa.tests.spec10.entity_jpa_3.0_fat/fat/src/com/ibm/ws/jpa/tests/spec10/entity/FATSuite.java
Java
epl-1.0
1,362
[ 30522, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: page title: Terra Rain Holdings Party date: 2016-05-24 author: Willie Simmons tags: weekly links, java status: published summary: Pellentesque ultrices vitae odio sed gravida. Nunc nisl dolor, fermentum. banner: images/banner/leisure-03.jpg booking: startDate: 10/01/2019 endDate: 10/05/2019 ctyhocn: LFDILHX groupCode: TRHP published: true --- Mauris vel cursus dolor, id malesuada enim. Nunc non velit vulputate, lobortis urna at, hendrerit libero. Praesent eget nisi orci. Mauris volutpat felis id lorem ullamcorper, vel vehicula nunc luctus. Integer dictum mollis cursus. Praesent gravida mi ut felis dignissim, a suscipit augue facilisis. Phasellus id nisl at libero aliquet tristique ac ut tortor. Aliquam convallis non odio ut tincidunt. * Ut cursus felis sed suscipit facilisis. Morbi id arcu nec felis auctor molestie et eget nisl. Curabitur malesuada bibendum metus vel volutpat. Duis sem nisl, accumsan ac commodo ut, suscipit id eros. Fusce vehicula augue rhoncus nibh vestibulum, sodales dignissim tellus vestibulum. Morbi semper molestie pulvinar. Etiam in tellus augue. Nulla lobortis tristique erat, quis imperdiet risus vulputate vel. Vivamus faucibus metus fringilla tellus sagittis vestibulum non et justo. Suspendisse fermentum nisl non finibus efficitur. Nunc elementum egestas orci, quis feugiat neque mollis ac. Sed pulvinar cursus blandit. Pellentesque volutpat, quam vel egestas hendrerit, enim est blandit magna, vel vulputate felis tortor sed lacus. Fusce quis pretium magna.
KlishGroup/prose-pogs
pogs/L/LFDILHX/TRHP/index.md
Markdown
mit
1,525
[ 30522, 1011, 1011, 1011, 9621, 1024, 3931, 2516, 1024, 14403, 4542, 9583, 2283, 3058, 1024, 2355, 1011, 5709, 1011, 2484, 3166, 1024, 9893, 13672, 22073, 1024, 4882, 6971, 1010, 9262, 3570, 1024, 2405, 12654, 1024, 21877, 12179, 4570, 4226,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>W29553_text</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div style="margin-left: auto; margin-right: auto; width: 800px; overflow: hidden;"> <div style="float: left;"> <a href="page36.html">&laquo;</a> </div> <div style="float: right;"> </div> </div> <hr/> <div style="position: absolute; margin-left: 330px; margin-top: 357px;"> <p class="styleSans10.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>">Alternatives to Flaring <br/>6a. <br/>6b. <br/>Purchaser capacity is not expected to be sufficient for the volumes produced from these wells. in the event that electric power is required on-site, a natural gas powered generator will be evaluated. Installation of a liquid stripping plant to be utilized in the event of upset conditions would not be economic. Such an installation will be re-evaluated as additional wells are completed and if conditions change. <br/>A natural gas powered generator could be expected to reduce flare volumes by approximately 30-40 MCFD. A liquid stripping plant could be expected to reduce flare volumes by approximately 40%. On lease gas use by Heater/Treaters will consume approximately 15 MCFD </p> </div> <div style="position: absolute; margin-left: 907px; margin-top: 1952px;"> <p class="styleSans1.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>"></p> </div> <div style="position: absolute; margin-left: 880px; margin-top: 2502px;"> <p class="styleSans12000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>"></p> </div> <div style="position: absolute; margin-left: 990px; margin-top: 2805px;"> <p class="styleSans1.0000<enum PANGO_WEIGHT_NORMAL of type PangoWeight><enum PANGO_STYLE_NORMAL of type PangoStyle>"></p> </div> </body> </html>
datamade/elpc_bakken
ocr_extracted/W29553_text/page37.html
HTML
mit
2,117
[ 30522, 1026, 16129, 1028, 1026, 2132, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, 1000, 3793, 1013, 16129, 1025, 25869, 13462, 1027, 21183, 2546, 1011, 1022, 1000, 1013, 1028, 1026, 2516...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /** * @fileoverview A command is an abstraction of an action a user can do in the * UI. * * When the focus changes in the document for each command a canExecute event * is dispatched on the active element. By listening to this event you can * enable and disable the command by setting the event.canExecute property. * * When a command is executed a command event is dispatched on the active * element. Note that you should stop the propagation after you have handled the * command if there might be other command listeners higher up in the DOM tree. */ cr.define('cr.ui', function() { /** * This is used to identify keyboard shortcuts. * @param {string} shortcut The text used to describe the keys for this * keyboard shortcut. * @constructor */ function KeyboardShortcut(shortcut) { var mods = {}; var ident = ''; shortcut.split('-').forEach(function(part) { var partLc = part.toLowerCase(); switch (partLc) { case 'alt': case 'ctrl': case 'meta': case 'shift': mods[partLc + 'Key'] = true; break; default: if (ident) throw Error('Invalid shortcut'); ident = part; } }); this.ident_ = ident; this.mods_ = mods; } KeyboardShortcut.prototype = { /** * Whether the keyboard shortcut object matches a keyboard event. * @param {!Event} e The keyboard event object. * @return {boolean} Whether we found a match or not. */ matchesEvent: function(e) { if (e.keyIdentifier == this.ident_) { // All keyboard modifiers needs to match. var mods = this.mods_; return ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].every(function(k) { return e[k] == !!mods[k]; }); } return false; } }; /** * Creates a new command element. * @constructor * @extends {HTMLElement} */ var Command = cr.ui.define('command'); Command.prototype = { __proto__: HTMLElement.prototype, /** * Initializes the command. */ decorate: function() { CommandManager.init(this.ownerDocument); if (this.hasAttribute('shortcut')) this.shortcut = this.getAttribute('shortcut'); }, /** * Executes the command by dispatching a command event on the given element. * If |element| isn't given, the active element is used instead. * If the command is {@code disabled} this does nothing. * @param {HTMLElement=} opt_element Optional element to dispatch event on. */ execute: function(opt_element) { if (this.disabled) return; var doc = this.ownerDocument; if (doc.activeElement) { var e = new cr.Event('command', true, false); e.command = this; (opt_element || doc.activeElement).dispatchEvent(e); } }, /** * Call this when there have been changes that might change whether the * command can be executed or not. * @param {Node=} opt_node Node for which to actuate command state. */ canExecuteChange: function(opt_node) { dispatchCanExecuteEvent(this, opt_node || this.ownerDocument.activeElement); }, /** * The keyboard shortcut that triggers the command. This is a string * consisting of a keyIdentifier (as reported by WebKit in keydown) as * well as optional key modifiers joinded with a '-'. * * Multiple keyboard shortcuts can be provided by separating them by * whitespace. * * For example: * "F1" * "U+0008-Meta" for Apple command backspace. * "U+0041-Ctrl" for Control A * "U+007F U+0008-Meta" for Delete and Command Backspace * * @type {string} */ shortcut_: '', get shortcut() { return this.shortcut_; }, set shortcut(shortcut) { var oldShortcut = this.shortcut_; if (shortcut !== oldShortcut) { this.keyboardShortcuts_ = shortcut.split(/\s+/).map(function(shortcut) { return new KeyboardShortcut(shortcut); }); // Set this after the keyboardShortcuts_ since that might throw. this.shortcut_ = shortcut; cr.dispatchPropertyChange(this, 'shortcut', this.shortcut_, oldShortcut); } }, /** * Whether the event object matches the shortcut for this command. * @param {!Event} e The key event object. * @return {boolean} Whether it matched or not. */ matchesEvent: function(e) { if (!this.keyboardShortcuts_) return false; return this.keyboardShortcuts_.some(function(keyboardShortcut) { return keyboardShortcut.matchesEvent(e); }); } }; /** * The label of the command. * @type {string} */ cr.defineProperty(Command, 'label', cr.PropertyKind.ATTR); /** * Whether the command is disabled or not. * @type {boolean} */ cr.defineProperty(Command, 'disabled', cr.PropertyKind.BOOL_ATTR); /** * Whether the command is hidden or not. * @type {boolean} */ cr.defineProperty(Command, 'hidden', cr.PropertyKind.BOOL_ATTR); /** * Whether the command is checked or not. * @type {boolean} */ cr.defineProperty(Command, 'checked', cr.PropertyKind.BOOL_ATTR); /** * Dispatches a canExecute event on the target. * @param {cr.ui.Command} command The command that we are testing for. * @param {Element} target The target element to dispatch the event on. */ function dispatchCanExecuteEvent(command, target) { var e = new CanExecuteEvent(command, true); target.dispatchEvent(e); command.disabled = !e.canExecute; } /** * The command managers for different documents. */ var commandManagers = {}; /** * Keeps track of the focused element and updates the commands when the focus * changes. * @param {!Document} doc The document that we are managing the commands for. * @constructor */ function CommandManager(doc) { doc.addEventListener('focus', this.handleFocus_.bind(this), true); // Make sure we add the listener to the bubbling phase so that elements can // prevent the command. doc.addEventListener('keydown', this.handleKeyDown_.bind(this), false); } /** * Initializes a command manager for the document as needed. * @param {!Document} doc The document to manage the commands for. */ CommandManager.init = function(doc) { var uid = cr.getUid(doc); if (!(uid in commandManagers)) { commandManagers[uid] = new CommandManager(doc); } }; CommandManager.prototype = { /** * Handles focus changes on the document. * @param {Event} e The focus event object. * @private */ handleFocus_: function(e) { var target = e.target; // Ignore focus on a menu button or command item if (target.menu || target.command) return; var commands = Array.prototype.slice.call( target.ownerDocument.querySelectorAll('command')); commands.forEach(function(command) { dispatchCanExecuteEvent(command, target); }); }, /** * Handles the keydown event and routes it to the right command. * @param {!Event} e The keydown event. */ handleKeyDown_: function(e) { var target = e.target; var commands = Array.prototype.slice.call( target.ownerDocument.querySelectorAll('command')); for (var i = 0, command; command = commands[i]; i++) { if (!command.disabled && command.matchesEvent(e)) { e.preventDefault(); // We do not want any other element to handle this. e.stopPropagation(); command.execute(); return; } } } }; /** * The event type used for canExecute events. * @param {!cr.ui.Command} command The command that we are evaluating. * @extends {Event} * @constructor * @class */ function CanExecuteEvent(command) { var e = command.ownerDocument.createEvent('Event'); e.initEvent('canExecute', true, false); e.__proto__ = CanExecuteEvent.prototype; e.command = command; return e; } CanExecuteEvent.prototype = { __proto__: Event.prototype, /** * The current command * @type {cr.ui.Command} */ command: null, /** * Whether the target can execute the command. Setting this also stops the * propagation. * @type {boolean} */ canExecute_: false, get canExecute() { return this.canExecute_; }, set canExecute(canExecute) { this.canExecute_ = !!canExecute; this.stopPropagation(); } }; // Export return { Command: Command, CanExecuteEvent: CanExecuteEvent }; });
timopulkkinen/BubbleFish
ui/webui/resources/js/cr/ui/command.js
JavaScript
bsd-3-clause
8,976
[ 30522, 1013, 1013, 9385, 1006, 1039, 1007, 2262, 1996, 10381, 21716, 5007, 6048, 1012, 2035, 2916, 9235, 1012, 1013, 1013, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 1037, 18667, 2094, 1011, 2806, 6105, 2008, 2064, 2022, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * * Copyright 2015 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #include <stdbool.h> #include <stdint.h> #include <string.h> #include <grpc/support/alloc.h> #include <grpc/support/log.h> #include "src/core/lib/json/json.h" bool squelch = true; bool leak_check = true; extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_error_handle error = GRPC_ERROR_NONE; auto json = grpc_core::Json::Parse( absl::string_view(reinterpret_cast<const char*>(data), size), &error); if (error == GRPC_ERROR_NONE) { auto text2 = json.Dump(); auto json2 = grpc_core::Json::Parse(text2, &error); GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(json == json2); } GRPC_ERROR_UNREF(error); return 0; }
stanley-cheung/grpc
test/core/json/fuzzer.cc
C++
apache-2.0
1,284
[ 30522, 1013, 1008, 1008, 1008, 9385, 2325, 24665, 15042, 6048, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "EOSProjectData.h" EOSProjectData::EOSProjectData() { } EOSProjectData::~EOSProjectData() { }
eranif/codelite
EOSWiki/EOSProjectData.cpp
C++
gpl-2.0
106
[ 30522, 1001, 2421, 1000, 1041, 2891, 21572, 20614, 2850, 2696, 1012, 1044, 1000, 1041, 2891, 21572, 20614, 2850, 2696, 1024, 1024, 1041, 2891, 21572, 20614, 2850, 2696, 1006, 1007, 1063, 1065, 1041, 2891, 21572, 20614, 2850, 2696, 1024, 102...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: Vim 基础命令 date: 2016-11-30 21:00:00 author:     hweining header-img: "img/post-bg-unix-linux.jpg" --- ## Vim 以前玩 Python 及之前用 Git 因为不熟悉 Vim 遇到了很多坑,进而导致屡次学习各项语言的放弃...惨痛教训就源于这莫名其妙的 Vim... 整理一下思路,重新出发。 Vi/Vim 常用的有三种模式: 1. 普通 模式 默认进入界面时的模式,此时只支持 Vi/Vim 的指令 2. Insert 模式 此模式下才能插入文本 3. 选择模式 ## 常用指令 * i 在指令模式下,按「i」激活编辑模式; * esc 在非指令模式下,按 esc 键退出 * :wq 保存并退出 ## 编辑(插入模式)模式常用指令 ### 进入 Insert 模式 在普通模式下使用下面的键将进入插入模式,并可以从相应的位置开始输入 | CMD | Description | |---|---| | i | 光标位置开始编辑 | | I | 行首插入 | | A | 行末插入 | | a | 自光标后编辑 | | o | 当前行之后插入一行 | | O | 当前行之前插入一行 | | cw | 替换从光标所在位置后到一个单词结尾的字符 | 在指令模式下的一些其他选项 ### 编辑快捷键 | CMD | Description | |---|---| | :w | 保存当前文件 | | :q | 退出,如文件有修改则需用强制模式退出 | | :q! | 强制退出,不保存修改 | | :wq | 保存并退出 | | :x | 保存并退出 | | :w <path> | 另存为 | | :saveas <path> | 另存为 | ## 选择模式常用指令 ### 光标移动快捷键 k - 上 j - 下 h - 左 l - 右 |...|**k**|...| |---|---|---| |**h**|...|**l**| |...|**j**|...| w 移动到下一个单词 b 移动到上一个单词 ### 翻页 Control + f Control + b ### 删除 | Key | Description | |---|---| | x | 删除光标所在字符 | | Delete | 删除光标所在字符 | | X | 删除光标所在前一个字符 | | dd | 删除整行 | | dw | 删除一个单词 | | d$ / D | 从当前位置删除至行尾 | | d^ | 从当前位置删除至行首 | | dG | 删除到文档结尾处 | | d1G | 删至文档首部 | ### 命令行进入设定退出 Ctrl + C 退出 ### 参考 *[简明 Vim 练级攻略|CoolShell](http://coolshell.cn/articles/5426.html)
hweining/hweining.github.com
_posts/2016-11-30-Vim.md
Markdown
mit
2,241
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 6819, 2213, 100, 100, 100, 100, 3058, 1024, 2355, 1011, 2340, 1011, 2382, 2538, 1024, 4002, 1024, 4002, 3166, 1024, 1044, 19845, 5582, 20346, 1011, 10047, 2290, 1024, 1000, 10047, 229...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// license:BSD-3-Clause // copyright-holders:Aaron Giles, Vas Crabb //============================================================ // // uimetrics.c - Win32 debug window handling // //============================================================ #include "uimetrics.h" #include "strconv.h" ui_metrics::ui_metrics(osd_options const &options) : m_debug_font(nullptr), m_debug_font_height(0), m_debug_font_width(0), m_debug_font_ascent(0), m_hscroll_height(GetSystemMetrics(SM_CYHSCROLL)), m_vscroll_width(GetSystemMetrics(SM_CXVSCROLL)) { // create a temporary DC HDC const temp_dc = GetDC(NULL); if (temp_dc != NULL) { float const size = options.debugger_font_size(); char const *const face = options.debugger_font(); // create a standard font TCHAR *t_face = tstring_from_utf8((!*face || !strcmp(OSDOPTVAL_AUTO, face)) ? "Lucida Console" : face); m_debug_font = CreateFont(-MulDiv((size <= 0) ? 9 : size, GetDeviceCaps(temp_dc, LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FIXED_PITCH, t_face); osd_free(t_face); if (m_debug_font == NULL) fatalerror("Unable to create debugger font\n"); // get the metrics HGDIOBJ const old_font = SelectObject(temp_dc, m_debug_font); TEXTMETRIC metrics; if (GetTextMetrics(temp_dc, &metrics)) { m_debug_font_width = metrics.tmAveCharWidth; m_debug_font_height = metrics.tmHeight; m_debug_font_ascent = metrics.tmAscent + metrics.tmExternalLeading; } SelectObject(temp_dc, old_font); ReleaseDC(NULL, temp_dc); } } ui_metrics::ui_metrics(ui_metrics const &that) : m_debug_font(NULL), m_debug_font_height(that.m_debug_font_height), m_debug_font_width(that.m_debug_font_width), m_debug_font_ascent(that.m_debug_font_ascent), m_hscroll_height(that.m_hscroll_height), m_vscroll_width(that.m_vscroll_width) { LOGFONT lf; if (GetObject(that.m_debug_font, sizeof(lf), &lf)) m_debug_font = CreateFontIndirect(&lf); } ui_metrics::~ui_metrics() { if (m_debug_font) DeleteObject(m_debug_font); }
RJRetro/mame
src/osd/modules/debugger/win/uimetrics.cpp
C++
gpl-2.0
2,085
[ 30522, 1013, 1013, 6105, 1024, 18667, 2094, 1011, 1017, 1011, 11075, 1013, 1013, 9385, 1011, 13304, 1024, 7158, 13287, 1010, 12436, 2015, 18081, 2497, 1013, 1013, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# © 2008-2020 Dorin Hongu <dhongu(@)gmail(.)com # See README.rst file on addons root folder for license details { "name": "Romania - Invoice Report ", "summary": "Localizare Terrabit", "version": "14.0.3.0.3", "author": "Dorin Hongu," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/l10n-romania", "license": "AGPL-3", "category": "Generic Modules", "depends": [ "base", "account", "l10n_ro_config", "purchase", # "deltatech_watermark" ], "data": [ "views/invoice_report.xml", "views/voucher_report.xml", "views/payment_report.xml", # 'views/account_invoice_view.xml', "views/account_voucher_report.xml", "views/account_bank_statement_view.xml", "views/statement_report.xml", # 'views/res_partner_view.xml', ], }
dhongu/l10n-romania
l10n_ro_invoice_report/__manifest__.py
Python
agpl-3.0
887
[ 30522, 1001, 1075, 2263, 1011, 12609, 2079, 6657, 4291, 2226, 1026, 28144, 5063, 2226, 1006, 1030, 1007, 20917, 4014, 1006, 1012, 1007, 4012, 1001, 2156, 30524, 1012, 1017, 1012, 1014, 1012, 1017, 1000, 1010, 1000, 3166, 1000, 1024, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.8"/> <title>LPM: Lagrangian Particle Methods: Member List</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> <script type="text/x-mathjax-config"> MathJax.Hub.Config({ extensions: ["tex2jax.js"], jax: ["input/TeX","output/HTML-CSS"], }); </script><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">LPM: Lagrangian Particle Methods &#160;<span id="projectnumber">2.0</span> </div> <div id="projectbrief">PDE solver</div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.8 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main&#160;Page</span></a></li> <li><a href="pages.html"><span>Related&#160;Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li class="current"><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="annotated.html"><span>Data&#160;Types&#160;List</span></a></li> <li><a href="classes.html"><span>Data&#160;Types</span></a></li> <li><a href="functions.html"><span>Data&#160;Fields</span></a></li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Modules</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="classplanarincompressiblesolvermodule.html">planarincompressiblesolvermodule</a></li><li class="navelem"><a class="el" href="interfaceplanarincompressiblesolvermodule_1_1new.html">new</a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="headertitle"> <div class="title">planarincompressiblesolvermodule::new Member List</div> </div> </div><!--header--> <div class="contents"> <p>This is the complete list of members for <a class="el" href="interfaceplanarincompressiblesolvermodule_1_1new.html">planarincompressiblesolvermodule::new</a>, including all inherited members.</p> <table class="directory"> <tr class="even"><td class="entry"><a class="el" href="group___planar_incompressible_solver.html#ga3c2ee482036b8ed3ab735b348394a744">newprivate</a>(self, plane)</td><td class="entry"><a class="el" href="interfaceplanarincompressiblesolvermodule_1_1new.html">planarincompressiblesolvermodule::new</a></td><td class="entry"><span class="mlabel">private</span></td></tr> </table></div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Tue Jan 12 2016 10:09:31 for LPM: Lagrangian Particle Methods by &#160;<a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.8 </small></address> </body> </html>
pbosler/lpm-v2
doc/html/interfaceplanarincompressiblesolvermodule_1_1new-members.html
HTML
mit
6,082
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 1060, 11039, 19968, 1015, 1012, 1014, 17459, 1013, 1013, 4372, 1000, 1000, 8299, 1024, 1013, 1013, 7479, 1012, 1059, 2509, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2014 Open Connectome Project (http://openconnecto.me) * Written by Da Zheng (zhengda1936@gmail.com) * * This file is part of FlashMatrix. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "matrix_store.h" #include "local_matrix_store.h" #include "mem_matrix_store.h" #include "EM_dense_matrix.h" #include "EM_object.h" #include "matrix_config.h" #include "local_mem_buffer.h" namespace fm { namespace detail { std::atomic<size_t> matrix_store::mat_counter; matrix_store::ptr matrix_store::create(size_t nrow, size_t ncol, matrix_layout_t layout, const scalar_type &type, int num_nodes, bool in_mem, safs::safs_file_group::ptr group) { if (in_mem) return mem_matrix_store::create(nrow, ncol, layout, type, num_nodes); else return EM_matrix_store::create(nrow, ncol, layout, type, group); } matrix_store::matrix_store(size_t nrow, size_t ncol, bool in_mem, const scalar_type &_type): type(_type) { this->nrow = nrow; this->ncol = ncol; this->in_mem = in_mem; this->entry_size = type.get_size(); this->cache_portion = true; } size_t matrix_store::get_num_portions() const { std::pair<size_t, size_t> chunk_size = get_portion_size(); if (is_wide()) return ceil(((double) get_num_cols()) / chunk_size.second); else return ceil(((double) get_num_rows()) / chunk_size.first); } local_matrix_store::ptr matrix_store::get_portion(size_t id) { size_t start_row; size_t start_col; size_t num_rows; size_t num_cols; std::pair<size_t, size_t> chunk_size = get_portion_size(); if (is_wide()) { start_row = 0; start_col = chunk_size.second * id; num_rows = get_num_rows(); num_cols = std::min(chunk_size.second, get_num_cols() - start_col); } else { start_row = chunk_size.first * id; start_col = 0; num_rows = std::min(chunk_size.first, get_num_rows() - start_row); num_cols = get_num_cols(); } return get_portion(start_row, start_col, num_rows, num_cols); } local_matrix_store::const_ptr matrix_store::get_portion(size_t id) const { size_t start_row; size_t start_col; size_t num_rows; size_t num_cols; std::pair<size_t, size_t> chunk_size = get_portion_size(); if (is_wide()) { start_row = 0; start_col = chunk_size.second * id; num_rows = get_num_rows(); num_cols = std::min(chunk_size.second, get_num_cols() - start_col); } else { start_row = chunk_size.first * id; start_col = 0; num_rows = std::min(chunk_size.first, get_num_rows() - start_row); num_cols = get_num_cols(); } return get_portion(start_row, start_col, num_rows, num_cols); } namespace { class reset_op: public set_operate { const scalar_type &type; size_t entry_size; public: reset_op(const scalar_type &_type): type(_type) { this->entry_size = type.get_size(); } virtual void set(void *arr, size_t num_eles, off_t row_idx, off_t col_idx) const { memset(arr, 0, num_eles * entry_size); } virtual const scalar_type &get_type() const { return type; } virtual set_operate::const_ptr transpose() const { return set_operate::const_ptr(); } }; class set_task: public thread_task { detail::local_matrix_store::ptr local_store; const set_operate &op; public: set_task(detail::local_matrix_store::ptr local_store, const set_operate &_op): op(_op) { this->local_store = local_store; } void run() { local_store->set_data(op); } }; /* * These two functions define the length and portion size for 1D partitioning * on a matrix. */ static inline size_t get_tot_len(const matrix_store &mat) { return mat.is_wide() ? mat.get_num_cols() : mat.get_num_rows(); } static inline size_t get_portion_size(const matrix_store &mat) { return mat.is_wide() ? mat.get_portion_size().second : mat.get_portion_size().first; } class EM_mat_setdata_dispatcher: public EM_portion_dispatcher { const set_operate &op; matrix_store &to_mat; public: EM_mat_setdata_dispatcher(matrix_store &store, const set_operate &_op); virtual void create_task(off_t global_start, size_t length); }; EM_mat_setdata_dispatcher::EM_mat_setdata_dispatcher(matrix_store &store, const set_operate &_op): EM_portion_dispatcher(get_tot_len(store), fm::detail::get_portion_size(store)), op(_op), to_mat(store) { } void EM_mat_setdata_dispatcher::create_task(off_t global_start, size_t length) { size_t global_start_row, global_start_col; size_t num_rows, num_cols; if (to_mat.is_wide()) { global_start_row = 0; global_start_col = global_start; num_rows = to_mat.get_num_rows(); num_cols = length; } else { global_start_row = global_start; global_start_col = 0; num_rows = length; num_cols = to_mat.get_num_cols(); } local_matrix_store::ptr buf; if (to_mat.store_layout() == matrix_layout_t::L_COL) buf = local_matrix_store::ptr(new local_buf_col_matrix_store( global_start_row, global_start_col, num_rows, num_cols, to_mat.get_type(), -1)); else buf = local_matrix_store::ptr(new local_buf_row_matrix_store( global_start_row, global_start_col, num_rows, num_cols, to_mat.get_type(), -1)); buf->set_data(op); to_mat.write_portion_async(buf, global_start_row, global_start_col); } } void matrix_store::reset_data() { set_data(reset_op(get_type())); } void matrix_store::set_data(const set_operate &op) { size_t num_chunks = get_num_portions(); if (is_in_mem() && num_chunks == 1) { local_matrix_store::ptr buf; if (store_layout() == matrix_layout_t::L_ROW) buf = local_matrix_store::ptr(new local_buf_row_matrix_store(0, 0, get_num_rows(), get_num_cols(), get_type(), -1)); else buf = local_matrix_store::ptr(new local_buf_col_matrix_store(0, 0, get_num_rows(), get_num_cols(), get_type(), -1)); buf->set_data(op); write_portion_async(buf, 0, 0); // After computation, some matrices buffer local portions in the thread, // we should try to clean these local portions. These local portions // may contain pointers to some matrices that don't exist any more. // We also need to clean them to reduce memory consumption. // We might want to keep the memory buffer for I/O on dense matrices. if (matrix_conf.is_keep_mem_buf()) detail::local_mem_buffer::clear_bufs( detail::local_mem_buffer::MAT_PORTION); else detail::local_mem_buffer::clear_bufs(); } else if (is_in_mem()) { detail::mem_thread_pool::ptr mem_threads = detail::mem_thread_pool::get_global_mem_threads(); for (size_t i = 0; i < num_chunks; i++) { detail::local_matrix_store::ptr local_store = get_portion(i); int node_id = local_store->get_node_id(); // If the local matrix portion is not assigned to any node, // assign the tasks in round robin fashion. if (node_id < 0) node_id = i % mem_threads->get_num_nodes(); mem_threads->process_task(node_id, new set_task(local_store, op)); } mem_threads->wait4complete(); } else { mem_thread_pool::ptr threads = mem_thread_pool::get_global_mem_threads(); EM_mat_setdata_dispatcher::ptr dispatcher( new EM_mat_setdata_dispatcher(*this, op)); EM_matrix_store *em_this = dynamic_cast<EM_matrix_store *>(this); assert(em_this); em_this->start_stream(); for (size_t i = 0; i < threads->get_num_threads(); i++) { io_worker_task *task = new io_worker_task(dispatcher); const EM_object *obj = dynamic_cast<const EM_object *>(this); task->register_EM_obj(const_cast<EM_object *>(obj)); threads->process_task(i % threads->get_num_nodes(), task); } threads->wait4complete(); em_this->end_stream(); } } matrix_stream::ptr matrix_stream::create(matrix_store::ptr store) { if (store->is_in_mem()) { mem_matrix_store::ptr mem_store = std::dynamic_pointer_cast<mem_matrix_store>(store); if (mem_store == NULL) { BOOST_LOG_TRIVIAL(error) << "The in-mem matrix store isn't writable"; return matrix_stream::ptr(); } else return mem_matrix_stream::create(mem_store); } else { EM_matrix_store::ptr em_store = std::dynamic_pointer_cast<EM_matrix_store>(store); if (em_store == NULL) { BOOST_LOG_TRIVIAL(error) << "The ext-mem matrix store isn't writable"; return matrix_stream::ptr(); } else return EM_matrix_stream::create(em_store); } } matrix_store::const_ptr matrix_store::get_cols( const std::vector<off_t> &idxs) const { matrix_store::const_ptr tm = transpose(); matrix_store::const_ptr rows = tm->get_rows(idxs); if (rows == NULL) return matrix_store::const_ptr(); else return rows->transpose(); } matrix_store::const_ptr matrix_store::get_cols(off_t start, off_t end) const { if (start < 0 || end < 0 || end - start < 0) { BOOST_LOG_TRIVIAL(error) << "invalid range for selecting columns"; return matrix_store::const_ptr(); } std::vector<off_t> idxs(end - start); for (size_t i = 0; i < idxs.size(); i++) idxs[i] = start + i; return get_cols(idxs); } matrix_store::const_ptr matrix_store::get_rows(off_t start, off_t end) const { if (start < 0 || end < 0 || end - start < 0) { BOOST_LOG_TRIVIAL(error) << "invalid range for selecting rows"; return matrix_store::const_ptr(); } std::vector<off_t> idxs(end - start); for (size_t i = 0; i < idxs.size(); i++) idxs[i] = start + i; return get_rows(idxs); } bool matrix_store::share_data(const matrix_store &store) const { // By default, we can use data id to determine if two matrices have // the same data. return get_data_id() == store.get_data_id() && get_data_id() != INVALID_MAT_ID; } matrix_append::matrix_append(matrix_store::ptr store) { this->res = store; q.resize(1000); last_append = -1; written_eles = 0; empty_portion = local_matrix_store::const_ptr(new local_buf_row_matrix_store( 0, 0, 0, 0, store->get_type(), -1, false)); } void matrix_append::write_async(local_matrix_store::const_ptr portion, off_t seq_id) { if (seq_id <= last_append) { BOOST_LOG_TRIVIAL(error) << "Append a repeated portion"; return; } if (portion == NULL) portion = empty_portion; std::vector<local_matrix_store::const_ptr> data; lock.lock(); // Add the new portion to the queue. If the queue is too small, // we should resize the queue first. off_t loc = seq_id - last_append - 1; assert(loc >= 0); if ((size_t) loc >= q.size()) q.resize(q.size() * 2); q[loc] = portion; off_t start_loc = -1; if (q.front()) start_loc = written_eles; // Get the portions from the queue. while (q.front()) { auto mat = q.front(); // If the portion isn't empty. if (mat->get_num_rows() > 0 && mat->get_num_cols() > 0) data.push_back(mat); q.pop_front(); q.push_back(local_matrix_store::const_ptr()); last_append++; written_eles += mat->get_num_rows() * mat->get_num_cols(); } lock.unlock(); for (size_t i = 0; i < data.size(); i++) { assert(start_loc >= 0); // TODO this works if the result matrix is stored in memory. if (res->is_wide()) { off_t start_row = 0; off_t start_col = start_loc / res->get_num_rows(); res->write_portion_async(data[i], start_row, start_col); } else { off_t start_row = start_loc / res->get_num_cols(); off_t start_col = 0; res->write_portion_async(data[i], start_row, start_col); } start_loc += data[i]->get_num_rows() * data[i]->get_num_cols(); } } matrix_append::~matrix_append() { for (size_t i = 0; i < q.size(); i++) assert(q[i] == NULL); } void matrix_append::flush() { for (size_t i = 0; i < q.size(); i++) assert(q[i] == NULL); } } }
flashxio/FlashX
matrix/matrix_store.cpp
C++
apache-2.0
11,850
[ 30522, 1013, 1008, 1008, 9385, 2297, 2330, 7532, 8462, 2622, 1006, 8299, 1024, 1013, 1013, 2330, 8663, 2638, 6593, 2080, 1012, 2033, 1007, 1008, 2517, 2011, 4830, 20985, 1006, 20985, 30524, 1012, 4012, 1007, 1008, 1008, 2023, 5371, 2003, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/compiler/xla/service/hlo_instruction.h" #include <algorithm> #include <deque> #include <ostream> #include <set> #include <unordered_set> #include <utility> #include "tensorflow/compiler/xla/layout_util.h" #include "tensorflow/compiler/xla/literal_util.h" #include "tensorflow/compiler/xla/protobuf_util.h" #include "tensorflow/compiler/xla/ptr_util.h" #include "tensorflow/compiler/xla/service/dfs_hlo_visitor_with_default.h" #include "tensorflow/compiler/xla/service/hlo_computation.h" #include "tensorflow/compiler/xla/service/hlo_module.h" #include "tensorflow/compiler/xla/service/name_uniquer.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/status_macros.h" #include "tensorflow/compiler/xla/types.h" #include "tensorflow/compiler/xla/util.h" #include "tensorflow/compiler/xla/window_util.h" #include "tensorflow/core/lib/core/errors.h" #include "tensorflow/core/lib/gtl/flatmap.h" #include "tensorflow/core/lib/strings/str_util.h" #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/platform/logging.h" namespace xla { using ::tensorflow::str_util::Join; using ::tensorflow::strings::StrAppend; using ::tensorflow::strings::StrCat; /* static */ StatusOr<std::unique_ptr<HloInstruction>> HloInstruction::CreateFromProto( HloModule* module, const HloInstructionProto& proto, const tensorflow::gtl::FlatMap<string, HloInstruction*>& instruction_map, tensorflow::gtl::FlatMap<string, HloComputation*>* computation_map) { TF_RET_CHECK(!proto.opcode().empty()); TF_ASSIGN_OR_RETURN(HloOpcode opcode, StringToHloOpcode(proto.opcode())); TF_RET_CHECK(proto.has_shape()); auto instruction = WrapUnique(new HloInstruction(opcode, proto.shape())); for (const string& operand_name : proto.operand_names()) { TF_RET_CHECK(ContainsKey(instruction_map, operand_name)) << "No instruction named " << operand_name; instruction->AppendOperand(instruction_map.at(operand_name)); } for (const string& predecessor_name : proto.control_predecessor_names()) { TF_RET_CHECK(ContainsKey(instruction_map, predecessor_name)) << "No instruction named " << predecessor_name; TF_RETURN_IF_ERROR(instruction_map.at(predecessor_name) ->AddControlDependencyTo(instruction.get())); } // In the proto, fused computations are held exclusively within the // HloInstructionProto and do not appear as an HloComputationProto within the // HloModuleProto. if (instruction->opcode() == HloOpcode::kFusion) { TF_RET_CHECK(proto.has_fused_instructions_computation()); TF_RET_CHECK(!proto.fusion_kind().empty()); TF_ASSIGN_OR_RETURN(instruction->fusion_kind_, StringToFusionKind(proto.fusion_kind())); TF_ASSIGN_OR_RETURN( std::unique_ptr<HloComputation> fused_computation, HloComputation::CreateFromProto( module, proto.fused_instructions_computation(), computation_map, /*fusion_instruction=*/instruction.get())); instruction->called_computations_.push_back( module->AddEmbeddedComputation(std::move(fused_computation))); } else { for (const string& computation_name : proto.called_computation_names()) { TF_RET_CHECK(ContainsKey(*computation_map, computation_name)) << "No computation named " << computation_name; instruction->called_computations_.push_back( computation_map->at(computation_name)); } } TF_RET_CHECK(!proto.name().empty()); instruction->name_ = proto.name(); instruction->metadata_ = proto.metadata(); if (proto.has_literal()) { instruction->literal_ = MakeUnique<Literal>(proto.literal()); } instruction->parameter_number_ = proto.parameter_number(); instruction->parameter_name_ = proto.parameter_name(); instruction->tuple_index_ = proto.tuple_index(); for (int64 dimension : proto.dimensions()) { instruction->dimensions_.push_back(dimension); } if (proto.has_window()) { instruction->window_ = MakeUnique<Window>(proto.window()); } if (proto.has_convolution_dimension_numbers()) { instruction->convolution_dimension_numbers_ = MakeUnique<ConvolutionDimensionNumbers>( proto.convolution_dimension_numbers()); } for (const HloInstructionProto::SliceDimensions& slice_dimensions : proto.slice_dimensions()) { instruction->slice_starts_.push_back(slice_dimensions.start()); instruction->slice_limits_.push_back(slice_dimensions.limit()); instruction->slice_strides_.push_back(slice_dimensions.stride()); } instruction->exponent_bits_ = proto.exponent_bits(); instruction->mantissa_bits_ = proto.mantissa_bits(); for (int64 dynamic_slice_size : proto.dynamic_slice_sizes()) { instruction->dynamic_slice_sizes_.push_back(dynamic_slice_size); } if (proto.has_padding_config()) { instruction->padding_config_ = MakeUnique<PaddingConfig>(proto.padding_config()); } instruction->outfeed_config_ = proto.outfeed_config(); instruction->distribution_ = proto.distribution(); instruction->epsilon_ = proto.epsilon(); instruction->feature_index_ = proto.feature_index(); instruction->channel_id_ = proto.channel_id(); instruction->infeed_config_ = proto.infeed_config(); instruction->custom_call_target_ = proto.custom_call_target(); instruction->outfeed_shape_ = proto.outfeed_shape(); return std::move(instruction); } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateParameter( int64 parameter_number, const Shape& shape, const string& name) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kParameter, shape)); instruction->parameter_number_ = parameter_number; instruction->parameter_name_ = name; instruction->name_ = "%" + name; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateTrace( const string& tag, HloInstruction* operand) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kTrace, ShapeUtil::MakeNil())); instruction->operands_.push_back(operand); instruction->literal_.reset(new Literal); instruction->literal_->append_u8s(tag); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateConstant( std::unique_ptr<Literal> literal) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kConstant, literal->shape())); instruction->literal_ = std::move(literal); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateGetTupleElement(const Shape& shape, HloInstruction* operand, int64 index) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kGetTupleElement, shape)); instruction->tuple_index_ = index; instruction->AppendOperand(operand); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateRng( const Shape& shape, RandomDistribution distribution, tensorflow::gtl::ArraySlice<HloInstruction*> parameters) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kRng, shape)); instruction->distribution_ = distribution; instruction->shape_ = shape; for (HloInstruction* param : parameters) { instruction->AppendOperand(param); } return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateNary( const Shape& shape, HloOpcode opcode, tensorflow::gtl::ArraySlice<HloInstruction*> operands) { if (opcode == HloOpcode::kCopy) { // It is impossible to copy an opaque shape, we don't know how big it is. CHECK(!ShapeUtil::IsOpaque(shape)); } auto instruction = WrapUnique(new HloInstruction(opcode, shape)); for (auto operand : operands) { instruction->AppendOperand(operand); } return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateUnary( const Shape& shape, HloOpcode opcode, HloInstruction* operand) { // Only certain opcodes are supported with CreateUnary: opcodes of unary // instructions with no auxiliary fields. switch (opcode) { case HloOpcode::kAbs: case HloOpcode::kRoundNearestAfz: case HloOpcode::kBitcast: case HloOpcode::kCeil: case HloOpcode::kCopy: case HloOpcode::kCos: case HloOpcode::kExp: case HloOpcode::kFloor: case HloOpcode::kIsFinite: case HloOpcode::kLog: case HloOpcode::kNot: case HloOpcode::kNegate: case HloOpcode::kSign: case HloOpcode::kSin: case HloOpcode::kSort: case HloOpcode::kTanh: break; default: LOG(FATAL) << "Invalid unary instruction opcode " << HloOpcodeString(opcode); } return CreateNary(shape, opcode, {operand}); } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateBinary( const Shape& shape, HloOpcode opcode, HloInstruction* lhs, HloInstruction* rhs) { // Only certain opcodes are supported with CreateBinary: opcodes of binary // instructions with no auxiliary fields. switch (opcode) { case (HloOpcode::kAdd): case (HloOpcode::kDivide): case (HloOpcode::kDot): case (HloOpcode::kEq): case (HloOpcode::kGe): case (HloOpcode::kGt): case (HloOpcode::kLe): case (HloOpcode::kLt): case (HloOpcode::kMaximum): case (HloOpcode::kMinimum): case (HloOpcode::kMultiply): case (HloOpcode::kNe): case (HloOpcode::kPower): case (HloOpcode::kRemainder): case (HloOpcode::kSubtract): case (HloOpcode::kAnd): case (HloOpcode::kOr): case (HloOpcode::kShiftLeft): case (HloOpcode::kShiftRightArithmetic): case (HloOpcode::kShiftRightLogical): break; default: LOG(FATAL) << "Invalid binary instruction opcode " << HloOpcodeString(opcode); } return CreateNary(shape, opcode, {lhs, rhs}); } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateTernary( const Shape& shape, HloOpcode opcode, HloInstruction* lhs, HloInstruction* rhs, HloInstruction* ehs) { // Only certain opcodes are supported with CreateTernary: opcodes of ternary // instructions with no auxiliary fields. switch (opcode) { case (HloOpcode::kClamp): case (HloOpcode::kSelect): break; default: LOG(FATAL) << "Invalid ternary instruction opcode " << HloOpcodeString(opcode); } return CreateNary(shape, opcode, {lhs, rhs, ehs}); } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateVariadic( const Shape& shape, HloOpcode opcode, tensorflow::gtl::ArraySlice<HloInstruction*> operands) { CHECK_EQ(HloOpcode::kTuple, opcode); return CreateNary(shape, opcode, operands); } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateMap( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands, HloComputation* map_computation, tensorflow::gtl::ArraySlice<HloInstruction*> static_operands) { CHECK(static_operands.empty()) << "static_operands not yet supported"; auto instruction = WrapUnique(new HloInstruction(HloOpcode::kMap, shape)); for (auto operand : operands) { instruction->AppendOperand(operand); } instruction->called_computations_.push_back(map_computation); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateConvolve( const Shape& shape, HloInstruction* lhs, HloInstruction* rhs, const Window& window, const ConvolutionDimensionNumbers& dimension_numbers) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kConvolution, shape)); if (window_util::HasBaseDilation(window)) { instruction->name_ = instruction->name() + "-base-dilated"; } if (window_util::HasWindowDilation(window)) { instruction->name_ = instruction->name() + "-window-dilated"; } instruction->AppendOperand(lhs); instruction->AppendOperand(rhs); instruction->window_ = MakeUnique<Window>(window); instruction->convolution_dimension_numbers_ = MakeUnique<ConvolutionDimensionNumbers>(dimension_numbers); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateReducePrecision(const Shape& shape, HloInstruction* operand, const int exponent_bits, const int mantissa_bits) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kReducePrecision, shape)); instruction->AppendOperand(operand); instruction->exponent_bits_ = exponent_bits; instruction->mantissa_bits_ = mantissa_bits; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateCrossReplicaSum(const Shape& shape, HloInstruction* operand) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kCrossReplicaSum, shape)); instruction->AppendOperand(operand); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateInfeed( const Shape& shape, const string& config) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kInfeed, shape)); instruction->set_infeed_config(config); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateOutfeed( const Shape& shape, HloInstruction* operand, tensorflow::StringPiece outfeed_config) { std::unique_ptr<HloInstruction> instruction = WrapUnique(new HloInstruction(HloOpcode::kOutfeed, ShapeUtil::MakeNil())); instruction->AppendOperand(operand); instruction->outfeed_config_ = outfeed_config.ToString(); instruction->outfeed_shape_ = shape; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateSend( HloInstruction* operand, int64 channel_id) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kSend, ShapeUtil::MakeNil())); instruction->AppendOperand(operand); instruction->channel_id_ = channel_id; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateRecv( const Shape& shape, int64 channel_id) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kRecv, shape)); instruction->channel_id_ = channel_id; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateReverse( const Shape& shape, HloInstruction* operand, tensorflow::gtl::ArraySlice<int64> dimensions) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kReverse, shape)); instruction->AppendOperand(operand); instruction->dimensions_.assign(dimensions.begin(), dimensions.end()); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateWhile( const Shape& shape, HloComputation* condition, HloComputation* body, HloInstruction* init) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kWhile, shape)); instruction->AppendOperand(init); // Body comes before condition computation in the vector. instruction->called_computations_.push_back(body); instruction->called_computations_.push_back(condition); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateSlice( const Shape& shape, HloInstruction* operand, tensorflow::gtl::ArraySlice<int64> start_indices, tensorflow::gtl::ArraySlice<int64> limit_indices, tensorflow::gtl::ArraySlice<int64> strides) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kSlice, shape)); instruction->AppendOperand(operand); instruction->slice_starts_.assign(start_indices.begin(), start_indices.end()); instruction->slice_limits_.assign(limit_indices.begin(), limit_indices.end()); instruction->slice_strides_.assign(strides.begin(), strides.end()); // For backward compatibility with old serialized computations: if there are // no strides, assume all strides are 1. // TODO(b/63317920): remove this code. if (instruction->slice_strides_.empty()) { instruction->slice_strides_ = std::vector<int64>(start_indices.size(), 1LL); } return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateDynamicSlice( const Shape& shape, HloInstruction* operand, HloInstruction* start_indices, tensorflow::gtl::ArraySlice<int64> slice_sizes) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kDynamicSlice, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(start_indices); instruction->dynamic_slice_sizes_.assign(slice_sizes.begin(), slice_sizes.end()); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateDynamicUpdateSlice(const Shape& shape, HloInstruction* operand, HloInstruction* update, HloInstruction* start_indices) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kDynamicUpdateSlice, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(update); instruction->AppendOperand(start_indices); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateConcatenate( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands, int64 dimension) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kConcatenate, shape)); for (auto operand : operands) { instruction->AppendOperand(operand); } instruction->dimensions_.push_back(dimension); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateConvert( const Shape& shape, HloInstruction* operand) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kConvert, shape)); instruction->AppendOperand(operand); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateReduce( const Shape& shape, HloInstruction* arg, HloInstruction* init_value, tensorflow::gtl::ArraySlice<int64> dimensions_to_reduce, HloComputation* reduce_computation) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kReduce, shape)); instruction->AppendOperand(arg); instruction->AppendOperand(init_value); instruction->dimensions_.assign(dimensions_to_reduce.begin(), dimensions_to_reduce.end()); instruction->called_computations_.push_back(reduce_computation); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateReduceWindow( const Shape& shape, HloInstruction* operand, HloInstruction* init_value, const Window& window, HloComputation* reduce_computation) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kReduceWindow, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(init_value); instruction->called_computations_.push_back(reduce_computation); instruction->window_ = MakeUnique<Window>(window); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateBatchNormTraining(const Shape& shape, HloInstruction* operand, HloInstruction* scale, HloInstruction* offset, float epsilon, int64 feature_index) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kBatchNormTraining, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(scale); instruction->AppendOperand(offset); instruction->epsilon_ = epsilon; instruction->feature_index_ = feature_index; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateBatchNormInference( const Shape& shape, HloInstruction* operand, HloInstruction* scale, HloInstruction* offset, HloInstruction* mean, HloInstruction* variance, float epsilon, int64 feature_index) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kBatchNormInference, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(scale); instruction->AppendOperand(offset); instruction->AppendOperand(mean); instruction->AppendOperand(variance); instruction->epsilon_ = epsilon; instruction->feature_index_ = feature_index; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateBatchNormGrad(const Shape& shape, HloInstruction* operand, HloInstruction* scale, HloInstruction* mean, HloInstruction* variance, HloInstruction* grad_output, float epsilon, int64 feature_index) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kBatchNormGrad, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(scale); instruction->AppendOperand(mean); instruction->AppendOperand(variance); instruction->AppendOperand(grad_output); instruction->epsilon_ = epsilon; instruction->feature_index_ = feature_index; return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateSelectAndScatter( const Shape& shape, HloInstruction* operand, HloComputation* select, const Window& window, HloInstruction* source, HloInstruction* init_value, HloComputation* scatter) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kSelectAndScatter, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(source); instruction->AppendOperand(init_value); // Select comes before scatter in the vector. instruction->called_computations_.push_back(select); instruction->called_computations_.push_back(scatter); instruction->window_ = MakeUnique<Window>(window); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateBroadcast( const Shape& shape, HloInstruction* operand, tensorflow::gtl::ArraySlice<int64> broadcast_dimensions) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kBroadcast, shape)); instruction->AppendOperand(operand); instruction->dimensions_.assign(broadcast_dimensions.begin(), broadcast_dimensions.end()); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreatePad( const Shape& shape, HloInstruction* operand, HloInstruction* padding_value, const PaddingConfig& padding_config) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kPad, shape)); instruction->AppendOperand(operand); instruction->AppendOperand(padding_value); instruction->padding_config_ = MakeUnique<PaddingConfig>(padding_config); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateReshape( const Shape& shape, HloInstruction* operand) { CHECK_EQ(ShapeUtil::ElementsIn(shape), ShapeUtil::ElementsIn(operand->shape())) << "shape: " << ShapeUtil::HumanString(shape) << " operand: " << ShapeUtil::HumanString(operand->shape()); auto instruction = WrapUnique(new HloInstruction(HloOpcode::kReshape, shape)); instruction->AppendOperand(operand); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateTranspose( const Shape& shape, HloInstruction* operand, tensorflow::gtl::ArraySlice<int64> dimensions) { CHECK_EQ(shape.dimensions().size(), dimensions.size()); CHECK_EQ(shape.dimensions().size(), operand->shape().dimensions().size()); CHECK(std::equal(operand->shape().dimensions().begin(), operand->shape().dimensions().end(), Permute(dimensions, shape.dimensions()).begin())); auto instruction = WrapUnique(new HloInstruction(HloOpcode::kTranspose, shape)); instruction->AppendOperand(operand); instruction->dimensions_.assign(dimensions.begin(), dimensions.end()); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateFusion( const Shape& shape, FusionKind fusion_kind, HloInstruction* fused_root) { auto instruction = WrapUnique(new HloInstruction(HloOpcode::kFusion, shape)); instruction->fusion_kind_ = fusion_kind; instruction->set_parent(fused_root->parent()); instruction->set_metadata(fused_root->metadata()); instruction->CloneAndFuseInternal(fused_root); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateFusionForBackwardConvolution( const Shape& shape, FusionKind fusion_kind, const Window& window, const ConvolutionDimensionNumbers& conv_dnums, HloInstruction* fused_root) { std::unique_ptr<HloInstruction> fusion = CreateFusion(shape, fusion_kind, fused_root); fusion->window_ = MakeUnique<Window>(window); fusion->convolution_dimension_numbers_ = MakeUnique<ConvolutionDimensionNumbers>(conv_dnums); return fusion; } void HloInstruction::MergeFusionInstruction( HloInstruction* instruction_to_merge) { CHECK_EQ(opcode_, HloOpcode::kFusion); CHECK_EQ(instruction_to_merge->opcode(), HloOpcode::kFusion); CHECK(std::find(operands().begin(), operands().end(), instruction_to_merge) != operands().end()); // Clone the instruction from which to merge fused instructions. std::unique_ptr<HloInstruction> clone = instruction_to_merge->Clone(); // Replace uses of fused parameters with the corresponding operand of the // fusion. Add all non-parameter fused instructions to 'unfused_instructions' // to be merged into 'this'. This is done in reverse post order. std::vector<HloInstruction*> unfused_instructions; auto fused_instructions = clone->fused_instructions_computation()->MakeInstructionPostOrder(); for (auto fused_it = fused_instructions.rbegin(); fused_it != fused_instructions.rend(); ++fused_it) { auto fused_instruction = *fused_it; if (fused_instruction->opcode() == HloOpcode::kParameter) { TF_CHECK_OK(fused_instruction->ReplaceAllUsesWith( clone->mutable_operand(fused_instruction->parameter_number()))); } else { unfused_instructions.push_back(fused_instruction); } } CHECK(unfused_instructions.front() == clone->fused_expression_root()); // Replace instruction_to_merge use of 'this' with unfused_root. TF_CHECK_OK( instruction_to_merge->ReplaceUseWith(this, unfused_instructions.front())); // Fuse 'unfused_instructions' into 'this'. for (auto& instruction : unfused_instructions) { FuseInstruction(instruction); instruction->DetachFromOperands(); } CHECK_EQ(0, clone->user_count()); clone->DetachFromOperands(); TF_CHECK_OK(parent()->parent()->RemoveEmbeddedComputation( clone->fused_instructions_computation())); } void HloInstruction::MergeFusionInstructionIntoMultiOutput( HloInstruction* instruction_to_merge) { CHECK_EQ(opcode_, HloOpcode::kFusion); CHECK_EQ(instruction_to_merge->opcode(), HloOpcode::kFusion); // Add all non-parameter fused instructions to 'unfused_instructions' to be // merged into 'this'. `old_to_new' maps the instructions in the fused node // to the disaseembled fusion instructions. // Note that we add the unfused instructions to this->parent_ computation. // This is necessary because the unique_id needs for an instruction and // it's only added when inserting to the computation. tensorflow::gtl::FlatMap<HloInstruction*, HloInstruction*> old_to_new; std::vector<HloInstruction*> unfused_instructions; auto computation_to_merge = instruction_to_merge->fused_instructions_computation(); auto post_order = computation_to_merge->MakeInstructionPostOrder(); for (auto rit = post_order.rbegin(); rit != post_order.rend(); ++rit) { auto fused_instruction = *rit; if (fused_instruction->opcode() == HloOpcode::kParameter) { InsertOrDie(&old_to_new, fused_instruction, instruction_to_merge->mutable_operand( fused_instruction->parameter_number())); continue; } // Here we clone the insertion and call FuseInstructionIntoMultiOutput() // which clones again. This can be improved. auto cloned_instruction = parent_->AddInstruction(fused_instruction->Clone()); unfused_instructions.push_back(cloned_instruction); InsertOrDie(&old_to_new, fused_instruction, cloned_instruction); } for (auto unfused_instruction : unfused_instructions) { for (int64 index = 0; index < unfused_instruction->operand_count(); index++) { auto new_operand = FindOrDie(old_to_new, unfused_instruction->mutable_operand(index)); TF_CHECK_OK(unfused_instruction->ReplaceOperandWith(index, new_operand)); } } HloInstruction* unfused_root = unfused_instructions.front(); TF_CHECK_OK(instruction_to_merge->ReplaceAllUsesWith(unfused_root)); TF_CHECK_OK( instruction_to_merge->parent()->RemoveInstruction(instruction_to_merge)); if (GetModule()) { TF_CHECK_OK(GetModule()->RemoveEmbeddedComputation(computation_to_merge)); } // Fuse the root instruction and generate multiple outputs. FuseInstructionIntoMultiOutput(unfused_root); TF_CHECK_OK(unfused_root->parent()->RemoveInstruction(unfused_root)); // The rest instructions are of normal fusing. for (int64 i = 1; i < unfused_instructions.size(); i++) { auto instruction = unfused_instructions[i]; FuseInstruction(instruction); TF_CHECK_OK(instruction->parent()->RemoveInstruction(instruction)); } } HloInstruction* HloInstruction::FuseInstructionInternal( HloInstruction* instruction_to_fuse, bool add_output) { CHECK_EQ(opcode_, HloOpcode::kFusion); // When add_output is false, this fusion instruction must be a user of // instruction_to_fuse. if (!add_output) { CHECK(IsUserOf(instruction_to_fuse)); } HloInstruction* fused_instruction = CloneAndFuseInternal(instruction_to_fuse, add_output); return fused_instruction; } HloInstruction* HloInstruction::CloneAndFuseInternal( HloInstruction* instruction_to_fuse, bool add_output) { CHECK_EQ(opcode_, HloOpcode::kFusion); CHECK(instruction_to_fuse->IsFusable()); VLOG(3) << "CloneAndFuseInternal:\n" << instruction_to_fuse->ToString(); HloInstruction* clone = nullptr; if (called_computations_.empty()) { // New fusion instruction. It should not be a multioutput instruction. CHECK(!add_output); auto builder = HloComputation::Builder("fused_computation", this); builder.AddInstruction(instruction_to_fuse->Clone(/*suffix=*/"")); called_computations_.push_back( CHECK_NOTNULL(GetModule())->AddEmbeddedComputation(builder.Build())); clone = fused_expression_root(); } else { clone = fused_instructions_computation()->AddInstruction( instruction_to_fuse->Clone(/*suffix=*/"")); // When add_output is false, instruction_to_fuse is necessarily an operand // of the fusion instruction. After fusion this will no longer be the case. // Remove the operand from the operand list and remove its corresponding // fused parameter instruction. Renumber parameters as necessary to make // parameter numbers consistent with their index in the // fused_parameter_ vector. bool in_operand_list = std::find(operands_.begin(), operands_.end(), instruction_to_fuse) != operands_.end(); CHECK(add_output || in_operand_list); const std::vector<HloInstruction*>& fused_parameters = fused_instructions_computation()->parameter_instructions(); for (int64 operand_num = 0; operand_num < operand_count(); ++operand_num) { if (instruction_to_fuse == operands_[operand_num]) { // replace the fused parameter instruction's uses with the clone. HloInstruction* fused_parameter = fused_parameters[operand_num]; TF_CHECK_OK(fused_parameter->ReplaceAllUsesWith(clone)); // Remove the corresponding fused parameter and operand from their // respective vectors. TF_CHECK_OK( fused_instructions_computation()->RemoveParameter(operand_num)); operands_.erase(operands_.begin() + operand_num); break; } } // We've cloned instruction_to_fuse into this fusion instruction, so this // fusion instruction is no longer a use of instruction_to_fuse. if (in_operand_list) { instruction_to_fuse->RemoveUser(this); // When the instruction_to_fuse does not have other users, we don't need // to generate a multioutput fusion instruction. if (instruction_to_fuse->user_count() == 0) { add_output = false; } } } // Reread the parameters in the computation. const std::vector<HloInstruction*>& fused_parameters = fused_instructions_computation()->parameter_instructions(); // Add each operand of the clone as an operand of the fusion instruction. A // complication is that some clone operands may already be operands of the // fusion instruction. for (int64 operand_num = 0; operand_num < clone->operand_count(); ++operand_num) { HloInstruction* operand = clone->mutable_operand(operand_num); // See if this operand is already an operand of the fusion node. CHECK_EQ(operands_.size(), fused_parameters.size()); HloInstruction* fused_param = nullptr; for (int64 i = 0; i < operands_.size(); ++i) { if (operands_[i] == operand) { fused_param = fused_parameters[i]; break; } } if (fused_param == nullptr) { // Clone's operand was not already an operand of the fusion // instruction. Add it as an operand and add a corresponding fused // parameter instruction. int64 param_no = fused_parameters.size(); // Name the parameter after the instruction it represents in the outer // (non-fusion) computation. Strip the leading "%" from the operand name // to avoid a double %%. string param_name = StrCat(operand->name().substr(1), ".param_", param_no); fused_param = fused_instructions_computation()->AddParameter( CreateParameter(param_no, operand->shape(), param_name)); AppendOperand(operand); } TF_CHECK_OK(clone->ReplaceOperandWith(operand_num, fused_param)); } if (add_output) { CHECK_GT(instruction_to_fuse->user_count(), 0); // If this is already a multioutput fusion instruction, expand the root // tuple by 1. HloInstruction* fused_root = fused_expression_root(); HloInstruction::InstructionVector tuple_elements; bool newly_created_tuple_instr = false; if (fused_root->opcode() == HloOpcode::kTuple) { tuple_elements = fused_root->operands(); } else { tuple_elements.push_back(fused_root); newly_created_tuple_instr = true; } if (clone->opcode() == HloOpcode::kTuple) { for (auto inst : clone->operands()) { tuple_elements.push_back(inst); } } else { tuple_elements.push_back(clone); } HloInstruction* new_root = fused_instructions_computation()->AddInstruction( HloInstruction::CreateTuple(tuple_elements)); fused_instructions_computation()->set_root_instruction(new_root); shape_ = new_root->shape(); if (fused_root->opcode() == HloOpcode::kTuple) { TF_CHECK_OK( fused_instructions_computation()->RemoveInstruction(fused_root)); } // If this is a newly created multioutput instruction, we need to update // the use of the original fusion instruction. if (newly_created_tuple_instr) { HloInstruction* new_instr = parent_->AddInstruction( HloInstruction::CreateGetTupleElement(fused_root->shape(), this, 0)); TF_CHECK_OK(ReplaceAllUsesWith(new_instr)); } int64 index = tuple_elements.size(); if (instruction_to_fuse->opcode() == HloOpcode::kTuple) { index -= instruction_to_fuse->operand_count(); std::vector<HloInstruction*> to_be_removed; for (auto old_gte : instruction_to_fuse->users()) { CHECK_EQ(old_gte->opcode(), HloOpcode::kGetTupleElement); int64 old_tuple_index = old_gte->tuple_index(); HloInstruction* new_gte = parent_->AddInstruction(HloInstruction::CreateGetTupleElement( old_gte->shape(), this, index + old_tuple_index)); TF_CHECK_OK(old_gte->ReplaceAllUsesWith(new_gte)); to_be_removed.push_back(old_gte); } for (auto old_gte : to_be_removed) { TF_CHECK_OK(parent_->RemoveInstruction(old_gte)); } TF_CHECK_OK(fused_instructions_computation()->RemoveInstruction(clone)); } else { HloInstruction* new_gte = parent_->AddInstruction(HloInstruction::CreateGetTupleElement( clone->shape(), this, index - 1)); TF_CHECK_OK(instruction_to_fuse->ReplaceAllUsesWith(new_gte)); } } VLOG(2) << "New clone:\n" << clone->ToString(); return clone; } RandomDistribution HloInstruction::random_distribution() const { CHECK_EQ(opcode_, HloOpcode::kRng); return distribution_; } bool HloInstruction::HasSideEffect() const { switch (opcode_) { case HloOpcode::kSend: case HloOpcode::kRecv: case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kTrace: return true; default: { // Check if any of the called computations has a side effect. for (const auto& computation : called_computations()) { if (computation->HasSideEffect()) { return true; } } return false; } } } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateCall( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands, HloComputation* computation) { std::unique_ptr<HloInstruction> instruction = WrapUnique(new HloInstruction(HloOpcode::kCall, shape)); for (auto operand : operands) { instruction->AppendOperand(operand); } instruction->called_computations_.push_back(computation); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateCustomCall( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands, tensorflow::StringPiece custom_call_target) { std::unique_ptr<HloInstruction> instruction = WrapUnique(new HloInstruction(HloOpcode::kCustomCall, shape)); for (auto operand : operands) { instruction->AppendOperand(operand); } instruction->custom_call_target_ = custom_call_target.ToString(); return instruction; } /* static */ std::unique_ptr<HloInstruction> HloInstruction::CreateTuple( tensorflow::gtl::ArraySlice<HloInstruction*> elements) { std::vector<Shape> element_shapes; for (auto element : elements) { element_shapes.push_back(element->shape()); } Shape tuple_shape = ShapeUtil::MakeTupleShape(element_shapes); return CreateVariadic(tuple_shape, HloOpcode::kTuple, elements); } std::unique_ptr<HloInstruction> HloInstruction::CloneWithNewOperands( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> new_operands) const { VLOG(3) << "CloneWithNewOperands:\n " << ToString(); VLOG(3) << " new operands:"; for (const HloInstruction* new_operand : new_operands) { VLOG(3) << " " << new_operand->name(); } std::unique_ptr<HloInstruction> clone; // Explicitly call the factory for the instruction type. This is more robust // in the face of code changes than copying fields explicitly. This also // properly sets the user fields of the operands. switch (opcode_) { // Unary ops. case HloOpcode::kAbs: case HloOpcode::kRoundNearestAfz: case HloOpcode::kBitcast: case HloOpcode::kCeil: case HloOpcode::kCopy: case HloOpcode::kCos: case HloOpcode::kExp: case HloOpcode::kIsFinite: case HloOpcode::kFloor: case HloOpcode::kLog: case HloOpcode::kNot: case HloOpcode::kNegate: case HloOpcode::kSign: case HloOpcode::kSin: case HloOpcode::kSort: case HloOpcode::kTanh: CHECK_EQ(new_operands.size(), 1); clone = CreateUnary(shape, opcode_, new_operands[0]); break; // Binary ops. case HloOpcode::kAdd: case HloOpcode::kDivide: case HloOpcode::kMultiply: case HloOpcode::kSubtract: case HloOpcode::kEq: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kLe: case HloOpcode::kLt: case HloOpcode::kNe: case HloOpcode::kDot: case HloOpcode::kMaximum: case HloOpcode::kMinimum: case HloOpcode::kPower: case HloOpcode::kRemainder: case HloOpcode::kAnd: case HloOpcode::kOr: case HloOpcode::kShiftLeft: case HloOpcode::kShiftRightArithmetic: case HloOpcode::kShiftRightLogical: CHECK_EQ(new_operands.size(), 2); clone = CreateBinary(shape, opcode_, new_operands[0], new_operands[1]); break; // Ternary ops. case HloOpcode::kClamp: case HloOpcode::kSelect: CHECK_EQ(new_operands.size(), 3); clone = CreateTernary(shape, opcode_, new_operands[0], new_operands[1], new_operands[2]); break; // Other supported ops. case HloOpcode::kBroadcast: CHECK_EQ(new_operands.size(), 1); clone = CreateBroadcast(shape, new_operands[0], dimensions_); break; case HloOpcode::kCall: clone = CreateCall(shape, new_operands, to_apply()); break; case HloOpcode::kCustomCall: clone = CreateCustomCall(shape, new_operands, custom_call_target_); break; case HloOpcode::kConcatenate: clone = CreateConcatenate(shape, new_operands, dimensions(0)); break; case HloOpcode::kConvert: CHECK_EQ(new_operands.size(), 1); clone = CreateConvert(shape, new_operands[0]); break; case HloOpcode::kReducePrecision: CHECK_EQ(new_operands.size(), 1); clone = CreateReducePrecision(shape, new_operands[0], exponent_bits_, mantissa_bits_); break; case HloOpcode::kConvolution: CHECK_EQ(new_operands.size(), 2); clone = CreateConvolve(shape, new_operands[0], new_operands[1], *window_, *convolution_dimension_numbers_); break; case HloOpcode::kCrossReplicaSum: CHECK_EQ(new_operands.size(), 1); clone = CreateCrossReplicaSum(shape, new_operands[0]); break; case HloOpcode::kGetTupleElement: CHECK_EQ(new_operands.size(), 1); clone = CreateGetTupleElement(shape, new_operands[0], tuple_index()); break; case HloOpcode::kMap: clone = CreateMap(shape, new_operands, to_apply()); break; case HloOpcode::kPad: CHECK_EQ(new_operands.size(), 2); clone = CreatePad(shape, new_operands[0], new_operands[1], *padding_config_); break; case HloOpcode::kReduce: CHECK_EQ(new_operands.size(), 2); clone = CreateReduce(shape, new_operands[0], new_operands[1], dimensions_, to_apply()); break; case HloOpcode::kReduceWindow: CHECK_EQ(new_operands.size(), 2); clone = CreateReduceWindow(shape, new_operands[0], new_operands[1], *window_, to_apply()); break; case HloOpcode::kSelectAndScatter: CHECK_EQ(new_operands.size(), 3); clone = CreateSelectAndScatter(shape, new_operands[0], select(), *window_, new_operands[1], new_operands[2], scatter()); break; case HloOpcode::kReverse: CHECK_EQ(new_operands.size(), 1); clone = CreateReverse(shape, new_operands[0], dimensions_); break; case HloOpcode::kRng: clone = CreateRng(shape, distribution_, new_operands); break; case HloOpcode::kReshape: CHECK_EQ(new_operands.size(), 1); clone = CreateReshape(shape, new_operands[0]); break; case HloOpcode::kSlice: CHECK_EQ(new_operands.size(), 1); clone = CreateSlice(shape, new_operands[0], slice_starts_, slice_limits_, slice_strides_); break; case HloOpcode::kDynamicSlice: clone = CreateDynamicSlice(shape, new_operands[0], new_operands[1], dynamic_slice_sizes_); break; case HloOpcode::kDynamicUpdateSlice: CHECK_EQ(new_operands.size(), 3); clone = CreateDynamicUpdateSlice(shape, new_operands[0], new_operands[1], new_operands[2]); break; case HloOpcode::kTranspose: CHECK_EQ(new_operands.size(), 1); clone = CreateTranspose(shape, new_operands[0], dimensions_); break; case HloOpcode::kTuple: clone = CreateTuple(new_operands); *clone->mutable_shape() = shape; break; case HloOpcode::kWhile: CHECK_EQ(new_operands.size(), 1); clone = CreateWhile(shape, while_condition(), while_body(), new_operands[0]); break; case HloOpcode::kConstant: clone = CreateConstant(literal_->CloneToUnique()); break; case HloOpcode::kFusion: clone = CloneFusionWithNewOperands(shape, new_operands); break; case HloOpcode::kParameter: clone = CreateParameter(parameter_number_, shape, parameter_name_); break; case HloOpcode::kBatchNormTraining: CHECK_EQ(new_operands.size(), 3); clone = CreateBatchNormTraining(shape, new_operands[0], new_operands[1], new_operands[2], epsilon(), feature_index()); break; case HloOpcode::kBatchNormInference: CHECK_EQ(new_operands.size(), 5); clone = CreateBatchNormInference( shape, new_operands[0], new_operands[1], new_operands[2], new_operands[3], new_operands[4], epsilon(), feature_index()); break; case HloOpcode::kInfeed: CHECK_EQ(new_operands.size(), 0); clone = CreateInfeed(shape, infeed_config()); break; case HloOpcode::kOutfeed: CHECK_EQ(new_operands.size(), 1); clone = CreateOutfeed(outfeed_shape_, new_operands[0], outfeed_config()); break; case HloOpcode::kBatchNormGrad: CHECK_EQ(new_operands.size(), 5); clone = CreateBatchNormGrad(shape, new_operands[0], new_operands[1], new_operands[2], new_operands[3], new_operands[4], epsilon(), feature_index()); break; case HloOpcode::kRecv: case HloOpcode::kSend: case HloOpcode::kUpdate: case HloOpcode::kIndex: case HloOpcode::kTrace: LOG(FATAL) << "Not yet implemented, clone: " << HloOpcodeString(opcode_); } clone->set_metadata(metadata_); return clone; } HloInstruction::~HloInstruction() {} std::unique_ptr<HloInstruction> HloInstruction::Clone( const string& suffix) const { std::unique_ptr<HloInstruction> clone = CloneWithNewOperands(shape_, operands_); if (suffix.empty()) { clone->name_ = name(); } else { // If an instruction is cloned multiple times avoid names like // foo.suffix.suffix.suffix. Instead of repeating the suffix add a numeric // suffix. Specifically, the clone of foo.suffix is named foo.suffix2, the // clone of foo.suffix2 is named foo.suffix3 and so on. const string dot_suffix = "." + suffix; size_t index = name().rfind(dot_suffix); if (index == string::npos) { // Existing name does not include ".suffix". clone->name_ = name() + dot_suffix; } else { // Existing name includes ".suffix". Determine if substring after // ".suffix" is numeric and should be replaced with an incremented number. string after_suffix = name().substr(index + dot_suffix.size()); if (after_suffix.empty()) { // Existing name ends in ".suffix". New name should end in ".suffix2". clone->name_ = name() + "2"; } else { // If names ends with .suffix[0-9]+ then replace with a suffix with the // numeric value incremented. int64 numeric_suffix; if (tensorflow::strings::safe_strto64(after_suffix, &numeric_suffix)) { clone->name_ = StrCat(name().substr(0, index), dot_suffix, numeric_suffix + 1); } else { // Substring after ".suffix" is non-numeric. clone->name_ = name() + dot_suffix; } } } } clone->set_parent(parent_); return clone; } std::unique_ptr<HloInstruction> HloInstruction::CloneFusionWithNewOperands( const Shape& shape, tensorflow::gtl::ArraySlice<HloInstruction*> operands) const { CHECK_EQ(opcode_, HloOpcode::kFusion); CHECK(parent() != nullptr); auto new_instruction = WrapUnique(new HloInstruction(HloOpcode::kFusion, shape)); // Add the operands to our new fusion instruction. for (HloInstruction* new_operand : operands) { new_instruction->AppendOperand(new_operand); } // Clone all the fused instructions for the new fusion instruction. std::map<HloInstruction*, HloInstruction*> old_to_new; std::list<std::unique_ptr<HloInstruction>> new_fused_instructions; // Create the list of fused parameters by mapping through the cloned, // fused instructions. for (HloInstruction* old_fused_parameter : fused_instructions_computation()->parameter_instructions()) { new_fused_instructions.push_back(old_fused_parameter->Clone()); HloInstruction* new_fusion_parameter = new_fused_instructions.back().get(); InsertOrDie(&old_to_new, old_fused_parameter, new_fusion_parameter); } for (auto old_fused_instruction : fused_instructions_computation()->MakeInstructionPostOrder()) { if (old_fused_instruction->opcode() == HloOpcode::kParameter) { FindOrDie(old_to_new, old_fused_instruction); continue; } std::vector<HloInstruction*> new_operands; for (int64 operand_idx = 0; operand_idx < old_fused_instruction->operand_count(); ++operand_idx) { HloInstruction* old_operand = old_fused_instruction->mutable_operand(operand_idx); new_operands.push_back(FindOrDie(old_to_new, old_operand)); } new_fused_instructions.push_back( old_fused_instruction->CloneWithNewOperands( old_fused_instruction->shape(), new_operands)); HloInstruction* new_fused_instruction = new_fused_instructions.back().get(); new_fused_instruction->set_parent(parent_); InsertOrDie(&old_to_new, old_fused_instruction, new_fused_instruction); } new_instruction->fusion_kind_ = fusion_kind_; auto computation_builder = HloComputation::Builder( fused_instructions_computation()->name() + ".clone", new_instruction.get()); // We iterated the fusion instructions in reverse post order which means // that we must reverse our new list of fusion instructions. for (auto new_fused_instruction_iter = new_fused_instructions.rbegin(); new_fused_instruction_iter != new_fused_instructions.rend(); ++new_fused_instruction_iter) { computation_builder.AddInstruction(std::move(*new_fused_instruction_iter)); } auto fused_root_ = fused_expression_root(); new_instruction->called_computations_.push_back( CHECK_NOTNULL(GetModule()) ->AddEmbeddedComputation( computation_builder.Build(FindOrDie(old_to_new, fused_root_)))); new_instruction->set_parent(parent_); return new_instruction; } std::pair<const HloInstruction*, ShapeIndex> HloInstruction::LatestNonGteAncestorAndIndex() const { const HloInstruction* hlo = this; ShapeIndex index; while (hlo->opcode() == HloOpcode::kGetTupleElement) { index.push_back(hlo->tuple_index()); hlo = hlo->operand(0); } // We built up index in the reverse order from what we want. std::reverse(index.begin(), index.end()); return {hlo, index}; } const HloInstruction* HloInstruction::LatestNonGteAncestor() const { const HloInstruction* hlo = this; while (hlo->opcode() == HloOpcode::kGetTupleElement) { hlo = hlo->operand(0); } return hlo; } const Literal& HloInstruction::literal() const { CHECK_EQ(HloOpcode::kConstant, opcode_); return *literal_; } bool HloInstruction::CanHaveDimensionsField() const { return (opcode() == HloOpcode::kReverse || opcode() == HloOpcode::kConcatenate || opcode() == HloOpcode::kReduce || opcode() == HloOpcode::kBroadcast || opcode() == HloOpcode::kTranspose); } const std::vector<int64>& HloInstruction::dimensions() const { CHECK(CanHaveDimensionsField()); return dimensions_; } int64 HloInstruction::dimensions(int64 index) const { return dimensions()[index]; } int64 HloInstruction::concatenate_dimension() const { CHECK(opcode() == HloOpcode::kConcatenate); CHECK_EQ(1, dimensions_.size()); return dimensions(0); } int64 HloInstruction::tuple_index() const { CHECK_EQ(HloOpcode::kGetTupleElement, opcode_); return tuple_index_; } const HloInstruction* HloInstruction::operand(int64 i) const { return operands_[i]; } HloInstruction* HloInstruction::mutable_operand(int64 i) { CHECK(operands_[i] != nullptr); return operands_[i]; } int64 HloInstruction::operand_index(const HloInstruction* target) const { for (int64 i = 0; i < operand_count(); ++i) { if (target == operand(i)) { return i; } } LOG(FATAL) << "target was not an operand"; } Status HloInstruction::AddControlDependencyTo(HloInstruction* instruction) { TF_RET_CHECK(instruction->parent() == parent()); if (std::find(control_successors_.begin(), control_successors_.end(), instruction) == control_successors_.end()) { control_successors_.push_back(instruction); TF_RET_CHECK(std::find(instruction->control_predecessors_.begin(), instruction->control_predecessors_.end(), this) == instruction->control_predecessors_.end()); instruction->control_predecessors_.push_back(this); } return Status::OK(); } Status HloInstruction::RemoveControlDependencyTo(HloInstruction* instruction) { auto succ_it = std::find(control_successors_.begin(), control_successors_.end(), instruction); TF_RET_CHECK(succ_it != control_successors_.end()); control_successors_.erase(succ_it); auto pred_it = std::find(instruction->control_predecessors_.begin(), instruction->control_predecessors_.end(), this); TF_RET_CHECK(pred_it != instruction->control_predecessors_.end()); instruction->control_predecessors_.erase(pred_it); return Status::OK(); } void HloInstruction::AppendOperand(HloInstruction* operand) { operands_.push_back(operand); operand->AddUser(this); } void HloInstruction::AddUser(HloInstruction* user) { if (!ContainsKey(user_set_, user)) { user_set_.insert(user); users_.push_back(user); } } bool HloInstruction::IsConstant() const { return opcode_ == HloOpcode::kConstant; } bool HloInstruction::HasConstantOperand() const { for (const HloInstruction* operand : operands_) { if (operand->IsConstant()) { return true; } } return false; } bool HloInstruction::IdenticalSlowPath( const HloInstruction& other, std::function<bool(const HloComputation*, const HloComputation*)> eq_computations) const { // Perform opcode specific checks. switch (opcode()) { // The result of these instructions only depend upon their opcode and // operands. case HloOpcode::kAbs: case HloOpcode::kRoundNearestAfz: case HloOpcode::kAdd: case HloOpcode::kCeil: case HloOpcode::kClamp: case HloOpcode::kCopy: case HloOpcode::kCos: case HloOpcode::kCrossReplicaSum: case HloOpcode::kDivide: case HloOpcode::kDot: case HloOpcode::kEq: case HloOpcode::kExp: case HloOpcode::kFloor: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kIsFinite: case HloOpcode::kLe: case HloOpcode::kLog: case HloOpcode::kAnd: case HloOpcode::kNot: case HloOpcode::kOr: case HloOpcode::kLt: case HloOpcode::kMaximum: case HloOpcode::kMinimum: case HloOpcode::kMultiply: case HloOpcode::kNe: case HloOpcode::kNegate: case HloOpcode::kPower: case HloOpcode::kRemainder: case HloOpcode::kSelect: case HloOpcode::kShiftLeft: case HloOpcode::kShiftRightArithmetic: case HloOpcode::kShiftRightLogical: case HloOpcode::kSign: case HloOpcode::kSin: case HloOpcode::kSubtract: case HloOpcode::kTanh: case HloOpcode::kTuple: return true; // These opcodes have complex or special behavior so just return false. case HloOpcode::kFusion: case HloOpcode::kRng: case HloOpcode::kTrace: case HloOpcode::kWhile: return false; case HloOpcode::kParameter: return parameter_number() == other.parameter_number() && // Check the shape too because `this` and `other` may be in // different HloComputations. ShapeUtil::Compatible(shape(), other.shape()); case HloOpcode::kBatchNormTraining: case HloOpcode::kBatchNormInference: case HloOpcode::kBatchNormGrad: return feature_index() == other.feature_index() && epsilon() == other.epsilon(); // A constant is defined by the value in the literal. case HloOpcode::kConstant: return literal() == other.literal(); // A convert result is determined by the primitive type that the operand is // converted into. case HloOpcode::kConvert: return shape().element_type() == other.shape().element_type(); // A reduce-precision operation is determined by the bit sizes. case HloOpcode::kReducePrecision: return exponent_bits() == other.exponent_bits() && mantissa_bits() == other.mantissa_bits(); // Convolution has a window and dimensions. case HloOpcode::kConvolution: return protobuf_util::ProtobufEquals(window(), other.window()) && protobuf_util::ProtobufEquals( convolution_dimension_numbers(), other.convolution_dimension_numbers()); // Reduction results are determined by the reduction dimension and the // reduction computation. case HloOpcode::kReduce: return dimensions() == other.dimensions() && eq_computations(to_apply(), other.to_apply()); case HloOpcode::kReduceWindow: return eq_computations(to_apply(), other.to_apply()) && protobuf_util::ProtobufEquals(window(), other.window()); // SelectAndScatter is determined by both select and scatter // computation as well as the window configuration. case HloOpcode::kSelectAndScatter: return eq_computations(select(), other.select()) && eq_computations(scatter(), other.scatter()) && protobuf_util::ProtobufEquals(window(), other.window()); case HloOpcode::kReshape: return ShapeUtil::Compatible(shape(), other.shape()); // Transpose result is determined by the final shape and the permutation. case HloOpcode::kTranspose: return ShapeUtil::Compatible(shape(), other.shape()) && dimensions() == other.dimensions(); // Remaining instructions with special values. case HloOpcode::kBitcast: return ShapeUtil::Equal(shape(), other.shape()); case HloOpcode::kBroadcast: return ShapeUtil::Compatible(shape(), other.shape()) && dimensions() == other.dimensions(); case HloOpcode::kConcatenate: return dimensions() == other.dimensions(); case HloOpcode::kGetTupleElement: return tuple_index() == other.tuple_index(); case HloOpcode::kPad: return protobuf_util::ProtobufEquals(padding_config(), other.padding_config()); case HloOpcode::kSlice: return slice_starts_ == other.slice_starts_ && slice_limits_ == other.slice_limits_; case HloOpcode::kDynamicSlice: return ShapeUtil::Compatible(shape(), other.shape()) && dynamic_slice_sizes_ == other.dynamic_slice_sizes_; case HloOpcode::kDynamicUpdateSlice: return ShapeUtil::Compatible(shape(), other.shape()); case HloOpcode::kCall: case HloOpcode::kMap: return eq_computations(to_apply(), other.to_apply()); case HloOpcode::kCustomCall: return custom_call_target_ == other.custom_call_target_; case HloOpcode::kReverse: return dimensions() == other.dimensions(); // These opcodes are not yet supported. case HloOpcode::kIndex: case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kSort: case HloOpcode::kUpdate: case HloOpcode::kSend: case HloOpcode::kRecv: return false; } } bool HloInstruction::IsRank2Transpose() const { return (opcode_ == HloOpcode::kTranspose) && dimensions_ == std::vector<int64>({1, 0}) && shape_.dimensions_size() == 2 && std::equal(shape_.dimensions().begin(), shape_.dimensions().end(), operands_[0]->shape_.dimensions().rbegin()); } void HloInstruction::RemoveUser(HloInstruction* user) { auto set_it = user_set_.find(user); CHECK(set_it != user_set_.end()); user_set_.erase(set_it); // This is linear in the number of the users, but a vector provides a stable // iteration order and much faster traversal. auto vec_it = std::find(users_.begin(), users_.end(), user); CHECK(vec_it != users_.end()); users_.erase(vec_it); } Status HloInstruction::ReplaceUseWith(HloInstruction* user, HloInstruction* new_producer) { TF_RET_CHECK(ShapeUtil::Compatible(shape(), new_producer->shape())) << "this shape: " << ShapeUtil::HumanString(shape()) << ", replacement shape: " << ShapeUtil::HumanString(new_producer->shape()); VLOG(3) << "Replacing uses of " << name() << " in " << user->name() << " with " << new_producer->name(); RemoveUser(user); TF_RET_CHECK( std::count(user->operands_.begin(), user->operands_.end(), this) >= 0); std::replace(user->operands_.begin(), user->operands_.end(), this, new_producer); new_producer->AddUser(user); return Status::OK(); } Status HloInstruction::ReplaceOperandWith(int64 operand_num, HloInstruction* new_operand) { TF_RET_CHECK(operand_num >= 0); TF_RET_CHECK(operand_num < operand_count()); HloInstruction* old_operand = mutable_operand(operand_num); TF_RET_CHECK( ShapeUtil::Compatible(old_operand->shape(), new_operand->shape())) << old_operand->shape().ShortDebugString() << " is not compatible with " << new_operand->shape().ShortDebugString(); operands_[operand_num] = new_operand; VLOG(3) << "Replacing operand " << operand_num << " of " << name() << " with " << new_operand->name() << ", was " << old_operand->name(); if (std::find(operands_.begin(), operands_.end(), old_operand) == operands_.end()) { old_operand->RemoveUser(this); } new_operand->AddUser(this); return Status::OK(); } Status HloInstruction::ReplaceAllUsesWith(HloInstruction* new_producer) { bool new_producer_is_user = false; for (HloInstruction* user : users()) { if (user == new_producer) { // It's possible that new_producer is a user of this instruction as might // be the case when replacing an instruction with a kCopy of itself. In // this case, don't do the replacement to avoid creating a cycle in the // graph. new_producer remains the only user of this instruction. new_producer_is_user = true; } else { std::replace(user->operands_.begin(), user->operands_.end(), this, new_producer); new_producer->AddUser(user); } } users_.clear(); user_set_.clear(); if (new_producer_is_user) { AddUser(new_producer); } if (parent_ && parent_->root_instruction() == this) { parent_->set_root_instruction(new_producer); } return Status::OK(); } void HloInstruction::DetachFromOperands() { VLOG(3) << "DetachFromOperands:\n " << ToString(); CHECK_EQ(0, user_count()); // An instruction may be repeated as an operand. To avoid calling RemoveUser // twice on the same operand, keep a set of already detached operands. std::set<HloInstruction*> detached_operands; for (int64 operand_num = 0; operand_num < operand_count(); ++operand_num) { HloInstruction* operand = operands_[operand_num]; if (!ContainsKey(detached_operands, operand)) { operand->RemoveUser(this); detached_operands.insert(operand); } operands_[operand_num] = nullptr; } } HloComputation* HloInstruction::to_apply() const { switch (opcode_) { case HloOpcode::kCall: case HloOpcode::kMap: case HloOpcode::kReduceWindow: case HloOpcode::kReduce: CHECK_EQ(called_computations_.size(), 1); return called_computations_[0]; default: LOG(FATAL) << "Invalid opcode for to_apply(): " << HloOpcodeString(opcode()); } } void HloInstruction::set_to_apply(HloComputation* computation) { // Don't allow changing the computation for fused instructions so we don't // have to recompute called_instructions for the entire fusion instruction. CHECK(!IsFused()); switch (opcode_) { case HloOpcode::kCall: case HloOpcode::kMap: case HloOpcode::kReduceWindow: case HloOpcode::kReduce: CHECK_EQ(called_computations_.size(), 1); called_computations_[0] = computation; break; default: LOG(FATAL) << "Invalid opcode for to_apply(): " << HloOpcodeString(opcode()); } } const string& HloInstruction::custom_call_target() const { CHECK_EQ(opcode_, HloOpcode::kCustomCall); return custom_call_target_; } const string& HloInstruction::outfeed_config() const { CHECK_EQ(opcode_, HloOpcode::kOutfeed); return outfeed_config_; } HloComputation* HloInstruction::while_condition() const { CHECK_EQ(HloOpcode::kWhile, opcode_); return called_computations_[kConditionComputationIndex]; } HloComputation* HloInstruction::while_body() const { CHECK_EQ(HloOpcode::kWhile, opcode_); return called_computations_[kBodyComputationIndex]; } void HloInstruction::set_while_condition(HloComputation* computation) { // Don't allow changing the computation for fused instructions so we don't // have to recompute called_instructions for the entire fusion instruction. CHECK(!IsFused()); CHECK_EQ(HloOpcode::kWhile, opcode_); called_computations_[kConditionComputationIndex] = computation; } void HloInstruction::set_while_body(HloComputation* computation) { // Don't allow changing the computation for fused instructions so we don't // have to recompute called_instructions for the entire fusion instruction. CHECK(!IsFused()); CHECK_EQ(HloOpcode::kWhile, opcode_); called_computations_[kBodyComputationIndex] = computation; } HloComputation* HloInstruction::select() const { CHECK_EQ(HloOpcode::kSelectAndScatter, opcode_); return called_computations_[kSelectComputationIndex]; } HloComputation* HloInstruction::scatter() const { CHECK_EQ(HloOpcode::kSelectAndScatter, opcode_); return called_computations_[kScatterComputationIndex]; } void HloInstruction::set_select(HloComputation* computation) { // Don't allow changing the computation for fused instructions so we don't // have to recompute called_instructions for the entire fusion instruction. CHECK(!IsFused()); CHECK_EQ(HloOpcode::kSelectAndScatter, opcode_); called_computations_[kSelectComputationIndex] = computation; } void HloInstruction::set_scatter(HloComputation* computation) { // Don't allow changing the computation for fused instructions so we don't // have to recompute called_instructions for the entire fusion instruction. CHECK(!IsFused()); CHECK_EQ(HloOpcode::kSelectAndScatter, opcode_); called_computations_[kScatterComputationIndex] = computation; } string HloInstruction::SignatureString() const { string operands = Join(operands_, ", ", [](string* out, HloInstruction* operand) { StrAppend(out, ShapeUtil::HumanString(operand->shape())); }); return StrCat("(", operands, ") -> ", ShapeUtil::HumanString(shape())); } string HloInstruction::ExtendedOpcodeStr() const { string opc_name = HloOpcodeString(opcode()); HloOpcode opc = opcode(); if (HloOpcode::kFusion == opc) { opc_name += ":" + xla::ToString(fusion_kind()); } return opc_name; } string HloInstruction::ToString(bool compact_operands, bool include_metadata) const { string result = StrCat(name(), " = ", ShapeUtil::HumanStringWithLayout(shape()), " ", ExtendedOpcodeStr(), "(", OperandsToString(compact_operands), ")"); for (const string& extra : ExtraAttributesToString()) { StrAppend(&result, ", ", extra); } if (include_metadata && (!metadata_.op_type().empty() || !metadata_.op_name().empty() || !metadata_.source_file().empty())) { StrAppend(&result, " # metadata=", metadata_.ShortDebugString()); } return result; } string HloInstruction::OperandsToString(bool compact) const { string operands; if (opcode() == HloOpcode::kConstant) { // For constants, show the actual value in place of an empty operand list. if (!ShapeUtil::IsTuple(shape()) && ShapeUtil::ElementsIn(shape()) <= 10) { // Literal::ToString emits multidimensional arrays over multiple // lines. Compact this into one line by stripping out white space. string tmp = literal().ToString(); std::replace(tmp.begin(), tmp.end(), '\n', ' '); std::vector<string> v = tensorflow::str_util::Split(tmp, ' '); bool first = true; // Concatenate elements in "v" with spaces separating them, but ignoring // empty entries. for (const auto& s : v) { if (s.empty()) { continue; } StrAppend(&operands, (first ? "" : " "), s); first = false; } } else { // Do not show large constants or tuples. operands = "{...}"; } } else if (opcode() == HloOpcode::kParameter) { StrAppend(&operands, parameter_number_); } else { tensorflow::gtl::ArraySlice<HloInstruction*> slice(operands_); const int64 kMaxOperandsToShowIfCompact = 4; if (compact && slice.size() > kMaxOperandsToShowIfCompact) { slice.remove_suffix(slice.size() - kMaxOperandsToShowIfCompact); } operands = Join(slice, ", ", [&](string* out, HloInstruction* operand) { *out += ShapeUtil::HumanStringWithLayout(operand->shape()); if (!compact) { StrAppend(out, " ", operand->name()); } }); const int64 remaining = operands_.size() - slice.size(); if (slice.size() != operands_.size()) { StrAppend(&operands, ", ...(+", remaining, ")"); } } return operands; } std::vector<string> HloInstruction::ExtraAttributesToString() const { std::vector<string> extra; if (CanHaveDimensionsField()) { extra.push_back(StrCat("dimensions={", Join(dimensions(), ","), "}")); } if (window_ != nullptr) { extra.push_back(window_util::ToString(*window_)); } if (padding_config_ != nullptr) { extra.push_back(StrCat("padding=", padding_config_->ShortDebugString())); } if (!slice_starts_.empty() && !slice_limits_.empty()) { std::vector<string> bounds; bounds.reserve(slice_starts_.size()); const bool omit_stride = std::all_of(slice_strides_.begin(), slice_strides_.end(), [](int64 stride) { return stride == 1; }); for (int i = 0; i < slice_starts_.size(); ++i) { string stride_str = omit_stride ? "" : StrCat(":", slice_strides_[i]); bounds.push_back(StrCat("[", slice_starts_[i], ":", slice_limits_[i], stride_str, "]")); } extra.push_back(StrCat("slice={", Join(bounds, ", "), "}")); } if (convolution_dimension_numbers_ != nullptr) { extra.push_back(ConvolutionDimensionNumbersToString()); } if (opcode() == HloOpcode::kWhile) { extra.push_back(StrCat("condition=%", while_condition()->name())); extra.push_back(StrCat("body=%", while_body()->name())); } else if (opcode() == HloOpcode::kSelectAndScatter) { extra.push_back(StrCat("select=%", select()->name())); extra.push_back(StrCat("scatter=%", scatter()->name())); } else if (opcode() == HloOpcode::kCall || opcode() == HloOpcode::kMap || opcode() == HloOpcode::kReduceWindow || opcode() == HloOpcode::kReduce) { extra.push_back(StrCat("to_apply=%", to_apply()->name())); } else if (!called_computations().empty()) { extra.push_back(StrCat( "calls=", Join(called_computations(), ", ", [](string* out, const HloComputation* computation) { StrAppend(out, "%", computation->name()); }))); } if (opcode() == HloOpcode::kSend || opcode() == HloOpcode::kRecv) { extra.push_back(StrCat("channel_id=", channel_id_)); } if (opcode() == HloOpcode::kGetTupleElement) { extra.push_back(StrCat("index=", tuple_index())); } if (device_assignment_.has_device()) { extra.push_back(StrCat("device=", device_assignment_.device())); } if (!control_successors_.empty()) { extra.push_back(StrCat( "control-successors=", Join(control_successors_, ", ", [](string* out, HloInstruction* succ) { StrAppend(out, succ->name()); }))); } return extra; } string HloInstruction::ToShortString() const { return StrCat(name(), " = ", HloOpcodeString(opcode()), "(", Join(operands_, ", ", [](string* out, HloInstruction* operand) { StrAppend(out, operand->name()); }), ")"); } HloInstructionProto HloInstruction::ToProto() const { HloInstructionProto proto; proto.set_name(name_); proto.set_opcode(HloOpcodeString(opcode_)); *proto.mutable_shape() = shape_; for (const HloInstruction* operand : operands_) { *proto.add_operand_names() = operand->name(); } for (const HloInstruction* control : control_predecessors_) { *proto.add_control_predecessor_names() = control->name(); } *proto.mutable_metadata() = metadata_; if (literal_ != nullptr) { *proto.mutable_literal() = literal_->ToProto(); } proto.set_parameter_number(parameter_number_); proto.set_parameter_name(parameter_name_); if (opcode() == HloOpcode::kFusion) { proto.set_fusion_kind(xla::ToString(fusion_kind())); *proto.mutable_fused_instructions_computation() = fused_instructions_computation()->ToProto(); } else { for (const HloComputation* computation : called_computations_) { *proto.add_called_computation_names() = computation->name(); } } proto.set_tuple_index(tuple_index_); for (int64 dimension : dimensions_) { proto.add_dimensions(dimension); } if (window_ != nullptr) { *proto.mutable_window() = *window_; } if (convolution_dimension_numbers_ != nullptr) { *proto.mutable_convolution_dimension_numbers() = *convolution_dimension_numbers_; } for (int i = 0; i < slice_starts_.size(); ++i) { auto* slice_dimension = proto.add_slice_dimensions(); slice_dimension->set_start(slice_starts_[i]); slice_dimension->set_limit(slice_limits_[i]); slice_dimension->set_stride(slice_strides_[i]); } proto.set_exponent_bits(exponent_bits_); proto.set_mantissa_bits(mantissa_bits_); for (int64 slice_size : dynamic_slice_sizes_) { proto.add_dynamic_slice_sizes(slice_size); } if (padding_config_ != nullptr) { *proto.mutable_padding_config() = *padding_config_; } proto.set_outfeed_config(outfeed_config_); if (opcode() == HloOpcode::kRng) { proto.set_distribution(distribution_); } proto.set_epsilon(epsilon_); proto.set_feature_index(feature_index_); proto.set_channel_id(channel_id_); proto.set_infeed_config(infeed_config_); proto.set_custom_call_target(custom_call_target_); *proto.mutable_outfeed_shape() = outfeed_shape_; return proto; } string HloInstruction::ToCategory() const { if (opcode() == HloOpcode::kTranspose || opcode() == HloOpcode::kCopy || opcode() == HloOpcode::kReshape) { return "data formatting"; } if (opcode() == HloOpcode::kConvolution) { string category = "convolution"; if (window_util::HasBaseDilation(window())) { category += " base-dilated"; } if (window_util::HasWindowDilation(window())) { category += " window-dilated"; } return category; } if (opcode() == HloOpcode::kFusion) { if (operands().size() == 2) { bool saw_rank_1 = false; bool saw_higher_rank = false; for (const auto* operand : operands()) { saw_rank_1 |= ShapeUtil::Rank(operand->shape()) == 1; saw_higher_rank |= ShapeUtil::Rank(operand->shape()) > 1; } if (saw_rank_1 && saw_higher_rank) { return "rank-1-broadcast binary fusion"; } } switch (fusion_kind()) { case FusionKind::kLoop: if (IsElementwise()) { return "elementwise fusion"; } else { return "non-elementwise fusion"; } case FusionKind::kInput: return "input fusion"; case FusionKind::kOutput: return "output fusion"; case FusionKind::kTransposeDot: return "dot fusion"; case FusionKind::kConvBackwardFilter: case FusionKind::kConvBackwardInput: return "convolution fusion"; case FusionKind::kCustom: return "custom fusion"; } } if (IsElementwise() && opcode() != HloOpcode::kFusion) { return "non-fusion elementwise"; } return HloOpcodeString(opcode()); } HloInstruction* HloInstruction::tracing() const { return trace_instruction_; } void HloInstruction::set_tracing(HloInstruction* trace_instruction) { trace_instruction_ = trace_instruction; } string HloInstruction::TracingTag() const { CHECK_EQ(HloOpcode::kTrace, opcode()); CHECK(literal_ != nullptr); return literal_->u8s_string(); } bool HloInstruction::IsFused() const { return parent_->IsFusionComputation(); } bool HloInstruction::IsFusable() const { // Instructions which are traced should not be fused. if (tracing()) { return false; } // Some kinds of instructions don't make sense to fuse. switch (opcode_) { case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kParameter: case HloOpcode::kTrace: case HloOpcode::kSend: case HloOpcode::kRecv: return false; // Only fuse Rng if it is used once, otherwise the random numbers generated // will be different in each fusion. If it is the root (user count = 0) // then it is the equivalent of having one user. case HloOpcode::kRng: return users_.size() <= 1; default: return true; } } HloComputation* HloInstruction::fused_instructions_computation() const { CHECK_EQ(opcode_, HloOpcode::kFusion); CHECK(!called_computations_.empty()); auto* fused_instructions_computation = called_computations_.front(); CHECK(fused_instructions_computation->IsFusionComputation()); return fused_instructions_computation; } HloInstruction* HloInstruction::fused_expression_root() const { CHECK_EQ(opcode_, HloOpcode::kFusion); return fused_instructions_computation()->root_instruction(); } HloInstruction* HloInstruction::fused_parameter(int64 parameter_number) const { CHECK_EQ(opcode_, HloOpcode::kFusion); return fused_instructions_computation()->parameter_instruction( parameter_number); } const std::vector<HloInstruction*>& HloInstruction::fused_parameters() const { CHECK_EQ(opcode_, HloOpcode::kFusion); return fused_instructions_computation()->parameter_instructions(); } const tensorflow::gtl::iterator_range<UnwrappingIterator< std::list<std::unique_ptr<HloInstruction>>::const_iterator>> HloInstruction::fused_instructions() const { CHECK_EQ(opcode_, HloOpcode::kFusion); const HloComputation* subcomp = fused_instructions_computation(); return subcomp->instructions(); } const tensorflow::gtl::iterator_range< UnwrappingIterator<std::list<std::unique_ptr<HloInstruction>>::iterator>> HloInstruction::fused_instructions() { CHECK_EQ(opcode_, HloOpcode::kFusion); return fused_instructions_computation()->instructions(); } int64 HloInstruction::fused_instruction_count() const { return fused_instructions_computation()->instruction_count(); } HloInstruction::HloInstruction(HloOpcode opcode, const Shape& shape) : unique_id_(-1), opcode_(opcode), shape_(shape), name_("%" + HloOpcodeString(opcode)) { TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(shape_)); } Status HloInstruction::Visit(DfsHloVisitor* visitor) { switch (opcode_) { case HloOpcode::kAbs: return visitor->HandleAbs(this, operands_[0]); case HloOpcode::kRoundNearestAfz: return visitor->HandleRound(this); case HloOpcode::kBatchNormTraining: return visitor->HandleBatchNormTraining(this); case HloOpcode::kBatchNormInference: return visitor->HandleBatchNormInference(this); case HloOpcode::kBatchNormGrad: return visitor->HandleBatchNormGrad(this); case HloOpcode::kSign: return visitor->HandleSign(this, operands_[0]); case HloOpcode::kConstant: return visitor->HandleConstant(this, *literal_); case HloOpcode::kGetTupleElement: return visitor->HandleGetTupleElement(this, operands_[0]); case HloOpcode::kParameter: return visitor->HandleParameter(this); case HloOpcode::kEq: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kLe: case HloOpcode::kLt: case HloOpcode::kNe: return visitor->HandleCompare(this, opcode_, operands_[0], operands_[1]); case HloOpcode::kAdd: return visitor->HandleAdd(this, operands_[0], operands_[1]); case HloOpcode::kDivide: return visitor->HandleDivide(this, operands_[0], operands_[1]); case HloOpcode::kSubtract: return visitor->HandleSubtract(this, operands_[0], operands_[1]); case HloOpcode::kMaximum: return visitor->HandleMaximum(this); case HloOpcode::kMinimum: return visitor->HandleMinimum(this); case HloOpcode::kAnd: return visitor->HandleAnd(this, operands_[0], operands_[1]); case HloOpcode::kOr: return visitor->HandleOr(this, operands_[0], operands_[1]); case HloOpcode::kShiftLeft: return visitor->HandleShiftLeft(this, operands_[0], operands_[1]); case HloOpcode::kShiftRightArithmetic: return visitor->HandleShiftRightArithmetic(this, operands_[0], operands_[1]); case HloOpcode::kShiftRightLogical: return visitor->HandleShiftRightLogical(this, operands_[0], operands_[1]); case HloOpcode::kConcatenate: return visitor->HandleConcatenate(this, operands_); case HloOpcode::kConvert: return visitor->HandleConvert(this); case HloOpcode::kCopy: return visitor->HandleCopy(this); case HloOpcode::kMultiply: return visitor->HandleMultiply(this, operands_[0], operands_[1]); case HloOpcode::kDot: return visitor->HandleDot(this, operands_[0], operands_[1]); case HloOpcode::kPower: return visitor->HandlePower(this, operands_[0], operands_[1]); case HloOpcode::kRemainder: return visitor->HandleRemainder(this, operands_[0], operands_[1]); case HloOpcode::kSelect: return visitor->HandleSelect(this, operands_[0], operands_[1], operands_[2]); case HloOpcode::kConvolution: return visitor->HandleConvolution(this, operands_[0], operands_[1], window()); case HloOpcode::kCrossReplicaSum: return visitor->HandleCrossReplicaSum(this); case HloOpcode::kTuple: return visitor->HandleTuple(this, operands_); case HloOpcode::kMap: return visitor->HandleMap(this, operands_, to_apply(), {}); case HloOpcode::kClamp: return visitor->HandleClamp(this, operands_[0], operands_[1], operands_[2]); case HloOpcode::kReduce: return visitor->HandleReduce(this, operands_[0], operands_[1], dimensions_, to_apply()); case HloOpcode::kReduceWindow: return visitor->HandleReduceWindow(this, operands_[0], window(), to_apply()); case HloOpcode::kSelectAndScatter: return visitor->HandleSelectAndScatter(this); case HloOpcode::kNegate: return visitor->HandleNegate(this, operands_[0]); case HloOpcode::kExp: return visitor->HandleExp(this, operands_[0]); case HloOpcode::kFloor: return visitor->HandleFloor(this, operands_[0]); case HloOpcode::kCeil: return visitor->HandleCeil(this, operands_[0]); case HloOpcode::kLog: return visitor->HandleLog(this, operands_[0]); case HloOpcode::kTanh: return visitor->HandleTanh(this, operands_[0]); case HloOpcode::kCos: return visitor->HandleCos(this, operands_[0]); case HloOpcode::kSin: return visitor->HandleSin(this, operands_[0]); case HloOpcode::kIsFinite: return visitor->HandleIsFinite(this, operands_[0]); case HloOpcode::kNot: return visitor->HandleNot(this, operands_[0]); case HloOpcode::kBitcast: return visitor->HandleBitcast(this); case HloOpcode::kBroadcast: return visitor->HandleBroadcast(this); case HloOpcode::kPad: return visitor->HandlePad(this); case HloOpcode::kReshape: return visitor->HandleReshape(this); case HloOpcode::kTranspose: return visitor->HandleTranspose(this); case HloOpcode::kReverse: return visitor->HandleReverse(this, operands_[0]); case HloOpcode::kReducePrecision: return visitor->HandleReducePrecision(this); case HloOpcode::kSlice: return visitor->HandleSlice(this, operands_[0]); case HloOpcode::kDynamicSlice: return visitor->HandleDynamicSlice(this, operands_[0], operands_[1]); case HloOpcode::kDynamicUpdateSlice: return visitor->HandleDynamicUpdateSlice(this, operands_[0], operands_[1], operands_[2]); case HloOpcode::kSort: return visitor->HandleSort(this, operands_[0]); case HloOpcode::kInfeed: return visitor->HandleInfeed(this); case HloOpcode::kOutfeed: return visitor->HandleOutfeed(this); case HloOpcode::kRng: return visitor->HandleRng(this, distribution_); case HloOpcode::kWhile: return visitor->HandleWhile(this); case HloOpcode::kFusion: return visitor->HandleFusion(this); case HloOpcode::kCall: return visitor->HandleCall(this); case HloOpcode::kCustomCall: return visitor->HandleCustomCall(this, operands_, custom_call_target_); case HloOpcode::kSend: return visitor->HandleSend(this); case HloOpcode::kRecv: return visitor->HandleRecv(this); // These opcodes are not handled here. case HloOpcode::kIndex: case HloOpcode::kTrace: case HloOpcode::kUpdate: break; } return Unimplemented("unhandled HloOpcode for DfsHloVisitor: %s", HloOpcodeString(opcode_).c_str()); } using DFSStack = tensorflow::gtl::InlinedVector<std::pair<int, HloInstruction*>, 16>; // Push "child" onto the dfs_stack if not already visited. Returns false if a // cycle was detected, and true otherwise. inline bool PushDFSChild(DfsHloVisitor* visitor, DFSStack* dfs_stack, HloInstruction* child) { CHECK(child != nullptr); const int id = child->unique_id(); CHECK_GE(id, 0) << "instruction may not have a parent computation"; switch (visitor->GetVisitState(id)) { case DfsHloVisitor::kVisiting: return false; case DfsHloVisitor::kVisited: // Nothing to do return true; case DfsHloVisitor::kNotVisited: dfs_stack->push_back(std::make_pair(id, child)); return true; } } using InternalCompareFunction = std::function<bool(std::pair<int, const HloInstruction*>, std::pair<int, const HloInstruction*>)>; static Status PostOrderDFS(HloInstruction* root, DfsHloVisitor* visitor, const InternalCompareFunction* operand_order, bool ignore_control_predecessors) { visitor->ReserveVisitStates(root->GetModule()->NumUniqueInstructionIds()); // dfs_stack holds pairs of <HloInstruction*->unique_id(), HloInstruction*>. // // We need to keep track of both the id and the instruction because // instructions can get deleted while they are on the stack, so we // can't always use the (potentiall dead) instruction object to grab // its id. DFSStack dfs_stack; dfs_stack.emplace_back(root->unique_id(), root); do { DCHECK(!dfs_stack.empty()); int current_id = dfs_stack.back().first; HloInstruction* current_node = dfs_stack.back().second; CHECK_GE(current_id, 0) << current_id << ": " << current_node << ": instruction may not have parent computation"; DfsHloVisitor::VisitState visit_state = visitor->GetVisitState(current_id); if (visit_state == DfsHloVisitor::kVisited) { dfs_stack.pop_back(); VLOG(3) << "Not visiting HLO " << current_node->name() << " as it was already visited."; continue; } if (visit_state == DfsHloVisitor::kVisiting) { dfs_stack.pop_back(); TF_RETURN_IF_ERROR(visitor->Preprocess(current_node)); VLOG(2) << "Visiting HLO " << current_node->name(); TF_RETURN_IF_ERROR(current_node->Visit(visitor)); visitor->SetVisitState(current_id, DfsHloVisitor::kVisited); TF_RETURN_IF_ERROR(visitor->Postprocess(current_node)); continue; } visitor->SetVisitState(current_id, DfsHloVisitor::kVisiting); const size_t old_dfs_stack_size = dfs_stack.size(); for (HloInstruction* child : current_node->operands()) { if (!TF_PREDICT_TRUE(PushDFSChild(visitor, &dfs_stack, child))) { return FailedPrecondition( "A cycle is detected while visiting instruction %s", current_node->ToString().c_str()); } } if (!ignore_control_predecessors) { for (HloInstruction* child : current_node->control_predecessors()) { if (!TF_PREDICT_TRUE(PushDFSChild(visitor, &dfs_stack, child))) { return FailedPrecondition( "A cycle is detected while visiting instruction %s", current_node->ToString().c_str()); } } } if (operand_order != nullptr) { std::sort(dfs_stack.begin() + old_dfs_stack_size, dfs_stack.end(), *operand_order); } // This makes the traversal order the same as what you'd expect // out of a recursive algorithm. std::reverse(dfs_stack.begin() + old_dfs_stack_size, dfs_stack.end()); } while (!dfs_stack.empty()); return Status::OK(); } Status HloInstruction::Accept(DfsHloVisitor* visitor, bool call_finish_visit, bool ignore_control_predecessors) { VLOG(3) << "HloInstruction::Accept(" << name() << ")"; TF_RETURN_IF_ERROR( PostOrderDFS(this, visitor, nullptr, ignore_control_predecessors)); if (call_finish_visit) { TF_RETURN_IF_ERROR(visitor->FinishVisit(this)); } return Status::OK(); } Status HloInstruction::AcceptWithOperandOrder( DfsHloVisitor* visitor, const CompareFunction& operand_order, bool call_finish_visit) { VLOG(2) << "HloInstruction::AcceptWithOperandOrder(" << name() << ")"; InternalCompareFunction func = [&operand_order]( std::pair<int, const HloInstruction*> a, std::pair<int, const HloInstruction*> b) { // Call the client's comparison function on the actual HloInstruction* // objects (ignoring the internal ids we also have in our stack entries) return operand_order(a.second, b.second); }; TF_RETURN_IF_ERROR(PostOrderDFS(this, visitor, &func, /*ignore_control_predecessors=*/false)); if (call_finish_visit) { VLOG(3) << "HloInstruction::AcceptWithOperandOrder BEFORE FINISH VISIT"; TF_RETURN_IF_ERROR(visitor->FinishVisit(this)); VLOG(3) << "HloInstruction::AcceptWithOperandOrder AFTER FINISH VISIT"; } VLOG(2) << "HloInstruction::AcceptWithOperandOrder EXIT"; return Status::OK(); } namespace { // Returns true if the given order is a topological sort of the instructions // it contains. bool OrderIsTopologicalSort(const std::vector<const HloInstruction*>& order) { // Create a map from instruction to its position in 'order'. std::unordered_map<const HloInstruction*, int> order_position; for (int i = 0; i < order.size(); i++) { if (!order_position.insert({order[i], i}).second) { // Instruction order[i] is duplicated in the order. return false; } } // Verify that the operand of each instruction in the order is also in the // order *and* the operand's position is earlier (defs are before uses for // all ops). for (auto* instruction : order) { for (auto* operand : instruction->operands()) { if (!ContainsKey(order_position, operand) || order_position.at(operand) >= order_position.at(instruction)) { return false; } } } return true; } } // namespace Status HloInstruction::Accept( const FunctionVisitor::VisitorFunction& visitor_func) { FunctionVisitor visitor(visitor_func); return this->Accept(&visitor); } Status HloInstruction::AcceptOrdered( DfsHloVisitor* visitor, const std::vector<const HloInstruction*>& order) { VLOG(2) << "HloInstruction::AcceptOrdered(" << name() << ")"; TF_RET_CHECK(OrderIsTopologicalSort(order)); // Compute the predecessors of this instruction. std::unordered_set<const HloInstruction*> predecessors; TF_RETURN_IF_ERROR(this->Accept([&predecessors](HloInstruction* instruction) { predecessors.insert(instruction); return Status::OK(); })); for (auto* const_instruction : order) { if (!ContainsKey(predecessors, const_instruction)) { // Instruction is not a predecessors of 'this'. continue; } // The visitor can mark instructions as visited to skip particular // instructions. if (visitor->DidVisit(*const_instruction)) { VLOG(3) << "Not visiting HLO " << const_instruction->name() << " as it was already visited."; continue; } HloInstruction* instruction = const_cast<HloInstruction*>(const_instruction); TF_RETURN_IF_ERROR(visitor->Preprocess(instruction)); VLOG(2) << "Visiting HLO " << instruction->name(); TF_RETURN_IF_ERROR(instruction->Visit(visitor)); visitor->SetVisited(*instruction); TF_RETURN_IF_ERROR(visitor->Postprocess(instruction)); } return visitor->FinishVisit(this); } const Shape& HloInstruction::outfeed_shape() const { DCHECK_EQ(opcode_, HloOpcode::kOutfeed); TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(shape_)); return outfeed_shape_; } const Shape& HloInstruction::shape() const { TF_DCHECK_OK(ShapeUtil::ValidateShapeWithOptionalLayout(shape_)); return shape_; } std::vector<int64> HloInstruction::OperandIndices( const HloInstruction* operand) const { std::vector<int64> result; for (int64 i = 0; i < operand_count(); ++i) { if (this->operand(i) == operand) { result.push_back(i); } } return result; } bool HloInstruction::IsElementwiseBinary() const { switch (opcode_) { // Binary elementwise operations. If you update this, please update // IsElementwise() accordingly. case HloOpcode::kAdd: case HloOpcode::kDivide: case HloOpcode::kEq: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kLe: case HloOpcode::kLt: case HloOpcode::kMaximum: case HloOpcode::kMinimum: case HloOpcode::kMultiply: case HloOpcode::kNe: case HloOpcode::kPower: case HloOpcode::kRemainder: case HloOpcode::kSubtract: case HloOpcode::kAnd: case HloOpcode::kOr: case HloOpcode::kShiftLeft: case HloOpcode::kShiftRightArithmetic: case HloOpcode::kShiftRightLogical: return true; default: return false; } } bool HloInstruction::IsElementwise() const { switch (opcode_) { // Nullary elementwise operations. case HloOpcode::kConstant: return true; // Unary elementwise operations. case HloOpcode::kAbs: case HloOpcode::kRoundNearestAfz: case HloOpcode::kCeil: case HloOpcode::kConvert: case HloOpcode::kCopy: case HloOpcode::kCos: case HloOpcode::kExp: case HloOpcode::kFloor: case HloOpcode::kIsFinite: case HloOpcode::kLog: case HloOpcode::kNot: case HloOpcode::kNegate: case HloOpcode::kReducePrecision: case HloOpcode::kSign: case HloOpcode::kSin: case HloOpcode::kTanh: return true; // Binary elementwise operations, the same as in IsElementwiseBinary(). // If you update this, please update IsElementwiseBinary() accordingly. case HloOpcode::kAdd: case HloOpcode::kDivide: case HloOpcode::kEq: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kLe: case HloOpcode::kLt: case HloOpcode::kMaximum: case HloOpcode::kMinimum: case HloOpcode::kMultiply: case HloOpcode::kNe: case HloOpcode::kPower: case HloOpcode::kRemainder: case HloOpcode::kSubtract: case HloOpcode::kAnd: case HloOpcode::kOr: case HloOpcode::kShiftLeft: case HloOpcode::kShiftRightArithmetic: case HloOpcode::kShiftRightLogical: return true; // Ternary elementwise operations. case HloOpcode::kSelect: return !ShapeUtil::IsTuple(shape_); case HloOpcode::kClamp: return true; // Other operations. case HloOpcode::kRng: case HloOpcode::kMap: return true; case HloOpcode::kFusion: if (fusion_kind() != FusionKind::kLoop) { return false; } for (auto* fused : fused_instructions()) { if (fused->opcode() != HloOpcode::kParameter && !fused->IsElementwise()) { return false; } } return true; default: return false; } } bool HloInstruction::ImplicitlyBroadcastsOperand(int64 operand_idx) const { CHECK(IsElementwise()); return !ShapeUtil::Equal(shape(), operand(operand_idx)->shape()); } namespace { bool IsInstructionElementwiseOnOperand(const HloInstruction* instruction, const HloInstruction* operand) { std::vector<int64> operand_indices = instruction->OperandIndices(operand); return std::all_of( operand_indices.begin(), operand_indices.end(), [instruction](int64 operand_index) { return instruction->IsElementwiseOnOperand(operand_index); }); } } // namespace bool HloInstruction::IsElementwiseOnOperand(int64 operand_idx) const { // For all instructions other than kFusion, being elementwise on one of the // operands is equivalent to being elementwise on all the operands. if (opcode() != HloOpcode::kFusion) { return IsElementwise(); } CHECK_EQ(HloOpcode::kFusion, opcode()); if (fusion_kind() != FusionKind::kLoop) { return false; } // A loop-fusion is elementwise on an operand if all operations (computed // using BFS) between the operand and the fused root are elementwise. std::deque<HloInstruction*> worklist; std::unordered_set<const HloInstruction*> visited; worklist.push_back(fused_parameter(operand_idx)); visited.insert(fused_parameter(operand_idx)); while (!worklist.empty()) { HloInstruction* operand = worklist.front(); worklist.pop_front(); for (HloInstruction* user : operand->users()) { CHECK_GE(user->unique_id(), 0); if (ContainsKey(visited, user)) { continue; } if (user->IsElementwise() || IsInstructionElementwiseOnOperand(user, operand)) { worklist.push_back(user); visited.insert(user); } else { return false; } } } return true; } // A helper class for memoized, recursive computation of HloOpcode::kFusion // in HloInstruction::OperandElementUse below. class HloInstruction::FusionReusesParamElements { public: using UseKind = HloInstruction::UseKind; // We could rather iterate backwards thru fused_instructions_ here, as it is // in reverse postorder, and compute whether each fused instruction reuses // the value of this parameter, which would save stack space but not allow // us to finish early if we find a reuse. static UseKind Compute(int64 i, const HloInstruction& hlo) { tensorflow::gtl::FlatMap<const HloInstruction*, UseKind> memoization_cache; return ComputeInternal(i, hlo, &memoization_cache); } private: static UseKind ComputeInternal( int64 i, const HloInstruction& hlo, tensorflow::gtl::FlatMap<const HloInstruction*, UseKind>* cache) { if (hlo.opcode_ == HloOpcode::kParameter && hlo.parameter_number_ == i) { return UseKind::kUse; } auto p = cache->emplace(&hlo, UseKind{}); auto value_it = p.first; const bool key_is_new = p.second; if (key_is_new) { for (int64 j = 0; j < hlo.operands_.size(); ++j) { UseKind old_val = value_it->second; // The next operation invalidates iterators. UseKind new_val = Plus(old_val, std::min(hlo.OperandElementUse(j), ComputeInternal(i, *hlo.operand(j), cache))); // Re-acquire the iterator. We could work harder to do this only if // absolutely necessary, but this code is not hot enough to warrant // that. value_it = cache->find(&hlo); value_it->second = new_val; } } return value_it->second; } // Fold operation for UseKinds. static UseKind Plus(UseKind a, UseKind b) { if (a == UseKind::kNoUse) { return b; } else if (b == UseKind::kNoUse) { return a; } else if (a == UseKind::kReuse || b == UseKind::kReuse) { return UseKind::kReuse; } else if (a == UseKind::kUsePermutingElements || b == UseKind::kUsePermutingElements) { return UseKind::kReuse; } else { CHECK(a == UseKind::kUse && b == UseKind::kUse); return UseKind::kUse; } } }; HloInstruction::UseKind HloInstruction::OperandElementUse(int64 i) const { switch (opcode_) { case HloOpcode::kBitcast: case HloOpcode::kConcatenate: case HloOpcode::kReshape: case HloOpcode::kReverse: case HloOpcode::kSlice: case HloOpcode::kTranspose: return UseKind::kUsePermutingElements; case HloOpcode::kPad: case HloOpcode::kReduce: // Pad reuses the padding value but not the padded array elements. // Reduce reuses the init value but not the operand array elements. return i > 0 ? UseKind::kReuse : UseKind::kUsePermutingElements; case HloOpcode::kFusion: // Uses the memoizing, recursive computation defined above. return FusionReusesParamElements::Compute(i, *fused_expression_root()); case HloOpcode::kDot: // Dot operations with inputs [A,B] * [B,1] do not re-use // elements on their left operand. // Dot operations with inputs [1,A] * [A,B] do not re-use // elements on their right operand. if (shape().dimensions_size() == 2) { if ((i == 0 && shape().dimensions(1) == 1) || (i == 1 && shape().dimensions(0) == 1)) { return UseKind::kUse; } } return UseKind::kReuse; case HloOpcode::kDynamicUpdateSlice: // Dynamic-update-slice reuses only operand 2 (start_indices). if (i == 0 || i == 1) { return UseKind::kUse; } return UseKind::kReuse; default: return IsElementwise() && !ImplicitlyBroadcastsOperand(i) ? UseKind::kUse : UseKind::kReuse; } } std::tuple<bool, std::vector<int64>, std::vector<int64>> HloInstruction::ReshapeMerelyInsertsOrDeletes1SizedDimensions() const { if (HloOpcode::kReshape != opcode_) { return std::make_tuple(false, std::vector<int64>(), std::vector<int64>()); } return ShapeUtil::InsertedOrDeleted1SizedDimensions(operand(0)->shape_, shape_); } string ToString(HloInstruction::FusionKind kind) { switch (kind) { case HloInstruction::FusionKind::kLoop: return "kLoop"; case HloInstruction::FusionKind::kInput: return "kInput"; case HloInstruction::FusionKind::kOutput: return "kOutput"; case HloInstruction::FusionKind::kTransposeDot: return "kTransposeDot"; case HloInstruction::FusionKind::kConvBackwardFilter: return "kConvBackwardFilter"; case HloInstruction::FusionKind::kConvBackwardInput: return "kConvBackwardInput"; case HloInstruction::FusionKind::kCustom: return "kCustom"; } } StatusOr<HloInstruction::FusionKind> StringToFusionKind( const string& kind_name) { if (kind_name == "kLoop") { return HloInstruction::FusionKind::kLoop; } if (kind_name == "kInput") { return HloInstruction::FusionKind::kInput; } if (kind_name == "kOutput") { return HloInstruction::FusionKind::kOutput; } if (kind_name == "kTransposeDot") { return HloInstruction::FusionKind::kTransposeDot; } if (kind_name == "kConvBackwardFilter") { return HloInstruction::FusionKind::kConvBackwardFilter; } if (kind_name == "kConvBackwardInput") { return HloInstruction::FusionKind::kConvBackwardInput; } if (kind_name == "kCustom") { return HloInstruction::FusionKind::kCustom; } return InvalidArgument("Unknown fusion kind: %s", kind_name.c_str()); } std::ostream& operator<<(std::ostream& os, HloInstruction::FusionKind kind) { return os << ToString(kind); } string HloInstruction::ConvolutionDimensionNumbersToString() const { string result; if (convolution_dimension_numbers_ == nullptr) { return result; } const ConvolutionDimensionNumbers& dnums = *convolution_dimension_numbers_; // Show the given dimension labels in order of major to minor based on the // shape's layout. const auto append_dims = [&](const std::vector<string>& dims, const Shape& shape) { CHECK_EQ(dims.size(), ShapeUtil::Rank(shape)); for (int64 logical = 0; logical < dims.size(); ++logical) { int64 physical = logical; if (!shape.layout().minor_to_major().empty()) { physical = LayoutUtil::Major(shape.layout(), logical); } result += dims[physical]; } }; // lhs_dims[i] is the symbol of the logical dimension i for the lhs // operand. E.g. if batch has dimension number 2, then lhs_dims[2] == "b". std::vector<string> lhs_dims(2 + dnums.spatial_dimensions().size()); lhs_dims[dnums.input_batch_dimension()] = 'b'; lhs_dims[dnums.input_feature_dimension()] = 'f'; for (int64 i = 0; i < dnums.spatial_dimensions().size(); ++i) { lhs_dims[dnums.spatial_dimensions(i)] = StrCat(i); } std::vector<string> rhs_dims(2 + dnums.kernel_spatial_dimensions().size()); rhs_dims[dnums.kernel_input_feature_dimension()] = "i"; rhs_dims[dnums.kernel_output_feature_dimension()] = "o"; for (int64 i = 0; i < dnums.spatial_dimensions().size(); ++i) { rhs_dims[dnums.kernel_spatial_dimensions(i)] = StrCat(i); } std::vector<string> output_dims(2 + dnums.spatial_dimensions().size()); output_dims[dnums.output_batch_dimension()] = 'b'; output_dims[dnums.output_feature_dimension()] = 'f'; for (int64 i = 0; i < dnums.spatial_dimensions().size(); ++i) { output_dims[dnums.spatial_dimensions(i)] = StrCat(i); } result += "dim_labels="; append_dims(lhs_dims, operand(0)->shape()); result += "_"; append_dims(rhs_dims, operand(1)->shape()); result += "->"; append_dims(output_dims, shape()); return result; } bool HloInstruction::CouldBeBitcast() const { switch (opcode_) { case HloOpcode::kTranspose: return true; case HloOpcode::kReshape: return std::get<0>(ReshapeMerelyInsertsOrDeletes1SizedDimensions()); default: return false; } } HloModule* HloInstruction::GetModule() const { if (parent_) { return parent_->parent(); } return nullptr; } void HloInstruction::UniquifyName(NameUniquer* name_uniquer) { string parent_str = parent() == nullptr ? "noparent" : parent()->name(); name_ = name_uniquer->GetUniqueName(name_); } void HloInstruction::set_outer_dimension_partitions( const std::vector<int64>& outer_dimension_partitions) { outer_dimension_partitions_ = outer_dimension_partitions; } void HloInstruction::RelayoutConstant(const Layout& new_layout, const ShapeIndex& shape_index) { CHECK_EQ(opcode(), HloOpcode::kConstant); Shape* mutable_array_subshape = ShapeUtil::GetMutableSubshape(mutable_shape(), shape_index); CHECK(ShapeUtil::IsArray(*mutable_array_subshape)); // Normally array_subshape will always have a layout, but this invariant is // temporarily broken in LayoutAssignment::AssignLayouts. if (!mutable_array_subshape->has_layout() || !LayoutUtil::Equal(mutable_array_subshape->layout(), new_layout)) { literal_ = literal_->Relayout(new_layout, shape_index); *mutable_array_subshape->mutable_layout() = new_layout; } } } // namespace xla
benoitsteiner/tensorflow-opencl
tensorflow/compiler/xla/service/hlo_instruction.cc
C++
apache-2.0
110,467
[ 30522, 1013, 1008, 9385, 2418, 1996, 23435, 12314, 6048, 1012, 2035, 2916, 9235, 1012, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// ------------------------------------------------------------------------------ //The MIT License(MIT) //Copyright(c) 2015 Office Developer //Permission is hereby granted, free of charge, to any person obtaining a copy //of this software and associated documentation files (the "Software"), to deal //in the Software without restriction, including without limitation the rights //to use, copy, modify, merge, publish, distribute, sublicense, and/or sell //copies of the Software, and to permit persons to whom the Software is //furnished to do so, subject to the following conditions: //The above copyright notice and this permission notice shall be included in all //copies or substantial portions of the Software. //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE //AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, //OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE //SOFTWARE. // ------------------------------------------------------------------------------ using System.Threading.Tasks; using Microsoft.Online.Applications.Core.Authentication; using Microsoft.Online.Applications.Core.Configuration; namespace Microsoft.Online.Applications.Core { public class ServiceProvider : IServiceInfoProvider { public IAuthenticationProvider AuthenticationProvider { get; private set; } public virtual Task<ServiceInformation> CreateServiceInfo(AppConfig appConfig, CredentialType credentialType) { var activeDirectoryServiceInfo = new AdalServiceInformation { ClientID = appConfig.ClientID, ClientSecret = appConfig.ClientSecret, Tenant = appConfig.TenantDomain, ServiceResource = appConfig.ServiceResource }; if (credentialType == CredentialType.Certificate) { activeDirectoryServiceInfo.AuthenticationProvider = this.AuthenticationProvider ?? new AdalCertificateAuthenticationProvider(activeDirectoryServiceInfo); } else { activeDirectoryServiceInfo.AuthenticationProvider = this.AuthenticationProvider ?? new AdalClientAuthenticationProvider(activeDirectoryServiceInfo); } return Task.FromResult<ServiceInformation>(activeDirectoryServiceInfo); } } }
jansenbe/PnP-Tools
Solutions/Tenant Information Portal/src/Microsoft.Online.Applications.Core/ServiceProvider.cs
C#
mit
2,638
[ 30522, 1013, 1013, 1011, 1011, 1011, 1011, 30524, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 10...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!-- Copyright (c) 2000-2016 Ericsson Telecom AB All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Baji, Laszlo Balasko, Jeno Farkas, Laszlo Forstner, Matyas Szabados, Kristof --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Language" content="en-us"> <title>anytype</title> </head> <body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> <table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> <tr> <td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td> </tr> </table> <table border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> <td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> <td><a href="any.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> <td><a href="apply.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> </tr> </table> <p><br clear="all"> </p> <hr> <h1>anytype</h1> <hr align="left" width="75%"> <p>This special type is defined as a shorthand for the union of all known types in a TTCN-3 module. Known types include the following: built-in types, user-defined types, imported ASN.1 and other imported external types. <ul> <li>The fieldnames of the anytype shall be uniquely identified by the corresponding type names using the &quot;dot&quot; notation.</li> </ul> <p>Related keywords:</p> <ul> <li><a href="union.html"><font face="Courier New" color="#003258" size="4"><b>union</b></font></a> &nbsp;</li> </ul> <hr align="left" width="50%"> <div align="center"> <center> <table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> <tr> <td width="100%"> <h3 align="center"><font face="Courier New" color="#003258" size="5"><b>anytype</b></font></h3> </td> </tr> </table> </center> </div> <p>&nbsp;</p> <div align="center"> <center> <table border="0" width="100%" bgcolor="#C9C2BB" cellpadding="4"> <tr> <td width="100%"> <blockquote> <p><u>TITAN specific restriction compared to the standard:</u></p> </blockquote> <ul> <li> <p>&nbsp;<font face="Courier New" size="4"><b>anytype</b></font> can only contain the simple types, the ones defined in the same module and the <b>address</b> type. Imported types are not included.</p> </li> <li> <p>&nbsp;The types included in the <font face="Courier New" size="4"><b>anytype</b></font> of a module have to be declared by the user, using extension attributes.</p> </li> </ul> </td> </tr> </table> </center> </div> <hr align="left" width="50%"> <p>Example 1: <p><font face="Courier New">module example {<br> type float MyFloat;<br> type charstring MyString;<br> type record MyRecord {<br> &nbsp;&nbsp;&nbsp;integer i,<br> &nbsp;&nbsp;&nbsp;float f<br> }<br> ...</font> <p><font face="Courier New">control {<br> &nbsp;&nbsp;&nbsp;var anytype v_any;<br> &nbsp;&nbsp;&nbsp;v_any.integer := 3;<br> &nbsp;&nbsp;&nbsp;v_any.charstring := "hello";<br> &nbsp;&nbsp;&nbsp;v_any.MyRecord := { i := 42, f := 0.5};<br> ...<br> &nbsp;&nbsp;&nbsp;v_any.integer := v_any.MyRecord.i - 2;<br> }<br> }<br> with {<br> extension "anytype integer, charstring, MyRecord" }<br> </font> <p><font face="Courier New" size="4"><b>anytype</b></font> is defined to contain 3 types: integer, charstring and the MyRecord type.<br> The type MyFloat will not be a part of the anytype.<br> 3 is assigned to the integer part of v_any making it hold an integer value.<br> "hello" is assigned to the charstring part of v_any making it hold a charstring value.<br> A record is assigned to the MyRecord part of v_any making it hold a MyRecord value.<br> The MyRecord contents of v_any is read and after decreasing it with 2 it is assigned to the integer part of v_any.<br> <hr align="left" width="25%"> <hr align="left" width="25%"> <p><a HREF="BNF.html#anytypekeyword">BNF definition</a> of <font face="Courier New">anytype</font></p> </body> </html>
BenceJanosSzabo/titan.core
help/info/anytype.html
HTML
epl-1.0
4,511
[ 30522, 1026, 999, 1011, 1011, 9385, 1006, 1039, 1007, 2456, 1011, 2355, 4388, 7092, 18126, 11113, 2035, 2916, 9235, 1012, 2023, 2565, 1998, 1996, 10860, 4475, 2024, 2081, 2800, 2104, 1996, 3408, 1997, 1996, 13232, 2270, 6105, 1058, 2487, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package assertion_test import ( . "github.com/chai2010/gopkg/database/leveldb/internal/ginkgo" . "github.com/chai2010/gopkg/database/leveldb/internal/gomega" "testing" ) func TestAssertion(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Assertion Suite") }
chai2010/goleveldb
leveldb/internal/gomega/internal/assertion/assertion_suite_test.go
GO
bsd-2-clause
272
[ 30522, 7427, 23617, 1035, 3231, 12324, 1006, 1012, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 15775, 2072, 11387, 10790, 1013, 2175, 2361, 2243, 2290, 1013, 7809, 1013, 2504, 18939, 1013, 4722, 1013, 18353, 2243, 3995, 1000, 1012, 1000, 21...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
var group__spi__interface__gr = [ [ "Status Error Codes", "group__spi__execution__status.html", "group__spi__execution__status" ], [ "SPI Events", "group__SPI__events.html", "group__SPI__events" ], [ "SPI Control Codes", "group__SPI__control.html", "group__SPI__control" ], [ "ARM_DRIVER_SPI", "group__spi__interface__gr.html#structARM__DRIVER__SPI", [ [ "GetVersion", "group__spi__interface__gr.html#a8834b281da48583845c044a81566c1b3", null ], [ "GetCapabilities", "group__spi__interface__gr.html#a065b5fc24d0204692f0f95a44351ac1e", null ], [ "Initialize", "group__spi__interface__gr.html#afac50d0b28860f7b569293e6b713f8a4", null ], [ "Uninitialize", "group__spi__interface__gr.html#adcf20681a1402869ecb5c6447fada17b", null ], [ "PowerControl", "group__spi__interface__gr.html#aba8f1c8019af95ffe19c32403e3240ef", null ], [ "Send", "group__spi__interface__gr.html#a44eedddf4428cf4b98883b6c27d31922", null ], [ "Receive", "group__spi__interface__gr.html#adb9224a35fe16c92eb0dd103638e4cf3", null ], [ "Transfer", "group__spi__interface__gr.html#ad88b63ed74c03ba06b0599ab06ad4cf7", null ], [ "GetDataCount", "group__spi__interface__gr.html#ad1d892ab3932f65cd7cdf2d0a91ae5da", null ], [ "Control", "group__spi__interface__gr.html#a6e0f47a92f626a971c5197fca6545505", null ], [ "GetStatus", "group__spi__interface__gr.html#a7305e7248420cdb4b02ceba87672178d", null ] ] ], [ "ARM_SPI_CAPABILITIES", "group__spi__interface__gr.html#structARM__SPI__CAPABILITIES", [ [ "simplex", "group__spi__interface__gr.html#af244e2c2facf6414e3886495ee6b40bc", null ], [ "ti_ssi", "group__spi__interface__gr.html#a8053c540e5d531b692224bdc2463f36a", null ], [ "microwire", "group__spi__interface__gr.html#a9b4e858eb1d414128994742bf121f94c", null ], [ "event_mode_fault", "group__spi__interface__gr.html#a309619714f0c4febaa497ebdb9b7e3ca", null ], [ "reserved", "group__spi__interface__gr.html#aa43c4c21b173ada1b6b7568956f0d650", null ] ] ], [ "ARM_SPI_STATUS", "group__spi__interface__gr.html#structARM__SPI__STATUS", [ [ "busy", "group__spi__interface__gr.html#a50c88f3c1d787773e2ac1b59533f034a", null ], [ "data_lost", "group__spi__interface__gr.html#a9675630df67587ecd171c7ef12b9d22a", null ], [ "mode_fault", "group__spi__interface__gr.html#aeaf54ec655b7a64b9e88578c5f39d4e3", null ], [ "reserved", "group__spi__interface__gr.html#aa43c4c21b173ada1b6b7568956f0d650", null ] ] ], [ "ARM_SPI_SignalEvent_t", "group__spi__interface__gr.html#gafde9205364241ee81290adc0481c6640", null ], [ "ARM_SPI_GetVersion", "group__spi__interface__gr.html#gad5db9209ef1d64a7915a7278d6a402c8", null ], [ "ARM_SPI_GetCapabilities", "group__spi__interface__gr.html#gaf4823a11ab5efcd47c79b13801513ddc", null ], [ "ARM_SPI_Initialize", "group__spi__interface__gr.html#ga1a3c11ed523a4355cd91069527945906", null ], [ "ARM_SPI_Uninitialize", "group__spi__interface__gr.html#ga0c480ee3eabb82fc746e89741ed2e03e", null ], [ "ARM_SPI_PowerControl", "group__spi__interface__gr.html#ga1a1e7e80ea32ae381b75213c32aa8067", null ], [ "ARM_SPI_Send", "group__spi__interface__gr.html#gab2a303d1071e926280d50682f4808479", null ], [ "ARM_SPI_Receive", "group__spi__interface__gr.html#ga726aff54e782ed9b47f7ba1280a3d8f6", null ], [ "ARM_SPI_Transfer", "group__spi__interface__gr.html#gaa24026b3822c10272e301f1505136ec2", null ], [ "ARM_SPI_GetDataCount", "group__spi__interface__gr.html#gaaaecaaf4ec1922f22e7f9de63af5ccdb", null ], [ "ARM_SPI_Control", "group__spi__interface__gr.html#gad18d229992598d6677bec250015e5d1a", null ], [ "ARM_SPI_GetStatus", "group__spi__interface__gr.html#ga60d33d8788a76c388cc36e066240b817", null ], [ "ARM_SPI_SignalEvent", "group__spi__interface__gr.html#ga505b2d787348d51351d38fee98ccba7e", null ] ];
ryankurte/stm32f4-base
drivers/CMSIS/docs/Driver/html/group__spi__interface__gr.js
JavaScript
mit
3,924
[ 30522, 13075, 2177, 1035, 1035, 11867, 2072, 1035, 1035, 8278, 1035, 1035, 24665, 1027, 1031, 1031, 1000, 3570, 7561, 9537, 1000, 1010, 1000, 2177, 1035, 1035, 11867, 2072, 1035, 1035, 7781, 1035, 1035, 3570, 1012, 16129, 1000, 1010, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2016 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ /** @file sys_log.h * @brief Logging macros. */ #ifndef __SYS_LOG_H #define __SYS_LOG_H #ifdef __cplusplus extern "C" { #endif #define SYS_LOG_LEVEL_OFF 0 #define SYS_LOG_LEVEL_ERROR 1 #define SYS_LOG_LEVEL_WARNING 2 #define SYS_LOG_LEVEL_INFO 3 #define SYS_LOG_LEVEL_DEBUG 4 /* Determine this compile unit log level */ #if !defined(SYS_LOG_LEVEL) /* Use default */ #define SYS_LOG_LEVEL CONFIG_SYS_LOG_DEFAULT_LEVEL #elif (SYS_LOG_LEVEL < CONFIG_SYS_LOG_OVERRIDE_LEVEL) /* Use override */ #undef SYS_LOG_LEVEL #define SYS_LOG_LEVEL CONFIG_SYS_LOG_OVERRIDE_LEVEL #endif /** * @brief System Log * @defgroup system_log System Log * @{ */ #if defined(CONFIG_SYS_LOG) && (SYS_LOG_LEVEL > SYS_LOG_LEVEL_OFF) #define IS_SYS_LOG_ACTIVE 1 extern void (*syslog_hook)(const char *fmt, ...); void syslog_hook_install(void (*hook)(const char *, ...)); /* decide print func */ #if defined(CONFIG_SYS_LOG_EXT_HOOK) #define SYS_LOG_BACKEND_FN syslog_hook #else #include <misc/printk.h> #define SYS_LOG_BACKEND_FN printk #endif /* Should use color? */ #if defined(CONFIG_SYS_LOG_SHOW_COLOR) #define SYS_LOG_COLOR_OFF "\x1B[0m" #define SYS_LOG_COLOR_RED "\x1B[0;31m" #define SYS_LOG_COLOR_YELLOW "\x1B[0;33m" #else #define SYS_LOG_COLOR_OFF "" #define SYS_LOG_COLOR_RED "" #define SYS_LOG_COLOR_YELLOW "" #endif /* CONFIG_SYS_LOG_SHOW_COLOR */ /* Should use log lv tags? */ #if defined(CONFIG_SYS_LOG_SHOW_TAGS) #define SYS_LOG_TAG_ERR " [ERR]" #define SYS_LOG_TAG_WRN " [WRN]" #define SYS_LOG_TAG_INF " [INF]" #define SYS_LOG_TAG_DBG " [DBG]" #else #define SYS_LOG_TAG_ERR "" #define SYS_LOG_TAG_WRN "" #define SYS_LOG_TAG_INF "" #define SYS_LOG_TAG_DBG "" #endif /* CONFIG_SYS_LOG_SHOW_TAGS */ /* Log domain name */ #if !defined(SYS_LOG_DOMAIN) #define SYS_LOG_DOMAIN "general" #endif /* SYS_LOG_DOMAIN */ /** * @def SYS_LOG_NO_NEWLINE * * @brief Specifies whether SYS_LOG should add newline at the end of line * or not. * * @details User can define SYS_LOG_NO_NEWLINE no prevent the header file * from adding newline if the debug print already has a newline character. */ #if !defined(SYS_LOG_NO_NEWLINE) #define SYS_LOG_NL "\n" #else #define SYS_LOG_NL "" #endif /* [domain] [level] function: */ #define LOG_LAYOUT "[%s]%s %s: %s" #define LOG_BACKEND_CALL(log_lv, log_color, log_format, color_off, ...) \ SYS_LOG_BACKEND_FN(LOG_LAYOUT log_format "%s" SYS_LOG_NL, \ SYS_LOG_DOMAIN, log_lv, __func__, log_color, ##__VA_ARGS__, color_off) #define LOG_NO_COLOR(log_lv, log_format, ...) \ LOG_BACKEND_CALL(log_lv, "", log_format, "", ##__VA_ARGS__) #define LOG_COLOR(log_lv, log_color, log_format, ...) \ LOG_BACKEND_CALL(log_lv, log_color, log_format, \ SYS_LOG_COLOR_OFF, ##__VA_ARGS__) #define SYS_LOG_ERR(...) LOG_COLOR(SYS_LOG_TAG_ERR, SYS_LOG_COLOR_RED, \ ##__VA_ARGS__) #if (SYS_LOG_LEVEL >= SYS_LOG_LEVEL_WARNING) #define SYS_LOG_WRN(...) LOG_COLOR(SYS_LOG_TAG_WRN, \ SYS_LOG_COLOR_YELLOW, ##__VA_ARGS__) #endif #if (SYS_LOG_LEVEL >= SYS_LOG_LEVEL_INFO) #define SYS_LOG_INF(...) LOG_NO_COLOR(SYS_LOG_TAG_INF, ##__VA_ARGS__) #endif #if (SYS_LOG_LEVEL == SYS_LOG_LEVEL_DEBUG) #define SYS_LOG_DBG(...) LOG_NO_COLOR(SYS_LOG_TAG_DBG, ##__VA_ARGS__) #endif #else /** * @def IS_SYS_LOG_ACTIVE * * @brief Specifies whether SYS_LOG is in use or not. * * @details This macro expands to 1 if SYS_LOG was activated for current .c * file, 0 otherwise. */ #define IS_SYS_LOG_ACTIVE 0 /** * @def SYS_LOG_ERR * * @brief Writes an ERROR level message to the log. * * @details Lowest logging level, these messages are logged whenever sys log is * active. it's meant to report severe errors, such as those from which it's * not possible to recover. * * @param ... A string optionally containing printk valid conversion specifier, * followed by as many values as specifiers. */ #define SYS_LOG_ERR(...) { ; } #endif /* CONFIG_SYS_LOG */ /* create dummy macros */ #if !defined(SYS_LOG_WRN) /** * @def SYS_LOG_WRN * * @brief Writes a WARNING level message to the log. * * @details available if SYS_LOG_LEVEL is SYS_LOG_LEVEL_WARNING or higher. * It's meant to register messages related to unusual situations that are * not necessarily errors. * * @param ... A string optionally containing printk valid conversion specifier, * followed by as many values as specifiers. */ #define SYS_LOG_WRN(...) { ; } #endif #if !defined(SYS_LOG_INF) /** * @def SYS_LOG_INF * * @brief Writes an INFO level message to the log. * * @details available if SYS_LOG_LEVEL is SYS_LOG_LEVEL_INFO or higher. * It's meant to write generic user oriented messages. * * @param ... A string optionally containing printk valid conversion specifier, * followed by as many values as specifiers. */ #define SYS_LOG_INF(...) { ; } #endif #if !defined(SYS_LOG_DBG) /** * @def SYS_LOG_DBG * * @brief Writes a DEBUG level message to the log. * * @details highest logging level, available if SYS_LOG_LEVEL is * SYS_LOG_LEVEL_DEBUG. It's meant to write developer oriented information. * * @param ... A string optionally containing printk valid conversion specifier, * followed by as many values as specifiers. */ #define SYS_LOG_DBG(...) { ; } #endif /** * @} */ #ifdef __cplusplus } #endif #endif /* __SYS_LOG_H */
fractalclone/zephyr-riscv
include/logging/sys_log.h
C
apache-2.0
5,357
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2355, 13420, 3840, 1008, 1008, 23772, 2595, 1011, 6105, 1011, 8909, 4765, 18095, 1024, 15895, 1011, 1016, 1012, 1014, 1008, 1013, 1013, 1008, 1008, 1030, 5371, 25353, 2015, 1035, 8833, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
import * as EventLogger from './' const log = new EventLogger() log.info('Basic information') log.information('Basic information') log.warning('Watch out!') log.warn('Watch out!') log.error('Something went wrong.') log.auditFailure('Audit Failure') log.auditSuccess('Audit Success') // Configurations new EventLogger('FooApplication') new EventLogger({ source: 'FooApplication', logPath: '/var/usr/local/log', eventLog: 'APPLICATION' })
DenisCarriere/eventlogger
types.ts
TypeScript
mit
446
[ 30522, 12324, 1008, 2004, 2724, 21197, 4590, 2013, 1005, 1012, 1013, 1005, 9530, 3367, 8833, 1027, 2047, 2724, 21197, 4590, 1006, 1007, 8833, 1012, 18558, 1006, 1005, 3937, 2592, 1005, 1007, 8833, 1012, 2592, 1006, 1005, 3937, 2592, 1005, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
export { default } from './src/layout-container.vue';
wisedu/bh-mint-ui2
packages/layout-container/index.js
JavaScript
mit
54
[ 30522, 9167, 1063, 12398, 1065, 2013, 1005, 1012, 1013, 5034, 2278, 1013, 9621, 1011, 11661, 1012, 24728, 2063, 1005, 1025, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 30524, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Mesostigmatophyceae CLASS #### Status ACCEPTED #### According to The Catalogue of Life, 3rd January 2011 #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Chlorophyta/Mesostigmatophyceae/README.md
Markdown
apache-2.0
175
[ 30522, 1001, 2033, 17063, 3775, 21693, 10610, 21281, 9071, 2465, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 1996, 10161, 1997, 2166, 1010, 3822, 2254, 2249, 1001, 1001, 1001, 1001, 2405, 1999, 19701, 1001, 1001,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- name: Feature request about: Suggest an idea to us! --- <!-- Before creating an feature request please make sure you are using the latest version. --> <!-- If this is a new audit please review the audit doc https://github.com/GoogleChrome/lighthouse/blob/master/docs/new-audits.md --> **Feature request summary** <!-- Describe what you want to be added --> <!-- Are you willing to work on this yourself? --> **What is the motivation or use case for changing this?** **How is this beneficial to Ligthhouse?**
mixed/lighthouse
.github/ISSUE_TEMPLATE/Feature_request.md
Markdown
apache-2.0
521
[ 30522, 1011, 1011, 1011, 2171, 1024, 3444, 5227, 2055, 1024, 6592, 2019, 2801, 2000, 2149, 999, 1011, 1011, 1011, 1026, 999, 1011, 1011, 2077, 4526, 2019, 3444, 5227, 3531, 2191, 2469, 2017, 2024, 2478, 1996, 6745, 2544, 1012, 1011, 1011,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Vuex To manage the state of an application you should use [Vuex][vuex-docs]. _Note:_ All of the below is explained in more detail in the official [Vuex documentation][vuex-docs]. ## Separation of concerns Vuex is composed of State, Getters, Mutations, Actions and Modules. When a user clicks on an action, we need to `dispatch` it. This action will `commit` a mutation that will change the state. _Note:_ The action itself will not update the state, only a mutation should update the state. ## File structure When using Vuex at GitLab, separate this concerns into different files to improve readability: ``` └── store ├── index.js # where we assemble modules and export the store ├── actions.js # actions ├── mutations.js # mutations ├── getters.js # getters ├── state.js # state └── mutation_types.js # mutation types ``` The following example shows an application that lists and adds users to the state. (For a more complex example implementation take a look at the security applications store in [here](https://gitlab.com/gitlab-org/gitlab-ee/tree/master/ee/app/assets/javascripts/vue_shared/security_reports/store)) ### `index.js` This is the entry point for our store. You can use the following as a guide: ```javascript import Vue from 'vue'; import Vuex from 'vuex'; import * as actions from './actions'; import * as getters from './getters'; import mutations from './mutations'; import state from './state'; Vue.use(Vuex); export const createStore = () => new Vuex.Store({ actions, getters, mutations, state, }); export default createStore(); ``` ### `state.js` The first thing you should do before writing any code is to design the state. Often we need to provide data from haml to our Vue application. Let's store it in the state for better access. ```javascript export default { endpoint: null, isLoading: false, error: null, isAddingUser: false, errorAddingUser: false, users: [], }; ``` #### Access `state` properties You can use `mapState` to access state properties in the components. ### `actions.js` An action is a payload of information to send data from our application to our store. An action is usually composed by a `type` and a `payload` and they describe what happened. Enforcing that every change is described as an action lets us have a clear understanding of what is going on in the app. In this file, we will write the actions that will call the respective mutations: ```javascript import * as types from './mutation_types'; import axios from '~/lib/utils/axios_utils'; import createFlash from '~/flash'; export const requestUsers = ({ commit }) => commit(types.REQUEST_USERS); export const receiveUsersSuccess = ({ commit }, data) => commit(types.RECEIVE_USERS_SUCCESS, data); export const receiveUsersError = ({ commit }, error) => commit(types.REQUEST_USERS_ERROR, error); export const fetchUsers = ({ state, dispatch }) => { dispatch('requestUsers'); axios.get(state.endpoint) .then(({ data }) => dispatch('receiveUsersSuccess', data)) .catch((error) => { dispatch('receiveUsersError', error) createFlash('There was an error') }); } export const requestAddUser = ({ commit }) => commit(types.REQUEST_ADD_USER); export const receiveAddUserSuccess = ({ commit }, data) => commit(types.RECEIVE_ADD_USER_SUCCESS, data); export const receiveAddUserError = ({ commit }, error) => commit(types.REQUEST_ADD_USER_ERROR, error); export const addUser = ({ state, dispatch }, user) => { dispatch('requestAddUser'); axios.post(state.endpoint, user) .then(({ data }) => dispatch('receiveAddUserSuccess', data)) .catch((error) => dispatch('receiveAddUserError', error)); } ``` #### Actions Pattern: `request` and `receive` namespaces When a request is made we often want to show a loading state to the user. Instead of creating an action to toggle the loading state and dispatch it in the component, create: 1. An action `requestSomething`, to toggle the loading state 1. An action `receiveSomethingSuccess`, to handle the success callback 1. An action `receiveSomethingError`, to handle the error callback 1. An action `fetchSomething` to make the request. 1. In case your application does more than a `GET` request you can use these as examples: - `PUT`: `createSomething` - `POST`: `updateSomething` - `DELETE`: `deleteSomething` The component MUST only dispatch the `fetchNamespace` action. Actions namespaced with `request` or `receive` should not be called from the component The `fetch` action will be responsible to dispatch `requestNamespace`, `receiveNamespaceSuccess` and `receiveNamespaceError` By following this pattern we guarantee: 1. All applications follow the same pattern, making it easier for anyone to maintain the code 1. All data in the application follows the same lifecycle pattern 1. Actions are contained and human friendly 1. Unit tests are easier 1. Actions are simple and straightforward #### Dispatching actions To dispatch an action from a component, use the `mapActions` helper: ```javascript import { mapActions } from 'vuex'; { methods: { ...mapActions([ 'addUser', ]), onClickUser(user) { this.addUser(user); }, }, }; ``` ### `mutations.js` The mutations specify how the application state changes in response to actions sent to the store. The only way to change state in a Vuex store should be by committing a mutation. **It's a good idea to think of the state before writing any code.** Remember that actions only describe that something happened, they don't describe how the application state changes. **Never commit a mutation directly from a component** ```javascript import * as types from './mutation_types'; export default { [types.REQUEST_USERS](state) { state.isLoading = true; }, [types.RECEIVE_USERS_SUCCESS](state, data) { // Do any needed data transformation to the received payload here state.users = data; state.isLoading = false; }, [types.REQUEST_USERS_ERROR](state, error) { state.isLoading = false; }, [types.REQUEST_ADD_USER](state, user) { state.isAddingUser = true; }, [types.RECEIVE_ADD_USER_SUCCESS](state, user) { state.isAddingUser = false; state.users.push(user); }, [types.REQUEST_ADD_USER_ERROR](state, error) { state.isAddingUser = true; state.errorAddingUser = error; }, }; ``` ### `getters.js` Sometimes we may need to get derived state based on store state, like filtering for a specific prop. Using a getter will also cache the result based on dependencies due to [how computed props work](https://vuejs.org/v2/guide/computed.html#Computed-Caching-vs-Methods) This can be done through the `getters`: ```javascript // get all the users with pets export const getUsersWithPets = (state, getters) => { return state.users.filter(user => user.pet !== undefined); }; ``` To access a getter from a component, use the `mapGetters` helper: ```javascript import { mapGetters } from 'vuex'; { computed: { ...mapGetters([ 'getUsersWithPets', ]), }, }; ``` ### `mutation_types.js` From [vuex mutations docs][vuex-mutations]: > It is a commonly seen pattern to use constants for mutation types in various Flux implementations. This allows the code to take advantage of tooling like linters, and putting all constants in a single file allows your collaborators to get an at-a-glance view of what mutations are possible in the entire application. ```javascript export const ADD_USER = 'ADD_USER'; ``` ### How to include the store in your application The store should be included in the main component of your application: ```javascript // app.vue import store from 'store'; // it will include the index.js file export default { name: 'application', store, ... }; ``` ### Communicating with the Store ```javascript <script> import { mapActions, mapState, mapGetters } from 'vuex'; import store from './store'; export default { store, computed: { ...mapGetters([ 'getUsersWithPets' ]), ...mapState([ 'isLoading', 'users', 'error', ]), }, methods: { ...mapActions([ 'fetchUsers', 'addUser', ]), onClickAddUser(data) { this.addUser(data); } }, created() { this.fetchUsers() } } </script> <template> <ul> <li v-if="isLoading"> Loading... </li> <li v-else-if="error"> {{ error }} </li> <template v-else> <li v-for="user in users" :key="user.id" > {{ user }} </li> </template> </ul> </template> ``` ### Vuex Gotchas 1. Do not call a mutation directly. Always use an action to commit a mutation. Doing so will keep consistency throughout the application. From Vuex docs: > why don't we just call store.commit('action') directly? Well, remember that mutations must be synchronous? Actions aren't. We can perform asynchronous operations inside an action. ```javascript // component.vue // bad created() { this.$store.commit('mutation'); } // good created() { this.$store.dispatch('action'); } ``` 1. Use mutation types instead of hardcoding strings. It will be less error prone. 1. The State will be accessible in all components descending from the use where the store is instantiated. ### Testing Vuex #### Testing Vuex concerns Refer to [vuex docs][vuex-testing] regarding testing Actions, Getters and Mutations. #### Testing components that need a store Smaller components might use `store` properties to access the data. In order to write unit tests for those components, we need to include the store and provide the correct state: ```javascript //component_spec.js import Vue from 'vue'; import { createStore } from './store'; import component from './component.vue' describe('component', () => { let store; let vm; let Component; beforeEach(() => { Component = Vue.extend(issueActions); }); afterEach(() => { vm.$destroy(); }); it('should show a user', () => { const user = { name: 'Foo', age: '30', }; store = createStore(); // populate the store store.dispatch('addUser', user); vm = new Component({ store, propsData: props, }).$mount(); }); }); ``` #### Testing Vuex actions and getters Because we're currently using [`babel-plugin-rewire`](https://github.com/speedskater/babel-plugin-rewire), you may encounter the following error when testing your Vuex actions and getters: `[vuex] actions should be function or object with "handler" function` To prevent this error from happening, you need to export an empty function as `default`: ```javascript // getters.js or actions.js // prevent babel-plugin-rewire from generating an invalid default during karma tests export default () => {}; ``` [vuex-docs]: https://vuex.vuejs.org [vuex-structure]: https://vuex.vuejs.org/en/structure.html [vuex-mutations]: https://vuex.vuejs.org/en/mutations.html [vuex-testing]: https://vuex.vuejs.org/en/testing.html
dreampet/gitlab
doc/development/fe_guide/vuex.md
Markdown
mit
11,300
[ 30522, 1001, 24728, 10288, 2000, 6133, 1996, 2110, 1997, 2019, 4646, 2017, 2323, 2224, 1031, 24728, 10288, 1033, 1031, 24728, 10288, 1011, 9986, 2015, 1033, 1012, 1035, 3602, 1024, 1035, 2035, 1997, 1996, 2917, 2003, 4541, 1999, 2062, 6987,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Class Foam::extrudeModels::linearDirection Description Extrudes by transforming points in a specified direction by a given distance \*---------------------------------------------------------------------------*/ #ifndef linearDirection_H #define linearDirection_H #include "point.H" #include "extrudeModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { namespace extrudeModels { /*---------------------------------------------------------------------------*\ Class linearDirection Declaration \*---------------------------------------------------------------------------*/ class linearDirection : public extrudeModel { // Private data //- Extrude direction vector direction_; //- Layer thickness scalar thickness_; public: //- Runtime type information TypeName("linearDirection"); // Constructors //- Construct from dictionary linearDirection(const dictionary& dict); //- Destructor virtual ~linearDirection(); // Member Operators point operator() ( const point& surfacePoint, const vector& surfaceNormal, const label layer ) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace extrudeModels } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //
OpenFOAM/OpenFOAM-2.3.x
src/mesh/extrudeModel/linearDirection/linearDirection.H
C++
gpl-3.0
2,664
[ 30522, 1013, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 101...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Oro\Bundle\ImapBundle\Manager; use Doctrine\ORM\EntityManager; use Oro\Bundle\EntityBundle\ORM\OroEntityManager; use Oro\Bundle\ImapBundle\Connector\ImapConnector; use Oro\Bundle\EmailBundle\Provider\EmailFlagManagerInterface; use Oro\Bundle\EmailBundle\Entity\EmailFolder; use Oro\Bundle\EmailBundle\Entity\Email; /** * Class ImapEmailFlagManager * * @package Oro\Bundle\ImapBundle\Manager * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ImapEmailFlagManager implements EmailFlagManagerInterface { const FLAG_UNSEEN = 'UNSEEN'; const FLAG_SEEN = '\Seen'; /** @var ImapConnector */ protected $connector; /** * @var EntityManager */ protected $em; /** * @param ImapConnector $connector * @param OroEntityManager $em */ public function __construct(ImapConnector $connector, OroEntityManager $em) { $this->connector = $connector; $this->em = $em; } /** * (@inherit) */ public function setFlags(EmailFolder $folder, Email $email, $flags) { $repoImapEmail = $this->em->getRepository('OroImapBundle:ImapEmail'); $uid = $repoImapEmail->getUid($folder->getId(), $email->getId()); $this->connector->selectFolder($folder->getFullName()); $this->connector->setFlags($uid, $flags); } /** * (@inherit) */ public function setUnseen(EmailFolder $folder, Email $email) { $this->setFlags($folder, $email, [self::FLAG_UNSEEN]); } /** * (@inherit) */ public function setSeen(EmailFolder $folder, Email $email) { $this->setFlags($folder, $email, [self::FLAG_SEEN]); } }
Djamy/platform
src/Oro/Bundle/ImapBundle/Manager/ImapEmailFlagManager.php
PHP
mit
1,702
[ 30522, 1026, 1029, 25718, 3415, 15327, 20298, 1032, 14012, 1032, 10047, 9331, 27265, 2571, 1032, 3208, 1025, 2224, 8998, 1032, 2030, 2213, 1032, 9178, 24805, 4590, 1025, 2224, 20298, 1032, 14012, 1032, 9178, 27265, 2571, 1032, 2030, 2213, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Periodically crawl web pages and alert the user of changes * Copyright (C) 2016 Owen Stenson * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * More information in the enclosed `LICENSE' file */ /* BS: * The biggest thing that a Command object needs to do is, given its * internal data and the current time, return the next time it should run. * There seem to be two ways of approaching this. * 1. each vector of Values is consolidated into a hash set of valid times: * this would be slightly costly in terms of initial construction and * memory usage, but fetching the 'next' valid value would be very fast. * 5 hash tables large enough to store `*****` is 263 bytes (134 u8s) * 2. fetch the 'next' valid value for each Value in the vector. that would * require implementing 'next' for Asterisk, Range, Constant, and Skip. * This would require less memory but maybe a little more cpu to find * 'next' an arbitrary (though effectively like 1 or 2) number of times. * It might be in our best interest to consolidate values also (e.g. * `2,1-3` and `1-3,3-4` are redundant), but I'm not sure how I'd do that. * (1) would probably be simpler, cleaner, and less interesting. * In hindsight, (1) involved a lot of redundant checks, so it is * certainly not an optimal use of cpu. It also makes spaghetti code * because the Gregorian calendar is awful. (2) is not an optimal use of * ram, but firing an event requires calling .contains() on a BTreeSet * of u8s instead of calling .next() on an arbitrary number of values. * 3. Populate (2)'s set of valid options and check once per minute. * Checks frequently, but there's not a lot there to mess up. * Negligibly more expensive than (2), and probably more reliable. * It should probably have a test suite anyway, though smaller than what * (2) would require (and WAY smaller than what (1) would require). */ /* mod.rs * This file will eventually house framework to tie in functionality for * Calendar and Action and maybe Schedule. It shouldn't be hefty. */ pub mod value_itr; pub mod calendar;
stensonowen/page-mon
src/event/mod.rs
Rust
gpl-3.0
2,801
[ 30522, 1013, 1008, 18043, 13529, 4773, 5530, 1998, 9499, 1996, 5310, 1997, 3431, 1008, 9385, 1006, 1039, 1007, 2355, 7291, 26261, 15551, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1024, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As String Return "Nothing here yet" End Function End Class
arobinson0x7c159d/EWTK
EWTKServer/EWTKServer/Controllers/HomeController.vb
Visual Basic
gpl-3.0
164
[ 30522, 2270, 2465, 2188, 8663, 13181, 10820, 22490, 2015, 2291, 1012, 4773, 1012, 19842, 2278, 1012, 11486, 3853, 5950, 1006, 1007, 2004, 5164, 2709, 1000, 2498, 2182, 2664, 1000, 2203, 3853, 2203, 2465, 102, 0, 0, 0, 0, 0, 0, 0, 0, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// Created file "Lib\src\Uuid\X64\guids" typedef struct _GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; } GUID; #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ extern const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } DEFINE_GUID(ENHANCED_STORAGE_PROPERTY_IS_AUTHENTICATION_SILO, 0x91248166, 0xb832, 0x4ad4, 0xba, 0xa4, 0x7c, 0xa0, 0xb6, 0xb2, 0x79, 0x8c);
Frankie-PellesC/fSDK
Lib/src/Uuid/X64/guids00000601.c
C
lgpl-3.0
482
[ 30522, 1013, 1013, 2580, 5371, 1000, 5622, 2497, 1032, 5034, 2278, 1032, 1057, 21272, 1032, 1060, 21084, 1032, 26458, 5104, 1000, 21189, 12879, 2358, 6820, 6593, 1035, 26458, 2094, 1063, 27121, 2146, 2951, 2487, 1025, 27121, 2460, 2951, 247...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- title: New Raspberry Pi 3 B+ Model image: https://www.raspberrypi.org/app/uploads/2018/03/770A5614-1617x1080.jpg excerpt: New Raspberry Pi 3 description: rpi 3 b+ categories: raspbian --- ![Base shot of Raspberry Pi 3 B+](https://www.raspberrypi.org/app/uploads/2018/03/770A5842-1612x1080.jpg) There has also been an update to Raspbian to accomodate the new model (dated 13 March 2018) ## Links [Raspberry Pi 3 B+ Product Page](https://www.raspberrypi.org/products/raspberry-pi-3-model-b-plus/) [Magpi article](https://www.raspberrypi.org/magpi/raspberry-pi-specs-benchmarks/) [Raspberry Pi Blog](https://www.raspberrypi.org/blog/raspberry-pi-3-model-bplus-sale-now-35/) [Element14](http://au.element14.com/buy-raspberry-pi?ICID=I-HP-LB-rasp-pi-model-3-bplus) [Core Electronics](https://core-electronics.com.au/raspberry-pi-3-model-b-plus.html) [Raspbian](https://www.raspberrypi.org/downloads/raspbian/)
raspberrypisig/raspberrypisig.github.io
_posts/2018-3-17-new-raspberry-pi.md
Markdown
mit
920
[ 30522, 1011, 1011, 1011, 2516, 1024, 2047, 20710, 2361, 9766, 14255, 1017, 1038, 1009, 2944, 3746, 1024, 16770, 1024, 1013, 1013, 7479, 1012, 20710, 2361, 9766, 8197, 1012, 8917, 1013, 10439, 1013, 2039, 11066, 2015, 1013, 2760, 1013, 6021,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_55) on Fri Mar 04 14:41:00 EST 2016 --> <title>ChanceCellInfoFormatter</title> <meta name="date" content="2016-03-04"> <link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="ChanceCellInfoFormatter"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/ChanceCellInfoFormatter.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-files/index-1.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html" title="interface in edu.towson.cis.cosc603.project2.monopoly.gui"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/FreeParkingCellInfoFormatter.html" title="class in edu.towson.cis.cosc603.project2.monopoly.gui"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html" target="_top">Frames</a></li> <li><a href="ChanceCellInfoFormatter.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <!-- ======== START OF CLASS DATA ======== --> <div class="header"> <div class="subTitle">edu.towson.cis.cosc603.project2.monopoly.gui</div> <h2 title="Class ChanceCellInfoFormatter" class="title">Class ChanceCellInfoFormatter</h2> </div> <div class="contentContainer"> <ul class="inheritance"> <li>java.lang.Object</li> <li> <ul class="inheritance"> <li>edu.towson.cis.cosc603.project2.monopoly.gui.ChanceCellInfoFormatter</li> </ul> </li> </ul> <div class="description"> <ul class="blockList"> <li class="blockList"> <dl> <dt>All Implemented Interfaces:</dt> <dd><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html" title="interface in edu.towson.cis.cosc603.project2.monopoly.gui">CellInfoFormatter</a></dd> </dl> <hr> <br> <pre>public class <span class="strong">ChanceCellInfoFormatter</span> extends java.lang.Object implements <a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html" title="interface in edu.towson.cis.cosc603.project2.monopoly.gui">CellInfoFormatter</a></pre> </li> </ul> </div> <div class="summary"> <ul class="blockList"> <li class="blockList"> <!-- =========== FIELD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="field_summary"> <!-- --> </a> <h3>Field Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation"> <caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Field and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>static java.lang.String</code></td> <td class="colLast"><code><strong><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html#CHANCE_CELL_LABEL">CHANCE_CELL_LABEL</a></strong></code>&nbsp;</td> </tr> </table> </li> </ul> <!-- ======== CONSTRUCTOR SUMMARY ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor_summary"> <!-- --> </a> <h3>Constructor Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation"> <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tr class="altColor"> <td class="colOne"><code><strong><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html#ChanceCellInfoFormatter()">ChanceCellInfoFormatter</a></strong>()</code>&nbsp;</td> </tr> </table> </li> </ul> <!-- ========== METHOD SUMMARY =========== --> <ul class="blockList"> <li class="blockList"><a name="method_summary"> <!-- --> </a> <h3>Method Summary</h3> <table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> <caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tr class="altColor"> <td class="colFirst"><code>java.lang.String</code></td> <td class="colLast"><code><strong><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html#format(edu.towson.cis.cosc603.project2.monopoly.IOwnable)">format</a></strong>(<a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/IOwnable.html" title="interface in edu.towson.cis.cosc603.project2.monopoly">IOwnable</a>&nbsp;cell)</code>&nbsp;</td> </tr> </table> <ul class="blockList"> <li class="blockList"><a name="methods_inherited_from_class_java.lang.Object"> <!-- --> </a> <h3>Methods inherited from class&nbsp;java.lang.Object</h3> <code>equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</code></li> </ul> </li> </ul> </li> </ul> </div> <div class="details"> <ul class="blockList"> <li class="blockList"> <!-- ============ FIELD DETAIL =========== --> <ul class="blockList"> <li class="blockList"><a name="field_detail"> <!-- --> </a> <h3>Field Detail</h3> <a name="CHANCE_CELL_LABEL"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>CHANCE_CELL_LABEL</h4> <pre>public static final&nbsp;java.lang.String CHANCE_CELL_LABEL</pre> <dl><dt><span class="strong">See Also:</span></dt><dd><a href="../../../../../../../constant-values.html#edu.towson.cis.cosc603.project2.monopoly.gui.ChanceCellInfoFormatter.CHANCE_CELL_LABEL">Constant Field Values</a></dd></dl> </li> </ul> </li> </ul> <!-- ========= CONSTRUCTOR DETAIL ======== --> <ul class="blockList"> <li class="blockList"><a name="constructor_detail"> <!-- --> </a> <h3>Constructor Detail</h3> <a name="ChanceCellInfoFormatter()"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>ChanceCellInfoFormatter</h4> <pre>public&nbsp;ChanceCellInfoFormatter()</pre> </li> </ul> </li> </ul> <!-- ============ METHOD DETAIL ========== --> <ul class="blockList"> <li class="blockList"><a name="method_detail"> <!-- --> </a> <h3>Method Detail</h3> <a name="format(edu.towson.cis.cosc603.project2.monopoly.IOwnable)"> <!-- --> </a> <ul class="blockListLast"> <li class="blockList"> <h4>format</h4> <pre>public&nbsp;java.lang.String&nbsp;format(<a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/IOwnable.html" title="interface in edu.towson.cis.cosc603.project2.monopoly">IOwnable</a>&nbsp;cell)</pre> <dl> <dt><strong>Specified by:</strong></dt> <dd><code><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html#format(edu.towson.cis.cosc603.project2.monopoly.IOwnable)">format</a></code>&nbsp;in interface&nbsp;<code><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html" title="interface in edu.towson.cis.cosc603.project2.monopoly.gui">CellInfoFormatter</a></code></dd> </dl> </li> </ul> </li> </ul> </li> </ul> </div> </div> <!-- ========= END OF CLASS DATA ========= --> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../../../overview-summary.html">Overview</a></li> <li><a href="package-summary.html">Package</a></li> <li class="navBarCell1Rev">Class</li> <li><a href="class-use/ChanceCellInfoFormatter.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../../../index-files/index-1.html">Index</a></li> <li><a href="../../../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/CellInfoFormatter.html" title="interface in edu.towson.cis.cosc603.project2.monopoly.gui"><span class="strong">Prev Class</span></a></li> <li><a href="../../../../../../../edu/towson/cis/cosc603/project2/monopoly/gui/FreeParkingCellInfoFormatter.html" title="class in edu.towson.cis.cosc603.project2.monopoly.gui"><span class="strong">Next Class</span></a></li> </ul> <ul class="navList"> <li><a href="../../../../../../../index.html?edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html" target="_top">Frames</a></li> <li><a href="ChanceCellInfoFormatter.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <div> <ul class="subNavList"> <li>Summary:&nbsp;</li> <li>Nested&nbsp;|&nbsp;</li> <li><a href="#field_summary">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_summary">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_summary">Method</a></li> </ul> <ul class="subNavList"> <li>Detail:&nbsp;</li> <li><a href="#field_detail">Field</a>&nbsp;|&nbsp;</li> <li><a href="#constructor_detail">Constr</a>&nbsp;|&nbsp;</li> <li><a href="#method_detail">Method</a></li> </ul> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
odomin2/ait642-Dominguez-project2-
Task 13 Detect Desing Smells/Monopoly/doc/edu/towson/cis/cosc603/project2/monopoly/gui/ChanceCellInfoFormatter.html
HTML
gpl-3.0
11,799
[ 30522, 1026, 999, 9986, 13874, 16129, 2270, 1000, 1011, 1013, 1013, 1059, 2509, 2278, 1013, 1013, 26718, 2094, 16129, 1018, 1012, 5890, 17459, 1013, 1013, 30524, 1011, 1011, 7013, 2011, 9262, 3527, 2278, 1006, 2544, 1015, 1012, 1021, 1012, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "trayicon.h" #include <QApplication> #include <QMenu> #include <QTimer> #include <conf/addressgroup.h> #include <conf/appgroup.h> #include <conf/confmanager.h> #include <conf/firewallconf.h> #include <form/controls/mainwindow.h> #include <fortsettings.h> #include <manager/hotkeymanager.h> #include <manager/windowmanager.h> #include <user/iniuser.h> #include <util/guiutil.h> #include <util/iconcache.h> #include "traycontroller.h" namespace { const char *const eventSingleClick = "singleClick"; const char *const eventDoubleClick = "doubleClick"; const char *const eventMiddleClick = "middleClick"; const char *const actionShowPrograms = "Programs"; const char *const actionShowOptions = "Options"; const char *const actionShowStatistics = "Statistics"; const char *const actionShowTrafficGraph = "TrafficGraph"; const char *const actionSwitchFilterEnabled = "FilterEnabled"; const char *const actionSwitchStopTraffic = "StopTraffic"; const char *const actionSwitchStopInetTraffic = "StopInetTraffic"; const char *const actionSwitchAutoAllowPrograms = "AutoAllowPrograms"; QString clickNameByType(TrayIcon::ClickType clickType) { switch (clickType) { case TrayIcon::SingleClick: return eventSingleClick; case TrayIcon::DoubleClick: return eventDoubleClick; case TrayIcon::MiddleClick: return eventMiddleClick; default: return QString(); } } QString actionNameByType(TrayIcon::ActionType actionType) { switch (actionType) { case TrayIcon::ActionShowPrograms: return actionShowPrograms; case TrayIcon::ActionShowOptions: return actionShowOptions; case TrayIcon::ActionShowStatistics: return actionShowStatistics; case TrayIcon::ActionShowTrafficGraph: return actionShowTrafficGraph; case TrayIcon::ActionSwitchFilterEnabled: return actionSwitchFilterEnabled; case TrayIcon::ActionSwitchStopTraffic: return actionSwitchStopTraffic; case TrayIcon::ActionSwitchStopInetTraffic: return actionSwitchStopInetTraffic; case TrayIcon::ActionSwitchAutoAllowPrograms: return actionSwitchAutoAllowPrograms; default: return QString(); } } TrayIcon::ActionType actionTypeByName(const QString &name) { if (name.isEmpty()) return TrayIcon::ActionNone; if (name == actionShowPrograms) return TrayIcon::ActionShowPrograms; if (name == actionShowOptions) return TrayIcon::ActionShowOptions; if (name == actionShowStatistics) return TrayIcon::ActionShowStatistics; if (name == actionShowTrafficGraph) return TrayIcon::ActionShowTrafficGraph; if (name == actionSwitchFilterEnabled) return TrayIcon::ActionSwitchFilterEnabled; if (name == actionSwitchStopTraffic) return TrayIcon::ActionSwitchStopTraffic; if (name == actionSwitchStopInetTraffic) return TrayIcon::ActionSwitchStopInetTraffic; if (name == actionSwitchAutoAllowPrograms) return TrayIcon::ActionSwitchAutoAllowPrograms; return TrayIcon::ActionNone; } TrayIcon::ActionType defaultActionTypeByClick(TrayIcon::ClickType clickType) { switch (clickType) { case TrayIcon::SingleClick: return TrayIcon::ActionShowPrograms; case TrayIcon::DoubleClick: return TrayIcon::ActionShowOptions; case TrayIcon::MiddleClick: return TrayIcon::ActionShowStatistics; default: return TrayIcon::ActionNone; } } void setActionCheckable(QAction *action, bool checked = false, const QObject *receiver = nullptr, const char *member = nullptr) { action->setCheckable(true); action->setChecked(checked); if (receiver) { QObject::connect(action, SIGNAL(toggled(bool)), receiver, member); } } QAction *addAction(QWidget *widget, const QIcon &icon, const QString &text, const QObject *receiver = nullptr, const char *member = nullptr, bool checkable = false, bool checked = false) { auto action = new QAction(icon, text, widget); if (receiver) { QObject::connect(action, SIGNAL(triggered(bool)), receiver, member); } if (checkable) { setActionCheckable(action, checked); } widget->addAction(action); return action; } } TrayIcon::TrayIcon(QObject *parent) : QSystemTrayIcon(parent), m_trayTriggered(false), m_ctrl(new TrayController(this)) { setupUi(); setupController(); connect(this, &QSystemTrayIcon::activated, this, &TrayIcon::onTrayActivated); } TrayIcon::~TrayIcon() { delete m_menu; } FortSettings *TrayIcon::settings() const { return ctrl()->settings(); } ConfManager *TrayIcon::confManager() const { return ctrl()->confManager(); } FirewallConf *TrayIcon::conf() const { return ctrl()->conf(); } IniOptions *TrayIcon::ini() const { return ctrl()->ini(); } IniUser *TrayIcon::iniUser() const { return ctrl()->iniUser(); } HotKeyManager *TrayIcon::hotKeyManager() const { return ctrl()->hotKeyManager(); } WindowManager *TrayIcon::windowManager() const { return ctrl()->windowManager(); } void TrayIcon::onMouseClicked(TrayIcon::ClickType clickType) { QAction *action = m_clickActions[clickType]; if (action) { action->trigger(); } } void TrayIcon::onTrayActivated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: m_trayTriggered = true; QTimer::singleShot(QApplication::doubleClickInterval(), this, [&] { if (m_trayTriggered) { m_trayTriggered = false; onMouseClicked(SingleClick); } }); break; case QSystemTrayIcon::DoubleClick: if (m_trayTriggered) { m_trayTriggered = false; onMouseClicked(DoubleClick); } break; case QSystemTrayIcon::MiddleClick: m_trayTriggered = false; onMouseClicked(MiddleClick); break; case QSystemTrayIcon::Context: m_trayTriggered = false; showTrayMenu(QCursor::pos()); break; default: break; } } void TrayIcon::updateTrayIcon(bool alerted) { const auto icon = alerted ? GuiUtil::overlayIcon(":/icons/sheild-96.png", ":/icons/error.png") : IconCache::icon(":/icons/sheild-96.png"); this->setIcon(icon); } void TrayIcon::showTrayMenu(const QPoint &pos) { m_menu->popup(pos); } void TrayIcon::updateTrayMenu(bool onlyFlags) { if (!onlyFlags) { updateAppGroupActions(); } updateTrayMenuFlags(); updateHotKeys(); } void TrayIcon::setupController() { connect(windowManager(), &WindowManager::optWindowChanged, this, &TrayIcon::updateTrayMenuFlags); connect(windowManager(), &WindowManager::graphWindowChanged, m_graphAction, &QAction::setChecked); connect(settings(), &FortSettings::passwordCheckedChanged, this, &TrayIcon::updateTrayMenuFlags); connect(ctrl(), &TrayController::retranslateUi, this, &TrayIcon::retranslateUi); retranslateUi(); } void TrayIcon::retranslateUi() { m_programsAction->setText(tr("Programs")); m_optionsAction->setText(tr("Options")); m_statisticsAction->setText(tr("Statistics")); m_zonesAction->setText(tr("Zones")); m_graphAction->setText(tr("Traffic Graph")); m_filterEnabledAction->setText(tr("Filter Enabled")); m_stopTrafficAction->setText(tr("Stop Traffic")); m_stopInetTrafficAction->setText(tr("Stop Internet Traffic")); m_autoAllowProgsAction->setText(tr("Auto-Allow New Programs")); m_quitAction->setText(tr("Quit")); } void TrayIcon::setupUi() { this->setToolTip(QApplication::applicationDisplayName()); setupTrayMenu(); updateTrayMenu(); updateTrayIcon(); updateClickActions(); } void TrayIcon::setupTrayMenu() { m_menu = new QMenu(); m_programsAction = addAction(m_menu, IconCache::icon(":/icons/application.png"), QString(), windowManager(), SLOT(showProgramsWindow())); addHotKey(m_programsAction, iniUser()->hotKeyPrograms()); m_optionsAction = addAction(m_menu, IconCache::icon(":/icons/cog.png"), QString(), windowManager(), SLOT(showOptionsWindow())); addHotKey(m_optionsAction, iniUser()->hotKeyOptions()); m_statisticsAction = addAction(m_menu, IconCache::icon(":/icons/chart_bar.png"), QString(), windowManager(), SLOT(showStatisticsWindow())); addHotKey(m_statisticsAction, iniUser()->hotKeyStatistics()); m_graphAction = addAction(m_menu, IconCache::icon(":/icons/action_log.png"), QString(), windowManager(), SLOT(switchGraphWindow()), true, !!windowManager()->graphWindow()); addHotKey(m_graphAction, iniUser()->hotKeyGraph()); m_zonesAction = addAction(m_menu, IconCache::icon(":/icons/ip_class.png"), QString(), windowManager(), SLOT(showZonesWindow())); addHotKey(m_zonesAction, iniUser()->hotKeyZones()); m_menu->addSeparator(); m_filterEnabledAction = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true); addHotKey(m_filterEnabledAction, iniUser()->hotKeyFilter()); m_stopTrafficAction = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true); addHotKey(m_stopTrafficAction, iniUser()->hotKeyStopTraffic()); m_stopInetTrafficAction = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true); addHotKey(m_stopInetTrafficAction, iniUser()->hotKeyStopInetTraffic()); m_autoAllowProgsAction = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true); addHotKey(m_autoAllowProgsAction, iniUser()->hotKeyAllowAllNew()); m_menu->addSeparator(); for (int i = 0; i < MAX_APP_GROUP_COUNT; ++i) { QAction *a = addAction(m_menu, QIcon(), QString(), this, SLOT(switchTrayFlag(bool)), true); if (i < 12) { const QString shortcutText = iniUser()->hotKeyAppGroupModifiers() + "+F" + QString::number(i + 1); addHotKey(a, shortcutText); } m_appGroupActions.append(a); } m_menu->addSeparator(); m_quitAction = addAction(m_menu, QIcon(), tr("Quit"), this, SLOT(quitProgram())); addHotKey(m_quitAction, iniUser()->hotKeyQuit()); } void TrayIcon::updateTrayMenuFlags() { const bool editEnabled = (!settings()->isPasswordRequired() && !windowManager()->optWindow()); m_filterEnabledAction->setEnabled(editEnabled); m_stopTrafficAction->setEnabled(editEnabled); m_stopInetTrafficAction->setEnabled(editEnabled); m_autoAllowProgsAction->setEnabled(editEnabled); m_filterEnabledAction->setChecked(conf()->filterEnabled()); m_stopTrafficAction->setChecked(conf()->stopTraffic()); m_stopInetTrafficAction->setChecked(conf()->stopInetTraffic()); m_autoAllowProgsAction->setChecked(conf()->allowAllNew()); int appGroupIndex = 0; for (QAction *action : qAsConst(m_appGroupActions)) { if (!action->isVisible()) break; const bool appGroupEnabled = conf()->appGroupEnabled(appGroupIndex++); action->setEnabled(editEnabled); action->setChecked(appGroupEnabled); } } void TrayIcon::updateAppGroupActions() { const int appGroupsCount = conf()->appGroups().count(); for (int i = 0; i < MAX_APP_GROUP_COUNT; ++i) { QAction *action = m_appGroupActions.at(i); QString menuLabel; bool visible = false; if (i < appGroupsCount) { const AppGroup *appGroup = conf()->appGroups().at(i); menuLabel = appGroup->menuLabel(); visible = true; } action->setText(menuLabel); action->setVisible(visible); action->setEnabled(visible); } } void TrayIcon::saveTrayFlags() { conf()->setFilterEnabled(m_filterEnabledAction->isChecked()); conf()->setStopTraffic(m_stopTrafficAction->isChecked()); conf()->setStopInetTraffic(m_stopInetTrafficAction->isChecked()); conf()->setAllowAllNew(m_autoAllowProgsAction->isChecked()); int i = 0; for (AppGroup *appGroup : conf()->appGroups()) { const QAction *action = m_appGroupActions.at(i++); appGroup->setEnabled(action->isChecked()); } confManager()->saveFlags(); } void TrayIcon::switchTrayFlag(bool checked) { if (iniUser()->confirmTrayFlags()) { const auto action = qobject_cast<QAction *>(sender()); Q_ASSERT(action); if (!windowManager()->showQuestionBox( tr("Are you sure to switch the \"%1\"?").arg(action->text()))) { action->setChecked(!checked); return; } } saveTrayFlags(); } void TrayIcon::quitProgram() { if (iniUser()->confirmQuit()) { if (!windowManager()->showQuestionBox(tr("Are you sure you want to quit the program?"))) return; } windowManager()->quitByCheckPassword(); } void TrayIcon::addHotKey(QAction *action, const QString &shortcutText) { if (shortcutText.isEmpty()) return; const QKeySequence shortcut = QKeySequence::fromString(shortcutText); hotKeyManager()->addAction(action, shortcut); } void TrayIcon::updateHotKeys() { hotKeyManager()->setEnabled(iniUser()->hotKeyEnabled()); } void TrayIcon::removeHotKeys() { hotKeyManager()->removeActions(); } TrayIcon::ActionType TrayIcon::clickEventActionType(ClickType clickType) const { const QString eventName = clickNameByType(clickType); const QString actionName = iniUser()->trayAction(eventName); const ActionType actionType = actionTypeByName(actionName); return (actionType != ActionNone) ? actionType : defaultActionTypeByClick(clickType); } void TrayIcon::setClickEventActionType(ClickType clickType, ActionType actionType) { const QString eventName = clickNameByType(clickType); const QString actionName = actionNameByType(actionType); iniUser()->setTrayAction(eventName, actionName); updateClickActions(); } void TrayIcon::updateClickActions() { m_clickActions[SingleClick] = clickActionFromIni(SingleClick); m_clickActions[DoubleClick] = clickActionFromIni(DoubleClick); m_clickActions[MiddleClick] = clickActionFromIni(MiddleClick); } QAction *TrayIcon::clickActionFromIni(ClickType clickType) const { const ActionType actionType = clickEventActionType(clickType); return clickActionByType(actionType); } QAction *TrayIcon::clickActionByType(ActionType actionType) const { switch (actionType) { case TrayIcon::ActionShowPrograms: return m_programsAction; case TrayIcon::ActionShowOptions: return m_optionsAction; case TrayIcon::ActionShowStatistics: return m_statisticsAction; case TrayIcon::ActionShowTrafficGraph: return m_graphAction; case TrayIcon::ActionSwitchFilterEnabled: return m_filterEnabledAction; case TrayIcon::ActionSwitchStopTraffic: return m_stopTrafficAction; case TrayIcon::ActionSwitchStopInetTraffic: return m_stopInetTrafficAction; case TrayIcon::ActionSwitchAutoAllowPrograms: return m_autoAllowProgsAction; } return nullptr; }
tnodir/fort
src/ui/form/tray/trayicon.cpp
C++
gpl-3.0
15,320
[ 30522, 1001, 2421, 1000, 11851, 28524, 1012, 1044, 1000, 1001, 2421, 1026, 1053, 29098, 19341, 3508, 1028, 1001, 2421, 1026, 1053, 3549, 2226, 1028, 1001, 2421, 1026, 1053, 7292, 2099, 1028, 1001, 2421, 1026, 9530, 2546, 1013, 4769, 17058, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef _EXEC_COMPONENT_IMPL_H #define _EXEC_COMPONENT_IMPL_H /******************************************************************************* * ALMA - Atacama Large Millimiter Array * (c) European Southern Observatory, 2004 * *This library is free software; you can redistribute it and/or *modify it under the terms of the GNU Lesser General Public *License as published by the Free Software Foundation; either *version 2.1 of the License, or (at your option) any later version. * *This library is distributed in the hope that it will be useful, *but WITHOUT ANY WARRANTY; without even the implied warranty of *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *Lesser General Public License for more details. * *You should have received a copy of the GNU Lesser General Public *License along with this library; if not, write to the Free Software *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * "@(#) $Id: execComponentTestImpl.h,v 1.14 2008/10/01 03:07:07 cparedes Exp $" * * who when what * -------- -------- ---------------------------------------------- * bjeram 2004-09-17 created */ /************************************************************************ * *---------------------------------------------------------------------- */ #ifndef __cplusplus #error This is a C++ include file and cannot be used from plain C #endif #include "taskComponent.h" class execComponentTestImpl: public virtual acscomponent::ACSComponentImpl, public virtual POA_ACS::TaskComponent { public: execComponentTestImpl( const ACE_CString& name, maci::ContainerServices *containerServices ); virtual ~execComponentTestImpl(); /** Implentation of TaskComponent's run method which print what it gets as the parameter to stdio. If parameter is 'throw' the run method throws an exception of type: TaskRunFailureEx @param parameters: parameters that is send to run method of the task. @throw taskErrType::TaskRunFailureEx */ virtual void run (const ACS::StringSequence & parameters, const char* fileName); }; #endif /*!_H*/
ACS-Community/ACS
LGPL/CommonSoftware/task/include/execComponentTestImpl.h
C
lgpl-2.1
2,174
[ 30522, 1001, 2065, 13629, 2546, 1035, 4654, 8586, 1035, 6922, 1035, 17727, 2140, 1035, 1044, 1001, 9375, 1035, 4654, 8586, 1035, 6922, 1035, 17727, 2140, 1035, 1044, 1013, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, 1008, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// DlgMSMeer.cpp : implementation file // #include "stdafx.h" #include "Risa.h" #include "DlgMSMeer.h" #include "afxdialogex.h" #include "msImageProcessor.h" // CDlgMSMeer dialog IMPLEMENT_DYNAMIC(CDlgMSMeer, CDialogEx) CDlgMSMeer::CDlgMSMeer(cv::Mat* pmImg, bool bColor, CWnd* pParent /*=NULL*/) : CDialogEx(CDlgMSMeer::IDD, pParent) , m_nOP(0) , m_sigmaS(6) , m_sigmaR(2) , m_nMinRegion(100) { m_pmSource = pmImg; m_bColor = bColor; hasFilter_ = 0; hasSegment_ = 0; cbgImage_ = NULL; filtImage_ = NULL; segmImage_ = NULL; } CDlgMSMeer::~CDlgMSMeer() { if(cbgImage_ != NULL) delete cbgImage_; if(filtImage_ != NULL) delete filtImage_; if(segmImage_ != NULL) delete segmImage_; } void CDlgMSMeer::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Radio(pDX, IDC_RADIO_OP, m_nOP); DDX_Text(pDX, IDC_EDIT_BW_SPATIAL, m_sigmaS); DDX_Text(pDX, IDC_EDIT_BW_COLOR, m_sigmaR); DDX_Text(pDX, IDC_EDIT_MIN_REGION, m_nMinRegion); } BEGIN_MESSAGE_MAP(CDlgMSMeer, CDialogEx) ON_BN_CLICKED(IDC_RUN, &CDlgMSMeer::OnBnClickedRun) ON_BN_CLICKED(IDOK, &CDlgMSMeer::OnBnClickedOk) END_MESSAGE_MAP() // CDlgMSMeer message handlers void CDlgMSMeer::OnBnClickedRun() { // TODO: Add your control notification handler code here UpdateData(TRUE); // ==> variable BeginWaitCursor(); // parameters // sigma_s // sigma_r // a // epsilon // minRegion // kernel radius // filter // speedup level sigmaS = m_sigmaS; sigmaR = m_sigmaR; minRegion = m_nMinRegion; //, kernelSize //obtain image dimensions float speedUpThreshold_ = (float) 0.1; SpeedUpLevel speedUpLevel_ = MED_SPEEDUP;; int width, height; width = cbgImage_->x_; height = cbgImage_->y_; //obtain image type (color or grayscale) imageType gtype; if(cbgImage_->colorIm_) gtype = COLOR; else gtype = GRAYSCALE; gpMsgbar->ShowMessage("Input parameters:\n"); gpMsgbar->ShowMessage("\tSpatial Bandwidth\t= %4d\n\tColor Bandwidth\t= %4.1f\n", sigmaS, sigmaR); gpMsgbar->ShowMessage("\tMinimum Region\t= %4d\n", minRegion); //determine operation (filtering or segmentation) int operation = m_nOP; //create instance of image processor class msImageProcessor *iProc = new msImageProcessor(); //define an input image using the image under consideration //(if filtering or segmentation has taken place, then use this // result upon performing fusing...) if((operation == 2)&&(hasFilter_)) iProc->DefineImage(filtImage_->im_, gtype, height, width); else iProc->DefineImage(cbgImage_->im_, gtype, height, width); int dim; if(cbgImage_->colorIm_) { dim = 3; m_mResult.create(height, width, CV_8UC3); }else{ dim = 1; m_mResult.create(height, width, CV_8UC1); } iProc->SetSpeedThreshold(speedUpThreshold_); switch(operation) { //filter case 1: iProc->Filter(sigmaS, sigmaR, speedUpLevel_); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } else if (iProc->ErrorStatus == EL_HALT) { break; } //obtain the filtered image.... filtImage_->Resize(width, height, cbgImage_->colorIm_); iProc->GetResults(filtImage_->im_); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } //indicate that only the filtered image has been computed... hasFilter_ = 1; hasSegment_ = 0; memcpy(m_mResult.data, filtImage_->im_, dim*height*width*sizeof(unsigned char)); if(m_bColor) { cv::Mat bgr(height, width, CV_8UC3 ); int from_to[] = { 0,2, 1,1, 2,0}; cv::mixChannels( &m_mResult, 1, &bgr, 1, from_to, 3 ); bgr.copyTo(m_mResult); } cv::namedWindow("filter", CV_WINDOW_AUTOSIZE ); cv::imshow( "filter", m_mResult); break; //fuse case 2: iProc->FuseRegions(sigmaR, minRegion); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } else if (iProc->ErrorStatus == EL_HALT) { break; } //obtain the segmented image... segmImage_->Resize(width, height, cbgImage_->colorIm_); iProc->GetResults(segmImage_->im_); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } //indicate that the segmented image has been computed... hasSegment_ = 1; memcpy(m_mResult.data, segmImage_->im_, dim*height*width*sizeof(unsigned char)); if(m_bColor) { cv::Mat bgr(height, width, CV_8UC3 ); int from_to[] = { 0,2, 1,1, 2,0}; cv::mixChannels( &m_mResult, 1, &bgr, 1, from_to, 3 ); bgr.copyTo(m_mResult); } cv::namedWindow("fuse", CV_WINDOW_AUTOSIZE ); cv::imshow( "fuse", m_mResult); break; //segment default: //filter the image... iProc->Filter(sigmaS, sigmaR, speedUpLevel_); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } else if (iProc->ErrorStatus == EL_HALT) { break; } //filter the image.... unsigned char *tempImage = new unsigned char [dim*height*width]; iProc->GetResults(tempImage); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); delete [] tempImage; return; } //fuse regions... iProc->FuseRegions(sigmaR, minRegion); if (iProc->ErrorStatus == EL_ERROR) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); delete [] tempImage; return; } else if (iProc->ErrorStatus == EL_HALT) { delete [] tempImage; break; } //obtain the segmented and filtered image... filtImage_->Resize(width, height, cbgImage_->colorIm_); memcpy(filtImage_->im_, tempImage, dim*height*width*sizeof(unsigned char)); delete [] tempImage; segmImage_->Resize(width, height, cbgImage_->colorIm_); iProc->GetResults(segmImage_->im_); if (iProc->ErrorStatus) { gpMsgbar->ShowMessage("%s\n", iProc->ErrorMessage); return; } //indicate that both the filtered and segmented image have been computed... hasFilter_ = 1; hasSegment_ = 1; memcpy(m_mResult.data, segmImage_->im_, dim*height*width*sizeof(unsigned char)); if(m_bColor) { cv::Mat bgr(height, width, CV_8UC3 ); int from_to[] = { 0,2, 1,1, 2,0}; cv::mixChannels( &m_mResult, 1, &bgr, 1, from_to, 3 ); bgr.copyTo(m_mResult); } cv::namedWindow("segment", CV_WINDOW_AUTOSIZE ); cv::imshow( "segment", m_mResult); } //delete the image processing object delete iProc; EndWaitCursor(); } BOOL CDlgMSMeer::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: Add extra initialization here cbgImage_ = new BgImage(); filtImage_ = new BgImage(); segmImage_ = new BgImage(); if(m_bColor) { cv::Mat rgb(m_pmSource->rows, m_pmSource->cols, CV_8UC3 ); int from_to[] = { 0,2, 1,1, 2,0}; cv::mixChannels( m_pmSource, 1, &rgb, 1, from_to, 3 ); cbgImage_->SetImageFromRGB(rgb.data, rgb.cols, rgb.rows, true); //rgb.copyTo(pNew->m_cvMat); }else cbgImage_->SetImageFromRGB(m_pmSource->data, m_pmSource->cols, m_pmSource->rows, true); hasFilter_ = 0; hasSegment_ = 0; return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDlgMSMeer::OnBnClickedOk() { // TODO: Add your control notification handler code here CDialogEx::OnOK(); if(m_mResult.data != NULL) { m_mResult.copyTo(*m_pmSource); } }
HedgehogTW/Risa
DlgMSMeer.cpp
C++
gpl-3.0
7,364
[ 30522, 1013, 1013, 21469, 21693, 6491, 11510, 1012, 18133, 2361, 1024, 7375, 5371, 1013, 1013, 1001, 2421, 1000, 2358, 2850, 2546, 2595, 1012, 1044, 1000, 1001, 2421, 1000, 15544, 3736, 1012, 1044, 1000, 1001, 2421, 1000, 21469, 21693, 6491...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function(Blueprint $table) { $table->increments('id'); $table->string('name')->unique(); $table->string('empresa')->unique(); $table->string('first_name'); $table->string('last_name'); $table->string('email')->unique()->nullable(); $table->string('password', 60); $table->integer('role_id'); $table->rememberToken()->nullable(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('users'); } }
3dlink/age
database/migrations/2014_10_12_000000_create_users_table.php
PHP
mit
774
[ 30522, 1026, 1029, 25718, 2224, 5665, 12717, 12556, 1032, 7809, 1032, 8040, 28433, 1032, 2630, 16550, 1025, 2224, 5665, 12717, 12556, 1032, 7809, 1032, 9230, 2015, 1032, 9230, 1025, 2465, 3443, 20330, 9153, 3468, 8908, 9230, 1063, 1013, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
(function ($) { 'use strict'; // Device check for limiting resize handling. var IS_DEVICE = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); function FullHeight(el, options) { this.el = $(el); var data = {}; $.each(this.el.data(), function (attr, value) { if (/^fullheight/.test(attr)) { var key = attr.replace('fullheight', '').toLowerCase(); data[key] = value; } }); options = $.extend({}, FullHeight.defaults, options, data); this.debug = options.debug; this.container = $(options.container); this.property = options.property; this.propertyBefore = this.el.css(this.property); // Chrome for Android resizes the browser a lot when scrolling due to the address bar collapsing. // This causes a lot of arbitrary layout jumps and slow image resize operations with this plugin. // So for device UA where height should not change, we only update if the width changes as well (f.ex. // orientation changes). this.allowDeviceHeightResize = !( options.allowDeviceHeightResize === null || options.allowDeviceHeightResize === false || options.allowDeviceHeightResize === 'false' ); this.lastWidth = this.container.innerWidth(); this.timerResize = 0; this.container.on('resize.yrkup3.fullheight', $.proxy(this, '_onResize')); this.update(); } FullHeight.defaults = { debug: false, allowDeviceHeightResize: false, container: window, property: 'min-height' }; FullHeight.prototype._onResize = function () { var newWidth = this.container.innerWidth(); var allowResize = !IS_DEVICE || this.allowDeviceHeightResize || newWidth !== this.lastWidth; // Do the update if expected. if (allowResize) { var root = this; clearTimeout(this.timerResize); this.timerResize = setTimeout(function () { root.update(); }, 200); } this.lastWidth = newWidth; }; FullHeight.prototype.update = function () { if (this.debug) { console.log('update', this.el); } var newHeight; var offset = this.container.offset(); if (typeof offset == 'undefined') { newHeight = $(window).innerHeight(); } else { newHeight = this.container.innerHeight() - (this.el.offset().top - offset.top); } if (newHeight !== this.lastHeight) { if (this.debug) { console.log('set `' + this.property + '` to ' + newHeight); } this.el.css(this.property, newHeight); this.lastHeight = newHeight; } }; FullHeight.prototype.dispose = function () { if (this.debug) { console.log('dispose'); } this.container.off('.yrkup3.fullheight'); this.el.css(this.property, this.propertyBefore); }; $.fn.fullheight = function (options) { this.each(function () { var el = $(this); // Store data var data = el.data('yrkup3.fullheight'); if (!data) { el.data('yrkup3.fullheight', (data = new FullHeight(el, options))); } // Run command if (typeof options == 'string') { data[options](); } }); return this; }; })(jQuery);
yrkup3/jquery-fullheight
src/jquery-fullheight.js
JavaScript
mit
2,998
[ 30522, 1006, 3853, 1006, 1002, 1007, 1063, 1005, 2224, 9384, 1005, 1025, 1013, 1013, 5080, 4638, 2005, 14879, 24501, 4697, 8304, 1012, 13075, 2003, 1035, 5080, 1027, 1013, 11924, 1064, 4773, 2891, 1064, 18059, 1064, 25249, 1064, 26322, 1064...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sonic Visualiser An audio file viewer and annotation editor. Centre for Digital Music, Queen Mary, University of London. This file copyright 2006 Chris Cannam. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #include "TempDirectory.h" #include "ResourceFinder.h" #include "system/System.h" #include "Exceptions.h" #include <QDir> #include <QFile> #include <QMutexLocker> #include <QSettings> #include <iostream> #include <cassert> #include <unistd.h> #include <time.h> TempDirectory * TempDirectory::m_instance = new TempDirectory; TempDirectory * TempDirectory::getInstance() { return m_instance; } TempDirectory::TempDirectory() : m_tmpdir("") { } TempDirectory::~TempDirectory() { cerr << "TempDirectory::~TempDirectory" << endl; cleanup(); } void TempDirectory::cleanup() { cleanupDirectory(""); } QString TempDirectory::getContainingPath() { QMutexLocker locker(&m_mutex); QSettings settings; settings.beginGroup("TempDirectory"); QString svDirParent = settings.value("create-in", "$HOME").toString(); settings.endGroup(); QString svDir = ResourceFinder().getUserResourcePrefix(); if (svDirParent != "$HOME") { //!!! iffy svDir.replace(QDir::home().absolutePath(), svDirParent); } if (!QFileInfo(svDir).exists()) { if (!QDir(svDirParent).mkpath(svDir)) { throw DirectoryCreationFailed(QString("%1 directory in %2") .arg(svDir).arg(svDirParent)); } } else if (!QFileInfo(svDir).isDir()) { throw DirectoryCreationFailed(QString("%1 is not a directory") .arg(svDir)); } cleanupAbandonedDirectories(svDir); return svDir; } QString TempDirectory::getPath() { if (m_tmpdir != "") return m_tmpdir; return createTempDirectoryIn(getContainingPath()); } QString TempDirectory::createTempDirectoryIn(QString dir) { // Entered with mutex held. QDir tempDirBase(dir); // Generate a temporary directory. Qt4.1 doesn't seem to be able // to do this for us, and mkdtemp is not standard. This method is // based on the way glibc does mkdtemp. static QString chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; QString suffix; int padlen = 6, attempts = 100; unsigned int r = (unsigned int)(time(0) ^ getpid()); for (int i = 0; i < padlen; ++i) { suffix += "X"; } for (int j = 0; j < attempts; ++j) { unsigned int v = r; for (int i = 0; i < padlen; ++i) { suffix[i] = chars[v % 62]; v /= 62; } QString candidate = QString("sv_%1").arg(suffix); if (tempDirBase.mkpath(candidate)) { m_tmpdir = tempDirBase.filePath(candidate); break; } r = r + 7777; } if (m_tmpdir == "") { throw DirectoryCreationFailed(QString("temporary subdirectory in %1") .arg(tempDirBase.canonicalPath())); } QString pidpath = QDir(m_tmpdir).filePath(QString("%1.pid").arg(getpid())); QFile pidfile(pidpath); if (!pidfile.open(QIODevice::WriteOnly)) { throw DirectoryCreationFailed(QString("pid file creation in %1") .arg(m_tmpdir)); } else { pidfile.close(); } return m_tmpdir; } QString TempDirectory::getSubDirectoryPath(QString subdir) { QString tmpdirpath = getPath(); QMutexLocker locker(&m_mutex); QDir tmpdir(tmpdirpath); QFileInfo fi(tmpdir.filePath(subdir)); if (!fi.exists()) { if (!tmpdir.mkdir(subdir)) { throw DirectoryCreationFailed(fi.filePath()); } else { return fi.filePath(); } } else if (fi.isDir()) { return fi.filePath(); } else { throw DirectoryCreationFailed(fi.filePath()); } } void TempDirectory::cleanupDirectory(QString tmpdir) { bool isRoot = false; if (tmpdir == "") { m_mutex.lock(); isRoot = true; tmpdir = m_tmpdir; if (tmpdir == "") { m_mutex.unlock(); return; } } QDir dir(tmpdir); dir.setFilter(QDir::Dirs | QDir::Files); for (unsigned int i = 0; i < dir.count(); ++i) { if (dir[i] == "." || dir[i] == "..") continue; QFileInfo fi(dir.filePath(dir[i])); if (fi.isDir()) { cleanupDirectory(fi.absoluteFilePath()); } else { if (!QFile(fi.absoluteFilePath()).remove()) { cerr << "WARNING: TempDirectory::cleanup: " << "Failed to unlink file \"" << fi.absoluteFilePath() << "\"" << endl; } } } QString dirname = dir.dirName(); if (dirname != "") { if (!dir.cdUp()) { cerr << "WARNING: TempDirectory::cleanup: " << "Failed to cd to parent directory of " << tmpdir << endl; return; } if (!dir.rmdir(dirname)) { cerr << "WARNING: TempDirectory::cleanup: " << "Failed to remove directory " << dirname << endl; } } if (isRoot) { m_tmpdir = ""; m_mutex.unlock(); } } void TempDirectory::cleanupAbandonedDirectories(QString svDir) { QDir dir(svDir, "sv_*", QDir::Name, QDir::Dirs); for (unsigned int i = 0; i < dir.count(); ++i) { QString dirpath = dir.filePath(dir[i]); QDir subdir(dirpath, "*.pid", QDir::Name, QDir::Files); if (subdir.count() == 0) { cerr << "INFO: Found temporary directory with no .pid file in it!\n(directory=\"" << dirpath << "\"). Removing it..." << endl; cleanupDirectory(dirpath); cerr << "...done." << endl; continue; } for (unsigned int j = 0; j < subdir.count(); ++j) { bool ok = false; int pid = QFileInfo(subdir[j]).baseName().toInt(&ok); if (!ok) continue; if (GetProcessStatus(pid) == ProcessNotRunning) { cerr << "INFO: Found abandoned temporary directory from " << "a previous, defunct process\n(pid=" << pid << ", directory=\"" << dirpath << "\"). Removing it..." << endl; cleanupDirectory(dirpath); cerr << "...done." << endl; break; } } } }
praaline/Praaline
svcore/base/TempDirectory.cpp
C++
gpl-3.0
7,104
[ 30522, 1013, 1008, 1011, 1008, 1011, 1039, 1011, 3937, 1011, 16396, 1024, 1018, 27427, 4765, 1011, 21628, 2015, 1011, 5549, 1024, 9152, 2140, 1011, 1008, 1011, 6819, 1024, 2275, 24529, 1027, 1022, 8541, 1027, 1018, 25430, 1027, 1018, 1024, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
// // Copyright (c) 2004-2011 Jaroslaw Kowalski <jaak@jkowalski.net> // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // * Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistributions in binary form must reproduce the above copyright notice, // this list of conditions and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // * Neither the name of Jaroslaw Kowalski nor the names of its // contributors may be used to endorse or promote products derived from this // software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // #if !NET_CF && !SILVERLIGHT namespace NLog.Targets { using System.ComponentModel; using System.Text; using System.Text.RegularExpressions; using NLog.Config; /// <summary> /// Highlighting rule for Win32 colorful console. /// </summary> [NLogConfigurationItem] public class ConsoleWordHighlightingRule { private Regex compiledRegex; /// <summary> /// Initializes a new instance of the <see cref="ConsoleWordHighlightingRule" /> class. /// </summary> public ConsoleWordHighlightingRule() { this.BackgroundColor = ConsoleOutputColor.NoChange; this.ForegroundColor = ConsoleOutputColor.NoChange; } /// <summary> /// Initializes a new instance of the <see cref="ConsoleWordHighlightingRule" /> class. /// </summary> /// <param name="text">The text to be matched..</param> /// <param name="foregroundColor">Color of the foreground.</param> /// <param name="backgroundColor">Color of the background.</param> public ConsoleWordHighlightingRule(string text, ConsoleOutputColor foregroundColor, ConsoleOutputColor backgroundColor) { this.Text = text; this.ForegroundColor = foregroundColor; this.BackgroundColor = backgroundColor; } /// <summary> /// Gets or sets the regular expression to be matched. You must specify either <c>text</c> or <c>regex</c>. /// </summary> /// <docgen category='Rule Matching Options' order='10' /> public string Regex { get; set; } /// <summary> /// Gets or sets the text to be matched. You must specify either <c>text</c> or <c>regex</c>. /// </summary> /// <docgen category='Rule Matching Options' order='10' /> public string Text { get; set; } /// <summary> /// Gets or sets a value indicating whether to match whole words only. /// </summary> /// <docgen category='Rule Matching Options' order='10' /> [DefaultValue(false)] public bool WholeWords { get; set; } /// <summary> /// Gets or sets a value indicating whether to ignore case when comparing texts. /// </summary> /// <docgen category='Rule Matching Options' order='10' /> [DefaultValue(false)] public bool IgnoreCase { get; set; } /// <summary> /// Gets the compiled regular expression that matches either Text or Regex property. /// </summary> public Regex CompiledRegex { get { if (this.compiledRegex == null) { string regexpression = this.Regex; if (regexpression == null && this.Text != null) { regexpression = System.Text.RegularExpressions.Regex.Escape(this.Text); if (this.WholeWords) { regexpression = "\b" + regexpression + "\b"; } } RegexOptions regexOptions = RegexOptions.Compiled; if (this.IgnoreCase) { regexOptions |= RegexOptions.IgnoreCase; } this.compiledRegex = new Regex(regexpression, regexOptions); } return this.compiledRegex; } } /// <summary> /// Gets or sets the foreground color. /// </summary> /// <docgen category='Formatting Options' order='10' /> [DefaultValue("NoChange")] public ConsoleOutputColor ForegroundColor { get; set; } /// <summary> /// Gets or sets the background color. /// </summary> /// <docgen category='Formatting Options' order='10' /> [DefaultValue("NoChange")] public ConsoleOutputColor BackgroundColor { get; set; } internal string MatchEvaluator(Match m) { StringBuilder result = new StringBuilder(); result.Append('\a'); result.Append((char)((int)this.ForegroundColor + 'A')); result.Append((char)((int)this.BackgroundColor + 'A')); result.Append(m.Value); result.Append('\a'); result.Append('X'); return result.ToString(); } internal string ReplaceWithEscapeSequences(string message) { return this.CompiledRegex.Replace(message, new MatchEvaluator(this.MatchEvaluator)); } } } #endif
jkowalski/NLog
src/NLog/Targets/ConsoleWordHighlightingRule.cs
C#
bsd-3-clause
6,309
[ 30522, 1013, 1013, 1013, 1013, 9385, 1006, 1039, 1007, 2432, 1011, 2249, 15723, 2891, 14919, 28874, 1026, 14855, 4817, 1030, 1046, 24144, 9777, 3211, 1012, 5658, 1028, 1013, 1013, 1013, 1013, 2035, 2916, 9235, 1012, 1013, 1013, 1013, 1013, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * libtcod 1.5.0 * Copyright (c) 2008,2009,2010 Jice * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * The name of Jice may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Jice ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL Jice BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <math.h> #include <stdlib.h> #include <string.h> #include "libtcod.h" #define WAVELET_TILE_SIZE 32 #define WAVELET_ARAD 16 #define SIMPLEX_SCALE 0.5f #define WAVELET_SCALE 2.0f typedef struct { int ndim; unsigned char map[256]; // Randomized map of indexes into buffer float buffer[256][TCOD_NOISE_MAX_DIMENSIONS]; // Random 256 x ndim buffer // fractal stuff float H; float lacunarity; float exponent[TCOD_NOISE_MAX_OCTAVES]; float *waveletTileData; TCOD_random_t rand; } perlin_data_t; static float lattice( perlin_data_t *data, int ix, float fx, int iy, float fy, int iz, float fz, int iw, float fw) { int n[4] = {ix, iy, iz, iw}; float f[4] = {fx, fy, fz, fw}; int nIndex = 0; int i; float value = 0; for(i=0; i<data->ndim; i++) nIndex = data->map[(nIndex + n[i]) & 0xFF]; for(i=0; i<data->ndim; i++) value += data->buffer[nIndex][i] * f[i]; return value; } #define DEFAULT_SEED 0x15687436 #define DELTA 1e-6f #define SWAP(a, b, t) t = a; a = b; b = t #define FLOOR(a) ((a)> 0 ? ((int)a) : (((int)a)-1) ) #define CUBIC(a) ( a * a * (3 - 2*a) ) static void normalize(perlin_data_t *data, float *f) { float magnitude = 0; int i; for(i=0; i<data->ndim; i++) magnitude += f[i]*f[i]; magnitude = 1 / sqrtf(magnitude); for(i=0; i<data->ndim; i++) f[i] *= magnitude; } TCOD_noise_t TCOD_noise_new(int ndim, float hurst, float lacunarity, TCOD_random_t random) { perlin_data_t *data=(perlin_data_t *)calloc(sizeof(perlin_data_t),1); int i, j; unsigned char tmp; float f = 1; data->rand = random ? random : TCOD_random_get_instance(); data->ndim = ndim; for(i=0; i<256; i++) { data->map[i] = (unsigned char)i; for(j=0; j<data->ndim; j++) data->buffer[i][j] = TCOD_random_get_float(data->rand,-0.5, 0.5); normalize(data,data->buffer[i]); } while(--i) { j = TCOD_random_get_int(data->rand,0, 255); SWAP(data->map[i], data->map[j], tmp); } data->H = hurst; data->lacunarity = lacunarity; for(i=0; i<TCOD_NOISE_MAX_OCTAVES; i++) { //exponent[i] = powf(f, -H); data->exponent[i] = 1.0f / f; f *= lacunarity; } return (TCOD_noise_t)data; } float TCOD_noise_perlin( TCOD_noise_t noise, float *f ) { perlin_data_t *data=(perlin_data_t *)noise; int n[TCOD_NOISE_MAX_DIMENSIONS]; // Indexes to pass to lattice function int i; float r[TCOD_NOISE_MAX_DIMENSIONS]; // Remainders to pass to lattice function float w[TCOD_NOISE_MAX_DIMENSIONS]; // Cubic values to pass to interpolation function float value; for(i=0; i<data->ndim; i++) { n[i] = FLOOR(f[i]); r[i] = f[i] - n[i]; w[i] = CUBIC(r[i]); } switch(data->ndim) { case 1: value = LERP(lattice(data,n[0], r[0],0,0,0,0,0,0), lattice(data,n[0]+1, r[0]-1,0,0,0,0,0,0), w[0]); break; case 2: value = LERP(LERP(lattice(data,n[0], r[0], n[1], r[1],0,0,0,0), lattice(data,n[0]+1, r[0]-1, n[1], r[1],0,0,0,0), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1,0,0,0,0), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1,0,0,0,0), w[0]), w[1]); break; case 3: value = LERP(LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2], r[2],0,0), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2], r[2],0,0), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2], r[2],0,0), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2], r[2],0,0), w[0]), w[1]), LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2]+1, r[2]-1,0,0), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2]+1, r[2]-1,0,0), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2]+1, r[2]-1,0,0), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2]+1, r[2]-1,0,0), w[0]), w[1]), w[2]); break; case 4: default: value = LERP(LERP(LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2], r[2], n[3], r[3]), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2], r[2], n[3], r[3]), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2], r[2], n[3], r[3]), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2], r[2], n[3], r[3]), w[0]), w[1]), LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2]+1, r[2]-1, n[3], r[3]), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2]+1, r[2]-1, n[3], r[3]), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2]+1, r[2]-1,0,0), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2]+1, r[2]-1, n[3], r[3]), w[0]), w[1]), w[2]), LERP(LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2], r[2], n[3]+1, r[3]-1), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2], r[2], n[3]+1, r[3]-1), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2], r[2], n[3]+1, r[3]-1), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2], r[2], n[3]+1, r[3]-1), w[0]), w[1]), LERP(LERP(lattice(data,n[0], r[0], n[1], r[1], n[2]+1, r[2]-1, n[3]+1, r[3]-1), lattice(data,n[0]+1, r[0]-1, n[1], r[1], n[2]+1, r[2]-1, n[3]+1, r[3]-1), w[0]), LERP(lattice(data,n[0], r[0], n[1]+1, r[1]-1, n[2]+1, r[2]-1,0,0), lattice(data,n[0]+1, r[0]-1, n[1]+1, r[1]-1, n[2]+1, r[2]-1, n[3]+1, r[3]-1), w[0]), w[1]), w[2]), w[3]); break; } return CLAMP(-0.99999f, 0.99999f, value); } typedef float (*TCOD_noise_func_t)( TCOD_noise_t noise, float *f ); static float TCOD_noise_fbm_int(TCOD_noise_t noise, float *f, float octaves, TCOD_noise_func_t func ) { float tf[TCOD_NOISE_MAX_DIMENSIONS]; perlin_data_t *data=(perlin_data_t *)noise; // Initialize locals double value = 0; int i,j; memcpy(tf,f,sizeof(float)*data->ndim); // Inner loop of spectral construction, where the fractal is built for(i=0; i<(int)octaves; i++) { value += (double)(func(noise,tf)) * data->exponent[i]; for (j=0; j < data->ndim; j++) tf[j] *= data->lacunarity; } // Take care of remainder in octaves octaves -= (int)octaves; if(octaves > DELTA) value += (double)(octaves * func(noise,tf)) * data->exponent[i]; return CLAMP(-0.99999f, 0.99999f, (float)value); } float TCOD_noise_fbm_perlin( TCOD_noise_t noise, float *f, float octaves ) { return TCOD_noise_fbm_int(noise,f,octaves,TCOD_noise_perlin); /* float tf[TCOD_NOISE_MAX_DIMENSIONS]; perlin_data_t *data=(perlin_data_t *)noise; // Initialize locals double value = 0; int i,j; memcpy(tf,f,sizeof(float)*data->ndim); // Inner loop of spectral construction, where the fractal is built for(i=0; i<(int)octaves; i++) { value += (double)(TCOD_noise_simplex(noise,tf)) * data->exponent[i]; for (j=0; j < data->ndim; j++) tf[j] *= data->lacunarity; } // Take care of remainder in octaves octaves -= (int)octaves; if(octaves > DELTA) value += (double)(octaves * TCOD_noise_simplex(noise,tf)) * data->exponent[i]; return CLAMP(-0.99999f, 0.99999f, (float)value); */ } float TCOD_noise_fbm_simplex( TCOD_noise_t noise, float *f, float octaves ) { return TCOD_noise_fbm_int(noise,f,octaves,TCOD_noise_simplex); } static float TCOD_noise_turbulence_int( TCOD_noise_t noise, float *f, float octaves, TCOD_noise_func_t func ) { float tf[TCOD_NOISE_MAX_DIMENSIONS]; perlin_data_t *data=(perlin_data_t *)noise; // Initialize locals double value = 0; int i,j; memcpy(tf,f,sizeof(float)*data->ndim); // Inner loop of spectral construction, where the fractal is built for(i=0; i<(int)octaves; i++) { float nval=func(noise,tf); value += (double)(ABS(nval)) * data->exponent[i]; for (j=0; j < data->ndim; j++) tf[j] *= data->lacunarity; } // Take care of remainder in octaves octaves -= (int)octaves; if(octaves > DELTA) { float nval=func(noise,tf); value += (double)(octaves * ABS(nval)) * data->exponent[i]; } return CLAMP(-0.99999f, 0.99999f, (float)value); } float TCOD_noise_turbulence_perlin( TCOD_noise_t noise, float *f, float octaves ) { return TCOD_noise_turbulence_int(noise,f,octaves,TCOD_noise_perlin); } float TCOD_noise_turbulence_simplex( TCOD_noise_t noise, float *f, float octaves ) { return TCOD_noise_turbulence_int(noise,f,octaves,TCOD_noise_simplex); } // simplex noise, adapted from Ken Perlin's presentation at Siggraph 2001 // and Stefan Gustavson implementation #define TCOD_NOISE_SIMPLEX_GRADIENT_1D(n,h,x) { \ float grad; \ h &= 0xF; \ grad=1.0f+(h & 7); \ if ( h & 8 ) grad = -grad; \ n = grad * x; \ } #define TCOD_NOISE_SIMPLEX_GRADIENT_2D(n,h,x,y) { \ float u,v; \ h &= 0x7; \ if ( h < 4 ) { \ u=x; \ v=2.0f*y; \ } else { \ u=y; \ v=2.0f*x; \ } \ n = ((h & 1) ? -u : u) + ((h & 2) ? -v :v ); \ } #define TCOD_NOISE_SIMPLEX_GRADIENT_3D(n,h,x,y,z) { \ float u,v; \ h &= 0xF; \ u = (h < 8 ? x : y); \ v = (h < 4 ? y : ( h == 12 || h == 14 ? x : z ) ); \ n= ((h & 1) ? -u : u ) + ((h & 2) ? -v : v); \ } #define TCOD_NOISE_SIMPLEX_GRADIENT_4D(n,h,x,y,z,t) { \ float u,v,w; \ h &= 0x1F; \ u = (h < 24 ? x:y); \ v = (h < 16 ? y:z); \ w = (h < 8 ? z:t); \ n= ((h & 1) ? -u : u ) + ((h & 2) ? -v : v) + ((h & 4) ? -w : w);\ } static float simplex[64][4] = { {0,1,2,3},{0,1,3,2},{0,0,0,0},{0,2,3,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,2,3,0}, {0,2,1,3},{0,0,0,0},{0,3,1,2},{0,3,2,1},{0,0,0,0},{0,0,0,0},{0,0,0,0},{1,3,2,0}, {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, {1,2,0,3},{0,0,0,0},{1,3,0,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,3,0,1},{2,3,1,0}, {1,0,2,3},{1,0,3,2},{0,0,0,0},{0,0,0,0},{0,0,0,0},{2,0,3,1},{0,0,0,0},{2,1,3,0}, {0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}, {2,0,1,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,0,1,2},{3,0,2,1},{0,0,0,0},{3,1,2,0}, {2,1,0,3},{0,0,0,0},{0,0,0,0},{0,0,0,0},{3,1,0,2},{0,0,0,0},{3,2,0,1},{3,2,1,0}, }; float TCOD_noise_simplex(TCOD_noise_t noise, float *f) { perlin_data_t *data=(perlin_data_t *)noise; switch(data->ndim) { case 1 : { int i0=(int)FLOOR(f[0]*SIMPLEX_SCALE); int i1=i0+1; float x0 = f[0]*SIMPLEX_SCALE - i0; float x1 = x0 - 1.0f; float t0 = 1.0f - x0*x0; float t1 = 1.0f - x1*x1; float n0,n1; t0 = t0*t0; t1 = t1*t1; i0=data->map[i0&0xFF]; TCOD_NOISE_SIMPLEX_GRADIENT_1D(n0,i0,x0); n0*=t0*t0; i1=data->map[i1&0xFF]; TCOD_NOISE_SIMPLEX_GRADIENT_1D(n1,i1,x1); n1*=t1*t1; return 0.25f * (n0+n1); } break; case 2 : { #define F2 0.366025403f // 0.5f * (sqrtf(3.0f)-1.0f); #define G2 0.211324865f // (3.0f - sqrtf(3.0f))/6.0f; float s = (f[0]+f[1])*F2*SIMPLEX_SCALE; float xs = f[0]*SIMPLEX_SCALE+s; float ys = f[1]*SIMPLEX_SCALE+s; int i=FLOOR(xs); int j=FLOOR(ys); float t = (i+j)*G2; float xo = i-t; float yo = j-t; float x0 = f[0]*SIMPLEX_SCALE-xo; float y0 = f[1]*SIMPLEX_SCALE-yo; int i1,j1,ii = i%256,jj = j%256; float n0,n1,n2,x1,y1,x2,y2,t0,t1,t2; if ( x0 > y0 ) { i1=1;j1=0; } else { i1=0;j1=1; } x1 = x0 - i1 + G2; y1 = y0 - j1 + G2; x2 = x0 - 1.0f + 2.0f * G2; y2 = y0 - 1.0f + 2.0f * G2; t0 = 0.5f - x0*x0 - y0*y0; if ( t0 < 0.0f ) { n0 = 0.0f; } else { int idx = (ii + data->map[jj])&0xFF; t0 *= t0; idx=data->map[idx]; TCOD_NOISE_SIMPLEX_GRADIENT_2D(n0,idx,x0,y0); n0 *= t0*t0; } t1 = 0.5f - x1*x1 -y1*y1; if ( t1 < 0.0f ) { n1 = 0.0f; } else { int idx = (ii + i1 + data->map[(jj+j1)&0xFF]) & 0xFF; t1 *= t1; idx=data->map[idx]; TCOD_NOISE_SIMPLEX_GRADIENT_2D(n1,idx,x1,y1); n1 *= t1*t1; } t2 = 0.5f - x2*x2 -y2*y2; if ( t2 < 0.0f ) { n2 = 0.0f; } else { int idx = (ii + 1 + data->map[(jj+1)&0xFF]) & 0xFF; t2 *= t2; idx=data->map[idx]; TCOD_NOISE_SIMPLEX_GRADIENT_2D(n2,idx,x2,y2); n2 *= t2*t2; } return 40.0f * (n0+n1+n2); } break; case 3 : { #define F3 0.333333333f #define G3 0.166666667f float n0,n1,n2,n3; float s =(f[0]+f[1]+f[2])*F3*SIMPLEX_SCALE; float xs=f[0]*SIMPLEX_SCALE+s; float ys=f[1]*SIMPLEX_SCALE+s; float zs=f[2]*SIMPLEX_SCALE+s; int i=FLOOR(xs); int j=FLOOR(ys); int k=FLOOR(zs); float t=(float)(i+j+k)*G3; float xo = i-t; float yo = j-t; float zo = k-t; float x0 = f[0]*SIMPLEX_SCALE-xo; float y0 = f[1]*SIMPLEX_SCALE-yo; float z0 = f[2]*SIMPLEX_SCALE-zo; int i1,j1,k1,i2,j2,k2,ii,jj,kk; float x1,y1,z1,x2,y2,z2,x3,y3,z3,t0,t1,t2,t3; if ( x0 >= y0 ) { if ( y0 >= z0 ) { i1=1;j1=0;k1=0;i2=1;j2=1;k2=0; } else if ( x0 >= z0 ) { i1=1;j1=0;k1=0;i2=1;j2=0;k2=1; } else { i1=0;j1=0;k1=1;i2=1;j2=0;k2=1; } } else { if ( y0 < z0 ) { i1=0;j1=0;k1=1;i2=0;j2=1;k2=1; } else if ( x0 < z0 ) { i1=0;j1=1;k1=0;i2=0;j2=1;k2=1; } else { i1=0;j1=1;k1=0;i2=1;j2=1;k2=0; } } x1 = x0 -i1 + G3; y1 = y0 -j1 + G3; z1 = z0 -k1 + G3; x2 = x0 -i2 + 2.0f*G3; y2 = y0 -j2 + 2.0f*G3; z2 = z0 -k2 + 2.0f*G3; x3 = x0 - 1.0f +3.0f * G3; y3 = y0 - 1.0f +3.0f * G3; z3 = z0 - 1.0f +3.0f * G3; ii = i%256; jj = j%256; kk = k%256; t0 = 0.6f - x0*x0 -y0*y0 -z0*z0; if ( t0 < 0.0f ) n0 = 0.0f; else { int idx = data->map[ (ii + data->map[ (jj + data->map[ kk ]) &0xFF ])& 0xFF ]; t0 *= t0; TCOD_NOISE_SIMPLEX_GRADIENT_3D(n0,idx,x0,y0,z0); n0 *= t0*t0; } t1 = 0.6f - x1*x1 -y1*y1 -z1*z1; if ( t1 < 0.0f ) n1 = 0.0f; else { int idx = data->map[ (ii + i1 + data->map[ (jj + j1 + data->map[ (kk + k1)& 0xFF ]) &0xFF ])& 0xFF ]; t1 *= t1; TCOD_NOISE_SIMPLEX_GRADIENT_3D(n1,idx,x1,y1,z1); n1 *= t1*t1; } t2 = 0.6f - x2*x2 -y2*y2 -z2*z2; if ( t2 < 0.0f ) n2 = 0.0f; else { int idx = data->map[ (ii + i2 + data->map[ (jj + j2 + data->map[ (kk + k2)& 0xFF ]) &0xFF ])& 0xFF ]; t2 *= t2; TCOD_NOISE_SIMPLEX_GRADIENT_3D(n2,idx,x2,y2,z2); n2 *= t2*t2; } t3 = 0.6f - x3*x3 -y3*y3 -z3*z3; if ( t3 < 0.0f ) n3 = 0.0f; else { int idx = data->map[ (ii + 1 + data->map[ (jj + 1 + data->map[ (kk + 1)& 0xFF ]) &0xFF ])& 0xFF ]; t3 *= t3; TCOD_NOISE_SIMPLEX_GRADIENT_3D(n3,idx,x3,y3,z3); n3 *= t3*t3; } return 32.0f * (n0+n1+n2+n3); } break; case 4 : { #define F4 0.309016994f // (sqrtf(5.0f)-1.0f)/4.0f #define G4 0.138196601f // (5.0f - sqrtf(5.0f))/20.0f float n0,n1,n2,n3,n4; float s = (f[0]+f[1]+f[2]+f[3])*F4 * SIMPLEX_SCALE; float xs=f[0]*SIMPLEX_SCALE+s; float ys=f[1]*SIMPLEX_SCALE+s; float zs=f[2]*SIMPLEX_SCALE+s; float ws=f[3]*SIMPLEX_SCALE+s; int i=FLOOR(xs); int j=FLOOR(ys); int k=FLOOR(zs); int l=FLOOR(ws); float t=(float)(i+j+k+l)*G4; float xo = i-t; float yo = j-t; float zo = k-t; float wo = l-t; float x0 = f[0]*SIMPLEX_SCALE-xo; float y0 = f[1]*SIMPLEX_SCALE-yo; float z0 = f[2]*SIMPLEX_SCALE-zo; float w0 = f[3]*SIMPLEX_SCALE-wo; int c1 = (x0 > y0 ? 32 : 0); int c2 = (x0 > z0 ? 16 : 0); int c3 = (y0 > z0 ? 8 : 0); int c4 = (x0 > w0 ? 4 : 0); int c5 = (y0 > w0 ? 2 : 0); int c6 = (z0 > w0 ? 1 : 0); int c = c1+c2+c3+c4+c5+c6; int i1,j1,k1,l1,i2,j2,k2,l2,i3,j3,k3,l3,ii,jj,kk,ll; float x1,y1,z1,w1,x2,y2,z2,w2,x3,y3,z3,w3,x4,y4,z4,w4,t0,t1,t2,t3,t4; i1 = simplex[c][0] >= 3 ? 1:0; j1 = simplex[c][1] >= 3 ? 1:0; k1 = simplex[c][2] >= 3 ? 1:0; l1 = simplex[c][3] >= 3 ? 1:0; i2 = simplex[c][0] >= 2 ? 1:0; j2 = simplex[c][1] >= 2 ? 1:0; k2 = simplex[c][2] >= 2 ? 1:0; l2 = simplex[c][3] >= 2 ? 1:0; i3 = simplex[c][0] >= 1 ? 1:0; j3 = simplex[c][1] >= 1 ? 1:0; k3 = simplex[c][2] >= 1 ? 1:0; l3 = simplex[c][3] >= 1 ? 1:0; x1 = x0 -i1 + G4; y1 = y0 -j1 + G4; z1 = z0 -k1 + G4; w1 = w0 -l1 + G4; x2 = x0 -i2 + 2.0f*G4; y2 = y0 -j2 + 2.0f*G4; z2 = z0 -k2 + 2.0f*G4; w2 = w0 -l2 + 2.0f*G4; x3 = x0 -i3 + 3.0f*G4; y3 = y0 -j3 + 3.0f*G4; z3 = z0 -k3 + 3.0f*G4; w3 = w0 -l3 + 3.0f*G4; x4 = x0 - 1.0f +4.0f * G4; y4 = y0 - 1.0f +4.0f * G4; z4 = z0 - 1.0f +4.0f * G4; w4 = w0 - 1.0f +4.0f * G4; ii = i%256; jj = j%256; kk = k%256; ll = l%256; t0 = 0.6f - x0*x0 -y0*y0 -z0*z0 -w0*w0; if ( t0 < 0.0f ) n0 = 0.0f; else { int idx = data->map[ (ii + data->map[ (jj + data->map[ (kk + data->map[ ll ] ) &0xFF]) &0xFF ])& 0xFF ]; t0 *= t0; TCOD_NOISE_SIMPLEX_GRADIENT_4D(n0,idx,x0,y0,z0,w0); n0 *= t0*t0; } t1 = 0.6f - x1*x1 -y1*y1 -z1*z1 -w1*w1; if ( t1 < 0.0f ) n1 = 0.0f; else { int idx = data->map[ (ii + i1 + data->map[ (jj + j1 + data->map[ (kk + k1 + data->map[ (ll+l1)&0xFF])& 0xFF ]) &0xFF ])& 0xFF ]; t1 *= t1; TCOD_NOISE_SIMPLEX_GRADIENT_4D(n1,idx,x1,y1,z1,w1); n1 *= t1*t1; } t2 = 0.6f - x2*x2 -y2*y2 -z2*z2 -w2*w2; if ( t2 < 0.0f ) n2 = 0.0f; else { int idx = data->map[ (ii + i2 + data->map[ (jj + j2 + data->map[ (kk + k2 + data->map[(ll+l2)&0xFF])& 0xFF ]) &0xFF ])& 0xFF ]; t2 *= t2; TCOD_NOISE_SIMPLEX_GRADIENT_4D(n2,idx,x2,y2,z2,w2); n2 *= t2*t2; } t3 = 0.6f - x3*x3 -y3*y3 -z3*z3 -w3*w3; if ( t3 < 0.0f ) n3 = 0.0f; else { int idx = data->map[ (ii + i3 + data->map[ (jj + j3 + data->map[ (kk + k3 + data->map[(ll+l3)&0xFF])& 0xFF ]) &0xFF ])& 0xFF ]; t3 *= t3; TCOD_NOISE_SIMPLEX_GRADIENT_4D(n3,idx,x3,y3,z3,w3); n3 *= t3*t3; } t4 = 0.6f - x4*x4 -y4*y4 -z4*z4 -w4*w4; if ( t4 < 0.0f ) n4 = 0.0f; else { int idx = data->map[ (ii + 1 + data->map[ (jj + 1 + data->map[ (kk + 1 + data->map[(ll+1)&0xFF])& 0xFF ]) &0xFF ])& 0xFF ]; t4 *= t4; TCOD_NOISE_SIMPLEX_GRADIENT_4D(n4,idx,x4,y4,z4,w4); n4 *= t4*t4; } return 27.0f * (n0+n1+n2+n3+n4); } break; } return 0.0f; } // wavelet noise, adapted from Robert L. Cook and Tony Derose 'Wavelet noise' paper static int absmod(int x, int n) { int m=x%n; return m < 0 ? m+n : m; } static void TCOD_noise_wavelet_downsample(float *from, float *to, int stride) { static float acoeffs[2*WAVELET_ARAD]= { 0.000334f, -0.001528f, 0.000410f, 0.003545f, -0.000938f, -0.008233f, 0.002172f, 0.019120f, -0.005040f,-0.044412f, 0.011655f, 0.103311f, -0.025936f, -0.243780f, 0.033979f, 0.655340f, 0.655340f, 0.033979f,-0.243780f,-0.025936f, 0.103311f, 0.011655f,-0.044412f,-0.005040f, 0.019120f, 0.002172f,-0.008233f,-0.000938f, 0.003546f, 0.000410f,-0.001528f, 0.000334f, }; static float *a = &acoeffs[WAVELET_ARAD]; int i; for (i=0; i < WAVELET_TILE_SIZE/2; i++) { int k; to[i*stride]=0; for (k=2*i-WAVELET_ARAD; k <2*i+WAVELET_ARAD; k++) { to[i*stride] += a[k-2*i]* from[ absmod(k,WAVELET_TILE_SIZE) * stride ]; } } } static void TCOD_noise_wavelet_upsample(float *from, float *to, int stride) { static float pcoeffs[4]= { 0.25f, 0.75f, 0.75f, 0.25f }; static float *p = &pcoeffs[2]; int i; for (i=0; i < WAVELET_TILE_SIZE; i++) { int k; to[i*stride]=0; for (k=i/2; k <i/2+1; k++) { to[i*stride] += p[i-2*k]* from[ absmod(k,WAVELET_TILE_SIZE/2) * stride ]; } } } static void TCOD_noise_wavelet_init(TCOD_noise_t pnoise) { perlin_data_t *data=(perlin_data_t *)pnoise; int ix,iy,iz,i,sz=WAVELET_TILE_SIZE*WAVELET_TILE_SIZE*WAVELET_TILE_SIZE*sizeof(float); float *temp1=(float *)malloc(sz); float *temp2=(float *)malloc(sz); float *noise=(float *)malloc(sz); int offset; for (i=0; i < WAVELET_TILE_SIZE*WAVELET_TILE_SIZE*WAVELET_TILE_SIZE; i++ ) { noise[i]=TCOD_random_get_float(data->rand,-1.0f,1.0f); } for (iy=0; iy < WAVELET_TILE_SIZE; iy++ ) { for (iz=0; iz < WAVELET_TILE_SIZE; iz++ ) { i = iy * WAVELET_TILE_SIZE + iz * WAVELET_TILE_SIZE * WAVELET_TILE_SIZE; TCOD_noise_wavelet_downsample(&noise[i], &temp1[i], 1); TCOD_noise_wavelet_upsample(&temp1[i], &temp2[i], 1); } } for (ix=0; ix < WAVELET_TILE_SIZE; ix++ ) { for (iz=0; iz < WAVELET_TILE_SIZE; iz++ ) { i = ix + iz * WAVELET_TILE_SIZE * WAVELET_TILE_SIZE; TCOD_noise_wavelet_downsample(&temp2[i], &temp1[i], WAVELET_TILE_SIZE); TCOD_noise_wavelet_upsample(&temp1[i], &temp2[i], WAVELET_TILE_SIZE); } } for (ix=0; ix < WAVELET_TILE_SIZE; ix++ ) { for (iy=0; iy < WAVELET_TILE_SIZE; iy++ ) { i = ix + iy * WAVELET_TILE_SIZE; TCOD_noise_wavelet_downsample(&temp2[i], &temp1[i], WAVELET_TILE_SIZE * WAVELET_TILE_SIZE); TCOD_noise_wavelet_upsample(&temp1[i], &temp2[i], WAVELET_TILE_SIZE * WAVELET_TILE_SIZE); } } for (i=0; i < WAVELET_TILE_SIZE*WAVELET_TILE_SIZE*WAVELET_TILE_SIZE; i++ ) { noise[i] -= temp2[i]; } offset = WAVELET_TILE_SIZE/2; if ( (offset & 1) == 0 ) offset++; for (i=0,ix=0; ix < WAVELET_TILE_SIZE; ix++ ) { for (iy=0; iy < WAVELET_TILE_SIZE; iy++ ) { for (iz=0; iz < WAVELET_TILE_SIZE; iz++ ) { temp1[i++]=noise[ absmod(ix+offset,WAVELET_TILE_SIZE) + absmod(iy+offset,WAVELET_TILE_SIZE)*WAVELET_TILE_SIZE + absmod(iz+offset,WAVELET_TILE_SIZE)*WAVELET_TILE_SIZE*WAVELET_TILE_SIZE ]; } } } for (i=0; i < WAVELET_TILE_SIZE*WAVELET_TILE_SIZE*WAVELET_TILE_SIZE; i++ ) { noise[i] += temp1[i]; } data->waveletTileData=noise; free(temp1); free(temp2); } float TCOD_noise_wavelet (TCOD_noise_t noise, float *f) { perlin_data_t *data=(perlin_data_t *)noise; float pf[3]; int i; int p[3],c[3],mid[3],n=WAVELET_TILE_SIZE; float w[3][3],t,result=0.0f; if ( data->ndim > 3 ) return 0.0f; // not supported if (! data->waveletTileData ) TCOD_noise_wavelet_init(noise); for (i=0; i < data->ndim; i++ ) pf[i]=f[i]*WAVELET_SCALE; for (i=data->ndim; i < 3; i++ ) pf[i]=0.0f; for (i=0; i < 3; i++ ) { mid[i]=(int)ceilf(pf[i]-0.5f); t=mid[i] - (pf[i]-0.5f); w[i][0]=t*t*0.5f; w[i][2]=(1.0f-t)*(1.0f-t)*0.5f; w[i][1]=1.0f - w[i][0]-w[i][2]; } for (p[2]=-1; p[2]<=1; p[2]++) { for (p[1]=-1; p[1]<=1; p[1]++) { for (p[0]=-1; p[0]<=1; p[0]++) { float weight=1.0f; for (i=0;i<3;i++) { c[i]=absmod(mid[i]+p[i],n); weight *= w[i][p[i]+1]; } result += weight * data->waveletTileData[ c[2]*n*n + c[1]*n + c[0] ]; } } } return CLAMP(-1.0f,1.0f,result); } float TCOD_noise_fbm_wavelet(TCOD_noise_t noise, float *f, float octaves) { return TCOD_noise_fbm_int(noise,f,octaves,TCOD_noise_wavelet); } float TCOD_noise_turbulence_wavelet(TCOD_noise_t noise, float *f, float octaves) { return TCOD_noise_turbulence_int(noise,f,octaves,TCOD_noise_wavelet); } void TCOD_noise_delete(TCOD_noise_t noise) { free((perlin_data_t *)noise); }
tenpn/toweringinferno
libtcod-1.5.0/src/noise_c.c
C
gpl-3.0
23,853
[ 30522, 1013, 1008, 1008, 5622, 19279, 3597, 2094, 1015, 1012, 1019, 1012, 1014, 1008, 9385, 1006, 1039, 1007, 2263, 1010, 2268, 1010, 2230, 10147, 3401, 1008, 2035, 2916, 9235, 1012, 1008, 1008, 25707, 1998, 2224, 1999, 3120, 1998, 12441, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Route} from '../config'; import {defaultUrlMatcher, PRIMARY_OUTLET} from '../shared'; import {UrlSegment, UrlSegmentGroup} from '../url_tree'; import {forEach} from './collection'; import {getOutlet} from './config'; export interface MatchResult { matched: boolean; consumedSegments: UrlSegment[]; lastChild: number; parameters: {[k: string]: string}; positionalParamSegments: {[k: string]: UrlSegment}; } const noMatch: MatchResult = { matched: false, consumedSegments: [], lastChild: 0, parameters: {}, positionalParamSegments: {} }; export function match( segmentGroup: UrlSegmentGroup, route: Route, segments: UrlSegment[]): MatchResult { if (route.path === '') { if (route.pathMatch === 'full' && (segmentGroup.hasChildren() || segments.length > 0)) { return {...noMatch}; } return { matched: true, consumedSegments: [], lastChild: 0, parameters: {}, positionalParamSegments: {} }; } const matcher = route.matcher || defaultUrlMatcher; const res = matcher(segments, segmentGroup, route); if (!res) return {...noMatch}; const posParams: {[n: string]: string} = {}; forEach(res.posParams!, (v: UrlSegment, k: string) => { posParams[k] = v.path; }); const parameters = res.consumed.length > 0 ? {...posParams, ...res.consumed[res.consumed.length - 1].parameters} : posParams; return { matched: true, consumedSegments: res.consumed, lastChild: res.consumed.length, // TODO(atscott): investigate combining parameters and positionalParamSegments parameters, positionalParamSegments: res.posParams ?? {} }; } export function split( segmentGroup: UrlSegmentGroup, consumedSegments: UrlSegment[], slicedSegments: UrlSegment[], config: Route[], relativeLinkResolution: 'legacy'|'corrected' = 'corrected') { if (slicedSegments.length > 0 && containsEmptyPathMatchesWithNamedOutlets(segmentGroup, slicedSegments, config)) { const s = new UrlSegmentGroup( consumedSegments, createChildrenForEmptyPaths( segmentGroup, consumedSegments, config, new UrlSegmentGroup(slicedSegments, segmentGroup.children))); s._sourceSegment = segmentGroup; s._segmentIndexShift = consumedSegments.length; return {segmentGroup: s, slicedSegments: []}; } if (slicedSegments.length === 0 && containsEmptyPathMatches(segmentGroup, slicedSegments, config)) { const s = new UrlSegmentGroup( segmentGroup.segments, addEmptyPathsToChildrenIfNeeded( segmentGroup, consumedSegments, slicedSegments, config, segmentGroup.children, relativeLinkResolution)); s._sourceSegment = segmentGroup; s._segmentIndexShift = consumedSegments.length; return {segmentGroup: s, slicedSegments}; } const s = new UrlSegmentGroup(segmentGroup.segments, segmentGroup.children); s._sourceSegment = segmentGroup; s._segmentIndexShift = consumedSegments.length; return {segmentGroup: s, slicedSegments}; } function addEmptyPathsToChildrenIfNeeded( segmentGroup: UrlSegmentGroup, consumedSegments: UrlSegment[], slicedSegments: UrlSegment[], routes: Route[], children: {[name: string]: UrlSegmentGroup}, relativeLinkResolution: 'legacy'|'corrected'): {[name: string]: UrlSegmentGroup} { const res: {[name: string]: UrlSegmentGroup} = {}; for (const r of routes) { if (emptyPathMatch(segmentGroup, slicedSegments, r) && !children[getOutlet(r)]) { const s = new UrlSegmentGroup([], {}); s._sourceSegment = segmentGroup; if (relativeLinkResolution === 'legacy') { s._segmentIndexShift = segmentGroup.segments.length; } else { s._segmentIndexShift = consumedSegments.length; } res[getOutlet(r)] = s; } } return {...children, ...res}; } function createChildrenForEmptyPaths( segmentGroup: UrlSegmentGroup, consumedSegments: UrlSegment[], routes: Route[], primarySegment: UrlSegmentGroup): {[name: string]: UrlSegmentGroup} { const res: {[name: string]: UrlSegmentGroup} = {}; res[PRIMARY_OUTLET] = primarySegment; primarySegment._sourceSegment = segmentGroup; primarySegment._segmentIndexShift = consumedSegments.length; for (const r of routes) { if (r.path === '' && getOutlet(r) !== PRIMARY_OUTLET) { const s = new UrlSegmentGroup([], {}); s._sourceSegment = segmentGroup; s._segmentIndexShift = consumedSegments.length; res[getOutlet(r)] = s; } } return res; } function containsEmptyPathMatchesWithNamedOutlets( segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], routes: Route[]): boolean { return routes.some( r => emptyPathMatch(segmentGroup, slicedSegments, r) && getOutlet(r) !== PRIMARY_OUTLET); } function containsEmptyPathMatches( segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], routes: Route[]): boolean { return routes.some(r => emptyPathMatch(segmentGroup, slicedSegments, r)); } function emptyPathMatch( segmentGroup: UrlSegmentGroup, slicedSegments: UrlSegment[], r: Route): boolean { if ((segmentGroup.hasChildren() || slicedSegments.length > 0) && r.pathMatch === 'full') { return false; } return r.path === ''; } /** * Determines if `route` is a path match for the `rawSegment`, `segments`, and `outlet` without * verifying that its children are a full match for the remainder of the `rawSegment` children as * well. */ export function isImmediateMatch( route: Route, rawSegment: UrlSegmentGroup, segments: UrlSegment[], outlet: string): boolean { // We allow matches to empty paths when the outlets differ so we can match a url like `/(b:b)` to // a config like // * `{path: '', children: [{path: 'b', outlet: 'b'}]}` // or even // * `{path: '', outlet: 'a', children: [{path: 'b', outlet: 'b'}]` // // The exception here is when the segment outlet is for the primary outlet. This would // result in a match inside the named outlet because all children there are written as primary // outlets. So we need to prevent child named outlet matches in a url like `/b` in a config like // * `{path: '', outlet: 'x' children: [{path: 'b'}]}` // This should only match if the url is `/(x:b)`. if (getOutlet(route) !== outlet && (outlet === PRIMARY_OUTLET || !emptyPathMatch(rawSegment, segments, route))) { return false; } if (route.path === '**') { return true; } return match(rawSegment, route, segments).matched; } export function noLeftoversInUrl( segmentGroup: UrlSegmentGroup, segments: UrlSegment[], outlet: string): boolean { return segments.length === 0 && !segmentGroup.children[outlet]; }
blesh/angular
packages/router/src/utils/config_matching.ts
TypeScript
mit
6,910
[ 30522, 1013, 1008, 1008, 1008, 1030, 6105, 1008, 9385, 8224, 11775, 2035, 2916, 9235, 1012, 1008, 1008, 2224, 1997, 2023, 3120, 3642, 2003, 9950, 2011, 2019, 10210, 1011, 2806, 6105, 2008, 2064, 2022, 1008, 2179, 1999, 1996, 6105, 5371, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#include "mlvalues.h" #include "memory.h" #include "callback.h" value mycallback1(value fun, value arg) { value res; res = callback(fun, arg); return res; } value mycallback2(value fun, value arg1, value arg2) { value res; res = callback2(fun, arg1, arg2); return res; } value mycallback3(value fun, value arg1, value arg2, value arg3) { value res; res = callback3(fun, arg1, arg2, arg3); return res; } value mycallback4(value fun, value arg1, value arg2, value arg3, value arg4) { value args[4]; value res; args[0] = arg1; args[1] = arg2; args[2] = arg3; args[3] = arg4; res = callbackN(fun, 4, args); return res; } value mypushroot(value v, value fun, value arg) { Begin_root(v) callback(fun, arg); End_roots(); return v; } value mycamlparam (value v, value fun, value arg) { CAMLparam3 (v, fun, arg); CAMLlocal2 (x, y); x = v; y = callback (fun, arg); v = x; CAMLreturn (v); }
mzp/coq-for-ipad
src/ocaml-3.12.0/testsuite/tests/callback/callbackprim.c
C
mit
942
[ 30522, 1001, 2421, 1000, 19875, 10175, 15808, 1012, 1044, 1000, 1001, 2421, 1000, 3638, 1012, 1044, 1000, 1001, 2421, 1000, 2655, 5963, 1012, 1044, 1000, 3643, 2026, 9289, 20850, 8684, 2487, 1006, 3643, 4569, 1010, 3643, 12098, 2290, 1007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php session_start(); include_once("../../lib/general/headhtml.php"); require_once("../../lib/modelo/business/ingresos.class.php"); $bd=new basedatosAdo(); //AQUI SE CONFIGURAN LOS CATALOGOS PREGUNTAR A CARLOS //OBJETO CODIGO EMPLEADO $catalogo[] = ingresos::catalogo_codpre('codpre1'); $catalogo[] = ingresos::catalogo_codpre('codpre2'); $_SESSION['ingresos'] = $catalogo; $titulo='REPORTE DE INGRESOS'; $orientacion='VERTICAL'; $tipopagina='CARTA'; ?> <?php include_once("../../lib/general/formtop.php")?> <tr> <td class="form_label_01"> <div align="left"><strong>C&oacute;digo de Presuspuestario:</strong></div></td> <td> <div align="left"> <? $tb=$bd->select("select min(distinct(codpre)) as codpre from ingresos");?> <input name="codpre1" type="text" class="breadcrumb" id="codpre1" value="<? echo $tb->fields['codpre'] ?>" size ="20"> <a href="#"><img src="../../img/search.gif" align="top" onclick="catalogo('ingresos',0); "></a> <!--AQUI SE HACEN LOS CATÁLOGOS --> </div></td> <td> <div align="left"> <? $tb=$bd->select("select max(distinct(codpre)) as codpre from ingresos");?> <input name="codpre2" type="text" class="breadcrumb" id="codpre2" value="<? echo $tb->fields['codpre'] ?>" size ="20"> <a href="#"><img src="../../img/search.gif" align="top" onclick="catalogo('ingresos',1); "></a> <!--AQUI SE HACEN LOS CATÁLOGOS --> </div></td> </tr> <!-- <tr> <td class="form_label_01"><strong>Acumulado:</strong></td> <td> <select id="status" name="status" class="breadcrumb"> <option value="S">SI</option> <option value="N">NO</option> </select> </td> <td>&nbsp; </td> </tr> <tr> --> <td class="form_label_01"><strong>Peri&oacute;do:</strong></td> <td> <select id="periodo" name="periodo" class="breadcrumb"> <? $sql="SELECT DISTINCT B.PEREJE as pereje FROM CONTABA A, CONTABA1 B WHERE A.FECINI = B.FECINI AND A.FECCIE = B.FECCIE ORDER BY B.PEREJE"; ?> <? LlenarComboSql($sql,"pereje","pereje","",$bd,0); ?> </select> </td> <td>&nbsp; </td> </tr> <!-- <tr> <td class="form_label_01"><strong>Niveles:</strong></td> <td> <? $tb=$bd->select("SELECT numrup as nrorup FROM CONTABA"); $auxnive11=$tb->fields["nrorup"]; ?> <input name="auxnivel" type="text" class="breadcrumb" id="auxnivel" size="3" maxlength="3" value="<? echo $tb->fields['nrorup'] ?>"> <font color="#000066" size="4"><strong> <input name="nrorup" type="hidden" id="nrorup" value="<? print $auxnive11; ?>"> </strong></font></td> <td>&nbsp;</td> </tr> <tr bordercolor="#FFFFFF"> <td class="form_label_01"><strong>Niveles Totales:</strong></td> <td colspan="2"> <? $tb=$bd->select("SELECT numrup as nrorup FROM CONTABA"); $auxnive2=$tb->fields["nrorup"]; ?> <input name="auxnivel2" type="text" class="breadcrumb" id="auxnivel2" size="3" maxlength="3" value="<? echo $tb->fields['nrorup'] ?>"> <font color="#000066" size="4"><strong> <input name="nrorup2" type="hidden" id="nrorup2" value="<? print $auxnive2; ?>"> </strong></font></td> </tr> <tr bordercolor="#FFFFFF"> <td class="form_label_01">&nbsp;</td> <td colspan="2">&nbsp;</td> </tr> <tr bordercolor="#6699CC"> <td class="form_label_01"> <div align="left"><strong>Filtro:</strong></div></td> <td colspan="2"> <div align="left"></div> <div align="left"> <input name="comodin" type="text" class="breadcrumb" id="comodin" value="%%" size="75"> <input name="sqls" type="hidden" id="sqls"> </div></td> </tr> <tr bordercolor="#6699CC"> <td colspan="3" class="form_label_01"></td> </tr> --> <?php include_once("../../lib/general/formbottom.php")?>
cidesa/siga-universitario
web/reportes/reportes/ingresos/ingresos.php
PHP
gpl-2.0
4,522
[ 30522, 1026, 1029, 25718, 5219, 1035, 2707, 1006, 1007, 1025, 2421, 1035, 2320, 1006, 1000, 1012, 1012, 1013, 1012, 1012, 1013, 5622, 2497, 1013, 2236, 1013, 2132, 11039, 19968, 1012, 25718, 1000, 1007, 1025, 5478, 1035, 2320, 1006, 1000, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<html lang="en"> <head> <title>Meta Options - Using as</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using as"> <meta name="generator" content="makeinfo 4.8"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Meta_002dDependent.html#Meta_002dDependent" title="Meta-Dependent"> <link rel="next" href="Meta-Syntax.html#Meta-Syntax" title="Meta Syntax"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- This file documents the GNU Assembler "as". Copyright (C) 1991-2013 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <p> <a name="Meta-Options"></a> Next:&nbsp;<a rel="next" accesskey="n" href="Meta-Syntax.html#Meta-Syntax">Meta Syntax</a>, Up:&nbsp;<a rel="up" accesskey="u" href="Meta_002dDependent.html#Meta_002dDependent">Meta-Dependent</a> <hr> </div> <h4 class="subsection">9.25.1 Options</h4> <p><a name="index-options-for-Meta-1361"></a><a name="index-Meta-options-1362"></a><a name="index-architectures_002c-Meta-1363"></a><a name="index-Meta-architectures-1364"></a> The Imagination Technologies Meta architecture is implemented in a number of versions, with each new version adding new features such as instructions and registers. For precise details of what instructions each core supports, please see the chip's technical reference manual. <p>The following table lists all available Meta options. <!-- man begin OPTIONS --> <dl> <dt><code>-mcpu=metac11</code><dd>Generate code for Meta 1.1. <br><dt><code>-mcpu=metac12</code><dd>Generate code for Meta 1.2. <br><dt><code>-mcpu=metac21</code><dd>Generate code for Meta 2.1. <br><dt><code>-mfpu=metac21</code><dd>Allow code to use FPU hardware of Meta 2.1. </dl> <!-- man end --> </body></html>
jocelynmass/nrf51
toolchain/deprecated/arm_cm0_4.9/share/doc/gcc-arm-none-eabi/html/as.html/Meta-Options.html
HTML
gpl-2.0
2,767
[ 30522, 1026, 16129, 11374, 1027, 1000, 4372, 1000, 1028, 1026, 2132, 1028, 1026, 2516, 1028, 18804, 7047, 1011, 2478, 2004, 1026, 1013, 2516, 1028, 1026, 18804, 8299, 1011, 1041, 15549, 2615, 1027, 1000, 4180, 1011, 2828, 1000, 4180, 1027, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php use yii\db\Schema; use yii\db\Migration; class m140924_133309_dropcols extends Migration { public function up() { $this->dropColumn('address', 'otherStreet'); $this->dropColumn('address', 'otherCity'); $this->dropColumn('address', 'otherZip'); } public function down() { echo "m140924_133309_dropcols cannot be reverted.\n"; return false; } }
chovajsa/billio
console/migrations/m140924_133309_dropcols.php
PHP
mit
409
[ 30522, 1026, 1029, 25718, 2224, 12316, 2072, 1032, 16962, 1032, 8040, 28433, 1025, 2224, 12316, 2072, 1032, 16962, 1032, 9230, 1025, 2465, 23290, 12740, 2683, 18827, 1035, 14506, 14142, 2683, 1035, 4530, 25778, 2015, 8908, 9230, 1063, 2270, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * JBoss, Home of Professional Open Source * Copyright 2012, Red Hat Middleware LLC, and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.arquillian.warp.ftest.commandBus; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.Target; /** * Annotated classes should be enriched by Arquillian dependency injection using {@link TestCaseEnricher} * * @author Lukas Fryc */ @Inherited @Documented @Retention(RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD}) @interface EnrichTestCase { }
arquillian/arquillian-extension-warp
ftest/src/test/java/org/jboss/arquillian/warp/ftest/commandBus/EnrichTestCase.java
Java
apache-2.0
1,355
[ 30522, 1013, 1008, 1008, 1046, 15853, 2015, 1010, 2188, 1997, 2658, 2330, 3120, 1008, 9385, 2262, 1010, 2417, 6045, 2690, 8059, 11775, 1010, 1998, 3265, 16884, 1008, 2011, 1996, 1030, 6048, 30524, 1037, 1008, 2440, 10328, 1997, 3265, 16884,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
## Install GEF ### Pre-requisites Only [GDB 7.x+](https://www.gnu.org/s/gdb) is required. It must compiled with Python 2 or 3 support. This can be verified with the following command: ``` bash $ gdb -nx -ex 'python print (sys.version)' -ex quit ``` This should display your version of Python compiled with `gdb`. For example, with Python2 ```bash $ gdb -nx -ex 'python print (sys.version)' -ex quit 2.7.3 (default, Mar 18 2014, 06:31:17) [GCC 4.6.3] ``` Or Python3 ```bash $ gdb -nx -ex 'python print (sys.version)' -ex quit 3.4.0 (default, Apr 11 2014, 13:08:40) [GCC 4.8.2] ``` ### Setup from repository The best way to use `GEF` is through cloning the git repository from GitHub, and source the file from your `~/.gdbinit`. ``` bash $ git clone https://github.com/hugsy/gef.git # or git pull to update $ echo 'source /path/to/gef.py' >> ~/.gdbinit ``` ### One-time setup script If you only need `GEF` for a one-time environment (VMs, etc.) that do not have/need `git` installed, just go with: ``` bash $ curl -s -L https://github.com/hugsy/gef/raw/master/gef.sh | sh ``` ### Optional dependancies A few commands were added to `GEF` to extend its possibilities. It is recommended to install the following modules: - [`capstone`](https://github.com/aquynh/capstone) **highly** recommended - [`ROPgadget`](https://github.com/JonathanSalwan/ROPgadget) **highly** recommended - [`python-radare2`](https://github.com/radare/radare2-bindings) It is recommended to install those modules through `python-pip`. The following commands will work for most distributions. ```bash $ pip install capstone $ pip install ropgadget ``` `radare2-python` is not packaged through `python-pip`. However, many distributions package `radare2` suite and its bindings. Last option will be to set it up from the source (compilation and installation). *Note*: GDB/Python3 users should be aware that `ROPgadget` does not supported (yet?) Python3. ### Check setup To check that `GEF` has been correctly installed, simply start a new `gdb` session against any binary. ```bash $ gdb -q /bin/ls ``` You should see the following header and prompt ```bash $ gdb-gef -q /bin/ls gef loaded, `gef help' to start, `gef config' to configure 29 commands loaded (10 sub-commands), using Python engine 2.7 Reading symbols from /bin/ls...(no debugging symbols found)...done. gef> ``` When loading, `gef` will check for dependencies. If it fails to load them, you will see a warning like: ```bash [+] Failed to load `assemble`: 'radare2 Python bindings could not be loaded' ``` This simply means that the associated commands will not be available. If you want those commands, simply install the modules.
firebitsbr/gef
docs/config.md
Markdown
mit
2,688
[ 30522, 1001, 1001, 16500, 16216, 2546, 1001, 1001, 1001, 3653, 1011, 2128, 24871, 2015, 2069, 1031, 1043, 18939, 1021, 1012, 1060, 1009, 1033, 1006, 16770, 1024, 1013, 1013, 7479, 1012, 27004, 1012, 8917, 1013, 1055, 1013, 1043, 18939, 1007...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
using MongoDB.Driver; namespace AspNet.Identity.MongoDB { public class IndexChecks { public static void EnsureUniqueIndexOnUserName<TUser>(IMongoCollection<TUser> users) where TUser : IdentityUser { var userName = Builders<TUser>.IndexKeys.Ascending(t => t.UserName); var unique = new CreateIndexOptions {Unique = true}; users.Indexes.CreateOneAsync(userName, unique); } public static void EnsureUniqueIndexOnRoleName<TRole>(IMongoCollection<TRole> roles) where TRole : IdentityRole { var roleName = Builders<TRole>.IndexKeys.Ascending(t => t.Name); var unique = new CreateIndexOptions {Unique = true}; roles.Indexes.CreateOneAsync(roleName, unique); } public static void EnsureUniqueIndexOnEmail<TUser>(IMongoCollection<TUser> users) where TUser : IdentityUser { var email = Builders<TUser>.IndexKeys.Ascending(t => t.Email); var unique = new CreateIndexOptions {Unique = true}; users.Indexes.CreateOneAsync(email, unique); } } }
winterdouglas/aspnet-identity-mongo
src/AspNet.Identity.MongoDB/IndexChecks.cs
C#
mit
993
[ 30522, 2478, 12256, 3995, 18939, 1012, 4062, 1025, 3415, 15327, 2004, 2361, 7159, 1012, 4767, 1012, 12256, 3995, 18939, 1063, 2270, 2465, 5950, 5403, 10603, 1063, 2270, 10763, 11675, 5676, 19496, 4226, 22254, 10288, 24891, 11795, 14074, 1026,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * This file was generated by orbit-idl-2 - DO NOT EDIT! */ #include <string.h> #define ORBIT2_STUBS_API #include "poatest.h" static ORBitSmallSkeleton get_skel_small_poatest(POA_poatest *servant, const char *opname,gpointer *m_data, gpointer *impl) { switch(opname[0]) { case 't': if(strcmp((opname + 1), "est")) break; *impl = (gpointer)servant->vepv->poatest_epv->test; {ORBit_IInterface *volatile _t_=&poatest__iinterface;*m_data = (gpointer)&_t_->methods._buffer [0];} return (ORBitSmallSkeleton)_ORBIT_skel_small_poatest_test; break; default: break; } return NULL; } void POA_poatest__init(PortableServer_Servant servant, CORBA_Environment *env) { static PortableServer_ClassInfo class_info = {NULL, (ORBit_small_impl_finder)&get_skel_small_poatest, "IDL:poatest:1.0", &poatest__classid, NULL, &poatest__iinterface}; PortableServer_ServantBase__init ( ((PortableServer_ServantBase *)servant), env); ORBit_skel_class_register (&class_info, (PortableServer_ServantBase *)servant, POA_poatest__fini, ORBIT_VEPV_OFFSET (POA_poatest__vepv, poatest_epv), (CORBA_unsigned_long) 0);} void POA_poatest__fini(PortableServer_Servant servant, CORBA_Environment *env) { PortableServer_ServantBase__fini(servant, env); }
chriskmanx/qmole
QMOLEDEV/ORBit2-2.14.19/test/poa/poatest-skels.c
C
gpl-3.0
1,247
[ 30522, 1013, 1008, 1008, 2023, 5371, 2001, 7013, 2011, 8753, 1011, 8909, 2140, 1011, 1016, 1011, 2079, 2025, 10086, 999, 1008, 1013, 1001, 2421, 1026, 5164, 1012, 1044, 1028, 1001, 9375, 8753, 2475, 1035, 24646, 5910, 1035, 17928, 1001, 2...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace App\Extension\JWT\Providers; use Illuminate\Support\ServiceProvider as ProviderContract; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; use App\Extension\JWT\Auth\Driver; /** * Description of JWTServiceProvider * * @author absolux */ class ServiceProvider extends ProviderContract { /** * Bootstrap JWT auth driver */ public function boot() { Auth::extend('jwt', function($app) { return new Driver($this->createUserProvider($app)); }); } /** * create a user provider for auth driver * * @return UserProvider */ protected function createUserProvider($app) { $repository = new TokenProvider(); return new UserProvider($app['hash'], $repository, $this->createModel()); } /** * @return Model */ protected function createModel() { $class = '\\'.ltrim(config('auth.model'), '\\'); return new $class(); } public function register() { $config_path = __DIR__ . '/../config.php'; $this->mergeConfigFrom($config_path, 'jwt'); } }
absolux/Collabor8-php-api
app/Extension/JWT/Providers/ServiceProvider.php
PHP
mit
1,175
[ 30522, 1026, 1029, 25718, 3415, 15327, 10439, 1032, 5331, 1032, 1046, 26677, 1032, 11670, 1025, 2224, 5665, 12717, 12556, 1032, 2490, 1032, 2326, 21572, 17258, 2121, 2004, 10802, 8663, 6494, 6593, 1025, 2224, 5665, 12717, 12556, 1032, 7809, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package mock.xmpp; import org.jitsi.protocol.xmpp.*; import java.util.*; /** * */ public class MockSetSimpleCapsOpSet extends MockCapsNode implements OperationSetSimpleCaps { private long discoveryDelay = 0; public MockSetSimpleCapsOpSet(String domain) { super(domain, new String[]{}); } public void addDiscoveryDelay(long millis) { this.discoveryDelay = millis; } private MockCapsNode findFirstLevel(String name) { for (MockCapsNode node : childNodes) { if (node.getNodeName().equals(name)) { return node; } } return null; } @Override public List<String> getItems(String nodeName) { ArrayList<String> result = new ArrayList<String>(childNodes.size()); MockCapsNode node; if (nodeName.endsWith(getNodeName())) { node = this; } else { node = findFirstLevel(nodeName); } if (node != null) { for (MockCapsNode child : node.getChildNodes()) { result.add(child.getNodeName()); } } return result; } @Override public boolean hasFeatureSupport(String contactAddress, String[] features) { MockCapsNode node = findChild(contactAddress); if (node == null) { return false; } String[] nodeFeatures = node.getFeatures(); for (String feature : features) { boolean found = false; for (String toCheck : nodeFeatures) { if (toCheck.equals(feature)) { found = true; break; } } if (!found) { return false; } } return true; } @Override public List<String> getFeatures(String node) { if (discoveryDelay > 0) { try { Thread.sleep(discoveryDelay); } catch (InterruptedException e) { throw new RuntimeException(e); } } MockCapsNode capsNode = findChild(node); if (capsNode == null) { return null; } return Arrays.asList(capsNode.getFeatures()); } //@Override public boolean hasFeatureSupport(String node, String subnode, String[] features) { return false; } }
DBatOWL/jicofo-mirror
test/mock/xmpp/MockSetSimpleCapsOpSet.java
Java
lgpl-2.1
2,635
[ 30522, 7427, 12934, 1012, 1060, 8737, 2361, 1025, 12324, 8917, 1012, 10147, 3215, 2072, 1012, 8778, 1012, 1060, 8737, 2361, 1012, 1008, 1025, 12324, 9262, 1012, 21183, 4014, 1012, 1008, 1025, 1013, 1008, 1008, 1008, 1008, 1013, 2270, 2465, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * $Id: Timer.h 862 2008-10-24 02:13:57Z takaya $ * Copyright (C) 2008 AIST, National Institute of Advanced Industrial Science and Technology */ #ifdef TIMER #if defined(__MICROBLAZE__) || defined(__PPC__) # include <xtmrctr.h> # define MAX_LOG 40 /* * Xilinx EDK environment doesn't provide strings.h which has the prototyp declaration of bzero(). * We don't know the reason. */ extern void bzero (void *__s, size_t __n); void Timer_Initialize(); void Timer(u8* String); void Timer_Start(u8 id); void Timer_End(u8 id, u8* String); void Show_Log(); #endif /* (__MICROBLASE__) || (__PPC__) */ #else #define Timer_Initialize() (0) #define Timer(x) (0) #define Timer_Start(x) (0) #define Timer_End(x,y) (0) #define Show_Log() #endif /* TIMER */
ohkawatks/orbe
repository/AIST/sw_services/orbe_v1_00_a/src/Timer.h
C
apache-2.0
789
[ 30522, 1013, 1008, 1008, 1002, 8909, 1024, 25309, 1012, 1044, 6564, 2475, 2263, 1011, 2184, 1011, 2484, 6185, 1024, 2410, 1024, 5401, 2480, 27006, 12186, 1002, 1008, 9385, 1006, 1039, 1007, 2263, 9932, 3367, 1010, 2120, 2820, 1997, 3935, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#!/usr/bin/env bash # Copyright 2018 The Kubernetes Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -o errexit set -o nounset set -o pipefail run_crd_tests() { set -o nounset set -o errexit create_and_use_new_namespace kube::log::status "Testing kubectl crd" kubectl "${kube_flags_with_token[@]:?}" create -f - << __EOF__ { "kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1beta1", "metadata": { "name": "foos.company.com" }, "spec": { "group": "company.com", "version": "v1", "scope": "Namespaced", "names": { "plural": "foos", "kind": "Foo" } } } __EOF__ # Post-Condition: assertion object exist kube::test::get_object_assert customresourcedefinitions "{{range.items}}{{if eq ${id_field:?} \\\"foos.company.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'foos.company.com:' kubectl "${kube_flags_with_token[@]}" create -f - << __EOF__ { "kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1beta1", "metadata": { "name": "bars.company.com" }, "spec": { "group": "company.com", "version": "v1", "scope": "Namespaced", "names": { "plural": "bars", "kind": "Bar" } } } __EOF__ # Post-Condition: assertion object exist kube::test::get_object_assert customresourcedefinitions "{{range.items}}{{if eq $id_field \\\"foos.company.com\\\" \\\"bars.company.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'bars.company.com:foos.company.com:' # This test ensures that the name printer is able to output a resource # in the proper "kind.group/resource_name" format, and that the # resource builder is able to resolve a GVK when a kind.group pair is given. kubectl "${kube_flags_with_token[@]}" create -f - << __EOF__ { "kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1beta1", "metadata": { "name": "resources.mygroup.example.com" }, "spec": { "group": "mygroup.example.com", "version": "v1alpha1", "scope": "Namespaced", "names": { "plural": "resources", "singular": "resource", "kind": "Kind", "listKind": "KindList" } } } __EOF__ # Post-Condition: assertion crd with non-matching kind and resource exists kube::test::get_object_assert customresourcedefinitions "{{range.items}}{{if eq $id_field \\\"foos.company.com\\\" \\\"bars.company.com\\\" \\\"resources.mygroup.example.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'bars.company.com:foos.company.com:resources.mygroup.example.com:' # This test ensures that we can create complex validation without client-side validation complaining kubectl "${kube_flags_with_token[@]}" create -f - << __EOF__ { "kind": "CustomResourceDefinition", "apiVersion": "apiextensions.k8s.io/v1beta1", "metadata": { "name": "validfoos.company.com" }, "spec": { "group": "company.com", "version": "v1", "scope": "Namespaced", "names": { "plural": "validfoos", "kind": "ValidFoo" }, "validation": { "openAPIV3Schema": { "properties": { "spec": { "type": "array", "items": { "type": "number" } } } } } } } __EOF__ # Post-Condition: assertion crd with non-matching kind and resource exists kube::test::get_object_assert customresourcedefinitions "{{range.items}}{{if eq $id_field \\\"foos.company.com\\\" \\\"bars.company.com\\\" \\\"resources.mygroup.example.com\\\" \\\"validfoos.company.com\\\"}}{{$id_field}}:{{end}}{{end}}" 'bars.company.com:foos.company.com:resources.mygroup.example.com:validfoos.company.com:' run_non_native_resource_tests # teardown kubectl delete customresourcedefinitions/foos.company.com "${kube_flags_with_token[@]}" kubectl delete customresourcedefinitions/bars.company.com "${kube_flags_with_token[@]}" kubectl delete customresourcedefinitions/resources.mygroup.example.com "${kube_flags_with_token[@]}" kubectl delete customresourcedefinitions/validfoos.company.com "${kube_flags_with_token[@]}" set +o nounset set +o errexit } kube::util::non_native_resources() { local times local wait local failed times=30 wait=10 for _ in $(seq 1 $times); do failed="" kubectl "${kube_flags[@]:?}" get --raw '/apis/company.com/v1' || failed=true kubectl "${kube_flags[@]}" get --raw '/apis/company.com/v1/foos' || failed=true kubectl "${kube_flags[@]}" get --raw '/apis/company.com/v1/bars' || failed=true if [ -z "${failed}" ]; then return 0 fi sleep ${wait} done kube::log::error "Timed out waiting for non-native-resources; tried ${times} waiting ${wait}s between each" return 1 } run_non_native_resource_tests() { set -o nounset set -o errexit create_and_use_new_namespace kube::log::status "Testing kubectl non-native resources" kube::util::non_native_resources # Test that we can list this new CustomResource (foos) kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can list this new CustomResource (bars) kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can list this new CustomResource (resources) kube::test::get_object_assert resources "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can create a new resource of type Kind kubectl "${kube_flags[@]}" create -f hack/testdata/CRD/resource.yaml "${kube_flags[@]}" # Test that -o name returns kind.group/resourcename output_message=$(kubectl "${kube_flags[@]}" get resource/myobj -o name) kube::test::if_has_string "${output_message}" 'kind.mygroup.example.com/myobj' output_message=$(kubectl "${kube_flags[@]}" get resources/myobj -o name) kube::test::if_has_string "${output_message}" 'kind.mygroup.example.com/myobj' output_message=$(kubectl "${kube_flags[@]}" get kind.mygroup.example.com/myobj -o name) kube::test::if_has_string "${output_message}" 'kind.mygroup.example.com/myobj' # Delete the resource with cascade. kubectl "${kube_flags[@]}" delete resources myobj --cascade=true # Make sure it's gone kube::test::wait_object_assert resources "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can create a new resource of type Foo kubectl "${kube_flags[@]}" create -f hack/testdata/CRD/foo.yaml "${kube_flags[@]}" # Test that we can list this new custom resource kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" 'test:' # Test alternate forms kube::test::get_object_assert foo "{{range.items}}{{$id_field}}:{{end}}" 'test:' kube::test::get_object_assert foos.company.com "{{range.items}}{{$id_field}}:{{end}}" 'test:' kube::test::get_object_assert foos.v1.company.com "{{range.items}}{{$id_field}}:{{end}}" 'test:' # Test all printers, with lists and individual items kube::log::status "Testing CustomResource printing" kubectl "${kube_flags[@]}" get foos kubectl "${kube_flags[@]}" get foos/test kubectl "${kube_flags[@]}" get foos -o name kubectl "${kube_flags[@]}" get foos/test -o name kubectl "${kube_flags[@]}" get foos -o wide kubectl "${kube_flags[@]}" get foos/test -o wide kubectl "${kube_flags[@]}" get foos -o json kubectl "${kube_flags[@]}" get foos/test -o json kubectl "${kube_flags[@]}" get foos -o yaml kubectl "${kube_flags[@]}" get foos/test -o yaml kubectl "${kube_flags[@]}" get foos -o "jsonpath={.items[*].someField}" --allow-missing-template-keys=false kubectl "${kube_flags[@]}" get foos/test -o "jsonpath={.someField}" --allow-missing-template-keys=false kubectl "${kube_flags[@]}" get foos -o "go-template={{range .items}}{{.someField}}{{end}}" --allow-missing-template-keys=false kubectl "${kube_flags[@]}" get foos/test -o "go-template={{.someField}}" --allow-missing-template-keys=false output_message=$(kubectl "${kube_flags[@]}" get foos/test -o name) kube::test::if_has_string "${output_message}" 'foo.company.com/test' # Test patching kube::log::status "Testing CustomResource patching" kubectl "${kube_flags[@]}" patch foos/test -p '{"patched":"value1"}' --type=merge kube::test::get_object_assert foos/test "{{.patched}}" 'value1' kubectl "${kube_flags[@]}" patch foos/test -p '{"patched":"value2"}' --type=merge --record kube::test::get_object_assert foos/test "{{.patched}}" 'value2' kubectl "${kube_flags[@]}" patch foos/test -p '{"patched":null}' --type=merge --record kube::test::get_object_assert foos/test "{{.patched}}" '<no value>' # Get local version CRD_RESOURCE_FILE="${KUBE_TEMP}/crd-foos-test.json" kubectl "${kube_flags[@]}" get foos/test -o json > "${CRD_RESOURCE_FILE}" # cannot apply strategic patch locally CRD_PATCH_ERROR_FILE="${KUBE_TEMP}/crd-foos-test-error" ! kubectl "${kube_flags[@]}" patch --local -f "${CRD_RESOURCE_FILE}" -p '{"patched":"value3"}' 2> "${CRD_PATCH_ERROR_FILE}" || exit 1 if grep -q "try --type merge" "${CRD_PATCH_ERROR_FILE}"; then kube::log::status "\"kubectl patch --local\" returns error as expected for CustomResource: $(cat "${CRD_PATCH_ERROR_FILE}")" else kube::log::status "\"kubectl patch --local\" returns unexpected error or non-error: $(cat "${CRD_PATCH_ERROR_FILE}")" exit 1 fi # can apply merge patch locally kubectl "${kube_flags[@]}" patch --local -f "${CRD_RESOURCE_FILE}" -p '{"patched":"value3"}' --type=merge -o json # can apply merge patch remotely kubectl "${kube_flags[@]}" patch --record -f "${CRD_RESOURCE_FILE}" -p '{"patched":"value3"}' --type=merge -o json kube::test::get_object_assert foos/test "{{.patched}}" 'value3' rm "${CRD_RESOURCE_FILE}" rm "${CRD_PATCH_ERROR_FILE}" # Test labeling kube::log::status "Testing CustomResource labeling" kubectl "${kube_flags[@]}" label foos --all listlabel=true kubectl "${kube_flags[@]}" label foo/test itemlabel=true # Test annotating kube::log::status "Testing CustomResource annotating" kubectl "${kube_flags[@]}" annotate foos --all listannotation=true kubectl "${kube_flags[@]}" annotate foo/test itemannotation=true # Test describing kube::log::status "Testing CustomResource describing" kubectl "${kube_flags[@]}" describe foos kubectl "${kube_flags[@]}" describe foos/test kubectl "${kube_flags[@]}" describe foos | grep listlabel=true kubectl "${kube_flags[@]}" describe foos | grep itemlabel=true # Delete the resource with cascade. kubectl "${kube_flags[@]}" delete foos test --cascade=true # Make sure it's gone kube::test::wait_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can create a new resource of type Bar kubectl "${kube_flags[@]}" create -f hack/testdata/CRD/bar.yaml "${kube_flags[@]}" # Test that we can list this new custom resource kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" 'test:' # Test that we can watch the resource. # Start watcher in background with process substitution, # so we can read from stdout asynchronously. kube::log::status "Testing CustomResource watching" exec 3< <(kubectl "${kube_flags[@]}" get bars --request-timeout=1m --watch-only -o name & echo $! ; wait) local watch_pid read -r <&3 watch_pid # We can't be sure when the watch gets established, # so keep triggering events (in the background) until something comes through. local tries=0 while [ ${tries} -lt 10 ]; do tries=$((tries+1)) kubectl "${kube_flags[@]}" patch bars/test -p "{\"patched\":\"${tries}\"}" --type=merge sleep 1 done & local patch_pid=$! # Wait up to 30s for a complete line of output. local watch_output read -r <&3 -t 30 watch_output # Stop the watcher and the patch loop. kill -9 "${watch_pid}" kill -9 "${patch_pid}" kube::test::if_has_string "${watch_output}" 'bar.company.com/test' # Delete the resource without cascade. kubectl "${kube_flags[@]}" delete bars test --cascade=false # Make sure it's gone kube::test::wait_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can create single item via apply kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/foo.yaml # Test that we have create a foo named test kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" 'test:' # Test that the field has the expected value kube::test::get_object_assert foos/test '{{.someField}}' 'field1' # Test that apply an empty patch doesn't change fields kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/foo.yaml # Test that the field has the same value after re-apply kube::test::get_object_assert foos/test '{{.someField}}' 'field1' # Test that apply has updated the subfield kube::test::get_object_assert foos/test '{{.nestedField.someSubfield}}' 'subfield1' # Update a subfield and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/foo-updated-subfield.yaml # Test that apply has updated the subfield kube::test::get_object_assert foos/test '{{.nestedField.someSubfield}}' 'modifiedSubfield' # Test that the field has the expected value kube::test::get_object_assert foos/test '{{.nestedField.otherSubfield}}' 'subfield2' # Delete a subfield and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/foo-deleted-subfield.yaml # Test that apply has deleted the field kube::test::get_object_assert foos/test '{{.nestedField.otherSubfield}}' '<no value>' # Test that the field does not exist kube::test::get_object_assert foos/test '{{.nestedField.newSubfield}}' '<no value>' # Add a field and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/foo-added-subfield.yaml # Test that apply has added the field kube::test::get_object_assert foos/test '{{.nestedField.newSubfield}}' 'subfield3' # Delete the resource kubectl "${kube_flags[@]}" delete -f hack/testdata/CRD/foo.yaml # Make sure it's gone kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' # Test that we can create list via apply kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/multi-crd-list.yaml # Test that we have create a foo and a bar from a list kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" 'test-list:' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" 'test-list:' # Test that the field has the expected value kube::test::get_object_assert foos/test-list '{{.someField}}' 'field1' kube::test::get_object_assert bars/test-list '{{.someField}}' 'field1' # Test that re-apply an list doesn't change anything kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/multi-crd-list.yaml # Test that the field has the same value after re-apply kube::test::get_object_assert foos/test-list '{{.someField}}' 'field1' kube::test::get_object_assert bars/test-list '{{.someField}}' 'field1' # Test that the fields have the expected value kube::test::get_object_assert foos/test-list '{{.someField}}' 'field1' kube::test::get_object_assert bars/test-list '{{.someField}}' 'field1' # Update fields and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/multi-crd-list-updated-field.yaml # Test that apply has updated the fields kube::test::get_object_assert foos/test-list '{{.someField}}' 'modifiedField' kube::test::get_object_assert bars/test-list '{{.someField}}' 'modifiedField' # Test that the field has the expected value kube::test::get_object_assert foos/test-list '{{.otherField}}' 'field2' kube::test::get_object_assert bars/test-list '{{.otherField}}' 'field2' # Delete fields and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/multi-crd-list-deleted-field.yaml # Test that apply has deleted the fields kube::test::get_object_assert foos/test-list '{{.otherField}}' '<no value>' kube::test::get_object_assert bars/test-list '{{.otherField}}' '<no value>' # Test that the fields does not exist kube::test::get_object_assert foos/test-list '{{.newField}}' '<no value>' kube::test::get_object_assert bars/test-list '{{.newField}}' '<no value>' # Add a field and then apply the change kubectl "${kube_flags[@]}" apply -f hack/testdata/CRD/multi-crd-list-added-field.yaml # Test that apply has added the field kube::test::get_object_assert foos/test-list '{{.newField}}' 'field3' kube::test::get_object_assert bars/test-list '{{.newField}}' 'field3' # Delete the resource kubectl "${kube_flags[@]}" delete -f hack/testdata/CRD/multi-crd-list.yaml # Make sure it's gone kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' ## kubectl apply --prune # Test that no foo or bar exist kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # apply --prune on foo.yaml that has foo/test kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/foo.yaml "${kube_flags[@]}" --prune-whitelist=company.com/v1/Foo --prune-whitelist=company.com/v1/Bar # check right crds exist kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" 'test:' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # apply --prune on bar.yaml that has bar/test kubectl apply --prune -l pruneGroup=true -f hack/testdata/CRD/bar.yaml "${kube_flags[@]}" --prune-whitelist=company.com/v1/Foo --prune-whitelist=company.com/v1/Bar # check right crds exist kube::test::wait_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" 'test:' # Delete the resource kubectl "${kube_flags[@]}" delete -f hack/testdata/CRD/bar.yaml # Make sure it's gone kube::test::get_object_assert foos "{{range.items}}{{$id_field}}:{{end}}" '' kube::test::get_object_assert bars "{{range.items}}{{$id_field}}:{{end}}" '' # Test 'kubectl create' with namespace, and namespace cleanup. kubectl "${kube_flags[@]}" create namespace non-native-resources kubectl "${kube_flags[@]}" create -f hack/testdata/CRD/bar.yaml --namespace=non-native-resources kube::test::get_object_assert bars '{{len .items}}' '1' --namespace=non-native-resources kubectl "${kube_flags[@]}" delete namespace non-native-resources # Make sure objects go away. kube::test::wait_object_assert bars '{{len .items}}' '0' --namespace=non-native-resources # Make sure namespace goes away. local tries=0 while kubectl "${kube_flags[@]}" get namespace non-native-resources && [ ${tries} -lt 10 ]; do tries=$((tries+1)) sleep ${tries} done set +o nounset set +o errexit }
mkumatag/origin
vendor/k8s.io/kubernetes/test/cmd/crd.sh
Shell
apache-2.0
19,398
[ 30522, 1001, 999, 1013, 2149, 2099, 1013, 8026, 1013, 4372, 2615, 24234, 1001, 9385, 2760, 1996, 13970, 5677, 7159, 2229, 6048, 1012, 1001, 1001, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package gtka import ( "github.com/gotk3/gotk3/gtk" "github.com/coyim/gotk3adapter/gliba" "github.com/coyim/gotk3adapter/gtki" ) type application struct { *gliba.Application internal *gtk.Application } func wrapApplicationSimple(v *gtk.Application) *application { if v == nil { return nil } return &application{gliba.WrapApplicationSimple(&v.Application), v} } func wrapApplication(v *gtk.Application, e error) (*application, error) { return wrapApplicationSimple(v), e } func unwrapApplication(v gtki.Application) *gtk.Application { if v == nil { return nil } return v.(*application).internal } func (v *application) GetActiveWindow() gtki.Window { ret := wrapWindowSimple(v.internal.GetActiveWindow()) if ret == nil { return nil } return ret }
twstrike/gotk3adapter
gtka/application.go
GO
gpl-3.0
773
[ 30522, 7427, 14181, 2912, 12324, 1006, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 2288, 2243, 2509, 1013, 2288, 2243, 2509, 1013, 14181, 2243, 1000, 1000, 21025, 2705, 12083, 1012, 4012, 1013, 2522, 10139, 2213, 1013, 2288, 2243, 2509, 844...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/*! * \file in_memory_configuration.h * \brief A ConfigurationInterface for testing purposes. * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * * This implementation accepts configuration parameters upon instantiation and * it is intended to be used in unit testing. * * ------------------------------------------------------------------------- * * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver * * This file is part of GNSS-SDR. * * GNSS-SDR is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * at your option) any later version. * * GNSS-SDR is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GNSS-SDR. If not, see <http://www.gnu.org/licenses/>. * * ------------------------------------------------------------------------- */ #ifndef GNSS_SDR_IN_MEMORY_CONFIGURATION_H_ #define GNSS_SDR_IN_MEMORY_CONFIGURATION_H_ #include <map> #include <memory> #include <string> #include "configuration_interface.h" class StringConverter; /*! * \brief This class is an implementation of the interface ConfigurationInterface. * * This implementation accepts configuration parameters upon instantiation and * it is intended to be used in unit testing. */ class InMemoryConfiguration : public ConfigurationInterface { public: InMemoryConfiguration(); virtual ~InMemoryConfiguration(); std::string property(std::string property_name, std::string default_value); bool property(std::string property_name, bool default_value); long property(std::string property_name, long default_value); int property(std::string property_name, int default_value); unsigned int property(std::string property_name, unsigned int default_value); float property(std::string property_name, float default_value); double property(std::string property_name, double default_value); void set_property(std::string property_name, std::string value); bool is_present(std::string property_name); private: std::map<std::string, std::string> properties_; std::unique_ptr<StringConverter> converter_; }; #endif /*GNSS_SDR_IN_MEMORY_CONFIGURATION_H_*/
taroz/gnss-sdr
src/core/receiver/in_memory_configuration.h
C
gpl-3.0
2,633
[ 30522, 1013, 1008, 999, 1008, 1032, 5371, 1999, 1035, 3638, 1035, 9563, 1012, 1044, 1008, 1032, 4766, 1037, 9563, 18447, 2121, 12172, 2005, 5604, 5682, 1012, 1008, 1032, 3166, 5828, 20704, 9463, 2015, 1010, 2230, 1012, 5828, 1012, 20704, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* Copyright (C) 2000 drscholl@users.sourceforge.net This is free software distributed under the terms of the GNU Public License. See the file COPYING for details. $Id$ */ #include <stdio.h> #include <time.h> #include <string.h> #include <stdlib.h> #include "opennap.h" #include "debug.h" /* this is nasty but a necessary evil to avoid using a static buffer */ char * append_string (char *in, const char *fmt, ...) { va_list ap; va_start (ap, fmt); vsnprintf (Buf, sizeof (Buf), fmt, ap); va_end (ap); if (!in) return STRDUP (Buf); else { int len = strlen (in); if(safe_realloc((void**)&in, len + strlen (Buf) + 1)) return 0; strcpy(in+len,Buf); return in; } } /* 604 <user> */ HANDLER (whois) { USER *sender, *user; time_t online; LIST *chan; USERDB *db; char *cap; char *rsp = 0; (void) tag; (void) len; CHECK_USER_CLASS ("whois"); sender = con->user; ASSERT (validate_connection (con)); user = hash_lookup (Users, pkt); if (!user) { /* check to see if this is a registered nick */ db = hash_lookup (User_Db, pkt); if (db) send_cmd (con, MSG_SERVER_WHOWAS, "%s \"%s\" %d", db->nick, Levels[db->level], db->lastSeen); else nosuchuser (con); return; } ASSERT (validate_user (user)); online = (int) (Current_Time - user->connected); rsp = append_string (rsp, "%s", user->nick); rsp = append_string (rsp, " \"%s\"", Levels[user->level]); rsp = append_string (rsp, " %d", (int) online); rsp = append_string (rsp, " \" "); /* always show channel membership to privileged users */ if (!user->cloaked || sender->level > LEVEL_USER) { for (chan = user->channels; chan; chan = chan->next) { if((((CHANNEL*)chan->data)->flags & ON_CHANNEL_PRIVATE)==0) rsp = append_string (rsp, "%s ", ((CHANNEL *) chan->data)->name); } } rsp = append_string (rsp, "\""); /* terminate the channel list */ if (user->muzzled) cap = "Muzzled"; else if (user->cloaked && sender->level > LEVEL_USER) cap = "Cloaked"; /* show cloaked state to privileged users */ else cap = "Active"; rsp = append_string (rsp, " \"%s\"", cap); rsp = append_string (rsp, " %d %d %d %d", user->shared, user->downloads, user->uploads, user->speed); rsp = append_string (rsp, " \"%s\"", user->clientinfo); /* moderators and above see some additional information */ if (sender->level > LEVEL_USER) { db = hash_lookup (User_Db, user->nick); rsp = append_string (rsp, " %d %d %s %d %d", user->totaldown, user->totalup, my_ntoa (user->ip), user->conport, user->port); #if EMAIL #define EmailAddr(db) db?db->email:"unknown" #else #define EmailAddr(db) "unknown" #endif rsp = append_string (rsp, " %s", EmailAddr(db)); } /* admins and above see the server the user is connected to. this is only admin+ since the windows client would likely barf if present. i assume that admin+ will use another client such as BWap which understands the extra field */ if (sender->level > LEVEL_MODERATOR) rsp = append_string (rsp, " %s", user->server ? user->server : Server_Name); send_user (sender, MSG_SERVER_WHOIS_RESPONSE, "%s", rsp); FREE (rsp); /* notify privileged users when someone requests their info */ if (user->level >= LEVEL_MODERATOR && sender != user) { ASSERT (validate_connection (user->con)); send_user (user, MSG_SERVER_NOSUCH, "%s has requested your info", con->user->nick); } }
scassiba/opennap
whois.c
C
gpl-2.0
3,577
[ 30522, 1013, 1008, 9385, 1006, 1039, 1007, 2456, 2852, 11624, 14511, 1030, 5198, 1012, 3120, 29278, 3351, 1012, 5658, 2023, 2003, 2489, 4007, 5500, 2104, 1996, 3408, 1997, 1996, 27004, 2270, 6105, 1012, 2156, 1996, 5371, 24731, 2005, 4751, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
.expander0, #top_right, #body_right, #bottom_right, #sidebar-left, #sidebar-right, body.two-sidebars .outer, body.sidebar-first .outer, body.sidebar-second .outer, body.two-sidebars .outer a, body.sidebar-first .outer a, body.sidebar-second .outer a { zoom: 1; } /* The above rule gives hasLayout to some page elements so that IE will not be buggy */ #middlecontainer { word-wrap: break-word; } .comment { margin: 0 !important; } .block .item-list li { vertical-align: top; } /** Drupal admin tables **/ #main tr.even th, #main tr.even td, #main tr.odd th, #main tr.odd td { border-bottom: 1px solid #ccc; /* IE doesn't display borders on table rows */ } /* Ubercart */ .uc-store-admin-panel .panel-title a { margin-left: 25px !important; } /* fix layout width in IE6 */ body.layout-jello .sizer0 { width:expression(document.body.clientWidth > 1440 ? "160px" : "40%" ); } /* HOLLY HACK FOR IE 6 */ * html { height: 0; } /* ALPHA TRANSPARENCY FIX */ img, .pngfix { behavior: url(/sites/all/themes/zeropoint/css/iepngfix.htc); /* change path here and in iepngfix.htc to match theme location */ } /* NO DROP-DOWN SHADOW */ ul.firstsublayer, ul.sublayer { background-image: none !important; }
cm5089/ArkVets
themes/zeropoint/css/ie6.css
CSS
gpl-2.0
1,217
[ 30522, 1012, 7818, 2121, 2692, 1010, 1001, 2327, 1035, 2157, 1010, 1001, 2303, 1035, 2157, 1010, 1001, 3953, 1035, 2157, 1010, 1001, 2217, 8237, 1011, 2187, 1010, 1001, 2217, 8237, 1011, 2157, 1010, 2303, 1012, 2048, 1011, 2217, 8237, 201...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Supported tags and respective `Dockerfile` links - [`3.1.23`, `3.1`, `3`, `latest` (*Dockerfile*)](https://github.com/docker-library/celery/blob/0652407560f353e749cbe001e8bdbb5db86c2291/Dockerfile) [![](https://badge.imagelayers.io/celery:latest.svg)](https://imagelayers.io/?images=celery:3.1.23) For more information about this image and its history, please see [the relevant manifest file (`library/celery`)](https://github.com/docker-library/official-images/blob/master/library/celery). This image is updated via [pull requests to the `docker-library/official-images` GitHub repo](https://github.com/docker-library/official-images/pulls?q=label%3Alibrary%2Fcelery). For detailed information about the virtual/transfer sizes and individual layers of each of the above supported tags, please see [the `celery/tag-details.md` file](https://github.com/docker-library/docs/blob/master/celery/tag-details.md) in [the `docker-library/docs` GitHub repo](https://github.com/docker-library/docs). # Celery Celery is an open source asynchronous task queue/job queue based on distributed message passing. It is focused on real-time operation, but supports scheduling as well. > [wikipedia.org/wiki/Celery_Task_Queue](https://en.wikipedia.org/wiki/Celery_Task_Queue) # How to use this image ## start a celery worker (RabbitMQ Broker) ```console $ docker run --link some-rabbit:rabbit --name some-celery -d celery ``` ### check the status of the cluster ```console $ docker run --link some-rabbit:rabbit --rm celery celery status ``` ## start a celery worker (Redis Broker) ```console $ docker run --link some-redis:redis -e CELERY_BROKER_URL=redis://redis --name some-celery -d celery ``` ### check the status of the cluster ```console $ docker run --link some-redis:redis -e CELERY_BROKER_URL=redis://redis --rm celery celery status ``` # Supported Docker versions This image is officially supported on Docker version 1.11.1. Support for older versions (down to 1.6) is provided on a best-effort basis. Please see [the Docker installation documentation](https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon. # User Feedback ## Documentation Documentation for this image is stored in the [`celery/` directory](https://github.com/docker-library/docs/tree/master/celery) of the [`docker-library/docs` GitHub repo](https://github.com/docker-library/docs). Be sure to familiarize yourself with the [repository's `README.md` file](https://github.com/docker-library/docs/blob/master/README.md) before attempting a pull request. ## Issues If you have any problems with or questions about this image, please contact us through a [GitHub issue](https://github.com/docker-library/celery/issues). If the issue is related to a CVE, please check for [a `cve-tracker` issue on the `official-images` repository first](https://github.com/docker-library/official-images/issues?q=label%3Acve-tracker). You can also reach many of the official image maintainers via the `#docker-library` IRC channel on [Freenode](https://freenode.net). ## Contributing You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can. Before you start to code, we recommend discussing your plans through a [GitHub issue](https://github.com/docker-library/celery/issues), especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.
pierreozoux/docs
celery/README.md
Markdown
mit
3,628
[ 30522, 1001, 3569, 22073, 1998, 7972, 1036, 8946, 2121, 8873, 2571, 1036, 6971, 1011, 1031, 1036, 1017, 1012, 1015, 1012, 2603, 1036, 1010, 1036, 1017, 1012, 1015, 1036, 1010, 1036, 1017, 1036, 1010, 1036, 6745, 1036, 1006, 1008, 8946, 21...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
YUI(M.yui.loader, {lang: M.local_mail_lang}).use('io-base', 'node', 'json-parse', 'panel', 'datatable-base', 'dd-plugin', 'moodle-form-dateselector', 'datatype-date', 'calendar-base', function(Y) { var mail_message_view = false; var mail_checkbox_labels_default = {}; var mail_view_type = ''; var mail_edit_label_panel; var mail_new_label_panel; var mail_undo_function = ''; var mail_undo_ids = ''; var mail_search_selected = ''; var mail_searchfrom_selected = ''; var mail_searchto_selected = ''; var mail_unread_selected = false; var mail_attach_selected = false; var mail_date_selected = ''; var mail_doing_search = false; var mail_after_message_search = false; var mail_before_message_search = false; var mail_perpageid = 0; var init = function(){ mail_view_type = Y.one('input[name="type"]').get('value'); if (Y.one('input[name="m"]')) { mail_message_view = true; Y.one('.mail_checkbox_all').remove(); } mail_enable_all_buttons(mail_message_view); if (!mail_message_view) { mail_select_none(); } if (mail_view_type == 'trash') { mail_remove_action('.mail_menu_action_markasstarred'); mail_remove_action('.mail_menu_action_markasunstarred'); } mail_update_menu_actions(); mail_create_edit_label_panel(); mail_create_new_label_panel(); mail_define_label_handlers(); }; var mail_define_label_handlers = function () { if (Y.one('#local_mail_form_new_label')) { //Click on new label color div Y.one('#local_mail_form_new_label').delegate('click', function(e) { e.stopPropagation(); mail_label_set_selected(this, 'new'); }, '.mail_label_color'); } if (Y.one('#local_mail_form_edit_label')) { //Click on edit label color div Y.one('#local_mail_form_edit_label').delegate('click', function(e) { e.stopPropagation(); mail_label_set_selected(this, 'edit'); }, '.mail_label_color'); } }; var mail_create_edit_label_panel = function () { var title = M.util.get_string('editlabel', 'local_mail'); var obj = (Y.one('.mail_list')?Y.one('.mail_list'):Y.one('.mail_view')); var position = obj.getXY(); var width = 400; var posx = position[0]+(Y.one('body').get('offsetWidth')/2)-width; mail_edit_label_panel = new Y.Panel({ srcNode : '#local_mail_form_edit_label', headerContent: title, width : width, zIndex : 5, centered : false, modal : true, visible : false, render : true, xy : [posx,position[1]], plugins : [Y.Plugin.Drag] }); mail_edit_label_panel.addButton({ value : M.util.get_string('submit', 'moodle'), section: Y.WidgetStdMod.FOOTER, action : function (e) { e.preventDefault(); mail_edit_label_panel.hide(); mail_doaction('setlabel'); } }); mail_edit_label_panel.addButton({ value : M.util.get_string('cancel', 'moodle'), section: Y.WidgetStdMod.FOOTER, action : function (e) { e.preventDefault(); mail_edit_label_panel.hide(); } }); }; var mail_create_new_label_panel = function () { var title = M.util.get_string('newlabel', 'local_mail'); var obj = (Y.one('.mail_list')?Y.one('.mail_list'):Y.one('.mail_view')); var position = obj.getXY(); var width = 400; var posx = position[0]+(Y.one('body').get('offsetWidth')/2)-width; mail_new_label_panel = new Y.Panel({ srcNode : '#local_mail_form_new_label', headerContent: title, width : width, zIndex : 5, centered : true, modal : true, visible : false, render : true, xy : [posx,position[1]], plugins : [Y.Plugin.Drag] }); mail_new_label_panel.addButton({ value : M.util.get_string('submit', 'moodle'), section: Y.WidgetStdMod.FOOTER, action : function (e) { e.preventDefault(); mail_new_label_panel.hide(); mail_doaction('newlabel'); } }); mail_new_label_panel.addButton({ value : M.util.get_string('cancel', 'moodle'), section: Y.WidgetStdMod.FOOTER, action : function (e) { e.preventDefault(); mail_new_label_panel.hide(); } }); }; var mail_hide_actions = function() { Y.all('.mail_menu_actions li').each(function(node){ node.hide(); }); mail_show_label_actions(false); }; var mail_show_label_actions = function(separator) { if (mail_view_type == 'label' && !mail_message_view) { if (separator) { Y.one('.mail_menu_action_separator').ancestor('li').show(); } Y.one('.mail_menu_action_editlabel').ancestor('li').show(); Y.one('.mail_menu_action_removelabel').ancestor('li').show(); } }; var mail_update_menu_actions = function() { var separator = false; mail_hide_actions(); if (mail_message_view) { if (mail_view_type == 'trash') { Y.one('.mail_menu_action_markasunread').ancestor('li').show(); } else { Y.one('.mail_menu_action_markasunread').ancestor('li').show(); if (Y.one('.mail_flags span').hasClass('mail_starred')) { Y.one('.mail_menu_action_markasunstarred').ancestor('li').show(); } else { Y.one('.mail_menu_action_markasstarred').ancestor('li').show(); } } } else { if (Y.all('.mail_selected.mail_unread').size()) { Y.one('.mail_menu_action_markasread').ancestor('li').show(); separator = true; } if (Y.all('.mail_selected.mail_unread').size() < Y.all('.mail_selected').size()) { Y.one('.mail_menu_action_markasunread').ancestor('li').show(); separator = true; } if (Y.all('.mail_selected span.mail_starred').size()) { Y.one('.mail_menu_action_markasunstarred').ancestor('li').show(); separator = true; } if (Y.all('.mail_selected span.mail_unstarred').size()) { Y.one('.mail_menu_action_markasstarred').ancestor('li').show(); separator = true; } } mail_show_label_actions(separator); }; var mail_toggle_menu = function() { var button = Y.one('.mail_checkbox_all'); var menu = Y.one('.mail_optselect'); var position = button.getXY(); if (!button.hasClass('mail_button_disabled')) { position[1] += button.get('clientHeight') + 2; menu.toggleClass('mail_hidden'); menu.setXY(position); } }; var mail_hide_menu_options = function() { Y.one('.mail_optselect').addClass('mail_hidden'); }; var mail_hide_menu_actions = function() { Y.one('.mail_actselect').addClass('mail_hidden'); }; var mail_hide_menu_labels = function() { if (mail_view_type != 'trash') { Y.one('.mail_labelselect').addClass('mail_hidden'); } }; var mail_hide_menu_search = function() { var menu = Y.one('#mail_menu_search'); if (menu) { menu.addClass('mail_hidden'); } if (M.form.dateselector.panel) { M.form.dateselector.panel.hide(); } }; var mail_toggle_menu_actions = function() { var button = Y.one('.mail_more_actions'); var menu = Y.one('.mail_actselect'); var position = button.getXY(); if (!button.hasClass('mail_button_disabled')) { position[1] += button.get('clientHeight') + 2; menu.toggleClass('mail_hidden'); menu.setXY(position); } }; var mail_toggle_menu_labels = function() { var button = Y.one('.mail_assignlbl'); var menu = Y.one('.mail_labelselect'); var position = button.getXY(); if (!button.hasClass('mail_button_disabled')) { position[1] += button.get('clientHeight') + 2; menu.toggleClass('mail_hidden'); menu.setXY(position); } }; var mail_toggle_menu_search = function() { var button = Y.one('#mail_search'); var menu = Y.one('#mail_menu_search'); var advsearch = Y.one('#mail_adv_search'); var position = button.getXY(); var date; position[1] += button.get('clientHeight') + 2; menu.toggleClass('mail_hidden'); menu.setXY(position); if (!menu.hasClass('mail_hidden')) { Y.one('#textsearch').focus(); if (!advsearch.hasClass('mail_hidden')) { mail_position_datepicker(); } if (mail_doing_search) { Y.one('#buttoncancelsearch').removeClass('mail_hidden'); } else { Y.one('#buttoncancelsearch').addClass('mail_hidden'); } } else { M.form.dateselector.panel.hide(); } }; var mail_toggle_adv_search = function() { var menu = Y.one('#mail_adv_search'); var status = Y.one('#mail_adv_status'); menu.toggleClass('mail_hidden'); if (menu.hasClass('mail_hidden')) { M.form.dateselector.panel.hide(); status.set('src', M.util.image_url('t/collapsed', 'moodle')); status.set('alt', 'collapsed'); } else { mail_position_datepicker(); status.set('src', M.util.image_url('t/expanded', 'moodle')); status.set('alt' ,'expanded'); } }; var mail_do_search = function() { mail_doing_search = true; mail_perpageid = 0; mail_search_selected = Y.one('#textsearch').get('value'); mail_searchfrom_selected = Y.one('#textsearchfrom').get('value'); mail_searchto_selected = Y.one('#textsearchto').get('value'); mail_unread_selected = Y.one('#searchunread').get('checked'); mail_attach_selected = Y.one('#searchattach').get('checked'); mail_select_none(); mail_check_selected(); Y.all('.mail_paging input').set('disabled', 'disabled'); mail_show_loading_image(); mail_doaction('search'); mail_hide_menu_search(); }; var mail_show_loading_image = function() { Y.one('.mail_list').addClass('mail_hidden'); Y.one('.mail_search_loading').removeClass('mail_hidden'); }; var mail_update_form_search = function() { Y.one('#textsearch').set('value', mail_search_selected); Y.one('#textsearchfrom').set('value', mail_searchfrom_selected); Y.one('#textsearchto').set('value', mail_searchto_selected); if (mail_unread_selected) { Y.one('#searchunread').set('checked', 'checked'); } if (mail_attach_selected) { Y.one('#searchattach').set('checked', 'checked'); } }; var mail_remove_action = function(action) { Y.one(action).ancestor('li').remove(); }; var mail_customize_menu_actions = function(checkbox) { var menu = Y.one('.mail_menu_actions'); var mailitem = checkbox.ancestor('.mail_item'); var separator = false; var nodes; if (mail_is_checkbox_checked(checkbox)) { //Read or unread if (mailitem.hasClass('mail_unread')) { menu.one('a.mail_menu_action_markasread').ancestor('li').show(); separator = true; } else { menu.one('a.mail_menu_action_markasunread').ancestor('li').show(); separator = true; } //Starred or unstarred if (mail_view_type != 'trash' && mailitem.one('.mail_flags span').hasClass('mail_starred')) { menu.one('a.mail_menu_action_markasunstarred').ancestor('li').show(); separator = true; } else { if (mail_view_type != 'trash') { menu.one('a.mail_menu_action_markasstarred').ancestor('li').show(); separator = true; } } } else { if (!Y.all('.mail_list .mail_selected').size()) { mail_hide_actions(); } else { //Read or unread if (mailitem.hasClass('mail_unread')) { if (!mailitem.siblings('.mail_selected.mail_unread').size()) { menu.one('a.mail_menu_action_markasread').ancestor('li').hide(); } } else { if (mailitem.siblings('.mail_selected.mail_unread').size() == mailitem.siblings('.mail_selected').size()) { menu.one('a.mail_menu_action_markasunread').ancestor('li').hide(); } } //Starred or unstarred if (mail_view_type != 'trash' && mailitem.one('.mail_flags a span').hasClass('mail_starred')) { nodes = mailitem.siblings(function(obj) { return obj.hasClass('mail_selected') && obj.one('.mail_flags a span.mail_starred'); }); if (!nodes.size()) { menu.one('a.mail_menu_action_markasunstarred').ancestor('li').hide(); } } else { nodes = mailitem.siblings(function(obj) { return obj.hasClass('mail_selected') && obj.one('.mail_flags a span.mail_unstarred'); }); if (mail_view_type != 'trash' && !nodes.size()) { menu.one('a.mail_menu_action_markasstarred').ancestor('li').hide(); } } } } mail_show_label_actions(separator); }; var mail_label_default_values = function () { var grouplabels; if (Y.one('.mail_labelselect').hasClass('mail_hidden')) { Y.each(M.local_mail.mail_labels, function (label, index) { mail_checkbox_labels_default[index] = 0; }); if (mail_message_view) { grouplabels = Y.all('.mail_group_labels span'); if (grouplabels) { mail_set_label_default_values(grouplabels); } } else { var nodes = mail_get_checkboxs_checked(); Y.each(nodes, function (node, index) { grouplabels = node.ancestor('.mail_item').all('.mail_group_labels span'); if (grouplabels) { mail_set_label_default_values(grouplabels); } }); } mail_label_set_values(); } }; var mail_set_label_default_values = function (grouplabels) { var classnames = []; var num; Y.each(grouplabels, function (grouplabel, index) { classnames = grouplabel.getAttribute('class').split(' '); Y.each(classnames, function(classname){ num = /mail_label_(\d+)/.exec(classname); if (num) { mail_checkbox_labels_default[num[1]] += 1; } }); }); if (mail_view_type == 'label') { num = parseInt(Y.one('input[name="itemid"]').get('value'), 10); mail_checkbox_labels_default[num] += 1; } }; var mail_menu_label_selection = function (node) { var checkbox = node.one('.mail_adv_checkbox'); if (checkbox) { mail_toggle_checkbox(checkbox); } }; var mail_customize_menu_label = function() { if (Y.all('.mail_menu_labels li').size() > 1) { if(mail_label_check_default_values()) { Y.one('.mail_menu_labels .mail_menu_label_newlabel').removeClass('mail_hidden'); Y.one('.mail_menu_labels .mail_menu_label_apply').addClass('mail_hidden'); } else { Y.one('.mail_menu_labels .mail_menu_label_newlabel').addClass('mail_hidden'); Y.one('.mail_menu_labels .mail_menu_label_apply').removeClass('mail_hidden'); } } }; var mail_label_check_default_values = function () { var isdefault = true; var classname; var labelid; var num; var labels = Y.all('.mail_menu_labels .mail_adv_checkbox'); if (!mail_message_view) { var total = mail_get_checkboxs_checked().size(); Y.each(labels, function(label, index) { classname = label.getAttribute('class'); num = /mail_label_value_(\d+)/.exec(classname); if (num) { labelid = num[1]; if (mail_checkbox_labels_default[labelid] == total) { isdefault = isdefault && label.hasClass('mail_checkbox1'); } else if(mail_checkbox_labels_default[labelid] > 0) { isdefault = isdefault && label.hasClass('mail_checkbox2'); } else { isdefault = isdefault && label.hasClass('mail_checkbox0'); } } }); } else { Y.each(labels, function(label, index) { classname = label.getAttribute('class'); num = /mail_label_value_(\d+)/.exec(classname); if (num) { labelid = num[1]; if (mail_checkbox_labels_default[labelid] == 1) { isdefault = isdefault && label.hasClass('mail_checkbox1'); } else { isdefault = isdefault && label.hasClass('mail_checkbox0'); } } }); } return isdefault; }; var mail_label_set_values = function () { var total = (mail_message_view?1:mail_get_checkboxs_checked().size()); var state; Y.each(mail_checkbox_labels_default, function(value, index){ if (value == total) { state = 1; } else if(value > 0) { state = 2; } else { state = 0; } mail_set_checkbox(Y.one('.mail_menu_labels .mail_label_value_'+index), state); }); }; var mail_get_label_value = function(checkbox){ var value; classnames = checkbox.getAttribute('class').split(' '); Y.each(classnames, function(classname){ num = /mail_label_value_(\d+)/.exec(classname); if (num) { value = num[1]; } }); return value; }; var mail_get_labels_checked = function(){ return Y.all('.mail_menu_labels .mail_checkbox1'); }; var mail_get_labels_thirdstate = function(){ return Y.all('.mail_menu_labels .mail_checkbox2'); }; var mail_get_labels_values = function(thirdstate){ var nodes = (thirdstate?mail_get_labels_thirdstate():mail_get_labels_checked()); var values = []; Y.each(nodes, function (node, index) { values.push(mail_get_label_value(node)); }); return values.join(); }; var mail_assign_labels = function (node) { node = (typeof node !== 'undefined' ? node : false); var grouplabels; var elem; var labelid = 0; if (mail_message_view) { grouplabels = Y.one('.mail_group_labels'); } else { grouplabels = node.ancestor('.mail_item').one('.mail_group_labels'); } if (mail_view_type == 'label') { labelid = parseInt(Y.one('input[name="itemid"]').get('value'), 10); } var lblstoadd = mail_get_labels_values(false).split(','); var lblstoremain = mail_get_labels_values(true).split(','); Y.each(M.local_mail.mail_labels, function (value, index) { if (Y.Array.indexOf(lblstoadd, index) != -1) { if (index != labelid) { elem = grouplabels.one('.mail_label_'+index); if (!elem) { elem = Y.Node.create('<span class="mail_label mail_label_'+M.local_mail.mail_labels[index].color+' mail_label_'+index+'">'+M.local_mail.mail_labels[index].name+'</span>'); grouplabels.append(elem); } } } else if (Y.Array.indexOf(lblstoremain, index) == -1) { if (!mail_message_view && index == labelid) { grouplabels.ancestor('.mail_item').remove(); } else { elem = grouplabels.one('.mail_label_'+index); if (elem) { elem.remove(); } } } }); }; var mail_check_selected = function() { mail_enable_all_buttons(Y.all('.mail_selected').size()); }; var mail_enable_button = function(button, bool) { bool = (typeof bool !== 'undefined' ? bool : false); if (bool) { button.removeClass('mail_button_disabled'); } else if(!button.hasClass('mail_checkbox_all')){ button.addClass('mail_button_disabled'); } }; var mail_enable_all_buttons = function(bool) { var mail_buttons = Y.all('.mail_toolbar .mail_buttons .mail_button'); Y.each(mail_buttons, (function(button) { button.removeClass('mail_hidden'); mail_enable_button(button, bool); })); if (Y.one('#mail_search')) { mail_enable_button(Y.one('#mail_search'), true); } if (Y.one('#buttonsearch')) { mail_enable_button(Y.one('#buttonsearch'), true); } if (Y.one('#buttoncancelsearch')) { mail_enable_button(Y.one('#buttoncancelsearch'), true); } if (mail_view_type == 'label') { mail_enable_button(Y.one('.mail_toolbar .mail_more_actions'), true); } }; var mail_get_checkboxs_checked = function(){ return Y.all('.mail_list .mail_checkbox1'); }; var mail_get_checkbox_value = function(checkbox){ var value; classnames = checkbox.getAttribute('class').split(' '); Y.each(classnames, function(classname){ num = /mail_checkbox_value_(\d+)/.exec(classname); if (num) { value = num[1]; } }); return value; }; var mail_get_checkboxs_values = function(){ var nodes = mail_get_checkboxs_checked(); var values = []; Y.each(nodes, function (node, index) { values.push(mail_get_checkbox_value(node)); }); return values.join(); }; var mail_set_checkbox = function(node, value){ if (value == 1) { node.removeClass('mail_checkbox0').removeClass('mail_checkbox2').addClass('mail_checkbox1'); } else if (value == 2) { node.removeClass('mail_checkbox0').removeClass('mail_checkbox1').addClass('mail_checkbox2'); } else { node.removeClass('mail_checkbox1').removeClass('mail_checkbox2').addClass('mail_checkbox0'); } }; var mail_toggle_checkbox = function(node){ if (node.hasClass('mail_checkbox0')) { mail_set_checkbox(node, 1); } else { mail_set_checkbox(node, 0); } }; var mail_is_checkbox_checked = function(node){ return node.hasClass('mail_checkbox1'); }; var mail_main_checkbox = function(){ if(!Y.all('.mail_selected').size()) { mail_set_checkbox(Y.one('.mail_checkbox_all > .mail_adv_checkbox'), 0); } else if(Y.all('.mail_selected').size() == Y.all('.mail_item').size()) { mail_set_checkbox(Y.one('.mail_checkbox_all > .mail_adv_checkbox'), 1); } else { mail_set_checkbox(Y.one('.mail_checkbox_all > .mail_adv_checkbox'), 2); } mail_check_selected(); }; var mail_select_all = function(){ var checkbox = Y.one('.mail_checkbox_all > .mail_adv_checkbox'); mail_set_checkbox(checkbox, 1); var nodes = Y.all('.mail_list .mail_adv_checkbox'); nodes.each(function(node) { mail_set_checkbox(node, 1); node.ancestor('.mail_item').addClass('mail_selected'); }); }; var mail_select_none = function(){ var checkbox = Y.one('.mail_checkbox_all > .mail_adv_checkbox'); mail_set_checkbox(checkbox, 0); var nodes = Y.all('.mail_list .mail_adv_checkbox'); nodes.each(function(node) { mail_set_checkbox(node, 0); node.ancestor('.mail_item').removeClass('mail_selected'); }); }; var mail_select_read = function(){ var nodes = Y.all('.mail_item > .mail_adv_checkbox'); var ancestor; if (nodes) { nodes.each(function(node) { ancestor = node.ancestor('.mail_item'); if (!ancestor.hasClass('mail_unread')){ mail_set_checkbox(node, 1); ancestor.addClass('mail_selected'); } else { mail_set_checkbox(node, 0); ancestor.removeClass('mail_selected'); } }); } }; var mail_select_unread = function() { var nodes = Y.all('.mail_item > .mail_adv_checkbox'); var ancestor; if (nodes) { nodes.each(function(node) { ancestor = node.ancestor('.mail_item'); if (ancestor.hasClass('mail_unread')){ mail_set_checkbox(node, 1); ancestor.addClass('mail_selected'); } else { mail_set_checkbox(node, 0); ancestor.removeClass('mail_selected'); } }); } }; var mail_select_starred = function() { var nodes = Y.all('.mail_item > .mail_adv_checkbox'); var ancestor; if (nodes) { nodes.each(function(node) { ancestor = node.ancestor('.mail_item'); if (ancestor.one('.mail_starred')) { mail_set_checkbox(node, 1); ancestor.addClass('mail_selected'); } else { mail_set_checkbox(node, 0); ancestor.removeClass('mail_selected'); } }); } }; var mail_select_unstarred = function() { var nodes = Y.all('.mail_item > .mail_adv_checkbox'); var ancestor; if (nodes) { nodes.each(function(node) { ancestor = node.ancestor('.mail_item'); if (ancestor.one('.mail_unstarred')) { mail_set_checkbox(node, 1); ancestor.addClass('mail_selected'); } else { mail_set_checkbox(node, 0); ancestor.removeClass('mail_selected'); } }); } }; //Success call var handleSuccess = function (transactionid, response, args) { var obj = Y.JSON.parse(response.responseText); var img; var node; if (obj.msgerror) { alert(obj.msgerror); } else { if (obj.html) { Y.one('#local_mail_main_form').setContent(obj.html); init(); mail_update_url(); } if (obj.search) { mail_perpageid = obj.search.perpageid; mail_doing_search = true; Y.one('#mail_search').addClass('mail_button_searching'); Y.one('.mail_paging input[name="prevpage"]').set('disabled', 'disabled'); Y.one('.mail_paging input[name="nextpage"]').set('disabled', 'disabled'); Y.one('.mail_paging > span').addClass('mail_hidden'); mail_search_selected = obj.search.query; mail_searchfrom_selected = obj.search.searchfrom; mail_searchto_selected = obj.search.searchto; mail_unread_selected = obj.search.unread; mail_attach_selected = obj.search.attach; mail_date_selected = obj.search.date; mail_update_form_search(); if (obj.search.prev) { Y.one('.mail_paging input[name="prevpage"]').set('disabled', ''); } if (obj.search.next) { Y.one('.mail_paging input[name="nextpage"]').set('disabled', ''); } if (!mail_message_view) { mail_before_message_search = obj.search.idbefore; mail_after_message_search = obj.search.idafter; } } if (obj.info) { if (obj.info.root) { node = Y.one('.mail_root span'); if (node) { node.setContent(obj.info.root); } node = Y.one('.mail_root'); if (node) { if(obj.info.root.match(/\(\d+\)/)) { node.addClass('local_mail_new_messages'); } else { node.removeClass('local_mail_new_messages'); } } } if (obj.info.inbox) { node = Y.one('.mail_inbox a img'); if (node) { img = node.get('outerHTML'); node = Y.one('.mail_inbox a'); if (node) { node.setContent(img+obj.info.inbox); } } } if (obj.info.drafts) { node = Y.one('.mail_drafts a img'); if (node) { img = node.get('outerHTML'); node = Y.one('.mail_drafts a'); if (node) { node.setContent(img+obj.info.drafts); } } } if (obj.info.courses) { Y.each(obj.info.courses, (function(value, index) { node = Y.one('.mail_course_'+index+' a img'); if (node) { img = node.get('outerHTML'); node = Y.one('.mail_course_'+index+' a'); if (node) { Y.one('.mail_course_'+index+' a').setContent(img+value); } } })); } if (obj.info.labels) { Y.each(obj.info.labels, (function(value, index) { node = Y.one('.mail_label_'+index+' a img'); if (node) { img = node.get('outerHTML'); node = Y.one('.mail_label_'+index+' a'); if (node) { node.setContent(img+value); } } })); } } //Undo last action if (obj.undo && mail_undo_function != 'undo') { var msg = M.util.get_string('undo'+mail_undo_function, 'local_mail', obj.undo.split(',').length); if (mail_undo_function == 'delete') { mail_undo_function = 'restore'; } else if (mail_undo_function == 'restore') { mail_undo_function = 'delete'; } mail_notification_message(msg); mail_undo_ids = obj.undo; } else { mail_undo_function = ''; } if(obj.redirect) { document.location.href = obj.redirect; } } }; //Failure call var handleFailure = function (transactionid, response, args) { console.log(response); }; //Update screen data and async call var mail_doaction = function(action, node) { node = (typeof node !== 'undefined' ? node : null); var nodes = mail_get_checkboxs_checked(); var obj; var child; var ancestor; var ids; var request; var mail_view; if(mail_message_view) { if(action == 'togglestarred') { obj = node.one('span'); if (obj.hasClass('mail_starred')) { action = 'unstarred'; obj.replaceClass('mail_starred', 'mail_unstarred'); node.set('title', M.util.get_string('unstarred','local_mail')); } else { action = 'starred'; obj.replaceClass('mail_unstarred', 'mail_starred'); node.set('title', M.util.get_string('starred','local_mail')); } } else if (action == 'delete' || action == 'restore') { mail_undo_function = action; mail_message_view = false; } else if (action == 'starred') { node = Y.one('.mail_flags span'); node.replaceClass('mail_unstarred', 'mail_starred'); node.ancestor('a').set('title', M.util.get_string('starred','local_mail')); } else if (action == 'unstarred') { node = Y.one('.mail_flags span'); node.replaceClass('mail_starred', 'mail_unstarred'); node.ancestor('a').set('title', M.util.get_string('unstarred','local_mail')); } else if(action == 'markasunread') { mail_message_view = false; } else if(action == 'goback') { mail_message_view = false; } else if(action == 'assignlabels') { mail_assign_labels(); } mail_view = true; ids = Y.one('input[name="m"]').get('value'); } else {//List messages view if(action == 'viewmail') { nodes.empty(); var url = node.get('href'); if (url.match(/compose\.php/)){ document.location.href = url; return 0; } else { ids = /m=(\d+)/.exec(node.get('href'))[1]; } } else if (action == 'delete') { mail_undo_function = action; ids = mail_get_checkboxs_values(); } else if (action == 'restore') { mail_undo_function = action; ids = mail_get_checkboxs_values(); } else if (action == 'discard') { ids = mail_get_checkboxs_values(); } else if (action == 'undo') { nodes.empty(); action = mail_undo_function; mail_undo_function = 'undo'; ids = mail_undo_ids; } else if (action == 'togglestarred') { obj = node.ancestor('.mail_item').one('.mail_adv_checkbox'); nodes = Y.all(obj); if (node.one('span').hasClass('mail_starred')) { action = 'unstarred'; } else { action = 'starred'; } ids = mail_get_checkbox_value(obj); } else if(action == 'perpage' || action == 'search'){ nodes.empty(); } else { ids = mail_get_checkboxs_values(); } if (nodes.size()) { nodes.each(function (node) { ancestor = node.ancestor('.mail_item'); if (action == 'starred') { child = ancestor.one('.mail_unstarred'); if(child) { child.replaceClass('mail_unstarred', 'mail_starred'); child.ancestor('a').set('title', M.util.get_string('starred','local_mail')); } } else if(action == 'unstarred') { if (mail_view_type == 'starred') { ancestor.remove(); } else { child = ancestor.one('.mail_starred'); if(child) { child.replaceClass('mail_starred', 'mail_unstarred'); child.ancestor('a').set('title', M.util.get_string('unstarred','local_mail')); } } } else if(action == 'markasread') { ancestor.removeClass('mail_unread'); } else if(action == 'markasunread') { ancestor.addClass('mail_unread'); } else if(action == 'delete' || action == 'restore' || action == 'discard') { ancestor.remove(); } else if(action == 'assignlabels') { mail_assign_labels(node); } }); } mail_view = false; } //Ajax call var cfg = { method: 'POST', data: { msgs: ids, sesskey: Y.one('input[name="sesskey"]').get('value'), type: mail_view_type, offset: Y.one('input[name="offset"]').get('value'), action: action, mailview: mail_view }, on: { success:handleSuccess, failure:handleFailure } }; if (Y.one('input[name="m"]')) { cfg.data.m = Y.one('input[name="m"]').get('value'); } if(Y.one('input[name="itemid"]')) { cfg.data.itemid = Y.one('input[name="itemid"]').get('value'); } if (action == 'perpage') { cfg.data.perpage = (node.get('innerText')?node.get('innerText'):node.get('textContent')); } if (action == 'assignlabels') { cfg.data.labelids = mail_get_labels_values(false); cfg.data.labeltsids = mail_get_labels_values(true); } if (action == 'setlabel') { obj = Y.one('#local_mail_edit_label_color'); cfg.data.labelname = Y.one('#local_mail_edit_label_name').get('value'); if (!cfg.data.labelname) { alert(M.util.get_string('erroremptylabelname', 'local_mail')); mail_label_edit(); return false; } else if (cfg.data.labelname.length > 100) { alert(M.util.get_string('maximumchars', 'moodle', 100)); mail_label_edit(); return false; } cfg.data.labelcolor = obj.get('value'); } if (action == 'newlabel') { obj = Y.one('#local_mail_new_label_color'); cfg.data.labelname = Y.one('#local_mail_new_label_name').get('value'); if (!cfg.data.labelname) { alert(M.util.get_string('erroremptylabelname', 'local_mail')); mail_label_new(); return false; } else if (cfg.data.labelname.length > 100) { alert(M.util.get_string('maximumchars', 'moodle', 100)); mail_label_new(); return false; } cfg.data.labelcolor = obj.get('value'); } if (action == 'nextpage' || action == 'prevpage' ) { obj = Y.one('#mail_loading_small'); var btn = Y.one('.mail_paging input[name="'+action+'"]'); var position = btn.getXY(); obj.removeClass('mail_hidden'); position[0] += (btn.get('offsetWidth')/2) - (obj.one('img').get('offsetWidth')/2); position[1] = btn.getXY()[1] + (obj.one('img').get('offsetHeight')/2); obj.setXY(position); } if (mail_doing_search) { //Go back when searching keeps current page if (action == 'goback') { if (mail_before_message_search) { cfg.data.before = mail_before_message_search; } else if (mail_after_message_search) { cfg.data.after = mail_after_message_search; } } cfg.data.search = mail_search_selected; cfg.data.searchfrom = mail_searchfrom_selected; cfg.data.searchto = mail_searchto_selected; cfg.data.unread = (mail_unread_selected?'1':''); cfg.data.attach = (mail_attach_selected?'1':''); cfg.data.time = mail_date_selected; cfg.data.perpageid = mail_perpageid; if (action == 'prevpage') { obj = Y.one('.mail_list .mail_item .mail_adv_checkbox'); if (obj) { cfg.data.after = mail_get_checkbox_value(obj); } cfg.data.action = 'search'; } else if (action == 'nextpage') { obj = Y.all('.mail_item:last-child .mail_adv_checkbox'); if (obj) { cfg.data.before = mail_get_checkbox_value(obj.shift()); cfg.data.perpageid = cfg.data.before; } cfg.data.action = 'search'; } cfg.data.searching = true; } if (mail_undo_function == 'undo') { cfg.data.undo = true; } request = Y.io(M.cfg.wwwroot + '/local/mail/ajax.php', cfg); }; var mail_label_confirm_delete = function(e) { var labelid; var message; var labelname = ''; labelid = Y.one('input[name="itemid"]').get('value'); labelname = M.local_mail.mail_labels[labelid].name; if (labelname.length > 25) { labelname = labelname.substring(0, 25) + '...'; } message = M.util.get_string('labeldeleteconfirm', 'local_mail', labelname); M.util.show_confirm_dialog(e, { 'callback' : mail_label_remove, 'message' : message, 'continuelabel': M.util.get_string('delete', 'local_mail') } ); }; var mail_label_remove = function() { var params = []; params.push('offset='+Y.one('input[name="offset"]').get('value')); params.push('sesskey='+Y.one('input[name="sesskey"]').get('value')); params.push('removelbl=1'); params.push('confirmlbl=1'); var url = Y.one('#local_mail_main_form').get('action'); document.location.href = url+'&'+params.join('&'); }; var mail_label_new = function() { mail_new_label_panel.show(); Y.one('#local_mail_form_new_label').removeClass('mail_hidden'); Y.one('#local_mail_new_label_name').focus(); }; var mail_label_edit = function() { var labelid = Y.one('input[name="itemid"]').get('value'); var labelname = M.local_mail.mail_labels[labelid].name; var labelcolor = M.local_mail.mail_labels[labelid].color; Y.one('#local_mail_edit_label_name').set('value', labelname); Y.all('.mail_label_color').removeClass('mail_label_color_selected'); if (!labelcolor) { Y.one('.mail_label_color.mail_label_nocolor').addClass('mail_label_color_selected'); labelcolor = ''; } else { Y.one('.mail_label_color.mail_label_' + labelcolor).addClass('mail_label_color_selected'); } Y.one('#local_mail_edit_label_color').set('value', labelcolor); mail_edit_label_panel.show(); Y.one('#local_mail_form_edit_label').removeClass('mail_hidden'); Y.one('#local_mail_edit_label_name').focus(); }; var mail_label_set_selected = function(obj, action) { Y.all('.mail_label_color').removeClass('mail_label_color_selected'); obj.addClass('mail_label_color_selected'); Y.one('#local_mail_' + action + '_label_color').set('value', obj.getAttribute('data-color')); }; var mail_update_url = function() { var params = []; var offset; var m; var type; if (history.pushState) { params.push('t='+mail_view_type); if (mail_message_view) { params.push('m='+Y.one('input[name="m"]').get('value')); } if (mail_view_type == 'course') { params.push('c='+Y.one('input[name="itemid"]').get('value')); } else { if (mail_view_type == 'label') { params.push('l='+Y.one('input[name="itemid"]').get('value')); } } offset = Y.one('input[name="offset"]').get('value'); if (parseInt(offset, 10) > 0) { params.push('offset='+offset); } history.pushState({}, document.title, M.cfg.wwwroot + '/local/mail/view.php?' + params.join('&')); } }; var mail_position_datepicker = function() { var menu = Y.one('#mail_menu_search'); var datepicker = Y.one('#dateselector-calendar-panel'); var search = Y.one('.mail_search_datepicker'); var position = menu.getXY(); position[0] += (menu.get('offsetWidth')/2) - (datepicker.get('offsetWidth')/2); position[1] = search.getXY()[1] - datepicker.get('offsetHeight'); datepicker.setXY(position); }; var mail_get_selected_date = function(cell, date) { mail_date_selected = cell.date.getFullYear() + ',' + cell.date.getMonth() + ',' + cell.date.getDate(); mail_set_selected_date(mail_date_selected); M.form.dateselector.panel.hide(); }; var mail_set_selected_date = function(date) { if (date) { var elems = date.split(','); date = Y.Date.format(new Date(elems[0], elems[1], elems[2]), {format:"%x"}) } else { date = Y.Date.format(new Date(), {format:"%x"}) } Y.one('#searchdate').set('text', date); }; var mail_notification_message = function(message) { if (message) { Y.one('#mail_notification').addClass('mail_enabled').removeClass('mail_novisible'); Y.one('#mail_notification_message').setContent(message); Y.one('#mail_notification_undo').removeClass('mail_novisible'); } else { Y.one('#mail_notification').removeClass('mail_enabled').addClass('mail_novisible'); Y.one('#mail_notification_message').setContent(''); Y.one('#mail_notification_undo').addClass('mail_novisible'); } }; var mail_reset_date_selected = function() { date = new Date(); mail_date_selected = date.getFullYear() + ',' + date.getMonth() + ',' + date.getDate(); M.form.dateselector.calendar.deselectDates(date); }; /*** Event listeners***/ //Background selection Y.one("#region-main").delegate('click', function(e) { var ancestor = this.ancestor('.mail_item'); mail_toggle_checkbox(this); ancestor.toggleClass('mail_selected'); mail_main_checkbox(); mail_customize_menu_actions(this); }, '.mail_list .mail_adv_checkbox'); //Select all/none Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); mail_toggle_checkbox(this); mail_hide_menu_options(); mail_hide_menu_labels(); if (mail_is_checkbox_checked(this)) { mail_select_all(); } else { mail_select_none(); } mail_check_selected(); mail_update_menu_actions(); }, '.mail_checkbox_all > .mail_adv_checkbox'); //Toggle menu select all/none Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); mail_toggle_menu(); mail_hide_menu_actions(); mail_hide_menu_labels(); mail_hide_menu_search(); }, '.mail_checkbox_all'); //Checkbox hides other menus Y.one("#region-main").delegate('click', function(e) { mail_hide_menu_options(); mail_hide_menu_labels(); }, '.mail_checkbox_all > .mail_adv_checkbox'); //Toggle menu actions Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); mail_toggle_menu_actions(); mail_hide_menu_options(); mail_hide_menu_labels(); mail_hide_menu_search(); }, '.mail_more_actions'); //Toggle menu actions Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); mail_label_default_values(); mail_customize_menu_label(); mail_toggle_menu_labels(); mail_hide_menu_options(); mail_hide_menu_actions(); mail_hide_menu_search(); }, '.mail_assignlbl'); //Menu select all Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_all(); mail_update_menu_actions(); }, '.mail_menu_option_all'); //Menu select none Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_none(); }, '.mail_menu_option_none'); //Menu select read Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_read(); mail_main_checkbox(); mail_update_menu_actions(); }, '.mail_menu_option_read'); //Menu select unread Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_unread(); mail_main_checkbox(); mail_update_menu_actions(); }, '.mail_menu_option_unread'); //Menu select starred Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_starred(); mail_main_checkbox(); mail_update_menu_actions(); }, '.mail_menu_option_starred'); //Menu select unstarred Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_toggle_menu(); mail_select_unstarred(); mail_main_checkbox(); mail_update_menu_actions(); }, '.mail_menu_option_unstarred'); Y.one("#region-main").delegate('click', function(e) { mail_check_selected(); }, '.mail_optselect'); Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); }, '.mail_labelselect'); //Menu action starred Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('starred'); mail_update_menu_actions(); }, '.mail_menu_action_markasstarred'); //Menu action unstarred Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('unstarred'); mail_update_menu_actions(); }, '.mail_menu_action_markasunstarred'); //Menu action markasread Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('markasread'); mail_update_menu_actions(); }, '.mail_menu_action_markasread'); //Menu action markasunread Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('markasunread'); mail_update_menu_actions(); }, '.mail_menu_action_markasunread'); //Menu action editlabel Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_label_edit(); }, '.mail_menu_action_editlabel'); //Menu action removelabel Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_label_confirm_delete(e); }, '.mail_menu_action_removelabel'); //Starred and unstarred Y.one('#region-main').delegate('click', function(e) { e.preventDefault(); mail_doaction('togglestarred', this); mail_update_menu_actions(); }, '.mail_flags a'); //Delete button Y.one("#region-main").delegate('click', function(e) { if (!this.hasClass('mail_button_disabled')) { mail_doaction('delete'); } }, '#mail_delete'); //Discard button Y.one("#region-main").delegate('click', function(e) { if (!this.hasClass('mail_button_disabled')) { mail_doaction('discard'); } }, '#mail_discard'); //Restore button Y.one("#region-main").delegate('click', function(e) { if (!this.hasClass('mail_button_disabled')) { mail_doaction('restore'); } }, '#mail_restore'); //Prev page button Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('prevpage'); }, 'input[name="prevpage"]'); //Prev page button Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('nextpage'); }, 'input[name="nextpage"]'); //Go back button Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('goback'); }, '.mail_goback'); //Mail per page Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('perpage', this); }, 'div.mail_perpage a'); //Hide all menus Y.on('click', function(e) { mail_hide_menu_options(); mail_hide_menu_actions(); mail_hide_menu_labels(); mail_hide_menu_search(); }, 'body'); //Show message Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doaction('viewmail', this); }, 'a.mail_link'); //Click apply changes on labels Y.one("#region-main").delegate('click', function(e) { mail_hide_menu_labels(); mail_doaction('assignlabels'); }, '.mail_menu_label_apply'); //Click new label Y.one("#region-main").delegate('click', function(e) { mail_hide_menu_labels(); mail_label_new(); }, '.mail_menu_label_newlabel'); //Click label on menu labels Y.one("#region-main").delegate('click', function(e) { mail_menu_label_selection(this); mail_customize_menu_label(); }, '.mail_menu_labels li'); //Click notification bar undo Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); var ancestor = Y.one('#mail_notification'); if (ancestor.hasClass('mail_enabled')) { ancestor.removeClass('mail_enabled').addClass('mail_novisible'); mail_doaction('undo'); } }, '#mail_notification_undo'); //Click cancel search button Y.one("#region-main").delegate('click', function(e) { e.preventDefault(); mail_doing_search = false; mail_hide_menu_search(); mail_doaction('goback'); mail_before_message_search = false; mail_after_message_search = false; mail_reset_date_selected(); }, '#buttoncancelsearch'); //Click search button Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); var date; mail_hide_menu_options(); mail_hide_menu_actions(); mail_hide_menu_labels(); mail_toggle_menu_search(); if (!mail_date_selected) { mail_reset_date_selected(); } mail_set_selected_date(mail_date_selected); }, '#mail_search'); //Click menu search Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); M.form.dateselector.panel.hide(); }, '#mail_menu_search'); //Click adv search Y.one("#region-main").delegate('click', function(e) { e.stopPropagation(); mail_toggle_adv_search(); }, '#mail_toggle_adv_search'); //Click date search Y.one("#local_mail_main_form").delegate('click', function(e) { e.stopPropagation(); if(Y.one('#dateselector-calendar-panel').hasClass('yui3-overlay-hidden')) { M.form.dateselector.panel.show(); } else { M.form.dateselector.panel.hide(); } }, '.mail_search_date'); Y.on('contentready', function() { if (M.form.dateselector.calendar) { M.form.dateselector.calendar.on('dateClick', mail_get_selected_date); M.form.dateselector.calendar.set('maximumDate', new Date()); M.form.dateselector.panel.set('zIndex', 1); Y.one('#dateselector-calendar-panel').setStyle('border', 0); M.form.dateselector.calendar.render(); } }, '#dateselector-calendar-panel'); //Click on button search Y.one("#region-main").delegate('keydown', function(e) { e.stopPropagation(); if (e.keyCode == 13) { this.focus(); mail_do_search(); } }, '#textsearch, #textsearchfrom, #textsearchto'); //Click on button search Y.one("#region-main").delegate('click', function(e) { mail_do_search(); }, '#buttonsearch'); //Initialize init(); mail_update_url(); });
nitro2010/moodle
local/mail/mail.js
JavaScript
gpl-3.0
58,550
[ 30522, 9805, 2072, 1006, 1049, 1012, 9805, 2072, 1012, 7170, 2121, 1010, 1063, 11374, 1024, 1049, 1012, 2334, 1035, 5653, 1035, 11374, 1065, 1007, 1012, 2224, 1006, 1005, 22834, 1011, 2918, 1005, 1010, 1005, 13045, 1005, 1010, 1005, 1046, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* arch/arm/mach-s5pv310/include/mach/regs-systimer.h * * Copyright (c) 2010 Samsung Electronics Co., Ltd. * http://www.samsung.com * * S5PV310 System Time configutation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ #ifndef __ASM_ARCH_REGS_SYSTIMER_H #define __ASM_ARCH_REGS_SYSTIMER_H #include <mach/map.h> #define S5PV310_TCFG (S5P_VA_SYSTIMER + (0x00)) #define S5PV310_TCON (S5P_VA_SYSTIMER + (0x04)) #define S5PV310_TICNTB (S5P_VA_SYSTIMER + (0x08)) #define S5PV310_TICNTO (S5P_VA_SYSTIMER + (0x0C)) #define S5PV310_INT_CSTAT (S5P_VA_SYSTIMER + (0x20)) #define S5PV310_FRCNTB (S5P_VA_SYSTIMER + (0x24)) #define S5PV310_FRCNTO (S5P_VA_SYSTIMER + (0x28)) #define S5PV310_TCFG_TICK_SWRST (1<<16) #define S5PV310_TCFG_CLKBASE_PCLK (0<<12) #define S5PV310_TCFG_CLKBASE_SYS_MAIN (1<<12) #define S5PV310_TCFG_CLKBASE_XRTCXTI (2<<12) #define S5PV310_TCFG_CLKBASE_MASK (3<<12) #define S5PV310_TCFG_CLKBASE_SHIFT (12) #define S5PV310_TCFG_PRESCALER_MASK (255<<0) #define S5PV310_TCFG_MUX_DIV1 (0<<8) #define S5PV310_TCFG_MUX_MASK (7<<8) #define S5PV310_TCON_FRC_START (1<<6) #define S5PV310_TCON_TICK_INT_START (1<<3) #define S5PV310_TCON_TICK_START (1<<0) #define S5PV310_INT_FRC_EN (1<<9) #define S5PV310_INT_TICK_EN (1<<8) #define S5PV310_INT_FRC_STATUS (1<<2) #define S5PV310_INT_TICK_STATUS (1<<1) #define S5PV310_INT_EN (1<<0) #endif /* __ASM_ARCH_REGS_SYSTIMER_H */
bedwa/P6800-Kernel
arch/arm/mach-s5pv310/include/mach/regs-systimer.h
C
gpl-2.0
1,555
[ 30522, 1013, 1008, 7905, 1013, 2849, 1013, 24532, 1011, 1055, 2629, 2361, 2615, 21486, 2692, 1013, 2421, 1013, 24532, 1013, 19723, 2015, 1011, 25353, 16643, 5017, 1012, 1044, 1008, 1008, 9385, 1006, 1039, 1007, 2230, 19102, 8139, 2522, 1012...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
#ifndef _ASMPPC_SIGNAL_H #define _ASMPPC_SIGNAL_H #include <linux/types.h> /* Avoid too many header ordering problems. */ struct siginfo; /* Most things should be clean enough to redefine this at will, if care is taken to make libc match. */ #define _NSIG 64 #define _NSIG_BPW 32 #define _NSIG_WORDS (_NSIG / _NSIG_BPW) typedef unsigned long old_sigset_t; /* at least 32 bits */ typedef struct { unsigned long sig[_NSIG_WORDS]; } sigset_t; #define SIGHUP 1 #define SIGINT 2 #define SIGQUIT 3 #define SIGILL 4 #define SIGTRAP 5 #define SIGABRT 6 #define SIGIOT 6 #define SIGBUS 7 #define SIGFPE 8 #define SIGKILL 9 #define SIGUSR1 10 #define SIGSEGV 11 #define SIGUSR2 12 #define SIGPIPE 13 #define SIGALRM 14 #define SIGTERM 15 #define SIGSTKFLT 16 #define SIGCHLD 17 #define SIGCONT 18 #define SIGSTOP 19 #define SIGTSTP 20 #define SIGTTIN 21 #define SIGTTOU 22 #define SIGURG 23 #define SIGXCPU 24 #define SIGXFSZ 25 #define SIGVTALRM 26 #define SIGPROF 27 #define SIGWINCH 28 #define SIGIO 29 #define SIGPOLL SIGIO /* #define SIGLOST 29 */ #define SIGPWR 30 #define SIGSYS 31 #define SIGUNUSED 31 /* These should not be considered constants from userland. */ #define SIGRTMIN 32 #define SIGRTMAX (_NSIG-1) /* * SA_FLAGS values: * * SA_ONSTACK is not currently supported, but will allow sigaltstack(2). * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the * SA_RESTART flag to get restarting signals (which were the default long ago) * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop. * SA_RESETHAND clears the handler when the signal is delivered. * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies. * SA_NODEFER prevents the current signal from being masked in the handler. * * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single * Unix names RESETHAND and NODEFER respectively. */ #define SA_NOCLDSTOP 0x00000001 #define SA_NOCLDWAIT 0x00000002 /* not supported yet */ #define SA_SIGINFO 0x00000004 #define SA_ONSTACK 0x08000000 #define SA_RESTART 0x10000000 #define SA_NODEFER 0x40000000 #define SA_RESETHAND 0x80000000 #define SA_NOMASK SA_NODEFER #define SA_ONESHOT SA_RESETHAND #define SA_INTERRUPT 0x20000000 /* dummy -- ignored */ #define SA_RESTORER 0x04000000 /* * sigaltstack controls */ #define SS_ONSTACK 1 #define SS_DISABLE 2 #define MINSIGSTKSZ 2048 #define SIGSTKSZ 8192 #ifdef __KERNEL__ /* * These values of sa_flags are used only by the kernel as part of the * irq handling routines. * * SA_INTERRUPT is also used by the irq handling routines. * SA_SHIRQ is for shared interrupt support on PCI and EISA. */ #define SA_PROBE SA_ONESHOT #define SA_SAMPLE_RANDOM SA_RESTART #define SA_SHIRQ 0x04000000 #endif #define SIG_BLOCK 0 /* for blocking signals */ #define SIG_UNBLOCK 1 /* for unblocking signals */ #define SIG_SETMASK 2 /* for setting the signal mask */ /* Type of a signal handler. */ typedef void (*__sighandler_t)(int); #define SIG_DFL ((__sighandler_t)0) /* default signal handling */ #define SIG_IGN ((__sighandler_t)1) /* ignore signal */ #define SIG_ERR ((__sighandler_t)-1) /* error return from signal */ struct old_sigaction { __sighandler_t sa_handler; old_sigset_t sa_mask; unsigned long sa_flags; void (*sa_restorer)(void); }; struct sigaction { __sighandler_t sa_handler; unsigned long sa_flags; void (*sa_restorer)(void); sigset_t sa_mask; /* mask last for extensibility */ }; struct k_sigaction { struct sigaction sa; }; typedef struct sigaltstack { void *ss_sp; int ss_flags; size_t ss_size; } stack_t; #ifdef __KERNEL__ #include <asm/sigcontext.h> #endif #endif
daydaygit/flrelse
uboot1.1.6/include/asm-ppc/signal.h
C
gpl-3.0
3,687
[ 30522, 1001, 2065, 13629, 2546, 1035, 2004, 8737, 15042, 1035, 4742, 1035, 1044, 1001, 9375, 1035, 2004, 8737, 15042, 1035, 4742, 1035, 1044, 1001, 2421, 1026, 11603, 1013, 4127, 1012, 1044, 1028, 1013, 1008, 4468, 2205, 2116, 20346, 13063,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * uiComponents.CustomLabel * *------------------------------------------------------------------------------ * Copyright (C) 2006-2008 University of Dundee. All rights reserved. * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * *------------------------------------------------------------------------------ */ package org.openmicroscopy.shoola.agents.editor.uiComponents; //Java imports import javax.swing.Icon; import javax.swing.JLabel; //Third-party libraries //Application-internal dependencies /** * A Custom Label, which should be used by the UI instead of using * JLabel. Sets the font to CUSTOM FONT. * * This font is also used by many other Custom UI components in this * package, making it easy to change the font in many components in * one place (here!). * * @author William Moore &nbsp;&nbsp;&nbsp;&nbsp; * <a href="mailto:will@lifesci.dundee.ac.uk">will@lifesci.dundee.ac.uk</a> * @version 3.0 * <small> * (<b>Internal version:</b> $Revision: $Date: $) * </small> * @since OME3.0 */ public class CustomLabel extends JLabel { private int fontSize; /** * Simply delegates to JLabel superclass. */ public CustomLabel() { super(); setFont(); } /** * Simply delegates to JLabel superclass. */ public CustomLabel(Icon image) { super(image); setFont(); } /** * Simply delegates to JLabel superclass. */ public CustomLabel(String text) { super(text); setFont(); } /** * Simply delegates to JLabel superclass. */ public CustomLabel(String text, int fontSize) { super(text); this.fontSize = fontSize; setFont(); } private void setFont() { if (fontSize == 0) setFont(new CustomFont()); else { setFont(CustomFont.getFontBySize(fontSize)); } } }
jballanc/openmicroscopy
components/insight/SRC/org/openmicroscopy/shoola/agents/editor/uiComponents/CustomLabel.java
Java
gpl-2.0
2,450
[ 30522, 1013, 1008, 1008, 21318, 9006, 29513, 7666, 1012, 7661, 20470, 2884, 1008, 1008, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright (c) 2010-2011 Mark Allen. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package com.restfb; import static com.restfb.json.JsonObject.NULL; import static com.restfb.util.ReflectionUtils.findFieldsWithAnnotation; import static com.restfb.util.ReflectionUtils.getFirstParameterizedTypeArgument; import static com.restfb.util.ReflectionUtils.isPrimitive; import static com.restfb.util.StringUtils.isBlank; import static com.restfb.util.StringUtils.trimToEmpty; import static java.util.Collections.unmodifiableList; import static java.util.Collections.unmodifiableSet; import static java.util.logging.Level.FINE; import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINEST; import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.logging.Logger; import com.restfb.exception.FacebookJsonMappingException; import com.restfb.json.JsonArray; import com.restfb.json.JsonException; import com.restfb.json.JsonObject; import com.restfb.types.Post.Comments; import com.restfb.util.ReflectionUtils.FieldWithAnnotation; /** * Default implementation of a JSON-to-Java mapper. * * @author <a href="http://restfb.com">Mark Allen</a> */ public class DefaultJsonMapper implements JsonMapper { /** * Logger. */ private static final Logger logger = Logger.getLogger(DefaultJsonMapper.class.getName()); /** * @see com.restfb.JsonMapper#toJavaList(String, Class) */ @Override public <T> List<T> toJavaList(String json, Class<T> type) { json = trimToEmpty(json); if (isBlank(json)) throw new FacebookJsonMappingException("JSON is an empty string - can't map it."); if (type == null) throw new FacebookJsonMappingException("You must specify the Java type to map to."); if (json.startsWith("{")) { // Sometimes Facebook returns the empty object {} when it really should be // returning an empty list [] (example: do an FQL query for a user's // affiliations - it's a list except when there are none, then it turns // into an object). Check for that special case here. if (isEmptyObject(json)) { if (logger.isLoggable(FINER)) logger.finer("Encountered {} when we should've seen []. " + "Mapping the {} as an empty list and moving on..."); return new ArrayList<T>(); } // Special case: if the only element of this object is an array called // "data", then treat it as a list. The Graph API uses this convention for // connections and in a few other places, e.g. comments on the Post // object. // Doing this simplifies mapping, so we don't have to worry about having a // little placeholder object that only has a "data" value. try { JsonObject jsonObject = new JsonObject(json); String[] fieldNames = JsonObject.getNames(jsonObject); if (fieldNames != null) { boolean hasSingleDataProperty = fieldNames.length == 1 && "data".equals(fieldNames[0]); Object jsonDataObject = jsonObject.get("data"); if (!hasSingleDataProperty && !(jsonDataObject instanceof JsonArray)) throw new FacebookJsonMappingException("JSON is an object but is being mapped as a list " + "instead. Offending JSON is '" + json + "'."); json = jsonDataObject.toString(); } } catch (JsonException e) { // Should never get here, but just in case... throw new FacebookJsonMappingException("Unable to convert Facebook response " + "JSON to a list of " + type.getName() + " instances. Offending JSON is " + json, e); } } try { List<T> list = new ArrayList<T>(); JsonArray jsonArray = new JsonArray(json); for (int i = 0; i < jsonArray.length(); i++) list.add(toJavaObject(jsonArray.get(i).toString(), type)); return unmodifiableList(list); } catch (FacebookJsonMappingException e) { throw e; } catch (Exception e) { throw new FacebookJsonMappingException("Unable to convert Facebook response " + "JSON to a list of " + type.getName() + " instances", e); } } /** * @see com.restfb.JsonMapper#toJavaObject(String, Class) */ @Override @SuppressWarnings("unchecked") public <T> T toJavaObject(String json, Class<T> type) { verifyThatJsonIsOfObjectType(json); try { // Are we asked to map to JsonObject? If so, short-circuit right away. if (type.equals(JsonObject.class)) return (T) new JsonObject(json); List<FieldWithAnnotation<Facebook>> fieldsWithAnnotation = findFieldsWithAnnotation(type, Facebook.class); Set<String> facebookFieldNamesWithMultipleMappings = facebookFieldNamesWithMultipleMappings(fieldsWithAnnotation); // If there are no annotated fields, assume we're mapping to a built-in // type. If this is actually the empty object, just return a new instance // of the corresponding Java type. if (fieldsWithAnnotation.size() == 0) if (isEmptyObject(json)) return createInstance(type); else return toPrimitiveJavaType(json, type); // Facebook will sometimes return the string "null". // Check for that and bail early if we find it. if ("null".equals(json)) return null; // Facebook will sometimes return the string "false" to mean null. // Check for that and bail early if we find it. if ("false".equals(json)) { if (logger.isLoggable(FINE)) logger.fine("Encountered 'false' from Facebook when trying to map to " + type.getSimpleName() + " - mapping null instead."); return null; } JsonObject jsonObject = new JsonObject(json); T instance = createInstance(type); if (instance instanceof JsonObject) return (T) jsonObject; // For each Facebook-annotated field on the current Java object, pull data // out of the JSON object and put it in the Java object for (FieldWithAnnotation<Facebook> fieldWithAnnotation : fieldsWithAnnotation) { String facebookFieldName = getFacebookFieldName(fieldWithAnnotation); if (!jsonObject.has(facebookFieldName)) { if (logger.isLoggable(FINER)) logger.finer("No JSON value present for '" + facebookFieldName + "', skipping. JSON is '" + json + "'."); continue; } fieldWithAnnotation.getField().setAccessible(true); // Set the Java field's value. // // If we notice that this Facebook field name is mapped more than once, // go into a special mode where we swallow any exceptions that occur // when mapping to the Java field. This is because Facebook will // sometimes return data in different formats for the same field name. // See issues 56 and 90 for examples of this behavior and discussion. if (facebookFieldNamesWithMultipleMappings.contains(facebookFieldName)) { try { fieldWithAnnotation.getField() .set(instance, toJavaType(fieldWithAnnotation, jsonObject, facebookFieldName)); } catch (FacebookJsonMappingException e) { logMultipleMappingFailedForField(facebookFieldName, fieldWithAnnotation, json); } catch (JsonException e) { logMultipleMappingFailedForField(facebookFieldName, fieldWithAnnotation, json); } } else { fieldWithAnnotation.getField().set(instance, toJavaType(fieldWithAnnotation, jsonObject, facebookFieldName)); } } return instance; } catch (FacebookJsonMappingException e) { throw e; } catch (Exception e) { throw new FacebookJsonMappingException("Unable to map JSON to Java. Offending JSON is '" + json + "'.", e); } } /** * Dumps out a log message when one of a multiple-mapped Facebook field name * JSON-to-Java mapping operation fails. * * @param facebookFieldName * The Facebook field name. * @param fieldWithAnnotation * The Java field to map to and its annotation. * @param json * The JSON that failed to map to the Java field. */ protected void logMultipleMappingFailedForField(String facebookFieldName, FieldWithAnnotation<Facebook> fieldWithAnnotation, String json) { if (!logger.isLoggable(FINER)) return; Field field = fieldWithAnnotation.getField(); if (logger.isLoggable(FINER)) logger.finer("Could not map '" + facebookFieldName + "' to " + field.getDeclaringClass().getSimpleName() + "." + field.getName() + ", but continuing on because '" + facebookFieldName + "' is mapped to multiple fields in " + field.getDeclaringClass().getSimpleName() + ". JSON is " + json); } /** * For a Java field annotated with the {@code Facebook} annotation, figure out * what the corresponding Facebook JSON field name to map to it is. * * @param fieldWithAnnotation * A Java field annotated with the {@code Facebook} annotation. * @return The Facebook JSON field name that should be mapped to this Java * field. */ protected String getFacebookFieldName(FieldWithAnnotation<Facebook> fieldWithAnnotation) { String facebookFieldName = fieldWithAnnotation.getAnnotation().value(); Field field = fieldWithAnnotation.getField(); // If no Facebook field name was specified in the annotation, assume // it's the same name as the Java field if (isBlank(facebookFieldName)) { if (logger.isLoggable(FINEST)) logger.finest("No explicit Facebook field name found for " + field + ", so defaulting to the field name itself (" + field.getName() + ")"); facebookFieldName = field.getName(); } return facebookFieldName; } /** * Finds any Facebook JSON fields that are mapped to more than 1 Java field. * * @param fieldsWithAnnotation * Java fields annotated with the {@code Facebook} annotation. * @return Any Facebook JSON fields that are mapped to more than 1 Java field. */ protected Set<String> facebookFieldNamesWithMultipleMappings(List<FieldWithAnnotation<Facebook>> fieldsWithAnnotation) { Map<String, Integer> facebookFieldsNamesWithOccurrenceCount = new HashMap<String, Integer>(); Set<String> facebookFieldNamesWithMultipleMappings = new HashSet<String>(); // Get a count of Facebook field name occurrences for each // @Facebook-annotated field for (FieldWithAnnotation<Facebook> fieldWithAnnotation : fieldsWithAnnotation) { String fieldName = getFacebookFieldName(fieldWithAnnotation); int occurrenceCount = facebookFieldsNamesWithOccurrenceCount.containsKey(fieldName) ? facebookFieldsNamesWithOccurrenceCount .get(fieldName) : 0; facebookFieldsNamesWithOccurrenceCount.put(fieldName, occurrenceCount + 1); } // Pull out only those field names with multiple mappings for (Entry<String, Integer> entry : facebookFieldsNamesWithOccurrenceCount.entrySet()) if (entry.getValue() > 1) facebookFieldNamesWithMultipleMappings.add(entry.getKey()); return unmodifiableSet(facebookFieldNamesWithMultipleMappings); } /** * @see com.restfb.JsonMapper#toJson(Object) */ @Override public String toJson(Object object) { // Delegate to recursive method return toJsonInternal(object).toString(); } /** * Is the given {@code json} a valid JSON object? * * @param json * The JSON to check. * @throws FacebookJsonMappingException * If {@code json} is not a valid JSON object. */ protected void verifyThatJsonIsOfObjectType(String json) { if (isBlank(json)) throw new FacebookJsonMappingException("JSON is an empty string - can't map it."); if (json.startsWith("[")) throw new FacebookJsonMappingException("JSON is an array but is being mapped as an object " + "- you should map it as a List instead. Offending JSON is '" + json + "'."); } /** * Recursively marshal the given {@code object} to JSON. * <p> * Used by {@link #toJson(Object)}. * * @param object * The object to marshal. * @return JSON representation of the given {@code object}. * @throws FacebookJsonMappingException * If an error occurs while marshaling to JSON. */ protected Object toJsonInternal(Object object) { if (object == null) return NULL; if (object instanceof List<?>) { JsonArray jsonArray = new JsonArray(); for (Object o : (List<?>) object) jsonArray.put(toJsonInternal(o)); return jsonArray; } if (object instanceof Map<?, ?>) { JsonObject jsonObject = new JsonObject(); for (Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) { if (!(entry.getKey() instanceof String)) throw new FacebookJsonMappingException("Your Map keys must be of type " + String.class + " in order to be converted to JSON. Offending map is " + object); try { jsonObject.put((String) entry.getKey(), toJsonInternal(entry.getValue())); } catch (JsonException e) { throw new FacebookJsonMappingException("Unable to process value '" + entry.getValue() + "' for key '" + entry.getKey() + "' in Map " + object, e); } } return jsonObject; } if (isPrimitive(object)) return object; if (object instanceof BigInteger) return ((BigInteger) object).longValue(); if (object instanceof BigDecimal) return ((BigDecimal) object).doubleValue(); // We've passed the special-case bits, so let's try to marshal this as a // plain old Javabean... List<FieldWithAnnotation<Facebook>> fieldsWithAnnotation = findFieldsWithAnnotation(object.getClass(), Facebook.class); JsonObject jsonObject = new JsonObject(); Set<String> facebookFieldNamesWithMultipleMappings = facebookFieldNamesWithMultipleMappings(fieldsWithAnnotation); if (facebookFieldNamesWithMultipleMappings.size() > 0) throw new FacebookJsonMappingException("Unable to convert to JSON because multiple @" + Facebook.class.getSimpleName() + " annotations for the same name are present: " + facebookFieldNamesWithMultipleMappings); for (FieldWithAnnotation<Facebook> fieldWithAnnotation : fieldsWithAnnotation) { String facebookFieldName = getFacebookFieldName(fieldWithAnnotation); fieldWithAnnotation.getField().setAccessible(true); try { jsonObject.put(facebookFieldName, toJsonInternal(fieldWithAnnotation.getField().get(object))); } catch (Exception e) { throw new FacebookJsonMappingException("Unable to process field '" + facebookFieldName + "' for " + object.getClass(), e); } } return jsonObject; } /** * Given a {@code json} value of something like {@code MyValue} or {@code 123} * , return a representation of that value of type {@code type}. * <p> * This is to support non-legal JSON served up by Facebook for API calls like * {@code Friends.get} (example result: {@code [222333,1240079]}). * * @param <T> * The Java type to map to. * @param json * The non-legal JSON to map to the Java type. * @param type * Type token. * @return Java representation of {@code json}. * @throws FacebookJsonMappingException * If an error occurs while mapping JSON to Java. */ @SuppressWarnings("unchecked") protected <T> T toPrimitiveJavaType(String json, Class<T> type) { if (String.class.equals(type)) { // If the string starts and ends with quotes, remove them, since Facebook // can serve up strings surrounded by quotes. if (json.length() > 1 && json.startsWith("\"") && json.endsWith("\"")) { json = json.replaceFirst("\"", ""); json = json.substring(0, json.length() - 1); } return (T) json; } if (Integer.class.equals(type) || Integer.TYPE.equals(type)) return (T) new Integer(json); if (Boolean.class.equals(type) || Boolean.TYPE.equals(type)) return (T) new Boolean(json); if (Long.class.equals(type) || Long.TYPE.equals(type)) return (T) new Long(json); if (Double.class.equals(type) || Double.TYPE.equals(type)) return (T) new Double(json); if (Float.class.equals(type) || Float.TYPE.equals(type)) return (T) new Float(json); if (BigInteger.class.equals(type)) return (T) new BigInteger(json); if (BigDecimal.class.equals(type)) return (T) new BigDecimal(json); throw new FacebookJsonMappingException("Don't know how to map JSON to " + type + ". Are you sure you're mapping to the right class? " + "Offending JSON is '" + json + "'."); } /** * Extracts JSON data for a field according to its {@code Facebook} annotation * and returns it converted to the proper Java type. * * @param fieldWithAnnotation * The field/annotation pair which specifies what Java type to * convert to. * @param jsonObject * "Raw" JSON object to pull data from. * @param facebookFieldName * Specifies what JSON field to pull "raw" data from. * @return A * @throws JsonException * If an error occurs while mapping JSON to Java. * @throws FacebookJsonMappingException * If an error occurs while mapping JSON to Java. */ protected Object toJavaType(FieldWithAnnotation<Facebook> fieldWithAnnotation, JsonObject jsonObject, String facebookFieldName) throws JsonException, FacebookJsonMappingException { Class<?> type = fieldWithAnnotation.getField().getType(); Object rawValue = jsonObject.get(facebookFieldName); // Short-circuit right off the bat if we've got a null value. if (NULL.equals(rawValue)) return null; if (String.class.equals(type)) { // Special handling here for better error checking. // Since JsonObject.getString() will return literal JSON text even if it's // _not_ a JSON string, we check the marshaled type and bail if needed. // For example, calling JsonObject.getString("results") on the below // JSON... // {"results":[{"name":"Mark Allen"}]} // ... would return the string "[{"name":"Mark Allen"}]" instead of // throwing an error. So we throw the error ourselves. // Per Antonello Naccarato, sometimes FB will return an empty JSON array // instead of an empty string. Look for that here. if (rawValue instanceof JsonArray) if (((JsonArray) rawValue).length() == 0) { if (logger.isLoggable(FINER)) logger.finer("Coercing an empty JSON array " + "to an empty string for " + fieldWithAnnotation); return ""; } // If the user wants a string, _always_ give her a string. // This is useful if, for example, you've got a @Facebook-annotated string // field that you'd like to have a numeric type shoved into. // User beware: this will turn *anything* into a string, which might lead // to results you don't expect. return rawValue.toString(); } if (Integer.class.equals(type) || Integer.TYPE.equals(type)) return new Integer(jsonObject.getInt(facebookFieldName)); if (Boolean.class.equals(type) || Boolean.TYPE.equals(type)) return new Boolean(jsonObject.getBoolean(facebookFieldName)); if (Long.class.equals(type) || Long.TYPE.equals(type)) return new Long(jsonObject.getLong(facebookFieldName)); if (Double.class.equals(type) || Double.TYPE.equals(type)) return new Double(jsonObject.getDouble(facebookFieldName)); if (Float.class.equals(type) || Float.TYPE.equals(type)) return new BigDecimal(jsonObject.getString(facebookFieldName)).floatValue(); if (BigInteger.class.equals(type)) return new BigInteger(jsonObject.getString(facebookFieldName)); if (BigDecimal.class.equals(type)) return new BigDecimal(jsonObject.getString(facebookFieldName)); if (List.class.equals(type)) return toJavaList(rawValue.toString(), getFirstParameterizedTypeArgument(fieldWithAnnotation.getField())); String rawValueAsString = rawValue.toString(); // Hack for issue 76 where FB will sometimes return a Post's Comments as // "[]" instead of an object type (wtf) if (Comments.class.isAssignableFrom(type) && rawValue instanceof JsonArray) { if (logger.isLoggable(FINE)) logger.fine("Encountered comment array '" + rawValueAsString + "' but expected a " + Comments.class.getSimpleName() + " object instead. Working around that " + "by coercing into an empty " + Comments.class.getSimpleName() + " instance..."); JsonObject workaroundJsonObject = new JsonObject(); workaroundJsonObject.put("count", 0); workaroundJsonObject.put("data", new JsonArray()); rawValueAsString = workaroundJsonObject.toString(); } // Some other type - recurse into it return toJavaObject(rawValueAsString, type); } /** * Creates a new instance of the given {@code type}. * * @param <T> * Java type to map to. * @param type * Type token. * @return A new instance of {@code type}. * @throws FacebookJsonMappingException * If an error occurs when creating a new instance ({@code type} is * inaccessible, doesn't have a public no-arg constructor, etc.) */ protected <T> T createInstance(Class<T> type) { String errorMessage = "Unable to create an instance of " + type + ". Please make sure that it's marked 'public' " + "and, if it's a nested class, is marked 'static'. " + "It should have a public, no-argument constructor."; try { return type.newInstance(); } catch (IllegalAccessException e) { throw new FacebookJsonMappingException(errorMessage, e); } catch (InstantiationException e) { throw new FacebookJsonMappingException(errorMessage, e); } } /** * Is the given JSON equivalent to the empty object (<code>{}</code>)? * * @param json * The JSON to check. * @return {@code true} if the JSON is equivalent to the empty object, * {@code false} otherwise. */ protected boolean isEmptyObject(String json) { return "{}".equals(json); } }
gooddata/GoodData-CL
connector/src/main/java/com/restfb/DefaultJsonMapper.java
Java
bsd-3-clause
26,108
[ 30522, 1013, 1008, 1008, 9385, 1006, 1039, 1007, 2230, 1011, 2249, 2928, 5297, 1012, 1008, 1008, 6656, 2003, 2182, 3762, 4379, 1010, 2489, 1997, 3715, 1010, 2000, 2151, 2711, 11381, 1037, 6100, 1008, 1997, 2023, 4007, 1998, 3378, 12653, 6...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
https://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=1068
andrewdefries/ToxCast
Figure4/FDA_Pesticides/PCID_1068.html
HTML
mit
62
[ 30522, 16770, 1024, 1013, 1013, 9047, 5403, 2213, 1012, 13316, 5638, 1012, 17953, 2213, 1012, 9152, 2232, 1012, 18079, 1013, 12654, 1013, 12654, 1012, 1039, 5856, 1029, 28744, 1027, 10114, 2620, 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
//===---- VerifyDiagnosticConsumer.cpp - Verifying Diagnostic Client ------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This is a concrete diagnostic client, which buffers the diagnostic messages. // //===----------------------------------------------------------------------===// #include "clang/Frontend/VerifyDiagnosticConsumer.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/TextDiagnosticBuffer.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Regex.h" #include "llvm/Support/raw_ostream.h" #include <climits> using namespace clang; VerifyDiagnosticConsumer::VerifyDiagnosticConsumer(DiagnosticsEngine &_Diags) : Diags(_Diags), PrimaryClient(Diags.getClient()), OwnsPrimaryClient(Diags.ownsClient()), Buffer(new TextDiagnosticBuffer()), CurrentPreprocessor(0) { Diags.takeClient(); } VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() { CheckDiagnostics(); Diags.takeClient(); if (OwnsPrimaryClient) delete PrimaryClient; } // DiagnosticConsumer interface. void VerifyDiagnosticConsumer::BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP) { // FIXME: Const hack, we screw up the preprocessor but in practice its ok // because it doesn't get reused. It would be better if we could make a copy // though. CurrentPreprocessor = const_cast<Preprocessor*>(PP); PrimaryClient->BeginSourceFile(LangOpts, PP); } void VerifyDiagnosticConsumer::EndSourceFile() { CheckDiagnostics(); PrimaryClient->EndSourceFile(); CurrentPreprocessor = 0; } void VerifyDiagnosticConsumer::HandleDiagnostic( DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) { if (FirstErrorFID.isInvalid() && Info.hasSourceManager()) { const SourceManager &SM = Info.getSourceManager(); FirstErrorFID = SM.getFileID(Info.getLocation()); } // Send the diagnostic to the buffer, we will check it once we reach the end // of the source file (or are destructed). Buffer->HandleDiagnostic(DiagLevel, Info); } //===----------------------------------------------------------------------===// // Checking diagnostics implementation. //===----------------------------------------------------------------------===// typedef TextDiagnosticBuffer::DiagList DiagList; typedef TextDiagnosticBuffer::const_iterator const_diag_iterator; namespace { /// Directive - Abstract class representing a parsed verify directive. /// class Directive { public: static Directive* Create(bool RegexKind, const SourceLocation &Location, const std::string &Text, unsigned Count); public: /// Constant representing one or more matches aka regex "+". static const unsigned OneOrMoreCount = UINT_MAX; SourceLocation Location; const std::string Text; unsigned Count; virtual ~Directive() { } // Returns true if directive text is valid. // Otherwise returns false and populates E. virtual bool isValid(std::string &Error) = 0; // Returns true on match. virtual bool Match(const std::string &S) = 0; protected: Directive(const SourceLocation &Location, const std::string &Text, unsigned Count) : Location(Location), Text(Text), Count(Count) { } private: Directive(const Directive&); // DO NOT IMPLEMENT void operator=(const Directive&); // DO NOT IMPLEMENT }; /// StandardDirective - Directive with string matching. /// class StandardDirective : public Directive { public: StandardDirective(const SourceLocation &Location, const std::string &Text, unsigned Count) : Directive(Location, Text, Count) { } virtual bool isValid(std::string &Error) { // all strings are considered valid; even empty ones return true; } virtual bool Match(const std::string &S) { return S.find(Text) != std::string::npos; } }; /// RegexDirective - Directive with regular-expression matching. /// class RegexDirective : public Directive { public: RegexDirective(const SourceLocation &Location, const std::string &Text, unsigned Count) : Directive(Location, Text, Count), Regex(Text) { } virtual bool isValid(std::string &Error) { if (Regex.isValid(Error)) return true; return false; } virtual bool Match(const std::string &S) { return Regex.match(S); } private: llvm::Regex Regex; }; typedef std::vector<Directive*> DirectiveList; /// ExpectedData - owns directive objects and deletes on destructor. /// struct ExpectedData { DirectiveList Errors; DirectiveList Warnings; DirectiveList Notes; ~ExpectedData() { DirectiveList* Lists[] = { &Errors, &Warnings, &Notes, 0 }; for (DirectiveList **PL = Lists; *PL; ++PL) { DirectiveList * const L = *PL; for (DirectiveList::iterator I = L->begin(), E = L->end(); I != E; ++I) delete *I; } } }; class ParseHelper { public: ParseHelper(const char *Begin, const char *End) : Begin(Begin), End(End), C(Begin), P(Begin), PEnd(NULL) { } // Return true if string literal is next. bool Next(StringRef S) { P = C; PEnd = C + S.size(); if (PEnd > End) return false; return !memcmp(P, S.data(), S.size()); } // Return true if number is next. // Output N only if number is next. bool Next(unsigned &N) { unsigned TMP = 0; P = C; for (; P < End && P[0] >= '0' && P[0] <= '9'; ++P) { TMP *= 10; TMP += P[0] - '0'; } if (P == C) return false; PEnd = P; N = TMP; return true; } // Return true if string literal is found. // When true, P marks begin-position of S in content. bool Search(StringRef S) { P = std::search(C, End, S.begin(), S.end()); PEnd = P + S.size(); return P != End; } // Advance 1-past previous next/search. // Behavior is undefined if previous next/search failed. bool Advance() { C = PEnd; return C < End; } // Skip zero or more whitespace. void SkipWhitespace() { for (; C < End && isspace(*C); ++C) ; } // Return true if EOF reached. bool Done() { return !(C < End); } const char * const Begin; // beginning of expected content const char * const End; // end of expected content (1-past) const char *C; // position of next char in content const char *P; private: const char *PEnd; // previous next/search subject end (1-past) }; } // namespace anonymous /// ParseDirective - Go through the comment and see if it indicates expected /// diagnostics. If so, then put them in the appropriate directive list. /// static void ParseDirective(const char *CommentStart, unsigned CommentLen, ExpectedData &ED, Preprocessor &PP, SourceLocation Pos) { // A single comment may contain multiple directives. for (ParseHelper PH(CommentStart, CommentStart+CommentLen); !PH.Done();) { // search for token: expected if (!PH.Search("expected")) break; PH.Advance(); // next token: - if (!PH.Next("-")) continue; PH.Advance(); // next token: { error | warning | note } DirectiveList* DL = NULL; if (PH.Next("error")) DL = &ED.Errors; else if (PH.Next("warning")) DL = &ED.Warnings; else if (PH.Next("note")) DL = &ED.Notes; else continue; PH.Advance(); // default directive kind bool RegexKind = false; const char* KindStr = "string"; // next optional token: - if (PH.Next("-re")) { PH.Advance(); RegexKind = true; KindStr = "regex"; } // skip optional whitespace PH.SkipWhitespace(); // next optional token: positive integer or a '+'. unsigned Count = 1; if (PH.Next(Count)) PH.Advance(); else if (PH.Next("+")) { Count = Directive::OneOrMoreCount; PH.Advance(); } // skip optional whitespace PH.SkipWhitespace(); // next token: {{ if (!PH.Next("{{")) { PP.Diag(Pos.getLocWithOffset(PH.C-PH.Begin), diag::err_verify_missing_start) << KindStr; continue; } PH.Advance(); const char* const ContentBegin = PH.C; // mark content begin // search for token: }} if (!PH.Search("}}")) { PP.Diag(Pos.getLocWithOffset(PH.C-PH.Begin), diag::err_verify_missing_end) << KindStr; continue; } const char* const ContentEnd = PH.P; // mark content end PH.Advance(); // build directive text; convert \n to newlines std::string Text; StringRef NewlineStr = "\\n"; StringRef Content(ContentBegin, ContentEnd-ContentBegin); size_t CPos = 0; size_t FPos; while ((FPos = Content.find(NewlineStr, CPos)) != StringRef::npos) { Text += Content.substr(CPos, FPos-CPos); Text += '\n'; CPos = FPos + NewlineStr.size(); } if (Text.empty()) Text.assign(ContentBegin, ContentEnd); // construct new directive Directive *D = Directive::Create(RegexKind, Pos, Text, Count); std::string Error; if (D->isValid(Error)) DL->push_back(D); else { PP.Diag(Pos.getLocWithOffset(ContentBegin-PH.Begin), diag::err_verify_invalid_content) << KindStr << Error; } } } /// FindExpectedDiags - Lex the main source file to find all of the // expected errors and warnings. static void FindExpectedDiags(Preprocessor &PP, ExpectedData &ED, FileID FID) { // Create a raw lexer to pull all the comments out of FID. if (FID.isInvalid()) return; SourceManager& SM = PP.getSourceManager(); // Create a lexer to lex all the tokens of the main file in raw mode. const llvm::MemoryBuffer *FromFile = SM.getBuffer(FID); Lexer RawLex(FID, FromFile, SM, PP.getLangOpts()); // Return comments as tokens, this is how we find expected diagnostics. RawLex.SetCommentRetentionState(true); Token Tok; Tok.setKind(tok::comment); while (Tok.isNot(tok::eof)) { RawLex.Lex(Tok); if (!Tok.is(tok::comment)) continue; std::string Comment = PP.getSpelling(Tok); if (Comment.empty()) continue; // Find all expected errors/warnings/notes. ParseDirective(&Comment[0], Comment.size(), ED, PP, Tok.getLocation()); }; } /// PrintProblem - This takes a diagnostic map of the delta between expected and /// seen diagnostics. If there's anything in it, then something unexpected /// happened. Print the map out in a nice format and return "true". If the map /// is empty and we're not going to print things, then return "false". /// static unsigned PrintProblem(DiagnosticsEngine &Diags, SourceManager *SourceMgr, const_diag_iterator diag_begin, const_diag_iterator diag_end, const char *Kind, bool Expected) { if (diag_begin == diag_end) return 0; SmallString<256> Fmt; llvm::raw_svector_ostream OS(Fmt); for (const_diag_iterator I = diag_begin, E = diag_end; I != E; ++I) { if (I->first.isInvalid() || !SourceMgr) OS << "\n (frontend)"; else OS << "\n Line " << SourceMgr->getPresumedLineNumber(I->first); OS << ": " << I->second; } Diags.Report(diag::err_verify_inconsistent_diags) << Kind << !Expected << OS.str(); return std::distance(diag_begin, diag_end); } static unsigned PrintProblem(DiagnosticsEngine &Diags, SourceManager *SourceMgr, DirectiveList &DL, const char *Kind, bool Expected) { if (DL.empty()) return 0; SmallString<256> Fmt; llvm::raw_svector_ostream OS(Fmt); for (DirectiveList::iterator I = DL.begin(), E = DL.end(); I != E; ++I) { Directive& D = **I; if (D.Location.isInvalid() || !SourceMgr) OS << "\n (frontend)"; else OS << "\n Line " << SourceMgr->getPresumedLineNumber(D.Location); OS << ": " << D.Text; } Diags.Report(diag::err_verify_inconsistent_diags) << Kind << !Expected << OS.str(); return DL.size(); } /// CheckLists - Compare expected to seen diagnostic lists and return the /// the difference between them. /// static unsigned CheckLists(DiagnosticsEngine &Diags, SourceManager &SourceMgr, const char *Label, DirectiveList &Left, const_diag_iterator d2_begin, const_diag_iterator d2_end) { DirectiveList LeftOnly; DiagList Right(d2_begin, d2_end); for (DirectiveList::iterator I = Left.begin(), E = Left.end(); I != E; ++I) { Directive& D = **I; unsigned LineNo1 = SourceMgr.getPresumedLineNumber(D.Location); bool FoundOnce = false; for (unsigned i = 0; i < D.Count; ++i) { DiagList::iterator II, IE; for (II = Right.begin(), IE = Right.end(); II != IE; ++II) { unsigned LineNo2 = SourceMgr.getPresumedLineNumber(II->first); if (LineNo1 != LineNo2) continue; const std::string &RightText = II->second; if (D.Match(RightText)) break; } if (II == IE) { if (D.Count == D.OneOrMoreCount) { if (!FoundOnce) LeftOnly.push_back(*I); // We are only interested in at least one match, so exit the loop. break; } // Not found. LeftOnly.push_back(*I); } else { // Found. The same cannot be found twice. Right.erase(II); FoundOnce = true; } } } // Now all that's left in Right are those that were not matched. unsigned num = PrintProblem(Diags, &SourceMgr, LeftOnly, Label, true); num += PrintProblem(Diags, &SourceMgr, Right.begin(), Right.end(), Label, false); return num; } /// CheckResults - This compares the expected results to those that /// were actually reported. It emits any discrepencies. Return "true" if there /// were problems. Return "false" otherwise. /// static unsigned CheckResults(DiagnosticsEngine &Diags, SourceManager &SourceMgr, const TextDiagnosticBuffer &Buffer, ExpectedData &ED) { // We want to capture the delta between what was expected and what was // seen. // // Expected \ Seen - set expected but not seen // Seen \ Expected - set seen but not expected unsigned NumProblems = 0; // See if there are error mismatches. NumProblems += CheckLists(Diags, SourceMgr, "error", ED.Errors, Buffer.err_begin(), Buffer.err_end()); // See if there are warning mismatches. NumProblems += CheckLists(Diags, SourceMgr, "warning", ED.Warnings, Buffer.warn_begin(), Buffer.warn_end()); // See if there are note mismatches. NumProblems += CheckLists(Diags, SourceMgr, "note", ED.Notes, Buffer.note_begin(), Buffer.note_end()); return NumProblems; } void VerifyDiagnosticConsumer::CheckDiagnostics() { ExpectedData ED; // Ensure any diagnostics go to the primary client. bool OwnsCurClient = Diags.ownsClient(); DiagnosticConsumer *CurClient = Diags.takeClient(); Diags.setClient(PrimaryClient, false); // If we have a preprocessor, scan the source for expected diagnostic // markers. If not then any diagnostics are unexpected. if (CurrentPreprocessor) { SourceManager &SM = CurrentPreprocessor->getSourceManager(); // Extract expected-error strings from main file. FindExpectedDiags(*CurrentPreprocessor, ED, SM.getMainFileID()); // Only check for expectations in other diagnostic locations // if they are not the main file (via ID or FileEntry) - the main // file has already been looked at, and its expectations must not // be added twice. if (!FirstErrorFID.isInvalid() && FirstErrorFID != SM.getMainFileID() && (!SM.getFileEntryForID(FirstErrorFID) || (SM.getFileEntryForID(FirstErrorFID) != SM.getFileEntryForID(SM.getMainFileID())))) { FindExpectedDiags(*CurrentPreprocessor, ED, FirstErrorFID); FirstErrorFID = FileID(); } // Check that the expected diagnostics occurred. NumErrors += CheckResults(Diags, SM, *Buffer, ED); } else { NumErrors += (PrintProblem(Diags, 0, Buffer->err_begin(), Buffer->err_end(), "error", false) + PrintProblem(Diags, 0, Buffer->warn_begin(), Buffer->warn_end(), "warn", false) + PrintProblem(Diags, 0, Buffer->note_begin(), Buffer->note_end(), "note", false)); } Diags.takeClient(); Diags.setClient(CurClient, OwnsCurClient); // Reset the buffer, we have processed all the diagnostics in it. Buffer.reset(new TextDiagnosticBuffer()); } DiagnosticConsumer * VerifyDiagnosticConsumer::clone(DiagnosticsEngine &Diags) const { if (!Diags.getClient()) Diags.setClient(PrimaryClient->clone(Diags)); return new VerifyDiagnosticConsumer(Diags); } Directive* Directive::Create(bool RegexKind, const SourceLocation &Location, const std::string &Text, unsigned Count) { if (RegexKind) return new RegexDirective(Location, Text, Count); return new StandardDirective(Location, Text, Count); }
abduld/clreflect
extern/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
C++
mit
17,593
[ 30522, 1013, 1013, 1027, 1027, 1027, 1011, 1011, 1011, 1011, 20410, 9032, 26745, 10074, 8663, 23545, 2099, 1012, 18133, 2361, 1011, 20410, 2075, 16474, 7396, 1011, 1011, 1011, 1011, 1011, 1011, 1027, 1027, 1027, 1013, 1013, 1013, 1013, 1013...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php namespace Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow; use Symfony\Component\HttpFoundation\Request; /** * Interface for custom publish workflow checkers */ interface PublishWorkflowCheckerInterface { /** * @param $contentDocument content document instance * @param bool $ignoreRole if to ignore the role when deciding if to consider the document as published * @param Request $request the request instance * @return boolean */ public function checkIsPublished($contentDocument, $ignoreRole = false, Request $request = null); }
WouterJ/CoreBundle
PublishWorkflow/PublishWorkflowCheckerInterface.php
PHP
mit
573
[ 30522, 1026, 1029, 25718, 3415, 15327, 25353, 2213, 14876, 4890, 1032, 4642, 2546, 1032, 14012, 1032, 4563, 27265, 2571, 1032, 10172, 6198, 12314, 1025, 2224, 25353, 2213, 14876, 4890, 1032, 6922, 1032, 8299, 14876, 18426, 3508, 1032, 5227, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.gotcreations.emojilibrary.controller; import android.animation.Animator; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Handler; import androidx.annotation.DrawableRes; import androidx.appcompat.widget.Toolbar; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.ImageButton; import android.widget.LinearLayout; import android.widget.TextView; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import com.gotcreations.emojilibrary.R; import com.gotcreations.emojilibrary.model.layout.EmojiCompatActivity; import com.gotcreations.emojilibrary.model.layout.EmojiEditText; import com.gotcreations.emojilibrary.model.layout.AppPanelEventListener; import com.gotcreations.emojilibrary.model.layout.TelegramPanelView; import com.gotcreations.emojilibrary.util.AbstractAnimatorListener; import static android.view.View.GONE; import static android.view.View.getDefaultSize; /** * Created by edgar on 18/02/2016. */ public class TelegramPanel extends AppPanel{ private static final String TAG = "TelegramPanel"; public static final int EMPTY_MESSAGE = 0; public static final int EMPTY_MESSAGE_EMOJI_KEYBOARD = 1; public static final int EMPTY_MESSAGE_KEYBOARD = 2; public static final int PREPARED_MESSAGE = 3; public static final int PREPARED_MESSAGE_EMOJI_KEYBOARD = 4; public static final int PREPARED_MESSAGE_KEYBOARD = 5; public static final int AUDIO = 6; private Toolbar mBottomPanel; private TextView audioTime; private TelegramPanelView panelView; private int state; // CONSTRUCTOR public TelegramPanel(EmojiCompatActivity activity, AppPanelEventListener listener) { super(activity); this.mActivity = activity; init(); this.mEmojiKeyboard = new EmojiKeyboard(this.mActivity, this.mInput); this.mListener = listener; } public TelegramPanel(EmojiCompatActivity activity) { this(activity, null); } // INITIALIZATION @Override protected void initBottomPanel() { this.audioTime = (TextView) this.mActivity.findViewById(R.id.audio_time); this.mBottomPanel = (Toolbar) this.mActivity.findViewById(R.id.panel); this.panelView = (TelegramPanelView) this.mActivity.findViewById(R.id.panel_container).getParent(); this.mBottomPanel.setNavigationIcon(R.drawable.input_emoji); this.mBottomPanel.inflateMenu(R.menu.telegram_menu); this.mBottomPanel.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (state == AUDIO) { fireOnMicOffClicked(); showAudioPanel(false); } else if (TelegramPanel.this.isEmojiKeyboardVisible) { TelegramPanel.this.closeCurtain(); if (TelegramPanel.this.mInput.isSoftKeyboardVisible()) { TelegramPanel.this.mBottomPanel.setNavigationIcon(R.drawable.ic_keyboard); TelegramPanel.this.mInput.hideSoftKeyboard(); } else { TelegramPanel.this.mBottomPanel.setNavigationIcon(R.drawable.input_emoji); TelegramPanel.this.mInput.showSoftKeyboard(); } } else { TelegramPanel.this.mBottomPanel.setNavigationIcon(R.drawable.ic_keyboard); TelegramPanel.this.closeCurtain(); TelegramPanel.this.showEmojiKeyboard(0); } } }); this.mBottomPanel.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.action_attach) { fireOnAttachClicked(); } else if (item.getItemId() == R.id.action_mic) { switch (state) { case AUDIO: fireOnSendClicked(); showAudioPanel(false); break; default: if (TelegramPanel.this.mInput.getText().toString().equals("")) { showAudioPanel(true); } else { fireOnSendClicked(); } } } return Boolean.TRUE; } }); this.mCurtain = (LinearLayout) this.mActivity.findViewById(R.id.curtain); this.state = EMPTY_MESSAGE; } @Override protected void setInputConfig() { this.mInput = (EmojiEditText) this.mBottomPanel.findViewById(R.id.input); mInput.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); this.mInput.addOnSoftKeyboardListener(new EmojiEditText.OnSoftKeyboardListener() { @Override public void onSoftKeyboardDisplay() { if (!TelegramPanel.this.isEmojiKeyboardVisible) { final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); scheduler.schedule(new Runnable() { @Override public void run() { Handler mainHandler = new Handler(TelegramPanel.this.mActivity.getMainLooper()); Runnable myRunnable = new Runnable() { @Override public void run() { TelegramPanel.this.openCurtain(); TelegramPanel.this.showEmojiKeyboard(0); } }; mainHandler.post(myRunnable); } }, 150, TimeUnit.MILLISECONDS); } } @Override public void onSoftKeyboardHidden() { if (TelegramPanel.this.isEmojiKeyboardVisible) { TelegramPanel.this.closeCurtain(); TelegramPanel.this.hideEmojiKeyboard(200); } } }); this.mInput.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { showSendOptions(true); } @Override public void afterTextChanged(Editable s) { } }); audioTime.setTextColor(panelView.getAudioTextColor()); mInput.setTextColor(panelView.getTextColor()); mInput.setHint(panelView.getHintText()); mInput.setHintTextColor(panelView.getTextColorHint()); setIcon(R.id.action_attach, panelView.getAttachIconColor(), R.drawable.ic_attachment); setIcon(R.id.action_mic, panelView.getAudioIconColor(), R.drawable.ic_mic); } private void setIcon(int itemId, int color, @DrawableRes int drawableId) { Drawable icon = mActivity.getResources().getDrawable(drawableId); icon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); setIcon(itemId, icon); } private void setIcon(int itemId, Drawable icon) { Menu menu = this.mBottomPanel.getMenu(); MenuItem mi = menu.findItem(itemId); mi.setIcon(icon); } @Override public void showAudioPanel(final boolean show) { if (show) { state = AUDIO; hideEmojiKeyboard(0); this.mInput.hideSoftKeyboard(); this.mInput.animate().alpha(0).setDuration(75).setListener(new AbstractAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { Log.d(TAG, "Hide mInput"); mInput.setVisibility(GONE); } }).start(); this.audioTime.animate().alpha(1).setDuration(75).setListener(new AbstractAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { Log.d(TAG, "show audioTime"); audioTime.setVisibility(View.VISIBLE); } }).start(); TelegramPanel.this.mBottomPanel.findViewById(R.id.action_attach).animate().scaleX(0).scaleY(0).setDuration(150).start(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(0).scaleY(0).setDuration(75).withEndAction(new Runnable() { @Override public void run() { setIcon(R.id.action_mic, panelView.getSendIconColor(), R.drawable.ic_send); TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(1).scaleY(1).setDuration(75).start(); } }).start(); } Drawable icCircle = mActivity.getResources().getDrawable(R.drawable.ic_circle); icCircle.setColorFilter(panelView.getAudioIconColor(), PorterDuff.Mode.SRC_ATOP); this.mBottomPanel.setNavigationIcon(icCircle); fireOnMicOnClicked(); } else { this.audioTime.animate().alpha(0).setDuration(75).setListener(new AbstractAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { Log.d(TAG, "Hide audioInput"); audioTime.setVisibility(GONE); } }).start(); this.mInput.animate().alpha(1).setDuration(75).setListener(new AbstractAnimatorListener() { @Override public void onAnimationEnd(Animator animation) { Log.d(TAG, "Show mInput"); mInput.setVisibility(View.VISIBLE); } }).start(); showSendOptions(true); } } public void showSendOptions(boolean show) { final MenuItem micButton = TelegramPanel.this.mBottomPanel.getMenu().findItem(R.id.action_mic); if (isEmojiKeyboardVisible) { this.mBottomPanel.setNavigationIcon(R.drawable.ic_keyboard); } else { this.mBottomPanel.setNavigationIcon(R.drawable.input_emoji); } if (!this.mInput.getText().toString().equals("") && show) { if (state != PREPARED_MESSAGE && state != PREPARED_MESSAGE_EMOJI_KEYBOARD && state != PREPARED_MESSAGE_KEYBOARD) { TelegramPanel.this.mBottomPanel.findViewById(R.id.action_attach).animate().scaleX(0).scaleY(0).setDuration(150).start(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(0).scaleY(0).setDuration(75).withEndAction(new Runnable() { @Override public void run() { setIcon(R.id.action_mic, panelView.getSendIconColor(), R.drawable.ic_send); TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(1).scaleY(1).setDuration(75).start(); } }).start(); } } state = PREPARED_MESSAGE; if (mInput.isSoftKeyboardVisible()) { state = PREPARED_MESSAGE_KEYBOARD; } else if (isEmojiKeyboardVisible) { state = PREPARED_MESSAGE_EMOJI_KEYBOARD; } } else { state = EMPTY_MESSAGE; if (mInput.isSoftKeyboardVisible()) { state = EMPTY_MESSAGE_KEYBOARD; } else if (isEmojiKeyboardVisible) { state = EMPTY_MESSAGE_EMOJI_KEYBOARD; } TelegramPanel.this.mBottomPanel.findViewById(R.id.action_attach).animate().scaleX(1).scaleY(1).setDuration(150).start(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(0).scaleY(0).setDuration(75).withEndAction(new Runnable() { @Override public void run() { setIcon(R.id.action_mic, panelView.getAudioIconColor(), R.drawable.ic_mic); TelegramPanel.this.mBottomPanel.findViewById(R.id.action_mic).animate().scaleX(1).scaleY(1).setDuration(75).start(); } }).start(); } } } public int getState() { return state; } public boolean isInState(int state) { return this.state == state; } public boolean isInAudioState() { return isInState(AUDIO); } public boolean isInMessageState() { return !isInAudioState(); } @Override public void hideEmojiKeyboard(int delay) { super.hideEmojiKeyboard(delay); this.mBottomPanel.setNavigationIcon(R.drawable.input_emoji); } public void setAudioTime(CharSequence time) { this.audioTime.setText(time); } }
ander7agar/emoji-keyboard
emoji-library/src/main/java/com/gotcreations/emojilibrary/controller/TelegramPanel.java
Java
apache-2.0
13,759
[ 30522, 7427, 4012, 1012, 2288, 16748, 10708, 1012, 7861, 29147, 18622, 10024, 2854, 1012, 11486, 1025, 12324, 11924, 1012, 7284, 1012, 25132, 1025, 12324, 11924, 1012, 8389, 1012, 8716, 8566, 4246, 1025, 12324, 11924, 1012, 8389, 1012, 4009, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"14178057","logradouro":"Rua Hugo Gaiofatto","bairro":"Jardim Campo Belo","cidade":"Sert\u00e3ozinho","uf":"SP","estado":"S\u00e3o Paulo"});
lfreneda/cepdb
api/v1/14178057.jsonp.js
JavaScript
cc0-1.0
154
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 15471, 2581, 17914, 28311, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 21766, 2050, 9395, 11721, 3695, 27753, 3406, 1000, 1010, 30524, 1010, 1000, 287...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*- package TestAPI::custom_response; # custom_response() doesn't alter the response code, but is used to # replace the standard response body use strict; use warnings FATAL => 'all'; use Apache2::Response (); use Apache2::Const -compile => qw(FORBIDDEN); sub handler { my $r = shift; my $how = $r->args || ''; # warn "$how"; # could be text or url $r->custom_response(Apache2::Const::FORBIDDEN, $how); return Apache2::Const::FORBIDDEN; } 1; __END__ <NoAutoConfig> <Location /TestAPI__custom_response> AuthName dummy AuthType none PerlAccessHandler TestAPI::custom_response </Location> </NoAutoConfig>
dreamhost/dpkg-ndn-perl-mod-perl
t/response/TestAPI/custom_response.pm
Perl
apache-2.0
788
[ 30522, 1001, 3531, 19274, 2498, 2077, 2023, 2240, 1024, 1011, 1008, 1011, 5549, 1024, 18133, 2121, 2140, 1025, 18133, 2121, 2140, 1011, 27427, 4765, 1011, 2504, 1024, 1018, 1025, 18133, 2121, 2140, 1011, 2506, 1011, 4861, 1011, 16396, 1024,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
package com.google.api.ads.dfp.jaxws.v201511; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlType; /** * <p>Java class for CustomTargetingValue.Status. * * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;simpleType name="CustomTargetingValue.Status"> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string"> * &lt;enumeration value="ACTIVE"/> * &lt;enumeration value="INACTIVE"/> * &lt;enumeration value="UNKNOWN"/> * &lt;/restriction> * &lt;/simpleType> * </pre> * */ @XmlType(name = "CustomTargetingValue.Status") @XmlEnum public enum CustomTargetingValueStatus { /** * * The object is active. * * */ ACTIVE, /** * * The object is no longer active. * * */ INACTIVE, /** * * The value returned if the actual value is not exposed by the requested * API version. * * */ UNKNOWN; public String value() { return name(); } public static CustomTargetingValueStatus fromValue(String v) { return valueOf(v); } }
gawkermedia/googleads-java-lib
modules/dfp_appengine/src/main/java/com/google/api/ads/dfp/jaxws/v201511/CustomTargetingValueStatus.java
Java
apache-2.0
1,306
[ 30522, 7427, 4012, 1012, 8224, 1012, 17928, 1012, 14997, 1012, 1040, 22540, 1012, 13118, 9333, 1012, 1058, 11387, 16068, 14526, 1025, 12324, 9262, 2595, 1012, 20950, 1012, 14187, 1012, 5754, 17287, 3508, 1012, 20950, 2368, 2819, 1025, 12324, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php /* * Copyright 2010 Nathan Samson <nathansamson at gmail dot com> * * This file is part of CoOrg. * * CoOrg is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * CoOrg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License * along with CoOrg. If not, see <http://www.gnu.org/licenses/>. */ class i18nAdminControllerTest extends CoOrgControllerTest { const dataset = 'admin.dataset.xml'; public function testIndex() { $this->login('dvorak'); $this->request('admin/i18n'); $this->assertRendered('i18n/index'); $this->assertVarSet('languages'); $this->assertVarSet('newLanguage'); } public function testIndexNotAllowed() { $this->login('azerty'); $this->request('admin/i18n'); $this->assertRedirected(''); $this->assertFlashError('You don\'t have the rights to view this page'); } public function testSave() { $this->login('dvorak'); $this->request('admin/i18n/save', array('language'=>'de', 'name'=>'German')); $this->assertFlashNotice('Installed "German"'); $this->assertRedirected('admin/i18n'); $this->assertNotNull(Language::get('de')); } public function testSaveFailure() { $this->login('dvorak'); $this->request('admin/i18n/save', array('language'=>'en', 'name'=>'Engels')); $this->assertFlashError('Did not install "Engels"'); $this->assertRendered('i18n/index'); $this->assertVarSet('newLanguage'); $this->assertVarSet('languages'); } public function testSaveNotAllowed() { $this->login('azerty'); $this->request('admin/i18n/save', array('language'=>'de', 'name'=>'German')); $this->assertFlashError('You don\'t have the rights to view this page'); $this->assertRedirected(''); } public function testUpdate() { $this->login('dvorak'); $this->request('admin/i18n/update', array('language'=>'en', 'name'=>'ENGELS')); $this->assertFlashNotice('Updated "ENGELS"'); $this->assertEquals('ENGELS', Language::get('en')->name); $this->assertRedirected('admin/i18n'); } public function testUpdateNotAllowed() { $this->login('azerty'); $this->request('admin/i18n/update', array('language'=>'en', 'name'=>'ENGELS')); $this->assertFlashError('You don\'t have the rights to view this page'); $this->assertRedirected(''); } public function testUpdateFailure() { $this->login('dvorak'); $this->request('admin/i18n/update', array('language'=>'en', 'name'=>'')); $this->assertFlashError('Did not update "en"'); } public function testUpdateNotFound() { $this->login('dvorak'); $this->request('admin/i18n/update', array('language'=>'br', 'name'=>'Brazil')); $this->assertFlashError('Language "br" not found'); $this->assertRedirected('admin/i18n'); } public function testDelete() { $this->login('dvorak'); $this->request('admin/i18n/delete', array('language'=>'en')); $this->assertFlashNotice('Deleted "English"'); $this->assertNull(Language::get('en')); $this->assertRedirected('admin/i18n'); } public function testDeleteNotFound() { $this->login('dvorak'); $this->request('admin/i18n/delete', array('language'=>'br')); $this->assertFlashError('Language "br" not found'); $this->assertRedirected('admin/i18n'); } public function testDeleteNotAllowed() { $this->login('azerty'); $this->request('admin/i18n/delete', array('language'=>'en')); $this->assertFlashError('You don\'t have the rights to view this page'); $this->assertRedirected(''); } private function login($u) { $s = new UserSession($u, $u); $s->save(); } } ?>
nathansamson/CoOrg
plugins/admin/tests/i18n.admin.controller.Test.php
PHP
agpl-3.0
4,294
[ 30522, 1026, 1029, 25718, 1013, 1008, 1008, 9385, 2230, 7150, 18375, 1026, 7150, 21559, 3385, 2012, 20917, 4014, 11089, 4012, 1028, 1008, 1008, 2023, 5371, 2003, 2112, 1997, 2522, 21759, 1012, 1008, 1008, 2522, 21759, 2003, 2489, 4007, 1024...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# make_gdalrasterband_view ## Prototype ```cpp template<T> gdal_raster_view<T> make_gdalrasterdata_view(GDALRasterBand* band); template<T> gdal_raster_view<T> make_gdalrasterdata_view(std::shared_ptr<GDALRasterBand> band); ``` ## Description Creates a gdal_raster_view for the band. The user is responsible for the lifetime of the band, which must exceed that of the gdal_raster_view. The `make_gdalrasterband_view` functions are not generally recommended to access raster data. Generally, the [`open` function](./open.md) is preferred. However, you may need to used the `make_gdalrasterdata_view` function in the following cases: 1. You need to interact with code that uses GDALRasterBand* already 2. You need to open multiple bands from the same dataset with read_write access. In the latter case, you can use two otherwise undocumented functions that open a GDALDataset and GDALRasterBand as a smart pointer. The dataset will be closed when the (last copy of) the shared_ptr is deleted. ```cpp std::shared_ptr<GDALDataset> detail::open_dataset(filesystem::path path, access elem_access); std::shared_ptr<GDALRasterBand> detail::open_band(std::shared_ptr<GDALDataset> dataset, int band_index); ``` ## Definition <pronto/raster/io.h> [(open in Github)](https://github.com/ahhz/raster/blob/master/include/pronto/raster/io.h) ## Requirements on types The native value type of the GDALRasterBand must be castable to T. ## Preconditions band must point to a valid and GDALRasterBand ## Complexity Constant cost, independent of raster size ## Example of use ```cpp //example_make_gdalrasterdata_view.cpp #include <pronto/raster/io.h> #include <pronto/raster/plot_raster.h> namespace pr = pronto::raster; int main() { // prepare a file in a separate scope { auto raster = pr::create<int>("test.tif", 3, 4, GDT_Byte); auto i = 0; for (auto&& v : raster) { i = (i + 3) % 7; v = i; } } // open dataset separately from band std::shared_ptr<GDALDataset> dataset = pr::detail::open_dataset("test.tif", pr::read_only); std::shared_ptr<GDALRasterBand> band = pr::detail::open_band(dataset, 1); // Note that here the type must be specified auto view = pr::make_gdalrasterdata_view<int>(band); plot_raster(view); return 0; } ``` ## Notes ## See also [`open`](./open.md)
ahhz/raster
docs/functions/make_gdalrasterband_view.md
Markdown
mit
2,324
[ 30522, 1001, 2191, 1035, 1043, 9305, 8180, 3334, 12733, 1035, 3193, 1001, 1001, 8773, 1036, 1036, 1036, 18133, 2361, 23561, 1026, 1056, 1028, 1043, 9305, 1035, 20710, 3334, 1035, 3193, 1026, 1056, 1028, 2191, 1035, 1043, 9305, 8180, 3334, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
OJ.extendClass( 'NwEvent', [OjEvent], { '_get_props_' : { 'data' : null }, '_constructor' : function(type/*, bubbles = false, cancelable = false, data = null*/){ var ln = arguments.length; this._super(OjEvent, '_constructor', ln > 3 ? [].slice.call(arguments, 0, 3) : arguments); if(ln > 3){ this._data = arguments[3]; } } } );
NuAge-Solutions/NW
src/js/events/NwEvent.js
JavaScript
gpl-3.0
361
[ 30522, 1051, 3501, 1012, 7949, 26266, 1006, 1005, 22064, 18697, 3372, 1005, 1010, 1031, 1051, 6460, 15338, 1033, 1010, 1063, 1005, 1035, 2131, 1035, 24387, 1035, 1005, 1024, 1063, 1005, 2951, 1005, 1024, 19701, 1065, 1010, 1005, 1035, 9570,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
# Mentha spicata subsp. glabrata (Lej. & Court.) Lebeau SUBSPECIES #### Status ACCEPTED #### According to International Plant Names Index #### Published in null #### Original name null ### Remarks null
mdoering/backbone
life/Plantae/Magnoliophyta/Magnoliopsida/Lamiales/Lamiaceae/Mentha/Mentha spicata/Mentha spicata glabrata/README.md
Markdown
apache-2.0
206
[ 30522, 1001, 2273, 8322, 11867, 5555, 2696, 24807, 1012, 1043, 20470, 14660, 1006, 3393, 3501, 1012, 1004, 2457, 1012, 1007, 3393, 26401, 11056, 1001, 1001, 1001, 1001, 3570, 3970, 1001, 1001, 1001, 1001, 2429, 2000, 2248, 3269, 3415, 5950,...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
--- layout: post title: "CSS居中布局" date: 2017-05-13 15:16:45 author: "Joan" tags: ["css"] --- > 参考链接:https://css-tricks.com/centering-css-complete-guide/ ## 一、水平居中 ### 1.inline 元素 ``` .center-children { text-align: center; } ``` `text-align` 属性规定元素中的文本的水平对齐方式。该属性需要添加在 inline 元素的父元素上。 ### 2.block 块级元素 ``` .center-me { margin: 0 auto; } ``` 使用这种方法的时候元素 width 不能为 auto。当 width 没有设置的时候 block 元素将占满整行。 ### 3.多个 block 元素 #### 方法1:inline 方法 ``` .inline-block-center { text-align: center; } .inline-block-center div { display: inline-block; text-align: left; } ``` 第一种方法将多个块的属性设置为 `inline-block`,然后使用 inline 元素水平居中的方法。 #### 方法2:flex 布局 ``` .flex-center { display: flex; justify-content: center; } ``` 第二种方法,直接使用 `flex` 布局。这样的好处在于不用将 block 元素设置为 inline 元素。 简单介绍一下 `flex` 布局:`flex-direction` 属性决定了主轴的方向,`row` 水平方向(默认)或者 `column` 垂直方向。而 `justify-content` 属性定义了项目在主轴上的对齐方式。 ## 二、垂直居中 ### 1.inline 元素 #### 单行 inline 元素 ``` .link { padding-top: 30px; padding-bottom: 30px; } ``` 最简单的方法就是让上下内边距相等,但如果内边距不确定的情况下就无法使用这种方法了。 ``` .center-text-trick { height: 100px; line-height: 100px; white-space: nowrap; } ``` 这种方法适用于只有一行文字的时候。使 `line-height` 行高与内联元素的高度相等。`white-space` 属性指定元素内的空白怎样处理,`nowrap` 表示不会换行。 #### 多行 inline 元素 ``` .flex-center-vertically { display: flex; justify-content: center; flex-direction: column; height: 400px; } ``` 使用 `flex` 布局,设置 `flex-direction` 排列方向为垂直。这个方法的一个很重要的问题就是:需要知道父级元素的高度。如果不定义父级元素的高度,那么父级元素会根据内部元素自动调整自身高度,那么也就不会有居中的问题了。 **PS:在很多情况下,这种自适应还是很有用处的。**但是主轴不同时,情况有可能会有所不同。当主轴方向为水平方向的时候,每一行子元素的高度将是一致的,也就是说子元素很可能会被拉长,除非固定每个子元素的高度。父级元素没有指定高度与宽度的话,高度将会自动包裹住所有行,宽度则是100%。因此,**当每一行的高度都需要根据子元素内部包含的东西自适应的时候,需要将主轴设置为垂直方向。** ### 2.block 块级元素 #### 知道元素高度—— margin 负值 ``` .parent { position: relative; } .child { position: absolute; top: 50%; height: 100px; margin-top: -50px; } ``` 首先把元素放置到父元素一半的高度上,即 top:50%。然后再把块元素向上移动高度的一半。最终元素就垂直居中了。 将 margin 负值设置为总高度的一半(如果设置了 padding 或者 border,那么要记得计算进去),达到向上移动一半高度的效果。 #### 不知道元素高度—— transform ``` .parent { position: relative; } .child { position: absolute; top: 50%; transform: translateY(-50%); } ``` CSS3 中的新属性 `transform`,这个属性翻译过来就是变形、转换,它可以帮助我们对元素进行 2D 或者 3D 转换。`translate` 值定义了平移量,其参数的百分比相对的是元素本身而不是父元素。 PS:translate 常译为“翻译”,但在这里它的意思是“平移”。 #### 布局方法—— flex ``` .parent { display: flex; flex-direction: column; justify-content: center; } ``` ## 三、水平垂直居中 其实与水平居中的方法差不多,有三种分别是:`margin` 负值; `transform` 属性平移;以及 `flex` 布局。代码如下: ``` .parent { position: relative; } .child { width: 300px; height: 100px; padding: 20px; position: absolute; top: 50%; left: 50%; margin: -70px 0 0 -170px; } ``` ``` .parent { position: relative; } .child { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } ``` ``` .parent { display: flex; justify-content: center; align-items: center; } ``` ## 总结 当需要居中的元素是 `inline` 内联元素的时候,比如居中一些文字,那么则需要用到一些文字属性,比如 `text-align` 以及 `inline-height`。 当需要居中的属性为 `block` 块级元素的时候,使用 `transform` 或者 `flex` 会更方便一些。如果内部涉及的元素比较多,使用 `flex` 会更好。
WJoan/WJoan.github.io
_posts/2017-05-13-css-center.markdown
Markdown
mit
4,975
[ 30522, 1011, 1011, 1011, 9621, 1024, 2695, 2516, 1024, 1000, 20116, 2015, 100, 1746, 100, 100, 1000, 3058, 1024, 2418, 1011, 5709, 1011, 2410, 2321, 1024, 2385, 1024, 3429, 3166, 1024, 1000, 7437, 1000, 22073, 1024, 1031, 1000, 20116, 201...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
INSTALL_DIR=usr/local/lib DEPS="coreutils" "sudo" REBARPROFILE ?= default include ../../config.mk include ../../_build/${REBARPROFILE}/lib/fifo_utils/priv/pkgng.mk .PHONY: prepare prepare: -rm -r $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT_INTERNAL) -rm $(STAGE_DIR)/+* -rm $(STAGE_DIR)/plist mkdir -p $(STAGE_DIR)/$(INSTALL_DIR) cp -r ../../_build/${REBARPROFILE}/rel/$(COMPONENT_INTERNAL) $(STAGE_DIR)/$(INSTALL_DIR)/$(COMPONENT_INTERNAL)
project-fifo/fifo-zlogin
rel/pkgng/Makefile
Makefile
bsd-3-clause
447
[ 30522, 16500, 1035, 16101, 1027, 2149, 2099, 1013, 2334, 1013, 5622, 2497, 2139, 4523, 1027, 1000, 4563, 21823, 4877, 1000, 1000, 19219, 2080, 1000, 2128, 8237, 21572, 8873, 2571, 1029, 1027, 12398, 2421, 1012, 1012, 1013, 1012, 30524, 1620...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright Droids Corporation, Microb Technology, Eirbot (2005) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Revision : $Id: s64_to_f64.h,v 1.3.6.3 2008-05-10 15:06:27 zer0 Exp $ * */ #include <aversive.h> #ifndef _S64_TO_F64_H_ #define _S64_TO_F64_H_ #if HOST_VERSION /* not optimized, but will work with any endianness */ static inline f64 s64_to_f64(int64_t i) { f64 f; f.f64_integer = ((i) >> 32); f.f64_decimal = (i); return f; } #else /* only for AVR, faster */ static inline f64 s64_to_f64(int64_t i) { f64 f; f.u.s64 = i; return f; } #endif #endif
eurobotics/aversive4dspic
modules/base/math/fixed_point/s64_to_f64.h
C
gpl-3.0
1,269
[ 30522, 1013, 1008, 1008, 9385, 2852, 17086, 3840, 1010, 12702, 2497, 2974, 1010, 1041, 4313, 18384, 1006, 2384, 1007, 1008, 1008, 2023, 2565, 2003, 2489, 4007, 1025, 2017, 2064, 2417, 2923, 3089, 8569, 2618, 2009, 1998, 1013, 2030, 19933, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Copyright 2018 NAVER Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.navercorp.pinpoint.hbase.schema.core.command; import com.navercorp.pinpoint.hbase.schema.reader.InvalidHbaseSchemaException; import com.navercorp.pinpoint.hbase.schema.reader.core.ChangeSet; import com.navercorp.pinpoint.hbase.schema.reader.core.ChangeType; import com.navercorp.pinpoint.hbase.schema.reader.core.TableChange; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.NamespaceDescriptor; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.io.compress.Compression; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; /** * @author HyunGil Jeong */ public class HbaseSchemaCommandManager { private final String namespace; private final Compression.Algorithm compressionAlgorithm; private final Set<TableName> affectedTables = new HashSet<>(); private final Map<TableName, TableCommand> tableCommandMap = new LinkedHashMap<>(); public HbaseSchemaCommandManager(String namespace, String compression) { this(namespace, compression, Collections.emptyList()); } public HbaseSchemaCommandManager(String namespace, String compression, List<HTableDescriptor> currentHtds) { if (StringUtils.isEmpty(namespace)) { this.namespace = NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR; } else { this.namespace = namespace; } this.compressionAlgorithm = getCompressionAlgorithm(compression); for (HTableDescriptor htd : filterTablesByNamespace(currentHtds)) { tableCommandMap.put(htd.getTableName(), new ModifyTableCommand(htd, this.compressionAlgorithm)); } } private Compression.Algorithm getCompressionAlgorithm(String compression) { if (StringUtils.isEmpty(compression)) { return Compression.Algorithm.NONE; } for (Compression.Algorithm compressionAlgorithm : Compression.Algorithm.values()) { if (compressionAlgorithm.getName().equalsIgnoreCase(compression)) { return compressionAlgorithm; } } throw new IllegalArgumentException("Unknown compression option : " + compression); } private List<HTableDescriptor> filterTablesByNamespace(List<HTableDescriptor> htds) { if (CollectionUtils.isEmpty(htds)) { return Collections.emptyList(); } List<HTableDescriptor> filteredHtds = new ArrayList<>(); for (HTableDescriptor htd : htds) { TableName tableName = htd.getTableName(); String namespace = tableName.getNamespaceAsString(); if (this.namespace.equalsIgnoreCase(namespace)) { filteredHtds.add(htd); } } return filteredHtds; } public String getNamespace() { return namespace; } public void applyChangeSet(ChangeSet changeSet) { Objects.requireNonNull(changeSet, "changeSet"); List<TableChange> tableChanges = changeSet.getTableChanges(); try { for (TableChange tableChange : tableChanges) { applyTableChange(tableChange); } } catch (Exception e) { throw new InvalidHbaseSchemaException("Error applying changeSet : " + changeSet.getId(), e); } } private void applyTableChange(TableChange tableChange) { ChangeType changeType = tableChange.getType(); TableName tableName = TableName.valueOf(namespace, tableChange.getName()); switch (changeType) { case CREATE: if (tableCommandMap.containsKey(tableName)) { throw new IllegalArgumentException("Cannot create an existing table : " + tableName); } TableCommand createTableCommand = new CreateTableCommand(tableName, compressionAlgorithm, tableChange.getSplitKeys()); createTableCommand.applyConfiguration(tableChange.getTableConfiguration()); createTableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges()); tableCommandMap.put(tableName, createTableCommand); break; case MODIFY: TableCommand tableCommand = tableCommandMap.get(tableName); if (tableCommand == null) { throw new IllegalArgumentException("Cannot modify a non-existent table : " + tableName); } tableCommand.applyConfiguration(tableChange.getTableConfiguration()); tableCommand.applyColumnFamilyChanges(tableChange.getColumnFamilyChanges()); break; default: throw new UnsupportedOperationException("Invalid change type : " + changeType); } affectedTables.add(tableName); } public List<TableCommand> getCommands() { return tableCommandMap.entrySet().stream() .filter(e -> affectedTables.contains(e.getKey())) .map(Map.Entry::getValue) .collect(Collectors.toList()); } public List<HTableDescriptor> getSchemaSnapshot() { return tableCommandMap.entrySet().stream() .filter(e -> affectedTables.contains(e.getKey())) .map(Map.Entry::getValue) .map(TableCommand::getHtd) .map(HTableDescriptor::new) .collect(Collectors.toList()); } }
naver/pinpoint
hbase/hbase-schema/src/main/java/com/navercorp/pinpoint/hbase/schema/core/command/HbaseSchemaCommandManager.java
Java
apache-2.0
6,290
[ 30522, 1013, 1008, 1008, 9385, 2760, 12847, 2099, 13058, 1012, 1008, 1008, 7000, 2104, 1996, 15895, 6105, 1010, 2544, 1016, 1012, 1014, 1006, 1996, 1000, 6105, 1000, 1007, 1025, 1008, 2017, 2089, 2025, 2224, 2023, 5371, 3272, 1999, 12646, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
<?php // <input type="radio" value="1" name="_customize-radio-redux_demo[opt-radio]" data-customize-setting-link="redux_demo[opt-color-title]"> //return; /** * Redux Framework is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * any later version. * Redux Framework is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with Redux Framework. If not, see <http://www.gnu.org/licenses/>. * * @package ReduxFramework * @author Dovy Paukstys (dovy) * @version 0.1.0 */ // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } // Don't duplicate me! if ( ! class_exists( 'ReduxFramework_extension_customizer' ) ) { /** * Main ReduxFramework customizer extension class * * @since 1.0.0 */ class ReduxFramework_extension_customizer { // Protected vars protected $redux; private $_extension_url; private $_extension_dir; private $parent; private $orig_options = array(); private static $post_values = array(); public static $version = "2.0.0"; private $options = array(); /** * Class Constructor. Defines the args for the extions class * * @since 1.0.0 * @access public * * @param array $sections Panel sections. * @param array $args Class constructor arguments. * @param array $extra_tabs Extra panel tabs. * * @return void */ public function __construct( $parent ) { $this->parent = $parent; $this->upload_dir = ReduxFramework::$_upload_dir . 'advanced-customizer/'; //add_action('wp_head', array( $this, '_enqueue_new' )); if ( $parent->args['customizer'] == false ) { return; } // Override the ReduxCore class add_filter( "redux/extension/{$this->parent->args['opt_name']}/customizer", array( $this, 'remove_core_customizer_class' ) ); global $pagenow, $wp_customize; if ( ! isset( $wp_customize ) && $pagenow !== "customize.php" && $pagenow !== "admin-ajax.php" ) { return; } if ( ( $pagenow !== "customize.php" && $pagenow !== "admin-ajax.php" && ! isset( $GLOBALS['wp_customize'] ) ) ) { //return; } if ( empty( $this->_extension_dir ) ) { $this->_extension_dir = trailingslashit( str_replace( '\\', '/', dirname( __FILE__ ) ) ); $this->_extension_url = site_url( str_replace( trailingslashit( str_replace( '\\', '/', ABSPATH ) ), '', $this->_extension_dir ) ); } self::get_post_values(); // Create defaults array $defaults = array(); /* customize_controls_init customize_controls_enqueue_scripts customize_controls_print_styles customize_controls_print_scripts customize_controls_print_footer_scripts */ //add_action('customize_save', ); if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == "on" ) { $this->parent->args['customizer_only'] = true; } if ( isset( $_POST['wp_customize'] ) && $_POST['wp_customize'] == "on" && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) && ! isset( $_POST['action'] ) ) { add_action( "redux/options/{$this->parent->args['opt_name']}/options", array( $this, '_override_values' ), 100 ); } add_action( 'customize_register', array( $this, '_register_customizer_controls' ) ); // Create controls add_action( 'wp_head', array( $this, 'customize_preview_init' ) ); //add_action( 'customize_save', array( $this, 'customizer_save_before' ) ); // Before save add_action( 'customize_save_after', array( &$this, 'customizer_save_after' ) ); // After save // Add global controls CSS file add_action( 'customize_controls_print_scripts', array( $this, 'enqueue_controls_css' ) ); add_action( 'customize_controls_init', array( $this, 'enqueue_panel_css' ) ); //add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_css' ) ); // Enqueue previewer css //add_action( 'wp_enqueue_scripts', array( &$this, '_enqueue_previewer_js' ) ); // Enqueue previewer javascript //add_action( "wp_footer", array( $this, '_enqueue_new' ), 100 ); //$this->_enqueue_new(); } function enqueue_controls_css() { require_once ReduxFramework::$_dir . 'core/enqueue.php'; $enqueue = new reduxCoreEnqueue ( $this->parent ); $enqueue->get_warnings_and_errors_array(); $enqueue->init(); wp_enqueue_style( 'redux-extension-advanced-customizer', $this->_extension_url . 'extension_customizer.css', '', time() ); wp_enqueue_script( 'redux-extension-customizer', $this->_extension_url . 'extension_customizer' . Redux_Functions::isMin() . '.js', array( 'jquery', 'redux-js' ), ReduxFramework_extension_customizer::$version, true ); wp_localize_script( 'redux-extension-customizer', 'redux_customizer', array( 'body_class' => sanitize_html_class( 'admin-color-' . get_user_option( 'admin_color' ), 'fresh' ) ) ); } function enqueue_panel_css() { } function remove_core_customizer_class( $path ) { return ""; } function customize_preview_init() { do_action( 'redux/customizer/live_preview' ); } protected static function get_post_values() { if ( empty( self::$post_values ) && isset( $_POST['customized'] ) && ! empty( $_POST['customized'] ) ) { self::$post_values = json_decode( stripslashes_deep( $_POST['customized'] ), true ); } } public function _override_values( $data ) { self::get_post_values(); if ( isset( $_POST['customized'] ) && ! empty( self::$post_values ) ) { if ( is_array( self::$post_values ) ) { foreach ( self::$post_values as $key => $value ) { if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) { //if (is_array($value)) { // $value = @stripslashes( $value ); // if ( function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() ) { // $value = @array_map( 'stripslashes_deep', $value ); // $value = @array_map( 'urldecode', $value ); // } //} else { // $value = @urldecode($value); //} $key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, "]" ) ); $data[ $key ] = $value; $GLOBALS[ $this->parent->args['global_variable'] ][ $key ] = $value; $this->parent->options[ $key ] = $value; } } } } return $data; } public function _enqueue_new() { //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/codemirror.min.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/colors-control.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/customizer-control.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/fonts-customizer-admin.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-control.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/header-models.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.slimscroll.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/jquery.ui.droppable.min.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/media-editor.min.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/new-customizer.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/previewing.js'."'></script>"; //echo "<script type='text/javascript' src='".$this->_extension_url . 'new/theme-customizer.js'."'></script>"; /* wp_enqueue_script('redux-extension-customizer-codemirror-js', $this->_extension_url . 'new/codemirror.min.js'); wp_enqueue_script('redux-extension-customizer-color-js', $this->_extension_url . 'new/colors-control.js'); wp_enqueue_script('redux-extension-customizer-controls-js', $this->_extension_url . 'new/customizer-control.js'); wp_enqueue_script('redux-extension-customizer-fonts-js', $this->_extension_url . 'new/fonts-customizer-admin.js'); wp_enqueue_script('redux-extension-customizer-header-js', $this->_extension_url . 'new/header-control.js'); wp_enqueue_script('redux-extension-customizer-models-js', $this->_extension_url . 'new/header-models.js'); wp_enqueue_script('redux-extension-customizer-slimscroll-js', $this->_extension_url . 'new/jquery.slimscroll.js'); wp_enqueue_script('redux-extension-customizer-droppable-js', $this->_extension_url . 'new/jquery.ui.droppable.min.js'); wp_enqueue_script('redux-extension-customizer-editor-js', $this->_extension_url . 'new/media-editor.min.js'); wp_enqueue_script('redux-extension-customizer-new-js', $this->_extension_url . 'new/new-customizer.js'); wp_enqueue_script('redux-extension-customizer-previewing-js', $this->_extension_url . 'new/previewing.js'); wp_enqueue_script('redux-extension-customizer-theme-js', $this->_extension_url . 'new/theme-customizer.js'); */ } public function render( $control ) { $fieldID = str_replace( $this->parent->args['opt_name'] . '-', '', $control->redux_id ); $field = $this->options[ $fieldID ]; if ( isset( $field['compiler'] ) && ! empty( $field['compiler'] ) ) { echo '<tr class="compiler">'; } else { echo '<tr>'; } echo '<th scope="row">' . $this->parent->field_head[ $field['id'] ] . '</th>'; echo '<td>'; //$field['data-customize-setting-link'] = array( // 'name' => $field['name'], // 'suffix' => isset($field['name_suffix']) ? $field['name_suffix'] : '' //); // $field['name'] = $field['id']; $this->parent->_field_input( $field ); echo '</td>'; echo '</tr>'; } // All sections, settings, and controls will be added here public function _register_customizer_controls( $wp_customize ) { if ( ! class_exists( 'Redux_Customizer_Section' ) ) { require_once dirname( __FILE__ ) . '/inc/customizer_section.php'; if ( method_exists( $wp_customize, 'register_section_type' ) ) { $wp_customize->register_section_type( 'Redux_Customizer_Section' ); } } if ( ! class_exists( 'Redux_Customizer_Panel' ) ) { require_once dirname( __FILE__ ) . '/inc/customizer_panel.php'; if ( method_exists( $wp_customize, 'register_panel_type' ) ) { $wp_customize->register_panel_type( 'Redux_Customizer_Panel' ); } } if ( ! class_exists( 'Redux_Customizer_Control' ) ) { require_once dirname( __FILE__ ) . '/inc/customizer_control.php'; } require_once dirname( __FILE__ ) . '/inc/customizer_fields.php'; require_once dirname( __FILE__ ) . '/inc/customizer_devs.php'; do_action( "redux/extension/customizer/control/includes" ); //if ($this->parent->args['dev_mode']) { // $section = new Redux_Customizer_rAds( $wp_customize, 'redux_rAds', array( // 'priority' => 0, // ) ); // $wp_customize->add_section( $section, array( // 'priority' => 0, // ) ); // // //$wp_customize->add_control( new Redux_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array( // // 'section' => 'redux_rAds', // // 'settings' => 'redux_rAds_field', // // 'type' => 'redux-rAds', // //) ) ); // // // // //} if ( $this->parent->args['dev_mode'] ) { //$args = array( // 'priority' => 0, //); ////$section = new Redux_Customizer_Section( $wp_customize, 'redux_rAds', $args ); ////$wp_customize->add_section( $section, $args ); //$this->add_section( 'redux_rAds', array( // 'title' => '', // 'priority' => 1, // 'description' => '', // 'capability' => 'edit_theme_options', //), $wp_customize ); // //$wp_customize->add_control( new WP_Customize_Color_Control( // $wp_customize, // 'redux_rAds_display', // array( // 'section' => 'redux_rAds', // 'settings' => 'redux_rAds_display', // ) //)); ////$wp_customize->add_control( new Redux_Customizer_Control_rAds( $wp_customize, 'reduxAdsDisplay', array( //// 'section' => 'redux_rAds', //// 'settings' => 'redux_rAds_field', //// 'type' => 'redux-rAds', ////) ) ); //start copyright settings //$section = new Redux_Customizer_section_rAds( $wp_customize, 'redux_rAds', array( // 'priority' => -999, //) ); //$wp_customize->add_section( $section, array( // 'priority' => -999, //) ); //$wp_customize->add_setting( // 'redux_rAds_empty' //); //$wp_customize->add_control( // new Redux_Customizer_Control_rAds( // $wp_customize, // 'redux_rAds_empty', // array( // 'section' => 'redux_rAds', // 'settings' => 'redux_rAds_empty' // ) // ) //); } $order = array( 'heading' => - 500, 'option' => - 500, ); $defaults = array( 'default-color' => '', 'default-image' => '', 'wp-head-callback' => '', 'admin-head-callback' => '', 'admin-preview-callback' => '' ); $panel = ""; $this->parent->args['options_api'] = false; $this->parent->_register_settings(); foreach ( $this->parent->sections as $key => $section ) { // Not a type that should go on the customizer if ( isset( $section['type'] ) && ( $section['type'] == "divide" ) ) { continue; } if ( isset( $section['id'] ) && $section['id'] == "import/export" ) { continue; } // If section customizer is set to false if ( isset( $section['customizer'] ) && $section['customizer'] === false ) { continue; } $section['permissions'] = isset( $section['permissions'] ) ? $section['permissions'] : 'edit_theme_options'; // No errors please if ( ! isset( $section['desc'] ) ) { $section['desc'] = ""; } // Fill the description if there is a subtitle if ( empty( $section['desc'] ) && ! empty( $section['subtitle'] ) ) { $section['desc'] = $section['subtitle']; } // Let's make a section ID from the title if ( empty( $section['id'] ) ) { $section['id'] = strtolower( str_replace( " ", "", $section['title'] ) ); } // No title is present, let's show what section is missing a title if ( ! isset( $section['title'] ) ) { $section['title'] = ""; } // Let's set a default priority if ( empty( $section['priority'] ) ) { $section['priority'] = $order['heading']; $order['heading'] ++; } //print_r($section); //print_r($this->parent->sections[$key+1]); //echo $key; //exit(); if ( method_exists( $wp_customize, 'add_panel' ) && ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) && isset( $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) && $this->parent->sections[ ( $key + 1 ) ]['subsection'] ) { $this->add_panel( $section['id'], array( 'priority' => $section['priority'], 'capability' => $section['permissions'], //'theme_supports' => '', 'title' => $section['title'], 'section' => $section, 'opt_name' => $this->parent->args['opt_name'], 'description' => '', ), $wp_customize ); $panel = $section['id']; $this->add_section( $section['id'], array( 'title' => $section['title'], 'priority' => $section['priority'], 'description' => $section['desc'], 'section' => $section, 'opt_name' => $this->parent->args['opt_name'], 'capability' => $section['permissions'], 'panel' => $panel ), $wp_customize ); } else { if ( ! isset( $section['subsection'] ) || ( isset( $section['subsection'] ) && $section['subsection'] != true ) ) { $panel = ""; } $this->add_section( $section['id'], array( 'title' => $section['title'], 'priority' => $section['priority'], 'description' => $section['desc'], 'opt_name' => $this->parent->args['opt_name'], 'section' => $section, 'capability' => $section['permissions'], 'panel' => $panel ), $wp_customize ); } if ( ! isset( $section['fields'] ) || ( isset( $section['fields'] ) && empty( $section['fields'] ) ) ) { continue; } foreach ( $section['fields'] as $skey => $option ) { if ( isset( $option['customizer'] ) && $option['customizer'] === false ) { continue; } if ( $this->parent->args['customizer'] === false && ( ! isset( $option['customizer'] ) || $option['customizer'] !== true ) ) { continue; } $this->options[ $option['id'] ] = $option; add_action( 'redux/advanced_customizer/control/render/' . $this->parent->args['opt_name'] . '-' . $option['id'], array( $this, 'render' ) ); $option['permissions'] = isset( $option['permissions'] ) ? $option['permissions'] : 'edit_theme_options'; // //if ( isset( $option['validate_callback'] ) && ! empty( $option['validate_callback'] ) ) { // continue; //} //Change the item priority if not set if ( $option['type'] != 'heading' && ! isset( $option['priority'] ) ) { $option['priority'] = $order['option']; $order['option'] ++; } if ( ! empty( $this->options_defaults[ $option['id'] ] ) ) { $option['default'] = $this->options_defaults['option']['id']; } //$option['id'] = $this->parent->args['opt_name'].'['.$option['id'].']'; //echo $option['id']; if ( ! isset( $option['default'] ) ) { $option['default'] = ""; } if ( ! isset( $option['title'] ) ) { $option['title'] = ""; } $option['id'] = $this->parent->args['opt_name'] . '[' . $option['id'] . ']'; if ( $option['type'] != "heading" && $option['type'] != "import_export" && ! empty( $option['type'] ) ) { $wp_customize->add_setting( $option['id'], array( 'default' => $option['default'], //'type' => 'option', //'capabilities' => $option['permissions'], //'capabilities' => 'edit_theme_options', //'capabilities' => $this->parent->args['page_permissions'], 'transport' => 'refresh', 'opt_name' => $this->parent->args['opt_name'], //'theme_supports' => '', //'sanitize_callback' => '__return_false', 'sanitize_callback' => array( $this, '_field_validation' ), //'sanitize_js_callback' =>array( &$parent, '_field_input' ), ) ); } if ( ! empty( $option['data'] ) && empty( $option['options'] ) ) { if ( empty( $option['args'] ) ) { $option['args'] = array(); } if ( $option['data'] == "elusive-icons" || $option['data'] == "elusive-icon" || $option['data'] == "elusive" ) { $icons_file = ReduxFramework::$_dir . 'inc/fields/select/elusive-icons.php'; $icons_file = apply_filters( 'redux-font-icons-file', $icons_file ); if ( file_exists( $icons_file ) ) { require_once $icons_file; } } $option['options'] = $this->parent->get_wordpress_data( $option['data'], $option['args'] ); } $class_name = 'Redux_Customizer_Control_' . $option['type']; do_action( 'redux/extension/customizer/control_init', $option ); if ( ! class_exists( $class_name ) ) { continue; } $wp_customize->add_control( new $class_name( $wp_customize, $option['id'], array( 'label' => $option['title'], 'section' => $section['id'], 'settings' => $option['id'], 'type' => 'redux-' . $option['type'], 'field' => $option, 'ReduxFramework' => $this->parent, 'priority' => $option['priority'], ) ) ); $section['fields'][ $skey ]['name'] = $option['id']; if ( ! isset ( $section['fields'][ $skey ]['class'] ) ) { // No errors please $section['fields'][ $skey ]['class'] = ""; } $this->controls[ $section['fields'][ $skey ]['id'] ] = $section['fields'][ $skey ]; add_action( 'redux/advanced_customizer/render/' . $option['id'], array( $this, 'field_render' ), $option['priority'] ); } } } public function add_section( $id, $args = array(), $wp_customize ) { if ( is_a( $id, 'WP_Customize_Section' ) ) { $section = $id; } else { $section_class = apply_filters( 'redux/customizer/section/class_name', "Redux_Customizer_Section" ); $section = new $section_class( $wp_customize, $id, $args ); } $wp_customize->add_section( $section, $args ); } /** * Add a customize panel. * * @since 4.0.0 * @access public * * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID. * @param array $args Optional. Panel arguments. Default empty array. */ public function add_panel( $id, $args = array(), $wp_customize ) { if ( is_a( $id, 'WP_Customize_Panel' ) ) { $panel = $id; } else { $panel_class = apply_filters( 'redux/customizer/panel/class_name', "Redux_Customizer_Panel" ); $panel = new $panel_class( $wp_customize, $id, $args ); } $wp_customize->add_panel( $panel, $args ); } public function field_render( $option ) { echo '1'; preg_match_all( "/\[([^\]]*)\]/", $option->id, $matches ); $id = $matches[1][0]; echo $option->link(); //$link = $option->link(); //echo $link; $this->parent->_field_input( $this->controls[ $id ] ); echo '2'; } public function customizer_save_before( $plugin_options ) { $this->before_save = $this->parent->options; //$parent->_field_input( $plugin_options ); } public function customizer_save_after( $wp_customize ) { if ( empty( $this->parent->options ) ) { $this->parent->get_options(); } if ( empty( $this->orig_options ) && ! empty( $this->parent->options ) ) { $this->orig_options = $this->parent->options; } $options = json_decode( stripslashes_deep( $_POST['customized'] ), true ); $compiler = false; $changed = false; foreach ( $options as $key => $value ) { if ( strpos( $key, $this->parent->args['opt_name'] ) !== false ) { $key = str_replace( $this->parent->args['opt_name'] . '[', '', rtrim( $key, "]" ) ); if ( ! isset( $this->orig_options[ $key ] ) || $this->orig_options[ $key ] != $value || ( isset( $this->orig_options[ $key ] ) && ! empty( $this->orig_options[ $key ] ) && empty( $value ) ) ) { $this->parent->options[ $key ] = $value; $changed = true; if ( isset( $this->parent->compiler_fields[ $key ] ) ) { $compiler = true; } } } } if ( $changed ) { $this->parent->set_options( $this->parent->options ); if ( $compiler ) { // Have to set this to stop the output of the CSS and typography stuff. $this->parent->no_output = true; $this->parent->_enqueue_output(); do_action( "redux/options/{$this->parent->args['opt_name']}/compiler", $this->parent->options, $this->parent->compilerCSS ); do_action( "redux/options/{$this->args['opt_name']}/compiler/advanced", $this->parent ); } } } /** * Enqueue CSS/JS for preview pane * * @since 1.0.0 * @access public * @global $wp_styles * @return void */ public function _enqueue_previewer() { wp_enqueue_script( 'redux-extension-previewer-js', $this->_extension_url . 'assets/js/preview.js' ); $localize = array( 'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'virtue' ), 'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'virtue' ), 'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'virtue' ), 'opt_name' => $this->args['opt_name'], //'folds' => $this->folds, 'options' => $this->parent->options, 'defaults' => $this->parent->options_defaults, ); wp_localize_script( 'redux-extension-previewer-js', 'reduxPost', $localize ); } /** * Enqueue CSS/JS for the customizer controls * * @since 1.0.0 * @access public * @global $wp_styles * @return void */ public function _enqueue() { global $wp_styles; //wp_enqueue_style( 'wp-pointer' ); //wp_enqueue_script( 'wp-pointer' ); // Remove when code is in place! //wp_enqueue_script('redux-extension-customizer-js', $this->_extension_url . 'assets/js/customizer.js'); // Get styles //wp_enqueue_style('redux-extension-customizer-css', $this->_extension_url . 'assets/css/customizer.css'); $localize = array( 'save_pending' => __( 'You have changes that are not saved. Would you like to save them now?', 'virtue' ), 'reset_confirm' => __( 'Are you sure? Resetting will lose all custom values.', 'virtue' ), 'preset_confirm' => __( 'Your current options will be replaced with the values of this preset. Would you like to proceed?', 'virtue' ), 'opt_name' => $this->args['opt_name'], //'folds' => $this->folds, 'field' => $this->parent->options, 'defaults' => $this->parent->options_defaults, ); // Values used by the javascript wp_localize_script( 'redux-js', 'redux_opts', $localize ); do_action( 'redux-enqueue-' . $this->args['opt_name'] ); foreach ( $this->sections as $section ) { if ( isset( $section['fields'] ) ) { foreach ( $section['fields'] as $field ) { if ( isset( $field['type'] ) ) { $field_class = 'ReduxFramework_' . $field['type']; if ( ! class_exists( $field_class ) ) { $class_file = apply_filters( 'redux-typeclass-load', $this->path . 'inc/fields/' . $field['type'] . '/field_' . $field['type'] . '.php', $field_class ); if ( $class_file ) { /** @noinspection PhpIncludeInspection */ require_once( $class_file ); } } if ( class_exists( $field_class ) && method_exists( $field_class, 'enqueue' ) ) { $enqueue = new $field_class( '', '', $this ); $enqueue->enqueue(); } } } } } } /** * Register Option for use * * @since 1.0.0 * @access public * @return void */ public function _register_setting() { } /** * Validate the options before insertion * * @since 3.0.0 * @access public * * @param array $plugin_options The options array * * @return */ public function _field_validation( $value ) { //print_r( $value ); //print_r( $_POST ); return $value; //return $this->parent->_validate_options( $plugin_options ); } /** * HTML OUTPUT. * * @since 1.0.0 * @access public * @return void */ public function _customizer_html_output() { } } // class function redux_customizer_custom_validation( $field ) { return $field; } } // if
johnndaf/Gasomax
wp-content/themes/virtue/themeoptions/inc/extensions/customizer/extension_customizer.php
PHP
gpl-2.0
38,115
[ 30522, 1026, 1029, 25718, 1013, 1013, 1026, 7953, 2828, 1027, 1000, 2557, 1000, 3643, 1027, 1000, 1015, 1000, 2171, 1027, 1000, 1035, 7661, 4697, 1011, 2557, 1011, 2417, 5602, 1035, 9703, 1031, 23569, 1011, 2557, 1033, 1000, 2951, 1011, 7...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
/* * Adjust display of page based on search results */ function findSearchResults(data, dataLength) { $("#duplicate_box").remove(); var userString = $("#searchForm #searchField").val(); var minSearchLength = 1; if (userString.length >= minSearchLength) { //this calls search() inside itself var numResults = populateResults(userString, dataLength, data); // If "results" is empty, activate the "add new client" button. if (numResults > 0) { // We've found some results, but we may still have to add a // new client (maybe a person with the same name as an // existing client). The "add new client" button will be // activated, but with a caveat. caveatText = "None Of The Above -- Add New Client"; $("#addNewClient").text(caveatText); } else { // No need for the caveat. $("#addNewClient").text(noCaveatText); } // If we're over the minimum length, we may add a new client. $("#searchForm #addNewClient").prop("disabled", false); } else if (userString.length == 0) { $("#searchForm #results").empty(); $("#addNewClient").text(noCaveatText); $("#searchForm #addNewClient").prop("disabled", true); } }; /* * Takes a user-entered string and returns the number of matching * entries. Along the way it fills in the result divs. */ function populateResults(userString, data_length, dataset) { var newHits = search(userString, data_length, dataset); // Create an array to hold indices of all the latest hits. If an // old hit isn't found in here, it gets removed. var newHitIndices = []; for (var i=0; i<newHits.length; i++) { newHitIndices.push(newHits[i].index); } var oldHits = $("#searchForm #results .hit"); oldHits.each(function() { // Remember these are not objects of class Hit; // they're DOM elements (of class "hit"). var oldHitIndex = $(this).data("entity-index"); for (var i=newHits.length-1; i>=0; i--) { if (oldHitIndex == newHits[i].index) { // There is already a <div> in the results field that // matches the one just returned; replace it with an // updated version (like a longer match string). $(this).empty(); $(this).replaceWith(getSummaryDiv(newHits[i])); newHits.splice(i, 1); // remove the match from "newHits" } } // Finally, if the entity of an old hit is no longer // represented in new hits, mark it for removal from the // results area. if ($.inArray(oldHitIndex, newHitIndices) < 0) { $(this).addClass("removeMe"); } }); // Now remove from the "results" div... $("#searchForm #results .hit.removeMe").remove(); // And add all newHits... for (var i=0; i<newHits.length; i++) { $("#searchForm #results").append(getSummaryDiv(newHits[i])); } // Return the number of matching entities. return $("#searchForm #results > .hit").length; }; function Entity() { // Start by setting all values to the empty string. for (var i=0; i<propertyListLength; i++) { this[propertyList[i]] = ""; } // Set some default values. this.personalId = -1; this.picture = "unknown.png"; // Use the names stored in the search form as default vals. // Usually they'll be overwritten, but not if this is a new client. this.firstName = $("#searchForm #firstName").val(); this.lastName = $("#searchForm #lastName").val(); }; function Hit(entity) { this.index = entity.personalId; this.removeMe = false; // Used when comparing to already-matched records. this.picture = entity.picture; this.firstName = entity.firstName; this.lastName = entity.lastName; this.gender = entity.gender; this.dob = entity.dob ? getFormattedDOB(entity.dob) : ""; this.age = entity.dob ? getYearsOld(entity.dob) : ""; }; function getFormattedDOB(date) { return moment(date).format('DD MMM YYYY'); }; function getYearsOld(date) { return moment().diff(date, 'years'); }; /* Hit factory holds a dictionary of hits (with entity indices as keys) that match user input. */ function HitFactory() { this.hits = {}; }; HitFactory.prototype.getHit = function(entity) { var hit = null; if (this.hits.hasOwnProperty(entity.personalId)) { hit = this.hits[entity.personalId]; } else { hit = new Hit(entity); this.hits[entity.personalId] = hit; } return hit; }; HitFactory.prototype.killHit = function(entity) { if (this.hits.hasOwnProperty(entity.index)) { delete this.hits[entity.index]; } }; HitFactory.prototype.allTheHits = function() { var hitList = []; for (index in this.hits) { hitList.push(this.hits[index]); } return hitList; }; /* * Takes a user-entered string and returns the set of matching * clients, as "hit" objects. */ function search(userString, data_length, dataset) { // First Trim any non-alphanumerics from the ends of the user's input. userString = userString.replace(/^[^\w]+/i, "").replace(/[^\w]+$/i, ""); // Then split the user's string on non-alphanumeric sequences. This // eliminates a dot after a middle initial, a comma if name is // entered as "Doe, John" (or as "Doe , John"), etc. userSubstrings = userString.split(/\s+[^\w]+\s*|\s*[^\w]+\s+|\s+/); // Store the first and second user substrings into some hidden form // fields. They might be used later if a new client is created. $("#searchForm #firstName").val(userSubstrings[0]); $("#searchForm #lastName").val(userSubstrings.length > 1 ? userSubstrings[1] : ""); // The hit factory will generate new a Hit object or return an // already instantiated one with the requested index. var hitFactory = new HitFactory(); var entity = null; var result = null; var matchLength = 0; var hit = null; // Turn the user's input into a list of regexes that will try to match against our matching terms. var userRegexes = $.map(userSubstrings, function(userSubstring) { return new RegExp("^" + userSubstring, "i"); }); // This is the list of "matching terms" we will try to match to user input. var matchingTerms = ["firstName", "lastName"]; for (var i=0; i<data_length; i++) { entity = dataset[i]; // Make a copies of "userRegexes" and "matchingTerms" that we can // alter as we search. var userRegexesCopy = userRegexes.slice(0); var matchingTermsCopy = matchingTerms.slice(0); while (userRegexesCopy.length > 0) { var userRegex = userRegexesCopy.shift(); var matchFound = false; for (var j=0; j < matchingTermsCopy.length; ) { if (entity[matchingTermsCopy[j]] !== null){ result = entity[matchingTermsCopy[j]].match(userRegex); } else { result = null; } if (result !== null) { // We found a match. Figure out how long it is. matchLength = result[0].length; // If the match is perfect OR if there are no more // user-entered search terms after this one, we may mark it // as a hit. if (matchLength == entity[matchingTermsCopy[j]].length || userRegexesCopy.length == 0) { hit = hitFactory.getHit(entity); hit[matchingTermsCopy[j]] = "<span class='marked'>" + entity[matchingTermsCopy[j]].substr(0, matchLength) + "</span>" + entity[matchingTermsCopy[j]].substr(matchLength); matchFound = true; // Remove this matching term from consideration when // processing other user search terms by splicing it out // of our copy of matching terms. matchingTermsCopy.splice(j, 1); // Since "matchingTermsCopy" is now shorter by 1, continue // the loop without incrementing the counter. continue; } } j++; } if (matchFound == false) { // If any part of the user-entered search terms failed to find // a match, previous matches don't matter. The entity should // not appear in the list of hits. hitFactory.killHit(entity); break; } } } return hitFactory.allTheHits(); }; function getSummaryDiv(hit) { var summaryDiv = $("<div class='hit'></div>"); if (hit.picture){ var picture = $("<div class='picture'><img src=\"img/" + hit.picture + "\"></div>"); } var text = $("<div class='text'></div>"); var fullName = $("<div class='summaryElement'><span>" + hit.firstName + " " + hit.lastName + "</span></div>"); var clear = $("<div class='clear'></div>"); var dob = $("<div class='summaryElement'><span class='label'>DOB: </span><span>" + hit.dob + "</span></div>"); var age = $("<div class='summaryElement'><span class='label'>age: </span><span>" + getYearsOld(hit.dob) + "</span></div>"); summaryDiv.append(picture); text.append(fullName); text.append(clear); text.append(dob); text.append(age); summaryDiv.append(text); summaryDiv.data("entity-index", hit.index); return summaryDiv; };
OpenTechStrategies/openhmis-intake
public/js/search.js
JavaScript
mit
10,538
[ 30522, 1013, 1008, 1008, 14171, 4653, 1997, 3931, 2241, 2006, 3945, 3463, 1008, 1013, 3853, 4858, 14644, 2818, 6072, 11314, 2015, 1006, 2951, 1010, 2951, 7770, 13512, 2232, 1007, 1063, 1002, 1006, 1000, 1001, 24473, 1035, 3482, 1000, 1007, ...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...
jsonp({"cep":"06320170","logradouro":"Rua Pedro Lobas","bairro":"Jardim das Belezas","cidade":"Carapicu\u00edba","uf":"SP","estado":"S\u00e3o Paulo"});
lfreneda/cepdb
api/v1/06320170.jsonp.js
JavaScript
cc0-1.0
152
[ 30522, 1046, 3385, 2361, 1006, 1063, 1000, 8292, 2361, 1000, 1024, 1000, 5757, 16703, 24096, 19841, 1000, 1010, 1000, 8833, 12173, 8162, 2080, 1000, 1024, 1000, 21766, 2050, 7707, 8840, 22083, 1000, 1010, 1000, 21790, 18933, 1000, 1024, 100...
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
[ -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100...