text
stringlengths
2
100k
meta
dict
/* Copyright (c) 2012 The VCT Project This file is part of VoxelConeTracing and is an implementation of "Interactive Indirect Illumination Using Voxel Cone Tracing" by Crassin et al VoxelConeTracing 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. VoxelConeTracing 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 VoxelConeTracing. If not, see <http://www.gnu.org/licenses/>. */ /*! * \author Dominik Lazarek ([email protected]) * \author Andreas Weinmann ([email protected]) */ #include "VoxelConeTracing/Scene/VoxelFragList.h" #include "VoxelConeTracing/Util/MathUtil.h" struct SDrawArraysIndirectCommand { SDrawArraysIndirectCommand() : numVertices(0), numPrimitives(0), firstVertexIdx(0), baseInstanceIdx(0) {} uint numVertices; uint numPrimitives; uint firstVertexIdx; uint baseInstanceIdx; }; VoxelFragList::VoxelFragList() { } VoxelFragList::~VoxelFragList() { } void VoxelFragList::init(uint voxelGridResolution, uint fragListSizeMultiplier, uint fragListSizeDivisor){ // Positions uint fraglistSizeByte = (sizeof(uint) * voxelGridResolution * voxelGridResolution * voxelGridResolution * fragListSizeMultiplier) / fragListSizeDivisor; GLint maxTexBufferSize = 0; glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTexBufferSize); maxTexBufferSize = maxTexBufferSize * sizeof(uint); if (fraglistSizeByte > maxTexBufferSize) { kore::Log::getInstance()->write("[ERROR] VoxelFragList-size of %u is not" "supported on this hardware!", fraglistSizeByte); } fraglistSizeByte = glm::min((uint)maxTexBufferSize,fraglistSizeByte); kore::Log::getInstance() ->write("Allocating voxel fragment list of size %f MB\n", MathUtil::byteToMB(fraglistSizeByte)); kore::STextureBufferProperties props; props.internalFormat = GL_R32UI; props.size = fraglistSizeByte; props.usageHint = GL_STATIC_DRAW; _voxelFragList.create(props, "VoxelFragmentList_Position"); _vflTexInfo.internalFormat = props.internalFormat; _vflTexInfo.texTarget = GL_TEXTURE_BUFFER; _vflTexInfo.texLocation = _voxelFragList.getTexHandle(); _shdVoxelFragList.component = NULL; _shdVoxelFragList.data = &_vflTexInfo; _shdVoxelFragList.name = "VoxelFragmentList_Position"; _shdVoxelFragList.type = GL_TEXTURE_BUFFER; initIndirectCommandBufs(); } void VoxelFragList::initIndirectCommandBufs() { // Voxel fragment list indirect command buf SDrawArraysIndirectCommand cmd; cmd.numVertices = 1; cmd.numPrimitives = 1; cmd.firstVertexIdx = 0; cmd.baseInstanceIdx = 0; kore::STextureBufferProperties props; props.internalFormat = GL_R32UI; props.size = sizeof(SDrawArraysIndirectCommand); props.usageHint = GL_STATIC_DRAW; _fragListIndirectCmdBuf.create(props, "IndirectCommandBuf",&cmd); _fragListIcbTexInfos.internalFormat = GL_R32UI; _fragListIcbTexInfos.texLocation = _fragListIndirectCmdBuf.getTexHandle(); _fragListIcbTexInfos.texTarget = GL_TEXTURE_BUFFER; _shdFragListIndirectCmdBuf.name = "IndirectCommandBuf"; _shdFragListIndirectCmdBuf.type = GL_TEXTURE_BUFFER; _shdFragListIndirectCmdBuf.data = &_fragListIcbTexInfos; ////////////////////////////////////////////////////////////////////////// } void VoxelFragList::destroy() { _voxelFragList.destroy(); }
{ "pile_set_name": "Github" }
Accept-Ranges: bytes Connection: keep-alive Content-Length: 612 Content-Type: text/html Date: Fri, 06 Oct 2017 09:38:58 GMT Etag: "59535732-264" Last-Modified: Wed, 28 Jun 2017 07:13:54 GMT Server: nginx
{ "pile_set_name": "Github" }
import tensorflow as tf from unrestricted_advex.mnist_baselines import mnist_utils flags = tf.app.flags FLAGS = flags.FLAGS flags.DEFINE_string("train_mode", "vanilla", "Model type (either 'vanilla' or 'adversarial')") flags.DEFINE_string("model_dir", "/tmp/two-class-mnist/vanilla", "Where to put the trained model checkpoint") flags.DEFINE_integer("batch_size", 128, "Batch size for training the model") flags.DEFINE_integer("total_batches", 1000000, "Total number of batches to train for") def main(_): assert FLAGS.train_mode in ['vanilla', 'adversarial'] mnist = mnist_utils.mnist_dataset(one_hot=True) next_batch_fn = lambda: mnist.train.next_batch(FLAGS.batch_size) mnist_utils.train_mnist(FLAGS.model_dir, next_batch_fn, FLAGS.total_batches, FLAGS.train_mode) if __name__ == "__main__": tf.app.run()
{ "pile_set_name": "Github" }
#----------------------------------------------------------------------------- # Copyright (c) 2005-2020, PyInstaller Development Team. # # Distributed under the terms of the GNU General Public License (version 2 # or later) with exception for distributing the bootloader. # # The full license is in the file COPYING.txt, distributed with this software. # # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception) #----------------------------------------------------------------------------- # Tested with django-babel v0.6.2. # Hook for https://github.com/python-babel/django-babel from PyInstaller.utils.hooks import copy_metadata datas = copy_metadata('django-babel')
{ "pile_set_name": "Github" }
# # This file and its contents are supplied under the terms of the # Common Development and Distribution License ("CDDL)". You may # only use this file in accordance with the terms of the CDDL. # # A full copy of the text of the CDDL should have accompanied this # source. A copy of the CDDL is also available via the Internet at # http://www.illumos.org/license/CDDL. # # # Copyright 2010 Nexenta Systems, Inc. All rights reserved. # set name=pkg.fmri value=pkg:/locale/ms@$(PKGVERS) set name=pkg.description value="Malaysian language support" set name=pkg.summary value="Malaysian language support" set name=info.classification \ value=org.opensolaris.category.2008:System/Localizations set name=variant.arch value=$(ARCH) dir path=usr group=sys dir path=usr/lib dir path=usr/lib/locale dir path=usr/lib/locale/ms_MY.UTF-8 dir path=usr/lib/locale/ms_MY.UTF-8/LC_COLLATE dir path=usr/lib/locale/ms_MY.UTF-8/LC_CTYPE dir path=usr/lib/locale/ms_MY.UTF-8/LC_MESSAGES dir path=usr/lib/locale/ms_MY.UTF-8/LC_MONETARY dir path=usr/lib/locale/ms_MY.UTF-8/LC_NUMERIC dir path=usr/lib/locale/ms_MY.UTF-8/LC_TIME file path=usr/lib/locale/ms_MY.UTF-8/LC_COLLATE/LCL_DATA mode=0444 file path=usr/lib/locale/ms_MY.UTF-8/LC_CTYPE/LCL_DATA mode=0444 file path=usr/lib/locale/ms_MY.UTF-8/LC_MESSAGES/LCL_DATA mode=0444 file path=usr/lib/locale/ms_MY.UTF-8/LC_MONETARY/LCL_DATA mode=0444 file path=usr/lib/locale/ms_MY.UTF-8/LC_NUMERIC/LCL_DATA mode=0444 file path=usr/lib/locale/ms_MY.UTF-8/LC_TIME/LCL_DATA mode=0444 license lic_CDDL license=lic_CDDL license usr/src/data/locale/data/THIRDPARTYLICENSE \ license=usr/src/data/locale/data/THIRDPARTYLICENSE
{ "pile_set_name": "Github" }
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved. // https://developers.google.com/protocol-buffers/ // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Author: [email protected] (Brian Olson) // // This file contains the definition for classes GzipInputStream and // GzipOutputStream. // // GzipInputStream decompresses data from an underlying // ZeroCopyInputStream and provides the decompressed data as a // ZeroCopyInputStream. // // GzipOutputStream is an ZeroCopyOutputStream that compresses data to // an underlying ZeroCopyOutputStream. #ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__ #define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__ #include <google/protobuf/stubs/common.h> #include <google/protobuf/io/zero_copy_stream.h> #include <zlib.h> namespace google { namespace protobuf { namespace io { // A ZeroCopyInputStream that reads compressed data through zlib class LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream { public: // Format key for constructor enum Format { // zlib will autodetect gzip header or deflate stream AUTO = 0, // GZIP streams have some extra header data for file attributes. GZIP = 1, // Simpler zlib stream format. ZLIB = 2, }; // buffer_size and format may be -1 for default of 64kB and GZIP format explicit GzipInputStream( ZeroCopyInputStream* sub_stream, Format format = AUTO, int buffer_size = -1); virtual ~GzipInputStream(); // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; } inline int ZlibErrorCode() const { return zerror_; } // implements ZeroCopyInputStream ---------------------------------- bool Next(const void** data, int* size); void BackUp(int count); bool Skip(int count); int64 ByteCount() const; private: Format format_; ZeroCopyInputStream* sub_stream_; z_stream zcontext_; int zerror_; void* output_buffer_; void* output_position_; size_t output_buffer_length_; int64 byte_count_; int Inflate(int flush); void DoNextOutput(const void** data, int* size); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream); }; class LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream { public: // Format key for constructor enum Format { // GZIP streams have some extra header data for file attributes. GZIP = 1, // Simpler zlib stream format. ZLIB = 2, }; struct Options { // Defaults to GZIP. Format format; // What size buffer to use internally. Defaults to 64kB. int buffer_size; // A number between 0 and 9, where 0 is no compression and 9 is best // compression. Defaults to Z_DEFAULT_COMPRESSION (see zlib.h). int compression_level; // Defaults to Z_DEFAULT_STRATEGY. Can also be set to Z_FILTERED, // Z_HUFFMAN_ONLY, or Z_RLE. See the documentation for deflateInit2 in // zlib.h for definitions of these constants. int compression_strategy; Options(); // Initializes with default values. }; // Create a GzipOutputStream with default options. explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream); // Create a GzipOutputStream with the given options. GzipOutputStream( ZeroCopyOutputStream* sub_stream, const Options& options); virtual ~GzipOutputStream(); // Return last error message or NULL if no error. inline const char* ZlibErrorMessage() const { return zcontext_.msg; } inline int ZlibErrorCode() const { return zerror_; } // Flushes data written so far to zipped data in the underlying stream. // It is the caller's responsibility to flush the underlying stream if // necessary. // Compression may be less efficient stopping and starting around flushes. // Returns true if no error. // // Please ensure that block size is > 6. Here is an excerpt from the zlib // doc that explains why: // // In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out // is greater than six to avoid repeated flush markers due to // avail_out == 0 on return. bool Flush(); // Writes out all data and closes the gzip stream. // It is the caller's responsibility to close the underlying stream if // necessary. // Returns true if no error. bool Close(); // implements ZeroCopyOutputStream --------------------------------- bool Next(void** data, int* size); void BackUp(int count); int64 ByteCount() const; private: ZeroCopyOutputStream* sub_stream_; // Result from calling Next() on sub_stream_ void* sub_data_; int sub_data_size_; z_stream zcontext_; int zerror_; void* input_buffer_; size_t input_buffer_length_; // Shared constructor code. void Init(ZeroCopyOutputStream* sub_stream, const Options& options); // Do some compression. // Takes zlib flush mode. // Returns zlib error code. int Deflate(int flush); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream); }; } // namespace io } // namespace protobuf } // namespace google #endif // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__
{ "pile_set_name": "Github" }
/* * shaders.c * Copyright (C) 2017 Kovid Goyal <kovid at kovidgoyal.net> * * Distributed under terms of the GPL3 license. */ #include "fonts.h" #include "gl.h" #include <stddef.h> enum { CELL_PROGRAM, CELL_BG_PROGRAM, CELL_SPECIAL_PROGRAM, CELL_FG_PROGRAM, BORDERS_PROGRAM, GRAPHICS_PROGRAM, GRAPHICS_PREMULT_PROGRAM, GRAPHICS_ALPHA_MASK_PROGRAM, BLIT_PROGRAM, BGIMAGE_PROGRAM, TINT_PROGRAM, NUM_PROGRAMS }; enum { SPRITE_MAP_UNIT, GRAPHICS_UNIT, BLIT_UNIT, BGIMAGE_UNIT }; // Sprites {{{ typedef struct { unsigned int cell_width, cell_height; int xnum, ynum, x, y, z, last_num_of_layers, last_ynum; GLuint texture_id; GLint max_texture_size, max_array_texture_layers; } SpriteMap; static const SpriteMap NEW_SPRITE_MAP = { .xnum = 1, .ynum = 1, .last_num_of_layers = 1, .last_ynum = -1 }; static GLint max_texture_size = 0, max_array_texture_layers = 0; SPRITE_MAP_HANDLE alloc_sprite_map(unsigned int cell_width, unsigned int cell_height) { if (!max_texture_size) { glGetIntegerv(GL_MAX_TEXTURE_SIZE, &(max_texture_size)); glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &(max_array_texture_layers)); #ifdef __APPLE__ // Since on Apple we could have multiple GPUs, with different capabilities, // upper bound the values according to the data from https://developer.apple.com/graphicsimaging/opengl/capabilities/ max_texture_size = MIN(8192, max_texture_size); max_array_texture_layers = MIN(512, max_array_texture_layers); #endif sprite_tracker_set_limits(max_texture_size, max_array_texture_layers); } SpriteMap *ans = calloc(1, sizeof(SpriteMap)); if (!ans) fatal("Out of memory allocating a sprite map"); *ans = NEW_SPRITE_MAP; ans->max_texture_size = max_texture_size; ans->max_array_texture_layers = max_array_texture_layers; ans->cell_width = cell_width; ans->cell_height = cell_height; return (SPRITE_MAP_HANDLE)ans; } SPRITE_MAP_HANDLE free_sprite_map(SPRITE_MAP_HANDLE sm) { SpriteMap *sprite_map = (SpriteMap*)sm; if (sprite_map) { if (sprite_map->texture_id) free_texture(&sprite_map->texture_id); free(sprite_map); } return NULL; } static bool copy_image_warned = false; static void copy_image_sub_data(GLuint src_texture_id, GLuint dest_texture_id, unsigned int width, unsigned int height, unsigned int num_levels) { if (!GLAD_GL_ARB_copy_image) { // ARB_copy_image not available, do a slow roundtrip copy if (!copy_image_warned) { copy_image_warned = true; log_error("WARNING: Your system's OpenGL implementation does not have glCopyImageSubData, falling back to a slower implementation"); } size_t sz = (size_t)width * height * num_levels; pixel *src = malloc(sz * sizeof(pixel)); if (src == NULL) { fatal("Out of memory."); } glBindTexture(GL_TEXTURE_2D_ARRAY, src_texture_id); glGetTexImage(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, GL_UNSIGNED_BYTE, src); glBindTexture(GL_TEXTURE_2D_ARRAY, dest_texture_id); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, num_levels, GL_RGBA, GL_UNSIGNED_BYTE, src); free(src); } else { glCopyImageSubData(src_texture_id, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, dest_texture_id, GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, width, height, num_levels); } } static void realloc_sprite_texture(FONTS_DATA_HANDLE fg) { GLuint tex; glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D_ARRAY, tex); // We use GL_NEAREST otherwise glyphs that touch the edge of the cell // often show a border between cells glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); unsigned int xnum, ynum, z, znum, width, height, src_ynum; sprite_tracker_current_layout(fg, &xnum, &ynum, &z); znum = z + 1; SpriteMap *sprite_map = (SpriteMap*)fg->sprite_map; width = xnum * sprite_map->cell_width; height = ynum * sprite_map->cell_height; glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, width, height, znum); if (sprite_map->texture_id) { // need to re-alloc src_ynum = MAX(1, sprite_map->last_ynum); copy_image_sub_data(sprite_map->texture_id, tex, width, src_ynum * sprite_map->cell_height, sprite_map->last_num_of_layers); glDeleteTextures(1, &sprite_map->texture_id); } glBindTexture(GL_TEXTURE_2D_ARRAY, 0); sprite_map->last_num_of_layers = znum; sprite_map->last_ynum = ynum; sprite_map->texture_id = tex; } static inline void ensure_sprite_map(FONTS_DATA_HANDLE fg) { SpriteMap *sprite_map = (SpriteMap*)fg->sprite_map; if (!sprite_map->texture_id) realloc_sprite_texture(fg); // We have to rebind since we don't know if the texture was ever bound // in the context of the current OSWindow glActiveTexture(GL_TEXTURE0 + SPRITE_MAP_UNIT); glBindTexture(GL_TEXTURE_2D_ARRAY, sprite_map->texture_id); } void send_sprite_to_gpu(FONTS_DATA_HANDLE fg, unsigned int x, unsigned int y, unsigned int z, pixel *buf) { SpriteMap *sprite_map = (SpriteMap*)fg->sprite_map; unsigned int xnum, ynum, znum; sprite_tracker_current_layout(fg, &xnum, &ynum, &znum); if ((int)znum >= sprite_map->last_num_of_layers || (znum == 0 && (int)ynum > sprite_map->last_ynum)) realloc_sprite_texture(fg); glBindTexture(GL_TEXTURE_2D_ARRAY, sprite_map->texture_id); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); x *= sprite_map->cell_width; y *= sprite_map->cell_height; glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, x, y, z, sprite_map->cell_width, sprite_map->cell_height, 1, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buf); } void send_image_to_gpu(GLuint *tex_id, const void* data, GLsizei width, GLsizei height, bool is_opaque, bool is_4byte_aligned, bool linear, RepeatStrategy repeat) { if (!(*tex_id)) { glGenTextures(1, tex_id); } glBindTexture(GL_TEXTURE_2D, *tex_id); glPixelStorei(GL_UNPACK_ALIGNMENT, is_4byte_aligned ? 4 : 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, linear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, linear ? GL_LINEAR : GL_NEAREST); RepeatStrategy r; switch (repeat) { case REPEAT_MIRROR: r = GL_MIRRORED_REPEAT; break; case REPEAT_CLAMP: r = GL_CLAMP_TO_EDGE; break; default: r = GL_REPEAT; } glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, r); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, r); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, is_opaque ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, data); } // }}} // Cell {{{ typedef struct { UniformBlock render_data; ArrayInformation color_table; GLint draw_bg_bitfield_location; } CellProgramLayout; static CellProgramLayout cell_program_layouts[NUM_PROGRAMS]; static ssize_t blit_vertex_array; typedef struct { GLint image_location, tiled_location, sizes_location, opacity_location, premult_location; } BGImageProgramLayout; static BGImageProgramLayout bgimage_program_layout = {0}; typedef struct { GLint tint_color_location, edges_location; } TintProgramLayout; static TintProgramLayout tint_program_layout = {0}; static void init_cell_program(void) { for (int i = CELL_PROGRAM; i < BORDERS_PROGRAM; i++) { cell_program_layouts[i].render_data.index = block_index(i, "CellRenderData"); cell_program_layouts[i].render_data.size = block_size(i, cell_program_layouts[i].render_data.index); cell_program_layouts[i].color_table.size = get_uniform_information(i, "color_table[0]", GL_UNIFORM_SIZE); cell_program_layouts[i].color_table.offset = get_uniform_information(i, "color_table[0]", GL_UNIFORM_OFFSET); cell_program_layouts[i].color_table.stride = get_uniform_information(i, "color_table[0]", GL_UNIFORM_ARRAY_STRIDE); } cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location = get_uniform_location(CELL_BG_PROGRAM, "draw_bg_bitfield"); // Sanity check to ensure the attribute location binding worked #define C(p, name, expected) { int aloc = attrib_location(p, #name); if (aloc != expected && aloc != -1) fatal("The attribute location for %s is %d != %d in program: %d", #name, aloc, expected, p); } for (int p = CELL_PROGRAM; p < BORDERS_PROGRAM; p++) { C(p, colors, 0); C(p, sprite_coords, 1); C(p, is_selected, 2); } #undef C blit_vertex_array = create_vao(); bgimage_program_layout.image_location = get_uniform_location(BGIMAGE_PROGRAM, "image"); bgimage_program_layout.opacity_location = get_uniform_location(BGIMAGE_PROGRAM, "opacity"); bgimage_program_layout.sizes_location = get_uniform_location(BGIMAGE_PROGRAM, "sizes"); bgimage_program_layout.tiled_location = get_uniform_location(BGIMAGE_PROGRAM, "tiled"); bgimage_program_layout.premult_location = get_uniform_location(BGIMAGE_PROGRAM, "premult"); tint_program_layout.tint_color_location = get_uniform_location(TINT_PROGRAM, "tint_color"); tint_program_layout.edges_location = get_uniform_location(TINT_PROGRAM, "edges"); } #define CELL_BUFFERS enum { cell_data_buffer, selection_buffer, uniform_buffer }; ssize_t create_cell_vao() { ssize_t vao_idx = create_vao(); #define A(name, size, dtype, offset, stride) \ add_attribute_to_vao(CELL_PROGRAM, vao_idx, #name, \ /*size=*/size, /*dtype=*/dtype, /*stride=*/stride, /*offset=*/offset, /*divisor=*/1); #define A1(name, size, dtype, offset) A(name, size, dtype, (void*)(offsetof(GPUCell, offset)), sizeof(GPUCell)) add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER); A1(sprite_coords, 4, GL_UNSIGNED_SHORT, sprite_x); A1(colors, 3, GL_UNSIGNED_INT, fg); add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER); A(is_selected, 1, GL_UNSIGNED_BYTE, NULL, 0); size_t bufnum = add_buffer_to_vao(vao_idx, GL_UNIFORM_BUFFER); alloc_vao_buffer(vao_idx, cell_program_layouts[CELL_PROGRAM].render_data.size, bufnum, GL_STREAM_DRAW); return vao_idx; #undef A #undef A1 } ssize_t create_graphics_vao() { ssize_t vao_idx = create_vao(); add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER); add_attribute_to_vao(GRAPHICS_PROGRAM, vao_idx, "src", 4, GL_FLOAT, 0, NULL, 0); return vao_idx; } struct CellUniformData { bool constants_set; bool alpha_mask_fg_set; GLint gploc, gpploc, cploc, cfploc, fg_loc, amask_premult_loc; GLfloat prev_inactive_text_alpha; }; static struct CellUniformData cell_uniform_data = {0, .prev_inactive_text_alpha=-1}; static inline void send_graphics_data_to_gpu(size_t image_count, ssize_t gvao_idx, const ImageRenderData *render_data) { size_t sz = sizeof(GLfloat) * 16 * image_count; GLfloat *a = alloc_and_map_vao_buffer(gvao_idx, sz, 0, GL_STREAM_DRAW, GL_WRITE_ONLY); for (size_t i = 0; i < image_count; i++, a += 16) memcpy(a, render_data[i].vertices, sizeof(render_data[0].vertices)); unmap_vao_buffer(gvao_idx, 0); a = NULL; } static inline void cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, CursorRenderInfo *cursor, bool inverted, OSWindow *os_window) { struct CellRenderData { GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg; GLuint default_fg, default_bg, highlight_fg, highlight_bg, cursor_color, cursor_text_color, url_color, url_style, inverted; GLuint xnum, ynum, cursor_fg_sprite_idx; GLfloat cursor_x, cursor_y, cursor_w; }; static struct CellRenderData *rd; // Send the uniform data rd = (struct CellRenderData*)map_vao_buffer(vao_idx, uniform_buffer, GL_WRITE_ONLY); if (UNLIKELY(screen->color_profile->dirty || screen->reload_all_gpu_data)) { copy_color_table_to_buffer(screen->color_profile, (GLuint*)rd, cell_program_layouts[CELL_PROGRAM].color_table.offset / sizeof(GLuint), cell_program_layouts[CELL_PROGRAM].color_table.stride / sizeof(GLuint)); } // Cursor position enum { BLOCK_IDX = 0, BEAM_IDX = 6, UNDERLINE_IDX = 7, UNFOCUSED_IDX = 8 }; if (cursor->is_visible) { rd->cursor_x = screen->cursor->x, rd->cursor_y = screen->cursor->y; if (cursor->is_focused) { switch(cursor->shape) { default: rd->cursor_fg_sprite_idx = BLOCK_IDX; break; case CURSOR_BEAM: rd->cursor_fg_sprite_idx = BEAM_IDX; break; case CURSOR_UNDERLINE: rd->cursor_fg_sprite_idx = UNDERLINE_IDX; break; } } else rd->cursor_fg_sprite_idx = UNFOCUSED_IDX; } else rd->cursor_x = screen->columns, rd->cursor_y = screen->lines; rd->cursor_w = rd->cursor_x; if ( (rd->cursor_fg_sprite_idx == BLOCK_IDX || rd->cursor_fg_sprite_idx == UNDERLINE_IDX) && screen_current_char_width(screen) > 1 ) rd->cursor_w += 1; rd->xnum = screen->columns; rd->ynum = screen->lines; rd->xstart = xstart; rd->ystart = ystart; rd->dx = dx; rd->dy = dy; unsigned int x, y, z; sprite_tracker_current_layout(os_window->fonts_data, &x, &y, &z); rd->sprite_dx = 1.0f / (float)x; rd->sprite_dy = 1.0f / (float)y; rd->inverted = inverted ? 1 : 0; rd->background_opacity = os_window->is_semi_transparent ? os_window->background_opacity : 1.0f; #define COLOR(name) colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.name, screen->color_profile->configured.name) rd->default_fg = COLOR(default_fg); rd->default_bg = COLOR(default_bg); rd->highlight_fg = COLOR(highlight_fg); rd->highlight_bg = COLOR(highlight_bg); rd->cursor_text_color = COLOR(cursor_text_color); #undef COLOR rd->cursor_color = cursor->color; rd->url_color = OPT(url_color); rd->url_style = OPT(url_style); rd->cursor_text_uses_bg = cursor_text_as_bg(screen->color_profile); unmap_vao_buffer(vao_idx, uniform_buffer); rd = NULL; } static inline bool cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, FONTS_DATA_HANDLE fonts_data) { size_t sz; CELL_BUFFERS; void *address; bool changed = false; ensure_sprite_map(fonts_data); bool cursor_pos_changed = screen->cursor->x != screen->last_rendered.cursor_x || screen->cursor->y != screen->last_rendered.cursor_y; bool disable_ligatures = screen->disable_ligatures == DISABLE_LIGATURES_CURSOR; bool screen_resized = screen->last_rendered.columns != screen->columns || screen->last_rendered.lines != screen->lines; if (screen->reload_all_gpu_data || screen->scroll_changed || screen->is_dirty || screen_resized || (disable_ligatures && cursor_pos_changed)) { sz = sizeof(GPUCell) * screen->lines * screen->columns; address = alloc_and_map_vao_buffer(vao_idx, sz, cell_data_buffer, GL_STREAM_DRAW, GL_WRITE_ONLY); screen_update_cell_data(screen, address, fonts_data, disable_ligatures && cursor_pos_changed); unmap_vao_buffer(vao_idx, cell_data_buffer); address = NULL; changed = true; } if (cursor_pos_changed) { screen->last_rendered.cursor_x = screen->cursor->x; screen->last_rendered.cursor_y = screen->cursor->y; } if (screen->reload_all_gpu_data || screen_resized || screen_is_selection_dirty(screen)) { sz = (size_t)screen->lines * screen->columns; address = alloc_and_map_vao_buffer(vao_idx, sz, selection_buffer, GL_STREAM_DRAW, GL_WRITE_ONLY); screen_apply_selection(screen, address, sz); unmap_vao_buffer(vao_idx, selection_buffer); address = NULL; changed = true; } if (gvao_idx && grman_update_layers(screen->grman, screen->scrolled_by, xstart, ystart, dx, dy, screen->columns, screen->lines, screen->cell_size)) { send_graphics_data_to_gpu(screen->grman->count, gvao_idx, screen->grman->render_data); changed = true; } screen->last_rendered.scrolled_by = screen->scrolled_by; screen->last_rendered.columns = screen->columns; screen->last_rendered.lines = screen->lines; return changed; } static void draw_bg(OSWindow *w) { blank_canvas(w->is_semi_transparent ? OPT(background_opacity) : 1.0f, OPT(background)); bind_program(BGIMAGE_PROGRAM); bind_vertex_array(blit_vertex_array); static bool bgimage_constants_set = false; if (!bgimage_constants_set) { glUniform1i(bgimage_program_layout.image_location, BGIMAGE_UNIT); glUniform1f(bgimage_program_layout.opacity_location, OPT(background_opacity)); GLfloat tiled = (OPT(background_image_layout) == TILING || OPT(background_image_layout) == MIRRORED) ? 1 : 0; glUniform1f(bgimage_program_layout.tiled_location, tiled); bgimage_constants_set = true; } glUniform4f(bgimage_program_layout.sizes_location, (GLfloat)w->window_width, (GLfloat)w->window_height, (GLfloat)w->bgimage->width, (GLfloat)w->bgimage->height); glUniform1f(bgimage_program_layout.premult_location, w->is_semi_transparent ? 1.f : 0.f); glActiveTexture(GL_TEXTURE0 + BGIMAGE_UNIT); glBindTexture(GL_TEXTURE_2D, w->bgimage->texture_id); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); unbind_vertex_array(); unbind_program(); } static void draw_graphics(int program, ssize_t vao_idx, ssize_t gvao_idx, ImageRenderData *data, GLuint start, GLuint count) { bind_program(program); bind_vertex_array(gvao_idx); glActiveTexture(GL_TEXTURE0 + GRAPHICS_UNIT); GLuint base = 4 * start; glEnable(GL_SCISSOR_TEST); for (GLuint i=0; i < count;) { ImageRenderData *rd = data + start + i; glBindTexture(GL_TEXTURE_2D, rd->texture_id); // You could reduce the number of draw calls by using // glDrawArraysInstancedBaseInstance but Apple chose to abandon OpenGL // before implementing it. for (GLuint k=0; k < rd->group_count; k++, base += 4, i++) glDrawArrays(GL_TRIANGLE_FAN, base, 4); } glDisable(GL_SCISSOR_TEST); bind_vertex_array(vao_idx); } #define BLEND_ONTO_OPAQUE glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // blending onto opaque colors #define BLEND_PREMULT glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // blending of pre-multiplied colors void draw_centered_alpha_mask(OSWindow *os_window, size_t screen_width, size_t screen_height, size_t width, size_t height, uint8_t *canvas) { static ImageRenderData data = {.group_count=1}; gpu_data_for_centered_image(&data, screen_width, screen_height, width, height); if (!data.texture_id) { glGenTextures(1, &data.texture_id); } glBindTexture(GL_TEXTURE_2D, data.texture_id); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, width, height, 0, GL_RED, GL_UNSIGNED_BYTE, canvas); bind_program(GRAPHICS_ALPHA_MASK_PROGRAM); if (!cell_uniform_data.alpha_mask_fg_set) { cell_uniform_data.alpha_mask_fg_set = true; glUniform1i(glGetUniformLocation(program_id(GRAPHICS_ALPHA_MASK_PROGRAM), "image"), GRAPHICS_UNIT); glUniform1ui(glGetUniformLocation(program_id(GRAPHICS_ALPHA_MASK_PROGRAM), "fg"), OPT(foreground)); } glUniform1f(cell_uniform_data.amask_premult_loc, os_window->is_semi_transparent ? 1.f : 0.f); send_graphics_data_to_gpu(1, os_window->gvao_idx, &data); glEnable(GL_BLEND); if (os_window->is_semi_transparent) { BLEND_PREMULT; } else { BLEND_ONTO_OPAQUE; } draw_graphics(GRAPHICS_ALPHA_MASK_PROGRAM, 0, os_window->gvao_idx, &data, 0, 1); glDisable(GL_BLEND); } static void draw_cells_simple(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen) { bind_program(CELL_PROGRAM); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); if (screen->grman->count) { glEnable(GL_BLEND); BLEND_ONTO_OPAQUE; draw_graphics(GRAPHICS_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, 0, screen->grman->count); glDisable(GL_BLEND); } } static inline bool has_bgimage(OSWindow *w) { return w->bgimage && w->bgimage->texture_id > 0; } static void draw_tint(bool premult, Screen *screen, GLfloat xstart, GLfloat ystart, GLfloat width, GLfloat height) { bind_program(TINT_PROGRAM); color_type window_bg = colorprofile_to_color(screen->color_profile, screen->color_profile->overridden.default_bg, screen->color_profile->configured.default_bg); #define C(shift) ((((GLfloat)((window_bg >> shift) & 0xFF)) / 255.0f)) float alpha = OPT(background_tint); if (premult) glUniform4f(tint_program_layout.tint_color_location, C(16) * alpha, C(8) * alpha, C(0) * alpha, alpha); else glUniform4f(tint_program_layout.tint_color_location, C(16), C(8), C(0), alpha); #undef C glUniform4f(tint_program_layout.edges_location, xstart, ystart - height, xstart + width, ystart); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); } static void draw_cells_interleaved(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWindow *w, GLfloat xstart, GLfloat ystart, GLfloat width, GLfloat height) { glEnable(GL_BLEND); BLEND_ONTO_OPAQUE; // draw background for all cells if (!has_bgimage(w)) { bind_program(CELL_BG_PROGRAM); glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 3); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); } else if (OPT(background_tint) > 0) { glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE); draw_tint(false, screen, xstart, ystart, width, height); BLEND_ONTO_OPAQUE; } if (screen->grman->num_of_below_refs || has_bgimage(w)) { if (screen->grman->num_of_below_refs) draw_graphics( GRAPHICS_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, 0, screen->grman->num_of_below_refs); bind_program(CELL_BG_PROGRAM); // draw background for non-default bg cells glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 2); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); } if (screen->grman->num_of_negative_refs) draw_graphics(GRAPHICS_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, screen->grman->num_of_below_refs, screen->grman->num_of_negative_refs); bind_program(CELL_SPECIAL_PROGRAM); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); bind_program(CELL_FG_PROGRAM); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); if (screen->grman->num_of_positive_refs) draw_graphics(GRAPHICS_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, screen->grman->num_of_negative_refs + screen->grman->num_of_below_refs, screen->grman->num_of_positive_refs); glDisable(GL_BLEND); } static void draw_cells_interleaved_premult(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, OSWindow *os_window, GLfloat xstart, GLfloat ystart, GLfloat width, GLfloat height) { if (OPT(background_tint) > 0.f) { glEnable(GL_BLEND); BLEND_PREMULT; draw_tint(true, screen, xstart, ystart, width, height); glDisable(GL_BLEND); } if (!os_window->offscreen_texture_id) { glGenFramebuffers(1, &os_window->offscreen_framebuffer); glGenTextures(1, &os_window->offscreen_texture_id); glBindTexture(GL_TEXTURE_2D, os_window->offscreen_texture_id); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, os_window->viewport_width, os_window->viewport_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } glBindTexture(GL_TEXTURE_2D, 0); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, os_window->offscreen_framebuffer); glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, os_window->offscreen_texture_id, 0); /* if (glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) fatal("Offscreen framebuffer not complete"); */ bind_program(CELL_BG_PROGRAM); if (!has_bgimage(os_window)) { // draw background for all cells glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 3); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); } else blank_canvas(0, 0); glEnable(GL_BLEND); BLEND_PREMULT; if (screen->grman->num_of_below_refs || has_bgimage(os_window)) { if (screen->grman->num_of_below_refs) draw_graphics( GRAPHICS_PREMULT_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, 0, screen->grman->num_of_below_refs); bind_program(CELL_BG_PROGRAM); // Draw background for non-default bg cells glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 2); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); } else { // Apply background_opacity glUniform1ui(cell_program_layouts[CELL_BG_PROGRAM].draw_bg_bitfield_location, 0); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); } if (screen->grman->num_of_negative_refs) { draw_graphics(GRAPHICS_PREMULT_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, screen->grman->num_of_below_refs, screen->grman->num_of_negative_refs); } bind_program(CELL_SPECIAL_PROGRAM); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); bind_program(CELL_FG_PROGRAM); glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, screen->lines * screen->columns); if (screen->grman->num_of_positive_refs) draw_graphics(GRAPHICS_PREMULT_PROGRAM, vao_idx, gvao_idx, screen->grman->render_data, screen->grman->num_of_negative_refs + screen->grman->num_of_below_refs, screen->grman->num_of_positive_refs); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); if (!has_bgimage(os_window)) glDisable(GL_BLEND); glEnable(GL_SCISSOR_TEST); // Now render the framebuffer to the screen bind_program(BLIT_PROGRAM); bind_vertex_array(blit_vertex_array); static bool blit_constants_set = false; if (!blit_constants_set) { glUniform1i(glGetUniformLocation(program_id(BLIT_PROGRAM), "image"), BLIT_UNIT); blit_constants_set = true; } glActiveTexture(GL_TEXTURE0 + BLIT_UNIT); glBindTexture(GL_TEXTURE_2D, os_window->offscreen_texture_id); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); } static inline void set_cell_uniforms(float current_inactive_text_alpha, bool force) { if (!cell_uniform_data.constants_set || force) { cell_uniform_data.gploc = glGetUniformLocation(program_id(GRAPHICS_PROGRAM), "inactive_text_alpha"); cell_uniform_data.gpploc = glGetUniformLocation(program_id(GRAPHICS_PREMULT_PROGRAM), "inactive_text_alpha"); cell_uniform_data.cploc = glGetUniformLocation(program_id(CELL_PROGRAM), "inactive_text_alpha"); cell_uniform_data.cfploc = glGetUniformLocation(program_id(CELL_FG_PROGRAM), "inactive_text_alpha"); cell_uniform_data.amask_premult_loc = glGetUniformLocation(program_id(GRAPHICS_ALPHA_MASK_PROGRAM), "alpha_mask_premult"); #define S(prog, name, val, type) { bind_program(prog); glUniform##type(glGetUniformLocation(program_id(prog), #name), val); } S(GRAPHICS_PROGRAM, image, GRAPHICS_UNIT, 1i); S(GRAPHICS_PREMULT_PROGRAM, image, GRAPHICS_UNIT, 1i); S(CELL_PROGRAM, sprites, SPRITE_MAP_UNIT, 1i); S(CELL_FG_PROGRAM, sprites, SPRITE_MAP_UNIT, 1i); S(CELL_PROGRAM, dim_opacity, OPT(dim_opacity), 1f); S(CELL_FG_PROGRAM, dim_opacity, OPT(dim_opacity), 1f); S(CELL_BG_PROGRAM, defaultbg, OPT(background), 1f); #undef S cell_uniform_data.constants_set = true; } if (current_inactive_text_alpha != cell_uniform_data.prev_inactive_text_alpha || force) { cell_uniform_data.prev_inactive_text_alpha = current_inactive_text_alpha; #define S(prog, loc) { bind_program(prog); glUniform1f(cell_uniform_data.loc, current_inactive_text_alpha); } S(CELL_PROGRAM, cploc); S(CELL_FG_PROGRAM, cfploc); S(GRAPHICS_PROGRAM, gploc); S(GRAPHICS_PREMULT_PROGRAM, gpploc); #undef S } } void blank_canvas(float background_opacity, color_type color) { // See https://github.com/glfw/glfw/issues/1538 for why we use pre-multiplied alpha #define C(shift) ((((GLfloat)((color >> shift) & 0xFF)) / 255.0f) * background_opacity) glClearColor(C(16), C(8), C(0), background_opacity); #undef C glClear(GL_COLOR_BUFFER_BIT); } bool send_cell_data_to_gpu(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, OSWindow *os_window) { bool changed = false; if (os_window->fonts_data) { if (cell_prepare_to_render(vao_idx, gvao_idx, screen, xstart, ystart, dx, dy, os_window->fonts_data)) changed = true; } return changed; } void draw_cells(ssize_t vao_idx, ssize_t gvao_idx, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, Screen *screen, OSWindow *os_window, bool is_active_window, bool can_be_focused) { CELL_BUFFERS; bool inverted = screen_invert_colors(screen); cell_update_uniform_block(vao_idx, screen, uniform_buffer, xstart, ystart, dx, dy, &screen->cursor_render_info, inverted, os_window); bind_vao_uniform_buffer(vao_idx, uniform_buffer, cell_program_layouts[CELL_PROGRAM].render_data.index); bind_vertex_array(vao_idx); float current_inactive_text_alpha = (!can_be_focused || screen->cursor_render_info.is_focused) && is_active_window ? 1.0f : (float)OPT(inactive_text_alpha); set_cell_uniforms(current_inactive_text_alpha, screen->reload_all_gpu_data); screen->reload_all_gpu_data = false; GLfloat w = (GLfloat)screen->columns * dx, h = (GLfloat)screen->lines * dy; // The scissor limits below are calculated to ensure that they do not // overlap with the pixels outside the draw area, // for a test case (scissor is also used to blit framebuffer in draw_cells_interleaved_premult) run: // kitty -o background=cyan -o background_opacity=0.7 -o cursor_blink_interval=0 -o window_margin_width=40 sh -c "kitty +kitten icat logo/kitty.png; read" #define SCALE(w, x) ((GLfloat)(os_window->viewport_##w) * (GLfloat)(x)) /* printf("columns=%d dx=%f w=%f vw=%d vh=%d left=%f width=%f\n", screen->columns, dx, w, os_window->viewport_width, os_window->viewport_height, SCALE(width, (xstart + 1.f)/2.f), SCALE(width, w / 2.f)); */ glScissor( (GLint)roundf(SCALE(width, (xstart + 1.f)/2.f)), // x (GLint)roundf(SCALE(height, (ystart - h + 1.f)/2.f)), // y (GLsizei)roundf(SCALE(width, w / 2.f)), // width (GLsizei)roundf(SCALE(height, h / 2.f)) // height ); #undef SCALE if (os_window->is_semi_transparent) { if (screen->grman->count || has_bgimage(os_window)) draw_cells_interleaved_premult( vao_idx, gvao_idx, screen, os_window, xstart, ystart, w, h); else draw_cells_simple(vao_idx, gvao_idx, screen); } else { if (screen->grman->num_of_negative_refs || screen->grman->num_of_below_refs || has_bgimage(os_window)) draw_cells_interleaved( vao_idx, gvao_idx, screen, os_window, xstart, ystart, w, h); else draw_cells_simple(vao_idx, gvao_idx, screen); } } // }}} // Borders {{{ enum BorderUniforms { BORDER_viewport, BORDER_background_opacity, BORDER_default_bg, BORDER_active_border_color, BORDER_inactive_border_color, BORDER_bell_border_color, NUM_BORDER_UNIFORMS }; static GLint border_uniform_locations[NUM_BORDER_UNIFORMS] = {0}; static void init_borders_program(void) { #define SET_LOC(which) border_uniform_locations[BORDER_##which] = get_uniform_location(BORDERS_PROGRAM, #which); SET_LOC(viewport) SET_LOC(background_opacity) SET_LOC(default_bg) SET_LOC(active_border_color) SET_LOC(inactive_border_color) SET_LOC(bell_border_color) #undef SET_LOC } ssize_t create_border_vao(void) { ssize_t vao_idx = create_vao(); add_buffer_to_vao(vao_idx, GL_ARRAY_BUFFER); add_attribute_to_vao(BORDERS_PROGRAM, vao_idx, "rect", /*size=*/4, /*dtype=*/GL_UNSIGNED_INT, /*stride=*/sizeof(GLuint)*5, /*offset=*/0, /*divisor=*/1); add_attribute_to_vao(BORDERS_PROGRAM, vao_idx, "rect_color", /*size=*/1, /*dtype=*/GL_UNSIGNED_INT, /*stride=*/sizeof(GLuint)*5, /*offset=*/(void*)(sizeof(GLuint)*4), /*divisor=*/1); return vao_idx; } void draw_borders(ssize_t vao_idx, unsigned int num_border_rects, BorderRect *rect_buf, bool rect_data_is_dirty, uint32_t viewport_width, uint32_t viewport_height, color_type active_window_bg, unsigned int num_visible_windows, bool all_windows_have_same_bg, OSWindow *w) { if (has_bgimage(w)) { glEnable(GL_BLEND); BLEND_ONTO_OPAQUE; draw_bg(w); } if (num_border_rects) { bind_vertex_array(vao_idx); bind_program(BORDERS_PROGRAM); if (rect_data_is_dirty) { size_t sz = sizeof(GLuint) * 5 * num_border_rects; void *borders_buf_address = alloc_and_map_vao_buffer(vao_idx, sz, 0, GL_STATIC_DRAW, GL_WRITE_ONLY); if (borders_buf_address) memcpy(borders_buf_address, rect_buf, sz); unmap_vao_buffer(vao_idx, 0); } #define CV3(x) (((float)((x >> 16) & 0xff))/255.f), (((float)((x >> 8) & 0xff))/255.f), (((float)(x & 0xff))/255.f) glUniform1f(border_uniform_locations[BORDER_background_opacity], w->is_semi_transparent ? w->background_opacity: 1.0f); glUniform3f(border_uniform_locations[BORDER_active_border_color], CV3(OPT(active_border_color))); glUniform3f(border_uniform_locations[BORDER_inactive_border_color], CV3(OPT(inactive_border_color))); glUniform3f(border_uniform_locations[BORDER_bell_border_color], CV3(OPT(bell_border_color))); glUniform2ui(border_uniform_locations[BORDER_viewport], viewport_width, viewport_height); color_type default_bg = (num_visible_windows > 1 && !all_windows_have_same_bg) ? OPT(background) : active_window_bg; glUniform3f(border_uniform_locations[BORDER_default_bg], CV3(default_bg)); #undef CV3 glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, num_border_rects); unbind_vertex_array(); unbind_program(); } if (has_bgimage(w)) glDisable(GL_BLEND); } // }}} // Python API {{{ static PyObject* compile_program(PyObject UNUSED *self, PyObject *args) { const char *vertex_shader, *fragment_shader; int which; GLuint vertex_shader_id = 0, fragment_shader_id = 0; if (!PyArg_ParseTuple(args, "iss", &which, &vertex_shader, &fragment_shader)) return NULL; if (which < 0 || which >= NUM_PROGRAMS) { PyErr_Format(PyExc_ValueError, "Unknown program: %d", which); return NULL; } Program *program = program_ptr(which); if (program->id != 0) { PyErr_SetString(PyExc_ValueError, "program already compiled"); return NULL; } program->id = glCreateProgram(); vertex_shader_id = compile_shader(GL_VERTEX_SHADER, vertex_shader); fragment_shader_id = compile_shader(GL_FRAGMENT_SHADER, fragment_shader); glAttachShader(program->id, vertex_shader_id); glAttachShader(program->id, fragment_shader_id); glLinkProgram(program->id); GLint ret = GL_FALSE; glGetProgramiv(program->id, GL_LINK_STATUS, &ret); if (ret != GL_TRUE) { GLsizei len; static char glbuf[4096]; glGetProgramInfoLog(program->id, sizeof(glbuf), &len, glbuf); log_error("Failed to compile GLSL shader!\n%s", glbuf); PyErr_SetString(PyExc_ValueError, "Failed to compile shader"); goto end; } init_uniforms(which); end: if (vertex_shader_id != 0) glDeleteShader(vertex_shader_id); if (fragment_shader_id != 0) glDeleteShader(fragment_shader_id); if (PyErr_Occurred()) { glDeleteProgram(program->id); program->id = 0; return NULL;} return Py_BuildValue("I", program->id); } #define PYWRAP0(name) static PyObject* py##name(PYNOARG) #define PYWRAP1(name) static PyObject* py##name(PyObject UNUSED *self, PyObject *args) #define PA(fmt, ...) if(!PyArg_ParseTuple(args, fmt, __VA_ARGS__)) return NULL; #define ONE_INT(name) PYWRAP1(name) { name(PyLong_AsSsize_t(args)); Py_RETURN_NONE; } #define TWO_INT(name) PYWRAP1(name) { int a, b; PA("ii", &a, &b); name(a, b); Py_RETURN_NONE; } #define NO_ARG(name) PYWRAP0(name) { name(); Py_RETURN_NONE; } #define NO_ARG_INT(name) PYWRAP0(name) { return PyLong_FromSsize_t(name()); } ONE_INT(bind_program) NO_ARG(unbind_program) PYWRAP0(create_vao) { int ans = create_vao(); if (ans < 0) return NULL; return Py_BuildValue("i", ans); } ONE_INT(bind_vertex_array) NO_ARG(unbind_vertex_array) TWO_INT(unmap_vao_buffer) NO_ARG(init_borders_program) NO_ARG(init_cell_program) static PyObject* sprite_map_set_limits(PyObject UNUSED *self, PyObject *args) { unsigned int w, h; if(!PyArg_ParseTuple(args, "II", &w, &h)) return NULL; sprite_tracker_set_limits(w, h); max_texture_size = w; max_array_texture_layers = h; Py_RETURN_NONE; } #define M(name, arg_type) {#name, (PyCFunction)name, arg_type, NULL} #define MW(name, arg_type) {#name, (PyCFunction)py##name, arg_type, NULL} static PyMethodDef module_methods[] = { M(compile_program, METH_VARARGS), M(sprite_map_set_limits, METH_VARARGS), MW(create_vao, METH_NOARGS), MW(bind_vertex_array, METH_O), MW(unbind_vertex_array, METH_NOARGS), MW(unmap_vao_buffer, METH_VARARGS), MW(bind_program, METH_O), MW(unbind_program, METH_NOARGS), MW(init_borders_program, METH_NOARGS), MW(init_cell_program, METH_NOARGS), {NULL, NULL, 0, NULL} /* Sentinel */ }; bool init_shaders(PyObject *module) { #define C(x) if (PyModule_AddIntConstant(module, #x, x) != 0) { PyErr_NoMemory(); return false; } C(CELL_PROGRAM); C(CELL_BG_PROGRAM); C(CELL_SPECIAL_PROGRAM); C(CELL_FG_PROGRAM); C(BORDERS_PROGRAM); C(GRAPHICS_PROGRAM); C(GRAPHICS_PREMULT_PROGRAM); C(GRAPHICS_ALPHA_MASK_PROGRAM); C(BLIT_PROGRAM); C(BGIMAGE_PROGRAM); C(TINT_PROGRAM); C(GLSL_VERSION); C(GL_VERSION); C(GL_VENDOR); C(GL_SHADING_LANGUAGE_VERSION); C(GL_RENDERER); C(GL_TRIANGLE_FAN); C(GL_TRIANGLE_STRIP); C(GL_TRIANGLES); C(GL_LINE_LOOP); C(GL_COLOR_BUFFER_BIT); C(GL_VERTEX_SHADER); C(GL_FRAGMENT_SHADER); C(GL_TRUE); C(GL_FALSE); C(GL_COMPILE_STATUS); C(GL_LINK_STATUS); C(GL_TEXTURE0); C(GL_TEXTURE1); C(GL_TEXTURE2); C(GL_TEXTURE3); C(GL_TEXTURE4); C(GL_TEXTURE5); C(GL_TEXTURE6); C(GL_TEXTURE7); C(GL_TEXTURE8); C(GL_MAX_ARRAY_TEXTURE_LAYERS); C(GL_TEXTURE_BINDING_BUFFER); C(GL_MAX_TEXTURE_BUFFER_SIZE); C(GL_MAX_TEXTURE_SIZE); C(GL_TEXTURE_2D_ARRAY); C(GL_LINEAR); C(GL_CLAMP_TO_EDGE); C(GL_NEAREST); C(GL_TEXTURE_MIN_FILTER); C(GL_TEXTURE_MAG_FILTER); C(GL_TEXTURE_WRAP_S); C(GL_TEXTURE_WRAP_T); C(GL_UNPACK_ALIGNMENT); C(GL_R8); C(GL_RED); C(GL_UNSIGNED_BYTE); C(GL_UNSIGNED_SHORT); C(GL_R32UI); C(GL_RGB32UI); C(GL_RGBA); C(GL_TEXTURE_BUFFER); C(GL_STATIC_DRAW); C(GL_STREAM_DRAW); C(GL_DYNAMIC_DRAW); C(GL_SRC_ALPHA); C(GL_ONE_MINUS_SRC_ALPHA); C(GL_WRITE_ONLY); C(GL_READ_ONLY); C(GL_READ_WRITE); C(GL_BLEND); C(GL_FLOAT); C(GL_UNSIGNED_INT); C(GL_ARRAY_BUFFER); C(GL_UNIFORM_BUFFER); #undef C if (PyModule_AddFunctions(module, module_methods) != 0) return false; return true; } // }}}
{ "pile_set_name": "Github" }
/** * Polish translation for bootstrap-datepicker * Robert <[email protected]> */ ;(function($){ $.fn.datepicker.dates['pl'] = { days: ["Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela"], daysShort: ["Nie", "Pn", "Wt", "Śr", "Czw", "Pt", "So", "Nie"], daysMin: ["N", "Pn", "Wt", "Śr", "Cz", "Pt", "So", "N"], months: ["Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień"], monthsShort: ["Sty", "Lu", "Mar", "Kw", "Maj", "Cze", "Lip", "Sie", "Wrz", "Pa", "Lis", "Gru"], today: "Dzisiaj", weekStart: 1 }; }(jQuery));
{ "pile_set_name": "Github" }
$ $! $" $# $$ $% $& $' $( $) $* $+ $, $- $. $/ $: $; $< $= $> $? $@ $[ $\ $] $^ $_ $` ${ $| $} $~
{ "pile_set_name": "Github" }
approvers: - juanvallejo - soltysh reviewers: - seans3 - deads2k - soltysh - juanvallejo labels: - sig/cli
{ "pile_set_name": "Github" }
<testcase> <info> <keywords> SMTP SIZE </keywords> </info> # # Server-side <reply> <servercmd> CAPA SIZE </servercmd> </reply> # # Client-side <client> <server> smtp </server> <name> SMTP with SIZE support </name> <file name="log/test912.eml"> From: different To: another body </file> <command> smtp://%HOSTIP:%SMTPPORT/912 --mail-rcpt [email protected] --mail-from [email protected] -T log/test912.eml </command> </client> # # Verify data after the test has been "shot" <verify> <protocol> EHLO 912 MAIL FROM:<[email protected]> SIZE=38 RCPT TO:<[email protected]> DATA QUIT </protocol> <upload> From: different To: another body . </upload> </verify> </testcase>
{ "pile_set_name": "Github" }
import acl from '@/utils/acl' import bytes from '@/utils/bytes' import filters from '@/utils/filters' import i18n from '@/utils/locale' import store from '@/store' import { format } from 'date-fns' const locales = { en: require('date-fns/locale/en'), fr: require('date-fns/locale/fr') } export const pfFormatters = { noAdminRolePermission: (value) => { if (!value) return null return value }, datetimeIgnoreZero: (value) => { return (value === '0000-00-00 00:00:00') ? '' : format(value, i18n.t('MM/DD/YYYY hh:mm A'), { locale: locales[i18n.locale] }) }, categoryId: (value, key, item) => { if (!value) return null if (acl.$can('read', 'nodes')) { store.dispatch('config/getRoles') if (store.state.config.roles) { return store.state.config.roles.filter(role => role.category_id === item.category_id).map(role => role.name)[0] } } else { return item.category_id } }, categoryIdFromIntOrString: (value) => { if (!value) return null if (!/^\d+$/.test(value)) { if (acl.$can('read', 'nodes')) { store.dispatch('config/getRoles') return store.state.config.roles.filter(role => role.name.toLowerCase() === value.toLowerCase()).map(role => role.category_id)[0] // string } else { return value } } else { return value // int } }, bypassRoleId: (value, key, item) => { if (!value) return null if (acl.$can('read', 'nodes')) { store.dispatch('config/getRoles') if (store.state.config.roles) { return store.state.config.roles.filter(role => role.category_id === item.bypass_role_id).map(role => role.name)[0] } } else { return item.bypass_role_id } }, securityEventIdToDesc: (value) => { if (!value) return null store.dispatch('config/getSecurityEvents') return store.getters['config/sortedSecurityEvents'].filter(securityEvent => securityEvent.id === value).map(securityEvent => securityEvent.desc)[0] }, securityEventIdsToDescCsv: (value) => { if (!value) return null store.dispatch('config/getSecurityEvents') const uVids = [...new Set(value.split(',').filter(item => item))] return store.getters['config/sortedSecurityEvents'].filter(securityEvent => uVids.includes(securityEvent.id)).map(securityEvent => securityEvent.desc).join(', ') }, yesNoFromString: (value) => { if (value === null || value === '') return null switch (value.toLowerCase()) { case 'yes': case 'y': case '1': case 'true': return 'yes' case 'no': case 'n': case '0': case 'false': return 'no' default: return null } }, genderFromString: (value) => { if (value === null || value === '') return null switch (value.toLowerCase()) { case 'm': case 'male': case 'man': return 'm' case 'f': case 'female': case 'woman': return 'f' case 'o': case 'other': return 'o' default: return null } }, fileSize: (value, key, item) => { if (value === null || value === '' || ('type' in item && item.type === 'dir')) return null return bytes.toHuman(value, 2, true) + 'B' }, shortDateTime: (value) => { return filters.shortDateTime(parseInt(value) * 1000) } }
{ "pile_set_name": "Github" }
INX / CPX #$19 / BRANCH somewhere Looks like a fragment of a loop that waits until X reaches $19 before terminating. Nothing creative or copyrightable here.
{ "pile_set_name": "Github" }
/** * The MIT License (MIT) * * Copyright (C) 2014-2015 Bacon2D Project * * 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. * * @author Ken VanDine <[email protected]> */ import QtQuick 2.3 import QtTest 1.0 import Bacon2D 1.0 TestCase { name: "SceneTests" function init() { game.gameState = Bacon2D.Running; compare(game.currentScene.running, true, "Scene.running was false"); } function cleanup() { game.gameState = Bacon2D.Paused; } function test_currentScene() { game.currentScene = scene; compare(game.currentScene, scene, "Current scene") } function test_runningScene() { game.currentScene = scene; compare(scene.running, true, "Running scene") } function test_nonRunningScene() { game.currentScene = scene2; compare(scene.running, false, "Non-running scene") } function test_runningScene2() { game.currentScene = scene2; compare(scene2.running, true, "Non-running scene") } function test_gameStatePaused() { game.currentScene = scene; game.gameState = Bacon2D.Paused; compare(scene.running, false, "Game paused") } function test_gameStateRunning() { game.currentScene = scene; game.gameState = Bacon2D.Running; compare(scene.running, true, "Game running") } Game { id: game currentScene: scene Scene { id: scene } Scene { id: scene2 } } }
{ "pile_set_name": "Github" }
// LUA mode. Ported to CodeMirror 2 from Franciszek Wawrzak's // CodeMirror 1 mode. // highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting CodeMirror.defineMode("lua", function(config, parserConfig) { var indentUnit = config.indentUnit; function prefixRE(words) { return new RegExp("^(?:" + words.join("|") + ")", "i"); } function wordRE(words) { return new RegExp("^(?:" + words.join("|") + ")$", "i"); } var specials = wordRE(parserConfig.specials || []); // long list of standard functions from lua manual var builtins = wordRE([ "_G","_VERSION","assert","collectgarbage","dofile","error","getfenv","getmetatable","ipairs","load", "loadfile","loadstring","module","next","pairs","pcall","print","rawequal","rawget","rawset","require", "select","setfenv","setmetatable","tonumber","tostring","type","unpack","xpcall", "coroutine.create","coroutine.resume","coroutine.running","coroutine.status","coroutine.wrap","coroutine.yield", "debug.debug","debug.getfenv","debug.gethook","debug.getinfo","debug.getlocal","debug.getmetatable", "debug.getregistry","debug.getupvalue","debug.setfenv","debug.sethook","debug.setlocal","debug.setmetatable", "debug.setupvalue","debug.traceback", "close","flush","lines","read","seek","setvbuf","write", "io.close","io.flush","io.input","io.lines","io.open","io.output","io.popen","io.read","io.stderr","io.stdin", "io.stdout","io.tmpfile","io.type","io.write", "math.abs","math.acos","math.asin","math.atan","math.atan2","math.ceil","math.cos","math.cosh","math.deg", "math.exp","math.floor","math.fmod","math.frexp","math.huge","math.ldexp","math.log","math.log10","math.max", "math.min","math.modf","math.pi","math.pow","math.rad","math.random","math.randomseed","math.sin","math.sinh", "math.sqrt","math.tan","math.tanh", "os.clock","os.date","os.difftime","os.execute","os.exit","os.getenv","os.remove","os.rename","os.setlocale", "os.time","os.tmpname", "package.cpath","package.loaded","package.loaders","package.loadlib","package.path","package.preload", "package.seeall", "string.byte","string.char","string.dump","string.find","string.format","string.gmatch","string.gsub", "string.len","string.lower","string.match","string.rep","string.reverse","string.sub","string.upper", "table.concat","table.insert","table.maxn","table.remove","table.sort" ]); var keywords = wordRE(["and","break","elseif","false","nil","not","or","return", "true","function", "end", "if", "then", "else", "do", "while", "repeat", "until", "for", "in", "local" ]); var indentTokens = wordRE(["function", "if","repeat","do", "\\(", "{"]); var dedentTokens = wordRE(["end", "until", "\\)", "}"]); var dedentPartial = prefixRE(["end", "until", "\\)", "}", "else", "elseif"]); function readBracket(stream) { var level = 0; while (stream.eat("=")) ++level; stream.eat("["); return level; } function normal(stream, state) { var ch = stream.next(); if (ch == "-" && stream.eat("-")) { if (stream.eat("[") && stream.eat("[")) return (state.cur = bracketed(readBracket(stream), "comment"))(stream, state); stream.skipToEnd(); return "comment"; } if (ch == "\"" || ch == "'") return (state.cur = string(ch))(stream, state); if (ch == "[" && /[\[=]/.test(stream.peek())) return (state.cur = bracketed(readBracket(stream), "string"))(stream, state); if (/\d/.test(ch)) { stream.eatWhile(/[\w.%]/); return "number"; } if (/[\w_]/.test(ch)) { stream.eatWhile(/[\w\\\-_.]/); return "variable"; } return null; } function bracketed(level, style) { return function(stream, state) { var curlev = null, ch; while ((ch = stream.next()) != null) { if (curlev == null) {if (ch == "]") curlev = 0;} else if (ch == "=") ++curlev; else if (ch == "]" && curlev == level) { state.cur = normal; break; } else curlev = null; } return style; }; } function string(quote) { return function(stream, state) { var escaped = false, ch; while ((ch = stream.next()) != null) { if (ch == quote && !escaped) break; escaped = !escaped && ch == "\\"; } if (!escaped) state.cur = normal; return "string"; }; } return { startState: function(basecol) { return {basecol: basecol || 0, indentDepth: 0, cur: normal}; }, token: function(stream, state) { if (stream.eatSpace()) return null; var style = state.cur(stream, state); var word = stream.current(); if (style == "variable") { if (keywords.test(word)) style = "keyword"; else if (builtins.test(word)) style = "builtin"; else if (specials.test(word)) style = "variable-2"; } if ((style != "comment") && (style != "string")){ if (indentTokens.test(word)) ++state.indentDepth; else if (dedentTokens.test(word)) --state.indentDepth; } return style; }, indent: function(state, textAfter) { var closing = dedentPartial.test(textAfter); return state.basecol + indentUnit * (state.indentDepth - (closing ? 1 : 0)); }, lineComment: "--", blockCommentStart: "--[[", blockCommentEnd: "]]" }; }); CodeMirror.defineMIME("text/x-lua", "lua");
{ "pile_set_name": "Github" }
OPEN GAME LICENSE Version 1.0a The following text is the property of Wizards of the Coast, Inc. and is Copyright 2000 Wizards of the Coast, Inc ("Wizards"). All Rights Reserved. 1. Definitions: (a)"Contributors" means the copyright and/or trademark owners who have contributed Open Game Content; (b)"Derivative Material" means copyrighted material including derivative works and translations (including into other computer languages), potation, modification, correction, addition, extension, upgrade, improvement, compilation, abridgment or other form in which an existing work may be recast, transformed or adapted; (c) "Distribute" means to reproduce, license, rent, lease, sell, broadcast, publicly display, transmit or otherwise distribute; (d)"Open Game Content" means the game mechanic and includes the methods, procedures, processes and routines to the extent such content does not embody the Product Identity and is an enhancement over the prior art and any additional content clearly identified as Open Game Content by the Contributor, and means any work covered by this License, including translations and derivative works under copyright law, but specifically excludes Product Identity. (e) "Product Identity" means product and product line names, logos and identifying marks including trade dress; artifacts; creatures characters; stories, storylines, plots, thematic elements, dialogue, incidents, language, artwork, symbols, designs, depictions, likenesses, formats, poses, concepts, themes and graphic, photographic and other visual or audio representations; names and descriptions of characters, spells, enchantments, personalities, teams, personas, likenesses and special abilities; places, locations, environments, creatures, equipment, magical or supernatural abilities or effects, logos, symbols, or graphic designs; and any other trademark or registered trademark clearly identified as Product identity by the owner of the Product Identity, and which specifically excludes the Open Game Content; (f) "Trademark" means the logos, names, mark, sign, motto, designs that are used by a Contributor to identify itself or its products or the associated products contributed to the Open Game License by the Contributor (g) "Use", "Used" or "Using" means to use, Distribute, copy, edit, format, modify, translate and otherwise create Derivative Material of Open Game Content. (h) "You" or "Your" means the licensee in terms of this agreement. 2. The License: This License applies to any Open Game Content that contains a notice indicating that the Open Game Content may only be Used under and in terms of this License. You must affix such a notice to any Open Game Content that you Use. No terms may be added to or subtracted from this License except as described by the License itself. No other terms or conditions may be applied to any Open Game Content distributed using this License. 3.Offer and Acceptance: By Using the Open Game Content You indicate Your acceptance of the terms of this License. 4. Grant and Consideration: In consideration for agreeing to use this License, the Contributors grant You a perpetual, worldwide, royalty-free, non-exclusive license with the exact terms of this License to Use, the Open Game Content. 5.Representation of Authority to Contribute: If You are contributing original material as Open Game Content, You represent that Your Contributions are Your original creation and/or You have sufficient rights to grant the rights conveyed by this License. 6.Notice of License Copyright: You must update the COPYRIGHT NOTICE portion of this License to include the exact text of the COPYRIGHT NOTICE of any Open Game Content You are copying, modifying or distributing, and You must add the title, the copyright date, and the copyright holder's name to the COPYRIGHT NOTICE of any original Open Game Content you Distribute. 7. Use of Product Identity: You agree not to Use any Product Identity, including as an indication as to compatibility, except as expressly licensed in another, independent Agreement with the owner of each element of that Product Identity. You agree not to indicate compatibility or co-adaptability with any Trademark or Registered Trademark in conjunction with a work containing Open Game Content except as expressly licensed in another, independent Agreement with the owner of such Trademark or Registered Trademark. The use of any Product Identity in Open Game Content does not constitute a challenge to the ownership of that Product Identity. The owner of any Product Identity used in Open Game Content shall retain all rights, title and interest in and to that Product Identity. 8. Identification: If you distribute Open Game Content You must clearly indicate which portions of the work that you are distributing are Open Game Content. 9. Updating the License: Wizards or its designated Agents may publish updated versions of this License. You may use any authorized version of this License to copy, modify and distribute any Open Game Content originally distributed under any version of this License. 10 Copy of this License: You MUST include a copy of this License with every copy of the Open Game Content You Distribute. 11. Use of Contributor Credits: You may not market or advertise the Open Game Content using the name of any Contributor unless You have written permission from the Contributor to do so. 12 Inability to Comply: If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Open Game Content due to statute, judicial order, or governmental regulation then You may not Use any Open Game Material so affected. 13 Termination: This License will terminate automatically if You fail to comply with all terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses shall survive the termination of this License. 14 Reformation: If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 15. COPYRIGHT NOTICE Open Game License v 1.0a Copyright 2000, Wizards of the Coast, Inc. System Reference Document. Copyright 2000, Wizards of the Coast, Inc.; Authors Jonathan Tweet, Monte Cook, Skip Williams, based on material by E. Gary Gygax and Dave Arneson. Kingmaker Player's Guide. Copyright 2010, Paizo Publishing, LLC; Authors: James Jacobs, Mark Moreland, and F. Wesley Schneider. PCGen dataset conversion for "Pathfinder Adventure Path: Kingmaker Player's Guide" Copyright 2010, PCGen Data Team (including, but not limited to Stefan Radermacher)
{ "pile_set_name": "Github" }
#! /usr/bin/python # -*- coding: utf-8 -*- # # Protocol Buffers - Google's data interchange format # Copyright 2008 Google Inc. All rights reserved. # https://developers.google.com/protocol-buffers/ # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following disclaimer # in the documentation and/or other materials provided with the # distribution. # * Neither the name of Google Inc. nor the names of its # contributors may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Unittest for reflection.py, which tests the generated C++ implementation.""" __author__ = '[email protected] (Jason Hsueh)' import os os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'cpp' os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION_VERSION'] = '2' from google.apputils import basetest from google.protobuf.internal import api_implementation from google.protobuf.internal import more_extensions_dynamic_pb2 from google.protobuf.internal import more_extensions_pb2 from google.protobuf.internal.reflection_test import * class ReflectionCppTest(basetest.TestCase): def testImplementationSetting(self): self.assertEqual('cpp', api_implementation.Type()) self.assertEqual(2, api_implementation.Version()) def testExtensionOfGeneratedTypeInDynamicFile(self): """Tests that a file built dynamically can extend a generated C++ type. The C++ implementation uses a DescriptorPool that has the generated DescriptorPool as an underlay. Typically, a type can only find extensions in its own pool. With the python C-extension, the generated C++ extendee may be available, but not the extension. This tests that the C-extension implements the correct special handling to make such extensions available. """ pb1 = more_extensions_pb2.ExtendedMessage() # Test that basic accessors work. self.assertFalse( pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension)) self.assertFalse( pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension)) pb1.Extensions[more_extensions_dynamic_pb2.dynamic_int32_extension] = 17 pb1.Extensions[more_extensions_dynamic_pb2.dynamic_message_extension].a = 24 self.assertTrue( pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension)) self.assertTrue( pb1.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension)) # Now serialize the data and parse to a new message. pb2 = more_extensions_pb2.ExtendedMessage() pb2.MergeFromString(pb1.SerializeToString()) self.assertTrue( pb2.HasExtension(more_extensions_dynamic_pb2.dynamic_int32_extension)) self.assertTrue( pb2.HasExtension(more_extensions_dynamic_pb2.dynamic_message_extension)) self.assertEqual( 17, pb2.Extensions[more_extensions_dynamic_pb2.dynamic_int32_extension]) self.assertEqual( 24, pb2.Extensions[more_extensions_dynamic_pb2.dynamic_message_extension].a) if __name__ == '__main__': basetest.main()
{ "pile_set_name": "Github" }
// SPDX-License-Identifier: GPL-2.0 /* * linux/fs/hfsplus/brec.c * * Copyright (C) 2001 * Brad Boyer ([email protected]) * (C) 2003 Ardis Technologies <[email protected]> * * Handle individual btree records */ #include "hfsplus_fs.h" #include "hfsplus_raw.h" static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd); static int hfs_brec_update_parent(struct hfs_find_data *fd); static int hfs_btree_inc_height(struct hfs_btree *); /* Get the length and offset of the given record in the given node */ u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off) { __be16 retval[2]; u16 dataoff; dataoff = node->tree->node_size - (rec + 2) * 2; hfs_bnode_read(node, retval, dataoff, 4); *off = be16_to_cpu(retval[1]); return be16_to_cpu(retval[0]) - *off; } /* Get the length of the key from a keyed record */ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec) { u16 retval, recoff; if (node->type != HFS_NODE_INDEX && node->type != HFS_NODE_LEAF) return 0; if ((node->type == HFS_NODE_INDEX) && !(node->tree->attributes & HFS_TREE_VARIDXKEYS) && (node->tree->cnid != HFSPLUS_ATTR_CNID)) { retval = node->tree->max_key_len + 2; } else { recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2); if (!recoff) return 0; if (recoff > node->tree->node_size - 2) { pr_err("recoff %d too large\n", recoff); return 0; } retval = hfs_bnode_read_u16(node, recoff) + 2; if (retval > node->tree->max_key_len + 2) { pr_err("keylen %d too large\n", retval); retval = 0; } } return retval; } int hfs_brec_insert(struct hfs_find_data *fd, void *entry, int entry_len) { struct hfs_btree *tree; struct hfs_bnode *node, *new_node; int size, key_len, rec; int data_off, end_off; int idx_rec_off, data_rec_off, end_rec_off; __be32 cnid; tree = fd->tree; if (!fd->bnode) { if (!tree->root) hfs_btree_inc_height(tree); node = hfs_bnode_find(tree, tree->leaf_head); if (IS_ERR(node)) return PTR_ERR(node); fd->bnode = node; fd->record = -1; } new_node = NULL; key_len = be16_to_cpu(fd->search_key->key_len) + 2; again: /* new record idx and complete record size */ rec = fd->record + 1; size = key_len + entry_len; node = fd->bnode; hfs_bnode_dump(node); /* get last offset */ end_rec_off = tree->node_size - (node->num_recs + 1) * 2; end_off = hfs_bnode_read_u16(node, end_rec_off); end_rec_off -= 2; hfs_dbg(BNODE_MOD, "insert_rec: %d, %d, %d, %d\n", rec, size, end_off, end_rec_off); if (size > end_rec_off - end_off) { if (new_node) panic("not enough room!\n"); new_node = hfs_bnode_split(fd); if (IS_ERR(new_node)) return PTR_ERR(new_node); goto again; } if (node->type == HFS_NODE_LEAF) { tree->leaf_count++; mark_inode_dirty(tree->inode); } node->num_recs++; /* write new last offset */ hfs_bnode_write_u16(node, offsetof(struct hfs_bnode_desc, num_recs), node->num_recs); hfs_bnode_write_u16(node, end_rec_off, end_off + size); data_off = end_off; data_rec_off = end_rec_off + 2; idx_rec_off = tree->node_size - (rec + 1) * 2; if (idx_rec_off == data_rec_off) goto skip; /* move all following entries */ do { data_off = hfs_bnode_read_u16(node, data_rec_off + 2); hfs_bnode_write_u16(node, data_rec_off, data_off + size); data_rec_off += 2; } while (data_rec_off < idx_rec_off); /* move data away */ hfs_bnode_move(node, data_off + size, data_off, end_off - data_off); skip: hfs_bnode_write(node, fd->search_key, data_off, key_len); hfs_bnode_write(node, entry, data_off + key_len, entry_len); hfs_bnode_dump(node); /* * update parent key if we inserted a key * at the start of the node and it is not the new node */ if (!rec && new_node != node) { hfs_bnode_read_key(node, fd->search_key, data_off + size); hfs_brec_update_parent(fd); } if (new_node) { hfs_bnode_put(fd->bnode); if (!new_node->parent) { hfs_btree_inc_height(tree); new_node->parent = tree->root; } fd->bnode = hfs_bnode_find(tree, new_node->parent); /* create index data entry */ cnid = cpu_to_be32(new_node->this); entry = &cnid; entry_len = sizeof(cnid); /* get index key */ hfs_bnode_read_key(new_node, fd->search_key, 14); __hfs_brec_find(fd->bnode, fd, hfs_find_rec_by_key); hfs_bnode_put(new_node); new_node = NULL; if ((tree->attributes & HFS_TREE_VARIDXKEYS) || (tree->cnid == HFSPLUS_ATTR_CNID)) key_len = be16_to_cpu(fd->search_key->key_len) + 2; else { fd->search_key->key_len = cpu_to_be16(tree->max_key_len); key_len = tree->max_key_len + 2; } goto again; } return 0; } int hfs_brec_remove(struct hfs_find_data *fd) { struct hfs_btree *tree; struct hfs_bnode *node, *parent; int end_off, rec_off, data_off, size; tree = fd->tree; node = fd->bnode; again: rec_off = tree->node_size - (fd->record + 2) * 2; end_off = tree->node_size - (node->num_recs + 1) * 2; if (node->type == HFS_NODE_LEAF) { tree->leaf_count--; mark_inode_dirty(tree->inode); } hfs_bnode_dump(node); hfs_dbg(BNODE_MOD, "remove_rec: %d, %d\n", fd->record, fd->keylength + fd->entrylength); if (!--node->num_recs) { hfs_bnode_unlink(node); if (!node->parent) return 0; parent = hfs_bnode_find(tree, node->parent); if (IS_ERR(parent)) return PTR_ERR(parent); hfs_bnode_put(node); node = fd->bnode = parent; __hfs_brec_find(node, fd, hfs_find_rec_by_key); goto again; } hfs_bnode_write_u16(node, offsetof(struct hfs_bnode_desc, num_recs), node->num_recs); if (rec_off == end_off) goto skip; size = fd->keylength + fd->entrylength; do { data_off = hfs_bnode_read_u16(node, rec_off); hfs_bnode_write_u16(node, rec_off + 2, data_off - size); rec_off -= 2; } while (rec_off >= end_off); /* fill hole */ hfs_bnode_move(node, fd->keyoffset, fd->keyoffset + size, data_off - fd->keyoffset - size); skip: hfs_bnode_dump(node); if (!fd->record) hfs_brec_update_parent(fd); return 0; } static struct hfs_bnode *hfs_bnode_split(struct hfs_find_data *fd) { struct hfs_btree *tree; struct hfs_bnode *node, *new_node, *next_node; struct hfs_bnode_desc node_desc; int num_recs, new_rec_off, new_off, old_rec_off; int data_start, data_end, size; tree = fd->tree; node = fd->bnode; new_node = hfs_bmap_alloc(tree); if (IS_ERR(new_node)) return new_node; hfs_bnode_get(node); hfs_dbg(BNODE_MOD, "split_nodes: %d - %d - %d\n", node->this, new_node->this, node->next); new_node->next = node->next; new_node->prev = node->this; new_node->parent = node->parent; new_node->type = node->type; new_node->height = node->height; if (node->next) next_node = hfs_bnode_find(tree, node->next); else next_node = NULL; if (IS_ERR(next_node)) { hfs_bnode_put(node); hfs_bnode_put(new_node); return next_node; } size = tree->node_size / 2 - node->num_recs * 2 - 14; old_rec_off = tree->node_size - 4; num_recs = 1; for (;;) { data_start = hfs_bnode_read_u16(node, old_rec_off); if (data_start > size) break; old_rec_off -= 2; if (++num_recs < node->num_recs) continue; /* panic? */ hfs_bnode_put(node); hfs_bnode_put(new_node); if (next_node) hfs_bnode_put(next_node); return ERR_PTR(-ENOSPC); } if (fd->record + 1 < num_recs) { /* new record is in the lower half, * so leave some more space there */ old_rec_off += 2; num_recs--; data_start = hfs_bnode_read_u16(node, old_rec_off); } else { hfs_bnode_put(node); hfs_bnode_get(new_node); fd->bnode = new_node; fd->record -= num_recs; fd->keyoffset -= data_start - 14; fd->entryoffset -= data_start - 14; } new_node->num_recs = node->num_recs - num_recs; node->num_recs = num_recs; new_rec_off = tree->node_size - 2; new_off = 14; size = data_start - new_off; num_recs = new_node->num_recs; data_end = data_start; while (num_recs) { hfs_bnode_write_u16(new_node, new_rec_off, new_off); old_rec_off -= 2; new_rec_off -= 2; data_end = hfs_bnode_read_u16(node, old_rec_off); new_off = data_end - size; num_recs--; } hfs_bnode_write_u16(new_node, new_rec_off, new_off); hfs_bnode_copy(new_node, 14, node, data_start, data_end - data_start); /* update new bnode header */ node_desc.next = cpu_to_be32(new_node->next); node_desc.prev = cpu_to_be32(new_node->prev); node_desc.type = new_node->type; node_desc.height = new_node->height; node_desc.num_recs = cpu_to_be16(new_node->num_recs); node_desc.reserved = 0; hfs_bnode_write(new_node, &node_desc, 0, sizeof(node_desc)); /* update previous bnode header */ node->next = new_node->this; hfs_bnode_read(node, &node_desc, 0, sizeof(node_desc)); node_desc.next = cpu_to_be32(node->next); node_desc.num_recs = cpu_to_be16(node->num_recs); hfs_bnode_write(node, &node_desc, 0, sizeof(node_desc)); /* update next bnode header */ if (next_node) { next_node->prev = new_node->this; hfs_bnode_read(next_node, &node_desc, 0, sizeof(node_desc)); node_desc.prev = cpu_to_be32(next_node->prev); hfs_bnode_write(next_node, &node_desc, 0, sizeof(node_desc)); hfs_bnode_put(next_node); } else if (node->this == tree->leaf_tail) { /* if there is no next node, this might be the new tail */ tree->leaf_tail = new_node->this; mark_inode_dirty(tree->inode); } hfs_bnode_dump(node); hfs_bnode_dump(new_node); hfs_bnode_put(node); return new_node; } static int hfs_brec_update_parent(struct hfs_find_data *fd) { struct hfs_btree *tree; struct hfs_bnode *node, *new_node, *parent; int newkeylen, diff; int rec, rec_off, end_rec_off; int start_off, end_off; tree = fd->tree; node = fd->bnode; new_node = NULL; if (!node->parent) return 0; again: parent = hfs_bnode_find(tree, node->parent); if (IS_ERR(parent)) return PTR_ERR(parent); __hfs_brec_find(parent, fd, hfs_find_rec_by_key); if (fd->record < 0) return -ENOENT; hfs_bnode_dump(parent); rec = fd->record; /* size difference between old and new key */ if ((tree->attributes & HFS_TREE_VARIDXKEYS) || (tree->cnid == HFSPLUS_ATTR_CNID)) newkeylen = hfs_bnode_read_u16(node, 14) + 2; else fd->keylength = newkeylen = tree->max_key_len + 2; hfs_dbg(BNODE_MOD, "update_rec: %d, %d, %d\n", rec, fd->keylength, newkeylen); rec_off = tree->node_size - (rec + 2) * 2; end_rec_off = tree->node_size - (parent->num_recs + 1) * 2; diff = newkeylen - fd->keylength; if (!diff) goto skip; if (diff > 0) { end_off = hfs_bnode_read_u16(parent, end_rec_off); if (end_rec_off - end_off < diff) { hfs_dbg(BNODE_MOD, "splitting index node\n"); fd->bnode = parent; new_node = hfs_bnode_split(fd); if (IS_ERR(new_node)) return PTR_ERR(new_node); parent = fd->bnode; rec = fd->record; rec_off = tree->node_size - (rec + 2) * 2; end_rec_off = tree->node_size - (parent->num_recs + 1) * 2; } } end_off = start_off = hfs_bnode_read_u16(parent, rec_off); hfs_bnode_write_u16(parent, rec_off, start_off + diff); start_off -= 4; /* move previous cnid too */ while (rec_off > end_rec_off) { rec_off -= 2; end_off = hfs_bnode_read_u16(parent, rec_off); hfs_bnode_write_u16(parent, rec_off, end_off + diff); } hfs_bnode_move(parent, start_off + diff, start_off, end_off - start_off); skip: hfs_bnode_copy(parent, fd->keyoffset, node, 14, newkeylen); hfs_bnode_dump(parent); hfs_bnode_put(node); node = parent; if (new_node) { __be32 cnid; if (!new_node->parent) { hfs_btree_inc_height(tree); new_node->parent = tree->root; } fd->bnode = hfs_bnode_find(tree, new_node->parent); /* create index key and entry */ hfs_bnode_read_key(new_node, fd->search_key, 14); cnid = cpu_to_be32(new_node->this); __hfs_brec_find(fd->bnode, fd, hfs_find_rec_by_key); hfs_brec_insert(fd, &cnid, sizeof(cnid)); hfs_bnode_put(fd->bnode); hfs_bnode_put(new_node); if (!rec) { if (new_node == node) goto out; /* restore search_key */ hfs_bnode_read_key(node, fd->search_key, 14); } new_node = NULL; } if (!rec && node->parent) goto again; out: fd->bnode = node; return 0; } static int hfs_btree_inc_height(struct hfs_btree *tree) { struct hfs_bnode *node, *new_node; struct hfs_bnode_desc node_desc; int key_size, rec; __be32 cnid; node = NULL; if (tree->root) { node = hfs_bnode_find(tree, tree->root); if (IS_ERR(node)) return PTR_ERR(node); } new_node = hfs_bmap_alloc(tree); if (IS_ERR(new_node)) { hfs_bnode_put(node); return PTR_ERR(new_node); } tree->root = new_node->this; if (!tree->depth) { tree->leaf_head = tree->leaf_tail = new_node->this; new_node->type = HFS_NODE_LEAF; new_node->num_recs = 0; } else { new_node->type = HFS_NODE_INDEX; new_node->num_recs = 1; } new_node->parent = 0; new_node->next = 0; new_node->prev = 0; new_node->height = ++tree->depth; node_desc.next = cpu_to_be32(new_node->next); node_desc.prev = cpu_to_be32(new_node->prev); node_desc.type = new_node->type; node_desc.height = new_node->height; node_desc.num_recs = cpu_to_be16(new_node->num_recs); node_desc.reserved = 0; hfs_bnode_write(new_node, &node_desc, 0, sizeof(node_desc)); rec = tree->node_size - 2; hfs_bnode_write_u16(new_node, rec, 14); if (node) { /* insert old root idx into new root */ node->parent = tree->root; if (node->type == HFS_NODE_LEAF || tree->attributes & HFS_TREE_VARIDXKEYS || tree->cnid == HFSPLUS_ATTR_CNID) key_size = hfs_bnode_read_u16(node, 14) + 2; else key_size = tree->max_key_len + 2; hfs_bnode_copy(new_node, 14, node, 14, key_size); if (!(tree->attributes & HFS_TREE_VARIDXKEYS) && (tree->cnid != HFSPLUS_ATTR_CNID)) { key_size = tree->max_key_len + 2; hfs_bnode_write_u16(new_node, 14, tree->max_key_len); } cnid = cpu_to_be32(node->this); hfs_bnode_write(new_node, &cnid, 14 + key_size, 4); rec -= 2; hfs_bnode_write_u16(new_node, rec, 14 + key_size + 4); hfs_bnode_put(node); } hfs_bnode_put(new_node); mark_inode_dirty(tree->inode); return 0; }
{ "pile_set_name": "Github" }
module Main where import Control.Concurrent import Foreign.C import GHC.Clock import GHC.Event import System.CPUTime import System.Posix.Types foreign import ccall unsafe "socket" c_socket :: CInt -> CInt -> CInt -> IO CInt makeTestSocketFd :: IO Fd makeTestSocketFd = do sockNum <- c_socket 1 -- PF_LOCAL 2 -- SOCK_DGRAM 0 return $ (fromIntegral sockNum :: Fd) callback :: FdKey -> Event -> IO () callback _ _ = return () -- Idle CPU usage with 0 for 0% and 10^12 for 100% idleCpuUsage :: IO Double idleCpuUsage = do startTime <- getMonotonicTime startCPUTime <- getCPUTime threadDelay 5000000 endCPUTime <- getCPUTime endTime <- getMonotonicTime return $ fromIntegral (endCPUTime - startCPUTime) / (endTime - startTime) main :: IO () main = do (Just eventMgr) <- getSystemEventManager fd <- makeTestSocketFd noEventUsage <- idleCpuUsage registerFd eventMgr callback fd evtRead OneShot registerFd eventMgr callback fd evtWrite OneShot eventTriggeredUsage <- idleCpuUsage -- CPU consumption should roughly be the same when just idling vs -- when idling after the event been triggered print $ eventTriggeredUsage / noEventUsage < 100.0
{ "pile_set_name": "Github" }
squares = [] for value in range(1,11): square = value**2 squares.append(square) print(squares)
{ "pile_set_name": "Github" }
# AUTOGENERATED FILE FROM balenalib/imx8mm-var-dart-fedora:26-run # http://bugs.python.org/issue19846 # > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. ENV LANG C.UTF-8 RUN dnf install -y \ python3-pip \ python3-dbus \ && dnf clean all # install "virtualenv", since the vast majority of users of this image will want it RUN pip3 install -U --no-cache-dir --ignore-installed pip setuptools \ && pip3 install --no-cache-dir virtualenv RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo $'As of January 1st, 2020, Python 2 was end-of-life, we will change the latest tag for Balenalib Python base image to Python 3.x and drop support for Python 2 soon. So after 1st July, 2020, all the balenalib Python latest tag will point to the latest Python 3 version and no changes, or fixes will be made to balenalib Python 2 base image. If you are using Python 2 for your application, please upgrade to Python 3 before 1st July.' > /.balena/messages/python-deprecation-warnin CMD ["echo","'No CMD command was set in Dockerfile! Details about CMD command could be found in Dockerfile Guide section in our Docs. Here's the link: https://balena.io/docs"] RUN curl -SLO "https://raw.githubusercontent.com/balena-io-library/base-images/8accad6af708fca7271c5c65f18a86782e19f877/scripts/assets/tests/[email protected]" \ && echo "Running test-stack@python" \ && chmod +x [email protected] \ && bash [email protected] \ && rm -rf [email protected] RUN [ ! -d /.balena/messages ] && mkdir -p /.balena/messages; echo $'Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): \nArchitecture: ARM v8 \nOS: Fedora 26 \nVariant: run variant \nDefault variable(s): UDEV=off \nThe following software stack is preinstalled: \nPython v3.8.3, Pip v20.1.1, Setuptools v49.1.0 \nExtra features: \n- Easy way to install packages with `install_packages <package-name>` command \n- Run anywhere with cross-build feature (for ARM only) \n- Keep the container idling with `balena-idle` command \n- Show base image details with `balena-info` command' > /.balena/messages/image-info RUN echo $'#!/bin/sh.real\nbalena-info\nrm -f /bin/sh\ncp /bin/sh.real /bin/sh\n/bin/sh "$@"' > /bin/sh-shim \ && chmod +x /bin/sh-shim \ && cp /bin/sh /bin/sh.real \ && mv /bin/sh-shim /bin/sh
{ "pile_set_name": "Github" }
<?xml version="1.0" standalone='no'?><!--*-nxml-*--> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h HTTP</name> <service> <type>_http._tcp</type> <port>80</port> </service> </service-group>
{ "pile_set_name": "Github" }
/* * linux/drivers/serial/21285.c * * Driver for the serial port on the 21285 StrongArm-110 core logic chip. * * Based on drivers/char/serial.c * * $Id: 21285.c,v 1.37 2002/07/28 10:03:27 rmk Exp $ */ #include <linux/module.h> #include <linux/tty.h> #include <linux/ioport.h> #include <linux/init.h> #include <linux/console.h> #include <linux/device.h> #include <linux/tty_flip.h> #include <linux/serial_core.h> #include <linux/serial.h> #include <asm/io.h> #include <asm/irq.h> #include <asm/mach-types.h> #include <asm/hardware/dec21285.h> #include <asm/hardware.h> #define BAUD_BASE (mem_fclk_21285/64) #define SERIAL_21285_NAME "ttyFB" #define SERIAL_21285_MAJOR 204 #define SERIAL_21285_MINOR 4 #define RXSTAT_DUMMY_READ 0x80000000 #define RXSTAT_FRAME (1 << 0) #define RXSTAT_PARITY (1 << 1) #define RXSTAT_OVERRUN (1 << 2) #define RXSTAT_ANYERR (RXSTAT_FRAME|RXSTAT_PARITY|RXSTAT_OVERRUN) #define H_UBRLCR_BREAK (1 << 0) #define H_UBRLCR_PARENB (1 << 1) #define H_UBRLCR_PAREVN (1 << 2) #define H_UBRLCR_STOPB (1 << 3) #define H_UBRLCR_FIFO (1 << 4) static const char serial21285_name[] = "Footbridge UART"; #define tx_enabled(port) ((port)->unused[0]) #define rx_enabled(port) ((port)->unused[1]) /* * The documented expression for selecting the divisor is: * BAUD_BASE / baud - 1 * However, typically BAUD_BASE is not divisible by baud, so * we want to select the divisor that gives us the minimum * error. Therefore, we want: * int(BAUD_BASE / baud - 0.5) -> * int(BAUD_BASE / baud - (baud >> 1) / baud) -> * int((BAUD_BASE - (baud >> 1)) / baud) */ static void serial21285_stop_tx(struct uart_port *port) { if (tx_enabled(port)) { disable_irq(IRQ_CONTX); tx_enabled(port) = 0; } } static void serial21285_start_tx(struct uart_port *port) { if (!tx_enabled(port)) { enable_irq(IRQ_CONTX); tx_enabled(port) = 1; } } static void serial21285_stop_rx(struct uart_port *port) { if (rx_enabled(port)) { disable_irq(IRQ_CONRX); rx_enabled(port) = 0; } } static void serial21285_enable_ms(struct uart_port *port) { } static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) { struct uart_port *port = dev_id; struct tty_struct *tty = port->info->tty; unsigned int status, ch, flag, rxs, max_count = 256; status = *CSR_UARTFLG; while (!(status & 0x10) && max_count--) { ch = *CSR_UARTDR; flag = TTY_NORMAL; port->icount.rx++; rxs = *CSR_RXSTAT | RXSTAT_DUMMY_READ; if (unlikely(rxs & RXSTAT_ANYERR)) { if (rxs & RXSTAT_PARITY) port->icount.parity++; else if (rxs & RXSTAT_FRAME) port->icount.frame++; if (rxs & RXSTAT_OVERRUN) port->icount.overrun++; rxs &= port->read_status_mask; if (rxs & RXSTAT_PARITY) flag = TTY_PARITY; else if (rxs & RXSTAT_FRAME) flag = TTY_FRAME; } uart_insert_char(port, rxs, RXSTAT_OVERRUN, ch, flag); status = *CSR_UARTFLG; } tty_flip_buffer_push(tty); return IRQ_HANDLED; } static irqreturn_t serial21285_tx_chars(int irq, void *dev_id) { struct uart_port *port = dev_id; struct circ_buf *xmit = &port->info->xmit; int count = 256; if (port->x_char) { *CSR_UARTDR = port->x_char; port->icount.tx++; port->x_char = 0; goto out; } if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { serial21285_stop_tx(port); goto out; } do { *CSR_UARTDR = xmit->buf[xmit->tail]; xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); port->icount.tx++; if (uart_circ_empty(xmit)) break; } while (--count > 0 && !(*CSR_UARTFLG & 0x20)); if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) uart_write_wakeup(port); if (uart_circ_empty(xmit)) serial21285_stop_tx(port); out: return IRQ_HANDLED; } static unsigned int serial21285_tx_empty(struct uart_port *port) { return (*CSR_UARTFLG & 8) ? 0 : TIOCSER_TEMT; } /* no modem control lines */ static unsigned int serial21285_get_mctrl(struct uart_port *port) { return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; } static void serial21285_set_mctrl(struct uart_port *port, unsigned int mctrl) { } static void serial21285_break_ctl(struct uart_port *port, int break_state) { unsigned long flags; unsigned int h_lcr; spin_lock_irqsave(&port->lock, flags); h_lcr = *CSR_H_UBRLCR; if (break_state) h_lcr |= H_UBRLCR_BREAK; else h_lcr &= ~H_UBRLCR_BREAK; *CSR_H_UBRLCR = h_lcr; spin_unlock_irqrestore(&port->lock, flags); } static int serial21285_startup(struct uart_port *port) { int ret; tx_enabled(port) = 1; rx_enabled(port) = 1; ret = request_irq(IRQ_CONRX, serial21285_rx_chars, 0, serial21285_name, port); if (ret == 0) { ret = request_irq(IRQ_CONTX, serial21285_tx_chars, 0, serial21285_name, port); if (ret) free_irq(IRQ_CONRX, port); } return ret; } static void serial21285_shutdown(struct uart_port *port) { free_irq(IRQ_CONTX, port); free_irq(IRQ_CONRX, port); } static void serial21285_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old) { unsigned long flags; unsigned int baud, quot, h_lcr; /* * We don't support modem control lines. */ termios->c_cflag &= ~(HUPCL | CRTSCTS | CMSPAR); termios->c_cflag |= CLOCAL; /* * We don't support BREAK character recognition. */ termios->c_iflag &= ~(IGNBRK | BRKINT); /* * Ask the core to calculate the divisor for us. */ baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); quot = uart_get_divisor(port, baud); switch (termios->c_cflag & CSIZE) { case CS5: h_lcr = 0x00; break; case CS6: h_lcr = 0x20; break; case CS7: h_lcr = 0x40; break; default: /* CS8 */ h_lcr = 0x60; break; } if (termios->c_cflag & CSTOPB) h_lcr |= H_UBRLCR_STOPB; if (termios->c_cflag & PARENB) { h_lcr |= H_UBRLCR_PARENB; if (!(termios->c_cflag & PARODD)) h_lcr |= H_UBRLCR_PAREVN; } if (port->fifosize) h_lcr |= H_UBRLCR_FIFO; spin_lock_irqsave(&port->lock, flags); /* * Update the per-port timeout. */ uart_update_timeout(port, termios->c_cflag, baud); /* * Which character status flags are we interested in? */ port->read_status_mask = RXSTAT_OVERRUN; if (termios->c_iflag & INPCK) port->read_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; /* * Which character status flags should we ignore? */ port->ignore_status_mask = 0; if (termios->c_iflag & IGNPAR) port->ignore_status_mask |= RXSTAT_FRAME | RXSTAT_PARITY; if (termios->c_iflag & IGNBRK && termios->c_iflag & IGNPAR) port->ignore_status_mask |= RXSTAT_OVERRUN; /* * Ignore all characters if CREAD is not set. */ if ((termios->c_cflag & CREAD) == 0) port->ignore_status_mask |= RXSTAT_DUMMY_READ; quot -= 1; *CSR_UARTCON = 0; *CSR_L_UBRLCR = quot & 0xff; *CSR_M_UBRLCR = (quot >> 8) & 0x0f; *CSR_H_UBRLCR = h_lcr; *CSR_UARTCON = 1; spin_unlock_irqrestore(&port->lock, flags); } static const char *serial21285_type(struct uart_port *port) { return port->type == PORT_21285 ? "DC21285" : NULL; } static void serial21285_release_port(struct uart_port *port) { release_mem_region(port->mapbase, 32); } static int serial21285_request_port(struct uart_port *port) { return request_mem_region(port->mapbase, 32, serial21285_name) != NULL ? 0 : -EBUSY; } static void serial21285_config_port(struct uart_port *port, int flags) { if (flags & UART_CONFIG_TYPE && serial21285_request_port(port) == 0) port->type = PORT_21285; } /* * verify the new serial_struct (for TIOCSSERIAL). */ static int serial21285_verify_port(struct uart_port *port, struct serial_struct *ser) { int ret = 0; if (ser->type != PORT_UNKNOWN && ser->type != PORT_21285) ret = -EINVAL; if (ser->irq != NO_IRQ) ret = -EINVAL; if (ser->baud_base != port->uartclk / 16) ret = -EINVAL; return ret; } static struct uart_ops serial21285_ops = { .tx_empty = serial21285_tx_empty, .get_mctrl = serial21285_get_mctrl, .set_mctrl = serial21285_set_mctrl, .stop_tx = serial21285_stop_tx, .start_tx = serial21285_start_tx, .stop_rx = serial21285_stop_rx, .enable_ms = serial21285_enable_ms, .break_ctl = serial21285_break_ctl, .startup = serial21285_startup, .shutdown = serial21285_shutdown, .set_termios = serial21285_set_termios, .type = serial21285_type, .release_port = serial21285_release_port, .request_port = serial21285_request_port, .config_port = serial21285_config_port, .verify_port = serial21285_verify_port, }; static struct uart_port serial21285_port = { .mapbase = 0x42000160, .iotype = UPIO_MEM, .irq = NO_IRQ, .fifosize = 16, .ops = &serial21285_ops, .flags = UPF_BOOT_AUTOCONF, }; static void serial21285_setup_ports(void) { serial21285_port.uartclk = mem_fclk_21285 / 4; } #ifdef CONFIG_SERIAL_21285_CONSOLE static void serial21285_console_putchar(struct uart_port *port, int ch) { while (*CSR_UARTFLG & 0x20) barrier(); *CSR_UARTDR = ch; } static void serial21285_console_write(struct console *co, const char *s, unsigned int count) { uart_console_write(&serial21285_port, s, count, serial21285_console_putchar); } static void __init serial21285_get_options(struct uart_port *port, int *baud, int *parity, int *bits) { if (*CSR_UARTCON == 1) { unsigned int tmp; tmp = *CSR_H_UBRLCR; switch (tmp & 0x60) { case 0x00: *bits = 5; break; case 0x20: *bits = 6; break; case 0x40: *bits = 7; break; default: case 0x60: *bits = 8; break; } if (tmp & H_UBRLCR_PARENB) { *parity = 'o'; if (tmp & H_UBRLCR_PAREVN) *parity = 'e'; } tmp = *CSR_L_UBRLCR | (*CSR_M_UBRLCR << 8); *baud = port->uartclk / (16 * (tmp + 1)); } } static int __init serial21285_console_setup(struct console *co, char *options) { struct uart_port *port = &serial21285_port; int baud = 9600; int bits = 8; int parity = 'n'; int flow = 'n'; if (machine_is_personal_server()) baud = 57600; /* * Check whether an invalid uart number has been specified, and * if so, search for the first available port that does have * console support. */ if (options) uart_parse_options(options, &baud, &parity, &bits, &flow); else serial21285_get_options(port, &baud, &parity, &bits); return uart_set_options(port, co, baud, parity, bits, flow); } static struct uart_driver serial21285_reg; static struct console serial21285_console = { .name = SERIAL_21285_NAME, .write = serial21285_console_write, .device = uart_console_device, .setup = serial21285_console_setup, .flags = CON_PRINTBUFFER, .index = -1, .data = &serial21285_reg, }; static int __init rs285_console_init(void) { serial21285_setup_ports(); register_console(&serial21285_console); return 0; } console_initcall(rs285_console_init); #define SERIAL_21285_CONSOLE &serial21285_console #else #define SERIAL_21285_CONSOLE NULL #endif static struct uart_driver serial21285_reg = { .owner = THIS_MODULE, .driver_name = "ttyFB", .dev_name = "ttyFB", .major = SERIAL_21285_MAJOR, .minor = SERIAL_21285_MINOR, .nr = 1, .cons = SERIAL_21285_CONSOLE, }; static int __init serial21285_init(void) { int ret; printk(KERN_INFO "Serial: 21285 driver $Revision: 1.37 $\n"); serial21285_setup_ports(); ret = uart_register_driver(&serial21285_reg); if (ret == 0) uart_add_one_port(&serial21285_reg, &serial21285_port); return ret; } static void __exit serial21285_exit(void) { uart_remove_one_port(&serial21285_reg, &serial21285_port); uart_unregister_driver(&serial21285_reg); } module_init(serial21285_init); module_exit(serial21285_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Intel Footbridge (21285) serial driver $Revision: 1.37 $"); MODULE_ALIAS_CHARDEV(SERIAL_21285_MAJOR, SERIAL_21285_MINOR);
{ "pile_set_name": "Github" }
--TEST-- SOAP typemap 9: SoapServer support for typemap's from_xml() (SoapFault) --SKIPIF-- <?php require_once('skipif.inc'); ?> --INI-- soap.wsdl_cache_enabled=0 --FILE-- <?php $GLOBALS['HTTP_RAW_POST_DATA']=" <env:Envelope xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:ns1=\"http://schemas.nothing.com\" > <env:Body> <ns1:dotest> <book xsi:type=\"ns1:book\"> <a xsi:type=\"xsd:string\">foo</a> <b xsi:type=\"xsd:string\">bar</b> </book> </ns1:dotest> </env:Body> <env:Header/> </env:Envelope>"; function book_from_xml($xml) { throw new SoapFault("Server", "Conversion Failed"); } class test{ function dotest($book){ $classname=get_class($book); return "Object: ".$classname. "(".$book->a.",".$book->b.")"; } } class book{ public $a="a"; public $b="c"; } $options=Array( 'actor' =>'http://schemas.nothing.com', 'typemap' => array(array("type_ns" => "http://schemas.nothing.com", "type_name" => "book", "from_xml" => "book_from_xml")) ); $server = new SoapServer(dirname(__FILE__)."/classmap.wsdl",$options); $server->setClass("test"); $server->handle($HTTP_RAW_POST_DATA); echo "ok\n"; ?> --EXPECT-- <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Server</faultcode><faultstring>Conversion Failed</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope> ok
{ "pile_set_name": "Github" }
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Threading.Tasks; using Pulumi.Serialization; namespace Pulumi.Aws.WafV2.Inputs { public sealed class RuleGroupRuleStatementAndStatementStatementOrStatementStatementGetArgs : Pulumi.ResourceArgs { /// <summary> /// A rule statement that defines a string match search for AWS WAF to apply to web requests. See Byte Match Statement below for details. /// </summary> [Input("byteMatchStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementByteMatchStatementGetArgs>? ByteMatchStatement { get; set; } /// <summary> /// A rule statement used to identify web requests based on country of origin. See GEO Match Statement below for details. /// </summary> [Input("geoMatchStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementGeoMatchStatementGetArgs>? GeoMatchStatement { get; set; } /// <summary> /// A rule statement used to detect web requests coming from particular IP addresses or address ranges. See IP Set Reference Statement below for details. /// </summary> [Input("ipSetReferenceStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementIpSetReferenceStatementGetArgs>? IpSetReferenceStatement { get; set; } /// <summary> /// A rule statement used to search web request components for matches with regular expressions. See Regex Pattern Set Reference Statement below for details. /// </summary> [Input("regexPatternSetReferenceStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementRegexPatternSetReferenceStatementGetArgs>? RegexPatternSetReferenceStatement { get; set; } /// <summary> /// A rule statement that compares a number of bytes against the size of a request component, using a comparison operator, such as greater than (&gt;) or less than (&lt;). See Size Constraint Statement below for more details. /// </summary> [Input("sizeConstraintStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementSizeConstraintStatementGetArgs>? SizeConstraintStatement { get; set; } /// <summary> /// An SQL injection match condition identifies the part of web requests, such as the URI or the query string, that you want AWS WAF to inspect. See SQL Injection Match Statement below for details. /// </summary> [Input("sqliMatchStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementSqliMatchStatementGetArgs>? SqliMatchStatement { get; set; } /// <summary> /// A rule statement that defines a cross-site scripting (XSS) match search for AWS WAF to apply to web requests. See XSS Match Statement below for details. /// </summary> [Input("xssMatchStatement")] public Input<Inputs.RuleGroupRuleStatementAndStatementStatementOrStatementStatementXssMatchStatementGetArgs>? XssMatchStatement { get; set; } public RuleGroupRuleStatementAndStatementStatementOrStatementStatementGetArgs() { } } }
{ "pile_set_name": "Github" }
// This file is part of Eigen, a lightweight C++ template library // for linear algebra. // // Copyright (C) 2012 Désiré Nuentsa-Wakam <[email protected]> // // 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/. /* * NOTE: This file is the modified version of [s,d,c,z]pruneL.c file in SuperLU * -- SuperLU routine (version 2.0) -- * Univ. of California Berkeley, Xerox Palo Alto Research Center, * and Lawrence Berkeley National Lab. * November 15, 1997 * * Copyright (c) 1994 by Xerox Corporation. All rights reserved. * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY * EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK. * * Permission is hereby granted to use or copy this program for any * purpose, provided the above notices are retained on all copies. * Permission to modify the code and to distribute modified code is * granted, provided the above notices are retained, and a notice that * the code was modified is included with the above copyright notice. */ #ifndef SPARSELU_PRUNEL_H #define SPARSELU_PRUNEL_H namespace Eigen { namespace internal { /** * \brief Prunes the L-structure. * * It prunes the L-structure of supernodes whose L-structure contains the current pivot row "pivrow" * * * \param jcol The current column of L * \param[in] perm_r Row permutation * \param[out] pivrow The pivot row * \param nseg Number of segments * \param segrep * \param repfnz * \param[out] xprune * \param glu Global LU data * */ template <typename Scalar, typename StorageIndex> void SparseLUImpl<Scalar,StorageIndex>::pruneL(const Index jcol, const IndexVector& perm_r, const Index pivrow, const Index nseg, const IndexVector& segrep, BlockIndexVector repfnz, IndexVector& xprune, GlobalLU_t& glu) { // For each supernode-rep irep in U(*,j] Index jsupno = glu.supno(jcol); Index i,irep,irep1; bool movnum, do_prune = false; Index kmin = 0, kmax = 0, minloc, maxloc,krow; for (i = 0; i < nseg; i++) { irep = segrep(i); irep1 = irep + 1; do_prune = false; // Don't prune with a zero U-segment if (repfnz(irep) == emptyIdxLU) continue; // If a snode overlaps with the next panel, then the U-segment // is fragmented into two parts -- irep and irep1. We should let // pruning occur at the rep-column in irep1s snode. if (glu.supno(irep) == glu.supno(irep1) ) continue; // don't prune // If it has not been pruned & it has a nonz in row L(pivrow,i) if (glu.supno(irep) != jsupno ) { if ( xprune (irep) >= glu.xlsub(irep1) ) { kmin = glu.xlsub(irep); kmax = glu.xlsub(irep1) - 1; for (krow = kmin; krow <= kmax; krow++) { if (glu.lsub(krow) == pivrow) { do_prune = true; break; } } } if (do_prune) { // do a quicksort-type partition // movnum=true means that the num values have to be exchanged movnum = false; if (irep == glu.xsup(glu.supno(irep)) ) // Snode of size 1 movnum = true; while (kmin <= kmax) { if (perm_r(glu.lsub(kmax)) == emptyIdxLU) kmax--; else if ( perm_r(glu.lsub(kmin)) != emptyIdxLU) kmin++; else { // kmin below pivrow (not yet pivoted), and kmax // above pivrow: interchange the two suscripts std::swap(glu.lsub(kmin), glu.lsub(kmax)); // If the supernode has only one column, then we // only keep one set of subscripts. For any subscript // intercnahge performed, similar interchange must be // done on the numerical values. if (movnum) { minloc = glu.xlusup(irep) + ( kmin - glu.xlsub(irep) ); maxloc = glu.xlusup(irep) + ( kmax - glu.xlsub(irep) ); std::swap(glu.lusup(minloc), glu.lusup(maxloc)); } kmin++; kmax--; } } // end while xprune(irep) = StorageIndex(kmin); //Pruning } // end if do_prune } // end pruning } // End for each U-segment } } // end namespace internal } // end namespace Eigen #endif // SPARSELU_PRUNEL_H
{ "pile_set_name": "Github" }
package com.szysky.customize.siv.range; import android.content.Context; import android.graphics.Point; import com.szysky.customize.siv.util.UIUtils; import java.util.ArrayList; /** * Author : suzeyu * Time : 2016-12-01 下午11:14 * Blog : http://szysky.com * GitHub : https://github.com/suzeyu1992 * ClassDescription : 微信 measure测量布局实现 */ public class WeChatLayoutManager implements ILayoutManager { private final Context context; /** * 缓存返回子元素布局对象 */ private final ArrayList<LayoutInfoGroup> mCacheList; /** * 布局子元素的下标 */ private int curCachePoint ; /** * 子元素的空隙, 例如两个图片的距离. 单位dp */ private float mSpacing = 1f; public WeChatLayoutManager(Context context) { this.context = context; // 创建子元素的布局对象集合, 用于后续使用 mCacheList = new ArrayList<>(); for (int i = 0; i < 9; i++) { LayoutInfoGroup layout = new LayoutInfoGroup(); layout.leftTopPoint = new Point(); layout.rightBottomPoint = new Point(); mCacheList.add(layout); } curCachePoint = 8; } @Override public ArrayList<LayoutInfoGroup> calculate(int viewWidth, int viewHeight, int viewNum) { // 缓存集合清除无用信息 cleanMaskCache(); // 默认微信群组效果只支持9张最大图片 if (viewNum > 9){ viewNum = 9; }else if (viewNum < 1){ throw new UnsupportedOperationException("不支持操作异常"); } // 容错控件非正方形场景处理 int layoutSquareSide ; // 正方形边长 if (viewWidth != viewHeight){ if (viewHeight - viewWidth > 0){ layoutSquareSide = viewWidth; }else{ layoutSquareSide = viewHeight; } }else{ layoutSquareSide = viewWidth; } // 返回的所有子元素布局信息集合 ArrayList<LayoutInfoGroup> infos = new ArrayList<>(); int half =0; // 子元素的边长 // 开始测量布局 if (viewNum == 1){ half = layoutSquareSide ; infos.add(createChildrenForTop(viewWidth/2 - half/2 , viewHeight/2 - half/2,half)); }else if(viewNum == 2){ half = layoutSquareSide / 2; fastTwoChild(viewWidth,(viewHeight-half)/2,half, infos ); }else if (viewNum == 3){ half = layoutSquareSide / 2; infos.add(createChildrenForTop(viewWidth/2 - half/2 , viewHeight/2 - half,half)); fastTwoChild(viewWidth,viewHeight/2,half, infos ); }else if (viewNum == 4){ half = layoutSquareSide / 2; fastTwoChild(viewWidth,viewHeight/2 - half,half, infos ); fastTwoChild(viewWidth,viewHeight/2 ,half, infos ); }else if (viewNum == 5){ half = layoutSquareSide / 3; fastTwoChild(viewWidth,viewHeight/2 - half,half, infos ); fastThreeChild(viewWidth, viewHeight/2, half, infos); }else if (viewNum == 6){ half = layoutSquareSide / 3; fastThreeChild(viewWidth, viewHeight/2 - half, half, infos); fastThreeChild(viewWidth, viewHeight/2, half, infos); }else if (viewNum == 7){ half = layoutSquareSide / 3; infos.add(createChildrenForTop(viewWidth/2 - half/2 , viewHeight/2 - half/2*3,half)); fastThreeChild(viewWidth, viewHeight/2 - half/2, half, infos); fastThreeChild(viewWidth, viewHeight/2 + half/2, half, infos); }else if (viewNum == 8){ half = layoutSquareSide / 3; fastTwoChild(viewWidth, viewHeight/2 - half/2*3 ,half,infos ); fastThreeChild(viewWidth, viewHeight/2 - half/2, half, infos); fastThreeChild(viewWidth, viewHeight/2 + half/2, half, infos); }else if (viewNum == 9){ half = layoutSquareSide / 3; fastThreeChild(viewWidth, viewHeight/2 - half/2*3, half, infos); fastThreeChild(viewWidth, viewHeight/2 - half/2, half, infos); fastThreeChild(viewWidth, viewHeight/2 + half/2, half, infos); } // 添加子元素之间的空隙 if (mSpacing > 0 && half > 0){ addSpacing(mSpacing, half, infos); } return infos; } /**存储子元素测量数据初始化**/ private void cleanMaskCache() { for (LayoutInfoGroup layoutInfoGroup : mCacheList) { layoutInfoGroup.leftTopPoint.set(0,0); layoutInfoGroup.rightBottomPoint.set(0,0); layoutInfoGroup.innerHeight = layoutInfoGroup.innerWidth = 0; } curCachePoint = 0; } /**对布局元素中的每个子元素添加空隙**/ private void addSpacing(float dp, int side , ArrayList<LayoutInfoGroup> datas){ int addPixel = (int) UIUtils.dip2px(context, dp); // 每个子元素的空隙不得超出子元素边长的三分之一 addPixel = addPixel > side/3 ? side/3 : addPixel ; // 开始添加空隙 for (LayoutInfoGroup data : datas) { data.innerHeight = data.innerWidth = data.innerWidth-2*addPixel; data.rightBottomPoint.set(data.rightBottomPoint.x - addPixel, data.rightBottomPoint.y - addPixel); data.leftTopPoint.set(data.leftTopPoint.x + addPixel, data.leftTopPoint.y + addPixel); } } /** * 通过左上点 创建子元素布局信息 * @param left 右上点的x * @param top 右上点的y * @param side 需要画出子元素的边长 */ private LayoutInfoGroup createChildrenForTop(int left, int top, int side){ LayoutInfoGroup childLayout = mCacheList.get(curCachePoint); childLayout.innerHeight = childLayout.innerWidth = side; childLayout.leftTopPoint.set(left, top); childLayout.rightBottomPoint.set(left + side, top+side); curCachePoint++; return childLayout; } /** * 通过右下点 创建子元素布局信息 * @param right 右下点的x * @param bottom 右下点的y * @param side 需要画出子元素的边长 */ private LayoutInfoGroup createChildrenForBottom(int right, int bottom, int side){ LayoutInfoGroup childLayout = mCacheList.get(curCachePoint); childLayout.innerHeight = childLayout.innerWidth = side; childLayout.leftTopPoint.set(right-side, bottom-side); childLayout.rightBottomPoint.set(right, bottom); curCachePoint++; return childLayout; } /** * 快速创建一个水平线两个子元素的场景, 如微信群组的, 2人, 3人, 4人, 5人, 8人 * @param viewWidth 控件的宽度 * @param positiveY 这一个水平线两张图片的左上角的y点 * @param side 子元素的边长 * @param mLayouts 布局集合 */ private void fastTwoChild(int viewWidth, int positiveY, int side, ArrayList<LayoutInfoGroup> mLayouts){ // 第一个元素 mLayouts.add(createChildrenForTop(viewWidth/2 - side , positiveY, side )); // 第二个元素 mLayouts.add(createChildrenForTop(viewWidth/2 , positiveY, side )); } /** * 快速创建一个水平线三个子元素的场景, 如微信群组的, 5人, 6人, 7人, 8人, 9人时 * @param viewWidth 控件的宽度 * @param positiveY 这一个水平线两张图片的左上角的y点 * @param side 子元素的边长 * @param mLayouts 布局集合 */ private void fastThreeChild(int viewWidth, int positiveY, int side, ArrayList<LayoutInfoGroup> mLayouts){ mLayouts.add(createChildrenForTop(viewWidth/2 - side/2*3 , positiveY, side )); mLayouts.add(createChildrenForTop(viewWidth/2 - side/2 , positiveY, side )); mLayouts.add(createChildrenForTop(viewWidth/2 + side/2 , positiveY, side )); } /** * 获取子元素的空隙 * @return 返回单位dp */ public float getSpacing() { return mSpacing; } /** * 设置子元素间的空隙 * @param mSpacing 单位dp */ public void setSpacing(float mSpacing) { this.mSpacing = mSpacing; } }
{ "pile_set_name": "Github" }
// Copyright Peter Dimov 2001 // Copyright Aleksey Gurtovoy 2001-2004 // // 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) // // Preprocessed version of "boost/mpl/bind.hpp" header // -- DO NOT modify by hand! namespace boost { namespace mpl { namespace aux { template< typename T, typename U1, typename U2, typename U3, typename U4 , typename U5 > struct resolve_bind_arg { typedef T type; }; template< typename T , typename Arg > struct replace_unnamed_arg { typedef Arg next; typedef T type; }; template< typename Arg > struct replace_unnamed_arg< arg< -1 >, Arg > { typedef typename Arg::next next; typedef Arg type; }; template< int N, typename U1, typename U2, typename U3, typename U4, typename U5 > struct resolve_bind_arg< arg<N>, U1, U2, U3, U4, U5 > { typedef typename apply_wrap5<mpl::arg<N>, U1, U2, U3, U4, U5>::type type; }; template< typename F, typename T1, typename T2, typename T3, typename T4 , typename T5, typename U1, typename U2, typename U3, typename U4 , typename U5 > struct resolve_bind_arg< bind< F,T1,T2,T3,T4,T5 >, U1, U2, U3, U4, U5 > { typedef bind< F,T1,T2,T3,T4,T5 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux template< typename F > struct bind0 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// public: typedef typename apply_wrap0< f_ >::type type; }; }; namespace aux { template< typename F, typename U1, typename U2, typename U3, typename U4 , typename U5 > struct resolve_bind_arg< bind0<F>, U1, U2, U3, U4, U5 > { typedef bind0<F> f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(1, bind0) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(1, bind0) template< typename F > struct bind< F,na,na,na,na,na > : bind0<F> { }; template< typename F, typename T1 > struct bind1 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// public: typedef typename apply_wrap1< f_ , typename t1::type >::type type; }; }; namespace aux { template< typename F, typename T1, typename U1, typename U2, typename U3 , typename U4, typename U5 > struct resolve_bind_arg< bind1< F,T1 >, U1, U2, U3, U4, U5 > { typedef bind1< F,T1 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(2, bind1) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(2, bind1) template< typename F, typename T1 > struct bind< F,T1,na,na,na,na > : bind1< F,T1 > { }; template< typename F, typename T1, typename T2 > struct bind2 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// public: typedef typename apply_wrap2< f_ , typename t1::type, typename t2::type >::type type; }; }; namespace aux { template< typename F, typename T1, typename T2, typename U1, typename U2 , typename U3, typename U4, typename U5 > struct resolve_bind_arg< bind2< F,T1,T2 >, U1, U2, U3, U4, U5 > { typedef bind2< F,T1,T2 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(3, bind2) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(3, bind2) template< typename F, typename T1, typename T2 > struct bind< F,T1,T2,na,na,na > : bind2< F,T1,T2 > { }; template< typename F, typename T1, typename T2, typename T3 > struct bind3 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// typedef aux::replace_unnamed_arg< T3,n3 > r3; typedef typename r3::type a3; typedef typename r3::next n4; typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3; /// public: typedef typename apply_wrap3< f_ , typename t1::type, typename t2::type, typename t3::type >::type type; }; }; namespace aux { template< typename F, typename T1, typename T2, typename T3, typename U1 , typename U2, typename U3, typename U4, typename U5 > struct resolve_bind_arg< bind3< F,T1,T2,T3 >, U1, U2, U3, U4, U5 > { typedef bind3< F,T1,T2,T3 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(4, bind3) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(4, bind3) template< typename F, typename T1, typename T2, typename T3 > struct bind< F,T1,T2,T3,na,na > : bind3< F,T1,T2,T3 > { }; template< typename F, typename T1, typename T2, typename T3, typename T4 > struct bind4 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// typedef aux::replace_unnamed_arg< T3,n3 > r3; typedef typename r3::type a3; typedef typename r3::next n4; typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3; /// typedef aux::replace_unnamed_arg< T4,n4 > r4; typedef typename r4::type a4; typedef typename r4::next n5; typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4; /// public: typedef typename apply_wrap4< f_ , typename t1::type, typename t2::type, typename t3::type , typename t4::type >::type type; }; }; namespace aux { template< typename F, typename T1, typename T2, typename T3, typename T4 , typename U1, typename U2, typename U3, typename U4, typename U5 > struct resolve_bind_arg< bind4< F,T1,T2,T3,T4 >, U1, U2, U3, U4, U5 > { typedef bind4< F,T1,T2,T3,T4 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(5, bind4) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(5, bind4) template< typename F, typename T1, typename T2, typename T3, typename T4 > struct bind< F,T1,T2,T3,T4,na > : bind4< F,T1,T2,T3,T4 > { }; template< typename F, typename T1, typename T2, typename T3, typename T4 , typename T5 > struct bind5 { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef aux::replace_unnamed_arg< F, mpl::arg<1> > r0; typedef typename r0::type a0; typedef typename r0::next n1; typedef typename aux::resolve_bind_arg< a0,U1,U2,U3,U4,U5 >::type f_; /// typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// typedef aux::replace_unnamed_arg< T3,n3 > r3; typedef typename r3::type a3; typedef typename r3::next n4; typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3; /// typedef aux::replace_unnamed_arg< T4,n4 > r4; typedef typename r4::type a4; typedef typename r4::next n5; typedef aux::resolve_bind_arg< a4,U1,U2,U3,U4,U5 > t4; /// typedef aux::replace_unnamed_arg< T5,n5 > r5; typedef typename r5::type a5; typedef typename r5::next n6; typedef aux::resolve_bind_arg< a5,U1,U2,U3,U4,U5 > t5; /// public: typedef typename apply_wrap5< f_ , typename t1::type, typename t2::type, typename t3::type , typename t4::type, typename t5::type >::type type; }; }; namespace aux { template< typename F, typename T1, typename T2, typename T3, typename T4 , typename T5, typename U1, typename U2, typename U3, typename U4 , typename U5 > struct resolve_bind_arg< bind5< F,T1,T2,T3,T4,T5 >, U1, U2, U3, U4, U5 > { typedef bind5< F,T1,T2,T3,T4,T5 > f_; typedef typename apply_wrap5< f_,U1,U2,U3,U4,U5 >::type type; }; } // namespace aux BOOST_MPL_AUX_ARITY_SPEC(6, bind5) BOOST_MPL_AUX_TEMPLATE_ARITY_SPEC(6, bind5) /// primary template (not a specialization!) template< typename F, typename T1, typename T2, typename T3, typename T4 , typename T5 > struct bind : bind5< F,T1,T2,T3,T4,T5 > { }; /// if_/eval_if specializations template< template< typename T1, typename T2, typename T3 > class F, typename Tag > struct quote3; template< typename T1, typename T2, typename T3 > struct if_; template< typename Tag, typename T1, typename T2, typename T3 > struct bind3< quote3< if_,Tag > , T1, T2, T3 > { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef mpl::arg<1> n1; typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// typedef aux::replace_unnamed_arg< T3,n3 > r3; typedef typename r3::type a3; typedef typename r3::next n4; typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3; /// typedef typename if_< typename t1::type , t2, t3 >::type f_; public: typedef typename f_::type type; }; }; template< template< typename T1, typename T2, typename T3 > class F, typename Tag > struct quote3; template< typename T1, typename T2, typename T3 > struct eval_if; template< typename Tag, typename T1, typename T2, typename T3 > struct bind3< quote3< eval_if,Tag > , T1, T2, T3 > { template< typename U1 = na, typename U2 = na, typename U3 = na , typename U4 = na, typename U5 = na > struct apply { private: typedef mpl::arg<1> n1; typedef aux::replace_unnamed_arg< T1,n1 > r1; typedef typename r1::type a1; typedef typename r1::next n2; typedef aux::resolve_bind_arg< a1,U1,U2,U3,U4,U5 > t1; /// typedef aux::replace_unnamed_arg< T2,n2 > r2; typedef typename r2::type a2; typedef typename r2::next n3; typedef aux::resolve_bind_arg< a2,U1,U2,U3,U4,U5 > t2; /// typedef aux::replace_unnamed_arg< T3,n3 > r3; typedef typename r3::type a3; typedef typename r3::next n4; typedef aux::resolve_bind_arg< a3,U1,U2,U3,U4,U5 > t3; /// typedef typename eval_if< typename t1::type , t2, t3 >::type f_; public: typedef typename f_::type type; }; }; }}
{ "pile_set_name": "Github" }
/* * Licensed to the Apache Software Foundation (ASF) under one or more contributor license * agreements. See the NOTICE file distributed with this work for additional information regarding * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance with the License. You may obtain a * copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ package org.apache.geode.internal.cache.tier.sockets.command; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import org.apache.geode.annotations.Immutable; import org.apache.geode.cache.Region; import org.apache.geode.cache.TransactionException; import org.apache.geode.cache.operations.KeySetOperationContext; import org.apache.geode.internal.cache.LocalRegion; import org.apache.geode.internal.cache.TXManagerImpl; import org.apache.geode.internal.cache.tier.Command; import org.apache.geode.internal.cache.tier.MessageType; import org.apache.geode.internal.cache.tier.sockets.BaseCommand; import org.apache.geode.internal.cache.tier.sockets.ChunkedMessage; import org.apache.geode.internal.cache.tier.sockets.Message; import org.apache.geode.internal.cache.tier.sockets.Part; import org.apache.geode.internal.cache.tier.sockets.ServerConnection; import org.apache.geode.internal.security.AuthorizeRequest; import org.apache.geode.internal.security.AuthorizeRequestPP; import org.apache.geode.internal.security.SecurityService; import org.apache.geode.security.NotAuthorizedException; import org.apache.geode.security.ResourcePermission.Operation; import org.apache.geode.security.ResourcePermission.Resource; public class KeySet extends BaseCommand { @Immutable private static final KeySet singleton = new KeySet(); public static Command getCommand() { return singleton; } @Override public void cmdExecute(final Message clientMessage, final ServerConnection serverConnection, final SecurityService securityService, long start) throws IOException, InterruptedException { Part regionNamePart = null; String regionName = null; serverConnection.setAsTrue(REQUIRES_RESPONSE); serverConnection.setAsTrue(REQUIRES_CHUNKED_RESPONSE); // Retrieve the region name from the message parts regionNamePart = clientMessage.getPart(0); regionName = regionNamePart.getCachedString(); ChunkedMessage chunkedResponseMsg = serverConnection.getChunkedResponseMessage(); final boolean isDebugEnabled = logger.isDebugEnabled(); if (isDebugEnabled) { logger.debug("{}: Received key set request ({} bytes) from {} for region {}", serverConnection.getName(), clientMessage.getPayloadLength(), serverConnection.getSocketString(), regionName); } // Process the key set request if (regionName == null) { String message = null; // if (regionName == null) (can only be null) { message = String.format("%s: The input region name for the key set request is null", serverConnection.getName()); logger.warn("{}: The input region name for the key set request is null", serverConnection.getName()); } writeKeySetErrorResponse(clientMessage, MessageType.KEY_SET_DATA_ERROR, message, serverConnection); serverConnection.setAsTrue(RESPONDED); return; } LocalRegion region = (LocalRegion) serverConnection.getCache().getRegion(regionName); if (region == null) { String reason = String.format("%s was not found during key set request", regionName); writeRegionDestroyedEx(clientMessage, regionName, reason, serverConnection); serverConnection.setAsTrue(RESPONDED); return; } if (isInTransaction() && region.getPartitionAttributes() != null) { // GEODE-5186: fail the the transaction if it is a retry after failover for keySet on // partitioned region if (clientMessage.isRetry()) { keySetWriteChunkedException(clientMessage, new TransactionException( "Failover on a set operation of a partitioned region is not allowed in a transaction."), serverConnection); serverConnection.setAsTrue(RESPONDED); return; } } try { securityService.authorize(Resource.DATA, Operation.READ, regionName); } catch (NotAuthorizedException ex) { keySetWriteChunkedException(clientMessage, ex, serverConnection); serverConnection.setAsTrue(RESPONDED); return; } KeySetOperationContext keySetContext = null; AuthorizeRequest authzRequest = serverConnection.getAuthzRequest(); if (authzRequest != null) { try { keySetContext = authzRequest.keySetAuthorize(regionName); } catch (NotAuthorizedException ex) { writeChunkedException(clientMessage, ex, serverConnection); serverConnection.setAsTrue(RESPONDED); return; } } // Update the statistics and write the reply // bserverStats.incLong(processDestroyTimeId, // DistributionStats.getStatTime() - start); // start = DistributionStats.getStatTime(); // Send header chunkedResponseMsg.setMessageType(MessageType.RESPONSE); chunkedResponseMsg.setTransactionId(clientMessage.getTransactionId()); chunkedResponseMsg.sendHeader(); // Send chunk response try { fillAndSendKeySetResponseChunks(region, regionName, keySetContext, serverConnection); serverConnection.setAsTrue(RESPONDED); } catch (Exception e) { // If an interrupted exception is thrown , rethrow it checkForInterrupt(serverConnection, e); // Otherwise, write an exception message and continue writeChunkedException(clientMessage, e, serverConnection, serverConnection.getChunkedResponseMessage()); serverConnection.setAsTrue(RESPONDED); return; } if (isDebugEnabled) { // logger.fine(getName() + ": Sent chunk (1 of 1) of register interest // response (" + chunkedResponseMsg.getBufferLength() + " bytes) for // region " + regionName + " key " + key); logger.debug("{}: Sent key set response for the region {}", serverConnection.getName(), regionName); } // bserverStats.incLong(writeDestroyResponseTimeId, // DistributionStats.getStatTime() - start); // bserverStats.incInt(destroyResponsesId, 1); } protected void keySetWriteChunkedException(Message clientMessage, Throwable ex, ServerConnection serverConnection) throws IOException { writeChunkedException(clientMessage, ex, serverConnection); } private void fillAndSendKeySetResponseChunks(LocalRegion region, String regionName, KeySetOperationContext context, ServerConnection servConn) throws IOException { // Get the key set Set keySet = region.keys(); KeySetOperationContext keySetContext = context; // Post-operation filtering AuthorizeRequestPP postAuthzRequest = servConn.getPostAuthzRequest(); if (postAuthzRequest != null) { keySetContext = postAuthzRequest.keySetAuthorize(regionName, keySet, keySetContext); keySet = keySetContext.getKeySet(); } List keyList = new ArrayList(MAXIMUM_CHUNK_SIZE); final boolean isTraceEnabled = logger.isTraceEnabled(); for (Iterator it = keySet.iterator(); it.hasNext();) { Object entryKey = it.next(); keyList.add(entryKey); if (isTraceEnabled) { logger.trace("{}: fillAndSendKeySetResponseKey <{}>; list size was {}; region: {}", servConn.getName(), entryKey, keyList.size(), region.getFullPath()); } if (keyList.size() == MAXIMUM_CHUNK_SIZE) { // Send the chunk and clear the list sendKeySetResponseChunk(region, keyList, false, servConn); keyList.clear(); } } // Send the last chunk even if the list is of zero size. sendKeySetResponseChunk(region, keyList, true, servConn); } private static void sendKeySetResponseChunk(Region region, List list, boolean lastChunk, ServerConnection servConn) throws IOException { ChunkedMessage chunkedResponseMsg = servConn.getChunkedResponseMessage(); chunkedResponseMsg.setNumberOfParts(1); chunkedResponseMsg.setLastChunk(lastChunk); chunkedResponseMsg.addObjPart(list, false); if (logger.isDebugEnabled()) { logger.debug("{}: Sending {} key set response chunk for region={}{}", servConn.getName(), (lastChunk ? " last " : " "), region.getFullPath(), (logger.isTraceEnabled() ? " keys=" + list + " chunk=<" + chunkedResponseMsg + ">" : "")); } chunkedResponseMsg.sendChunk(servConn); } boolean isInTransaction() { return TXManagerImpl.getCurrentTXState() != null; } }
{ "pile_set_name": "Github" }
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Example - example-example40-jquery</title> <script src="../../components/jquery-2.1.1/jquery.js"></script> <script src="../../../angular.js"></script> <script src="script.js"></script> </head> <body ng-app="xmpl"> <div ng-controller="XmplController"> {{ greeting }} </div> </body> </html>
{ "pile_set_name": "Github" }
import { chakra, forwardRef, PropsOf, omitThemingProps, StylesProvider, SystemProps, ThemingProps, useMultiStyleConfig, useStyles, } from "@chakra-ui/system" import { cx, getValidChildren, __DEV__ } from "@chakra-ui/utils" import * as React from "react" export interface BreadcrumbSeparatorProps extends PropsOf<typeof chakra.div> { spacing?: SystemProps["mx"] } /** * React component that separates each breadcrumb link */ export const BreadcrumbSeparator = forwardRef<BreadcrumbSeparatorProps, "span">( function BreadcrumbSeparator(props, ref) { const { spacing, ...rest } = props const styles = useStyles() const separatorStyles = { mx: spacing, ...styles.separator, } return ( <chakra.span ref={ref} role="presentation" {...rest} __css={separatorStyles} /> ) }, ) if (__DEV__) { BreadcrumbSeparator.displayName = "BreadcrumbSeparator" } export interface BreadcrumbLinkProps extends PropsOf<typeof chakra.a> { isCurrentPage?: boolean } /** * Breadcrumb link. * * It renders a `span` when it's the current link. Otherwise, * it renders an anchor tag. */ export const BreadcrumbLink = forwardRef<BreadcrumbLinkProps, "a">( function BreadcrumbLink(props, ref) { const { isCurrentPage, as, className, ...rest } = props const styles = useStyles() const sharedProps = { ref, as, className: cx("chakra-breadcrumb__link", className), ...rest, } if (isCurrentPage) { return <chakra.span aria-current="page" {...sharedProps} /> } return <chakra.a __css={styles.link} {...sharedProps} /> }, ) if (__DEV__) { BreadcrumbLink.displayName = "BreadcrumbLink" } interface BreadcrumbItemOptions extends BreadcrumbOptions { isCurrentPage?: boolean isLastChild?: boolean } export interface BreadcrumbItemProps extends BreadcrumbItemOptions, PropsOf<typeof chakra.li> {} /** * BreadcrumbItem is used to group a breadcrumb link. * It renders a `li` element to denote it belongs to an order list of links. * * @see Docs https://chakra-ui.com/components/breadcrumbs */ export const BreadcrumbItem = forwardRef<BreadcrumbItemProps, "li">( function BreadcrumbItem(props, ref) { const { isCurrentPage, separator, isLastChild, spacing, children, className, ...rest } = props const validChildren = getValidChildren(children) const clones = validChildren.map((child) => { if (child.type === BreadcrumbLink) { return React.cloneElement(child, { isCurrentPage, }) } if (child.type === BreadcrumbSeparator) { return React.cloneElement(child, { spacing, children: child.props.children || separator, }) } return child }) const _className = cx("chakra-breadcrumb__list-item", className) return ( <chakra.li ref={ref} className={_className} {...rest} __css={{ display: "inline-flex", alignItems: "center", }} > {clones} {!isLastChild && ( <BreadcrumbSeparator spacing={spacing} children={separator} /> )} </chakra.li> ) }, ) if (__DEV__) { BreadcrumbItem.displayName = "BreadcrumbItem" } export interface BreadcrumbOptions { /** * The visual separator between each breadcrumb item */ separator?: string | React.ReactElement /** * The left and right margin applied to the separator */ spacing?: SystemProps["mx"] } export interface BreadcrumbProps extends PropsOf<typeof chakra.nav>, BreadcrumbOptions, ThemingProps {} /** * Breadcrumb is used to render a breadcrumb navigation landmark. * It renders a `nav` element with `aria-label` set to `Breadcrumb` * * @see Docs https://chakra-ui.com/components/breadcrumbs */ export const Breadcrumb = forwardRef<BreadcrumbProps, "nav">( function Breadcrumb(props, ref) { const styles = useMultiStyleConfig("Breadcrumb", props) const ownProps = omitThemingProps(props) const { children, spacing = "0.5rem", separator = "/", className, ...rest } = ownProps const validChildren = getValidChildren(children) const count = validChildren.length const clones = validChildren.map((child, index) => React.cloneElement(child, { separator, spacing, isLastChild: count === index + 1, }), ) const _className = cx("chakra-breadcrumb", className) return ( <chakra.nav ref={ref} aria-label="breadcrumb" className={_className} {...rest} > <StylesProvider value={styles}> <chakra.ol className="chakra-breadcrumb__list">{clones}</chakra.ol> </StylesProvider> </chakra.nav> ) }, ) if (__DEV__) { Breadcrumb.displayName = "Breadcrumb" }
{ "pile_set_name": "Github" }
<?xml version="1.0"?> <CONFIG> <ProjectOptions> <Version Value="9"/> <General> <Flags> <MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasTitleStatement Value="False"/> </Flags> <SessionStorage Value="InProjectDir"/> <MainUnit Value="0"/> <UseAppBundle Value="False"/> <ResourceType Value="res"/> </General> <i18n> <EnableI18N LFM="False"/> </i18n> <VersionInfo> <StringTable ProductVersion=""/> </VersionInfo> <BuildModes Count="1"> <Item1 Name="Default" Default="True"/> </BuildModes> <PublishOptions> <Version Value="2"/> <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> <ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/> </PublishOptions> <RunParams> <local> <FormatVersion Value="1"/> <LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> </local> </RunParams> <RequiredPackages Count="1"> <Item1> <PackageName Value="LazUtils"/> </Item1> </RequiredPackages> <Units Count="1"> <Unit0> <Filename Value="testunicode.pas"/> <IsPartOfProject Value="True"/> <UnitName Value="TestUnicode"/> </Unit0> </Units> </ProjectOptions> <CompilerOptions> <Version Value="10"/> <Target> <Filename Value="testunicode"/> </Target> <SearchPaths> <IncludeFiles Value="$(ProjOutDir)"/> <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> </SearchPaths> <Linking> <Debugging> <GenerateDebugInfo Value="True"/> <DebugInfoType Value="dsAuto"/> </Debugging> </Linking> <Other> <CompilerMessages> <UseMsgFile Value="True"/> </CompilerMessages> <CompilerPath Value="$(CompPath)"/> </Other> </CompilerOptions> <Debugging> <Exceptions Count="3"> <Item1> <Name Value="EAbort"/> </Item1> <Item2> <Name Value="ECodetoolError"/> </Item2> <Item3> <Name Value="EFOpenError"/> </Item3> </Exceptions> </Debugging> </CONFIG>
{ "pile_set_name": "Github" }
package main import ( "database/sql" "fmt" "github.com/mattn/go-sqlite3" "log" ) func main() { sql.Register("sqlite3_with_extensions", &sqlite3.SQLiteDriver{ Extensions: []string{ "sqlite3_mod_regexp", }, }) db, err := sql.Open("sqlite3_with_extensions", ":memory:") if err != nil { log.Fatal(err) } defer db.Close() // Force db to make a new connection in pool // by putting the original in a transaction tx, err := db.Begin() if err != nil { log.Fatal(err) } defer tx.Commit() // New connection works (hopefully!) rows, err := db.Query("select 'hello world' where 'hello world' regexp '^hello.*d$'") if err != nil { log.Fatal(err) } defer rows.Close() for rows.Next() { var helloworld string rows.Scan(&helloworld) fmt.Println(helloworld) } }
{ "pile_set_name": "Github" }
/*************************************************************************** can_setup.c - description ------------------- begin : 24.12.2011 copyright : Copyright (c) 2011, Robert Bosch Engineering and Business Solutions. All rights reserved. author : Klaus Demlehner, [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software, you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License * * version 2.1 as published by the Free Software Foundation. * * * ***************************************************************************/ /** Library to talk to Tiny-CAN devices. You find the latest versions at http://www.tiny-can.com/ **/ #include <windows.h> #include <basetyps.h> #include <commctrl.h> #include <windowsx.h> #include "global.h" #include "mhs_types.h" #include "../res/resource.h" #include "util.h" #include "gui_util.h" #include "mhsbmcfg.h" #include "can_setup.h" TMhsCanCfg *CanCfg = NULL; #define CanSpeedTabSize 9 static const char *CanSpeedTabStr[] = {"10 kBit/s", "20 kBit/s", "50 kBit/s", "100 kBit/s", "125 kBit/s", "250 kBit/s", "500 kBit/s", "800 kBit/s", "1 MBit/s"}; static const uint32_t CanSpeedTab[] = {10, 20, 50, 100, 125, 250, 500, 800, 1000}; static BOOL g_bBTRRadioBtnChecked = FALSE; static void EnableDisableControls(HWND hdlg, int nDlgItem) { HWND hWndBitRate = GetDlgItem(hdlg, IDC_CAN_SPEED); HWND hWndBTR = GetDlgItem(hdlg, IDC_BTR_EDIT); if (nDlgItem == IDC_RADIOBTN_BITRATE) { EnableWindow(hWndBitRate, TRUE); // Enable the bit rate combo box EnableWindow(hWndBTR, FALSE); // Disable the BTR edit box g_bBTRRadioBtnChecked = FALSE; } else { EnableWindow(hWndBitRate, FALSE); // Disable the bit rate combo box EnableWindow(hWndBTR, TRUE); // Enable the BTR edit box g_bBTRRadioBtnChecked = TRUE; } } static void InitCanSetupDlg(HWND hdlg, TMhsCanCfg *cfg) { int nResIDRadioItem = 0; SetDlgItemText(hdlg, IDC_SNR_EDIT, cfg->m_CanSnrStr); SetDlgItemHex(hdlg, IDC_BTR_EDIT, HEX_WORD, cfg->m_CanBtrValue); cfg->m_bBitRateSelected = FillComboBox(hdlg, IDC_CAN_SPEED, CanSpeedTabStr, (const DWORD *) CanSpeedTab, CanSpeedTabSize, cfg->m_CanSpeed); // Set default value as bitrate if ( cfg->m_bBitRateSelected ) { nResIDRadioItem = IDC_RADIOBTN_BITRATE; } else { nResIDRadioItem = IDC_RADIOBTN_BTR; } CheckRadioButton(hdlg, IDC_RADIOBTN_BITRATE, IDC_RADIOBTN_BTR, nResIDRadioItem); EnableDisableControls(hdlg, nResIDRadioItem); } DOUBLE dCalculateBaudRateFromBTRs(UCHAR ucBTR0, UCHAR ucBTR1) { UBTR1 uBTR1val; UBTR0 uBTR0val; DOUBLE dBaudRate = 0; BYTE byBRP = 0; BYTE byNBT = 0; BYTE byTSEG1 = 0; BYTE byTSEG2 = 0; char* pcStopStr = NULL; DOUBLE dblClock = 16; uBTR0val.ucBTR0 = ucBTR0; uBTR1val.ucBTR1 = ucBTR1; // BRP = BRPbit+1 byBRP = (uBTR0val.sBTR0Bit.ucBRPbit + 1); // TSEG1 = TSEG1bit +1 byTSEG1 = (uBTR1val.sBTR1Bit.ucTSEG1bit + 1 ); //TSEG2 = TSEG2bit+1; byTSEG2 = (uBTR1val.sBTR1Bit.ucTSEG2bit + 1 ); //NBT = TESG1 + TSEG2 +1 byNBT = ( byTSEG1 + byTSEG2 + 1) ; dBaudRate = (DOUBLE)( dblClock / ( 2.0 * byBRP * byNBT )); dBaudRate = dBaudRate * (defFACT_FREQUENCY / defFACT_BAUD_RATE); /* covert to bps */ dBaudRate*=1000; return dBaudRate; } static BOOL SaveCanSetup(HWND hdlg, TMhsCanCfg *cfg) { short unBTRVal; UBTR0 sBtr0Reg; UBTR1 sBtr1Reg; UINT unNbt0 = 0; FLOAT fNbt = 0; UINT unBrp0 = 0; UINT unNbt1 = 0; UINT unBrp1 = 0; FLOAT fBrp = 0; WORD unProductNbtNBrp= 0; DOUBLE dBaudRate = 0; DOUBLE dblClock = 16; GetDlgItemTextCpy(cfg->m_CanSnrStr, hdlg, IDC_SNR_EDIT, MHS_STR_SIZE); if ( g_bBTRRadioBtnChecked ) { cfg->m_CanBtrValue = GetDlgItemHex(hdlg, IDC_BTR_EDIT); unBTRVal = cfg->m_CanBtrValue; sBtr1Reg.ucBTR1 = (0x00FF & unBTRVal); sBtr0Reg.ucBTR0 = (unBTRVal >> 8); // Get the baudrate for BTR0 and BTR1 values. dBaudRate = dCalculateBaudRateFromBTRs(sBtr0Reg.ucBTR0 ,sBtr1Reg.ucBTR1); // Calculate the NBT and BRP product. and NBT value using BTR0 value unProductNbtNBrp = (UINT)((dblClock/(dBaudRate/1000))/2.0* (defFACT_FREQUENCY / defFACT_BAUD_RATE)); unBrp0 = (sBtr0Reg.sBTR0Bit.ucBRPbit+1); unNbt0 = unProductNbtNBrp/unBrp0; fNbt = (FLOAT)unProductNbtNBrp/unBrp0; unNbt1 = (sBtr1Reg.sBTR1Bit.ucTSEG1bit+1)+ (sBtr1Reg.sBTR1Bit.ucTSEG2bit+1)+1; unBrp1 = unProductNbtNBrp/unNbt1; fBrp = (FLOAT)unProductNbtNBrp/unNbt1; //Check if the BTR0 and BTR1 value entered is valid. if Not valid // Restore the previos value else calculate the new list. if( unNbt0>defMAX_NBT || unNbt0<defMIN_NBT || fNbt != unNbt0 || unBrp1>defMAX_BRP || unBrp1<defMIN_BRP || unBrp1 != fBrp || unNbt1>defMAX_NBT || unNbt1<defMIN_NBT ) { MessageBox(hdlg, "Invalid BTRs Configuration!", "Warning", MB_OK|MB_ICONSTOP); return FALSE; } } else { cfg->m_CanBtrValue = 0; cfg->m_CanSpeed = GetComboBox(hdlg, IDC_CAN_SPEED); /* Validate baud rate selection */ if ( cfg->m_CanSpeed > 1000 ) { MessageBox(hdlg, "Please select baud rate!", "Warning", MB_OK|MB_ICONSTOP); return FALSE; } } return TRUE; } static BOOL CALLBACK CanSetupDlgProc(HWND hdlg, UINT uMessage, WPARAM wparam, LPARAM lparam) { switch(uMessage) { case WM_INITDIALOG : { InitCanSetupDlg(hdlg, CanCfg); break; } case WM_COMMAND : { switch (LOWORD(wparam)) { case IDOK : { if( SaveCanSetup(hdlg, CanCfg) ) { EndDialog(hdlg, TRUE); return(TRUE); } else { return(FALSE); } } case IDCANCEL : { EndDialog(hdlg, TRUE); return(TRUE); } case IDC_RADIOBTN_BITRATE : case IDC_RADIOBTN_BTR : case BN_CLICKED: { EnableDisableControls(hdlg, wparam); } } break; } } return(FALSE); } int ShowCanSetupDlg(HINSTANCE hInstance, HWND hwnd, TMhsCanCfg *cfg) { CanCfg = cfg; if (((DWORD)DialogBox(hInstance, MAKEINTRESOURCE(IDD_CAN_SETUP), hwnd, CanSetupDlgProc)) == TRUE) return(1); else return(0); }
{ "pile_set_name": "Github" }
/* Soot - a J*va Optimization Framework * Copyright (C) 1999 Patrick Lam, Patrick Pominville and Raja Vallee-Rai * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Modified by the Sable Research Group and others 1997-1999. * See the 'credits' file distributed with Soot for the complete list of * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot) */ package soot.baf; import java.util.*; import soot.*; public interface LookupSwitchInst extends Inst { public Unit getDefaultTarget(); public void setDefaultTarget(Unit defTarget); public UnitBox getDefaultTargetBox(); public void setLookupValue(int index, int value); public int getLookupValue(int index); public List getLookupValues(); public void setLookupValues(List values); public int getTargetCount(); public Unit getTarget(int index); public UnitBox getTargetBox(int index); public void setTarget(int index, Unit target); public List getTargets(); public void setTargets(List<Unit> targets); }
{ "pile_set_name": "Github" }
<!-- XML Document Type Definition for GNUstep Documentation Markup Language (gsdoc). Written by Richard Frith-Macdonald Based on GDML by 1997 Yoo C. Chung This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This document 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 Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. --> <!-- gsdoc is an XML language - Typical usage: <?xml version="1.0"?> <!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 1.0.3//EN" "http://www.gnustep.org/gsdoc.xml"> <gsdoc base="myDocName"> </gsdoc> --> <!--***** Character entities. *****--> <!-- General purpose characters for gsdoc. --> <!ENTITY copy "&#169;"> <!-- copyright symbol --> <!ENTITY tm "&#174;"> <!-- trademark symbol --> <!ENTITY reg "&#174;"> <!ENTITY dots "&#8230;"> <!-- ellipsis (...) --> <!ENTITY nbsp "&#160;"> <!-- non breakable space --> <!ENTITY amp "&#38;#38;"> <!-- ampersand --> <!ENTITY apos "&#39;"> <!-- apos --> <!ENTITY quot "&#34;"> <!-- quotation mark (") --> <!ENTITY lt "&#38;#60;"> <!-- lesser than symbol --> <!ENTITY gt "&#62;"> <!-- greater than symbol --> <!--***** Entity declarations. *****--> <!-- Boolean values for attributes --> <!ENTITY % boolean "(yes|no)"> <!-- Entity for phrase elements. --> <!ENTITY % phrase "var | ivar | em | code | strong | file | site"> <!-- Entity for cross references. --> <!ENTITY % xref "ref | uref | url | email | prjref"> <!-- Entity for anchors. --> <!ENTITY % anchor "label | entry"> <!-- Entity for simple text level elements. --> <!ENTITY % text "#PCDATA | %xref; | %anchor; | %phrase; | footnote | br"> <!-- Entity for list elements. --> <!ENTITY % list "list | enum | deflist | qalist | dictionary"> <!-- Entity for block level elements. --> <!ENTITY % block "%text; | %list; | p | example | embed | index"> <!-- Entity for definition elements and blocks. --> <!ENTITY % defblock "%text; | %list; | heading | p | example | embed | index | class | category | protocol | function | macro | type | variable | constant | EOModel | EOEntity"> <!--**********--> <!-- Used for describing something. --> <!ELEMENT desc (%block;)*> <!-- A footnote. --> <!ELEMENT footnote (%text;)*> <!--***** Phrase elements. *****--> <!-- The content is a metasyntactic variable or argument name. --> <!ELEMENT var (%text;)*> <!-- The content is a metasyntactic ivariable name. --> <!ELEMENT ivar (%text;)*> <!-- Emphasize the content. --> <!ELEMENT em (%text;)*> <!-- The content is too important that simple emphasizing isn't enough. --> <!ELEMENT strong (%text;)*> <!-- The content is either a name for code (e.g. class names), or a relatively short code fragment. --> <!ELEMENT code (%text;)*> <!-- The content is a file name. --> <!ELEMENT file (#PCDATA)*> <!-- The content is a fully qualified domain name on the Internet. --> <!ELEMENT site (#PCDATA)*> <!--***** List elements. *****--> <!-- An item in a list. --> <!ELEMENT item (%block;)*> <!-- An enumerated list. --> <!ELEMENT enum (item+)> <!-- A ordinary, unnumbered list. --> <!ELEMENT list (item+)> <!-- A term to defined in a definition list. --> <!ELEMENT term (%text;)*> <!-- A definition list. --> <!ELEMENT deflist (term, desc)+> <!-- A question for a question and answer list. --> <!ELEMENT question (%text;)*> <!-- An answer for a question and answer list. --> <!ELEMENT answer (%block;)*> <!-- A question and answer list. --> <!ELEMENT qalist (question, answer)+> <!--**********--> <!--***** Cross references. *****--> <!-- A reference. ID of the reference. TYPE of reference, if implied, a reference to a label. CLASS specific class for a method, may be one of the following formats - classname, classname(categoryname), (protocolname) --> <!ELEMENT ref (%text;)*> <!ATTLIST ref id CDATA #REQUIRED type (class|category|protocol|method|ivariable|function|type|macro|variable|constant|label|EOModel|EOEntity|tool) "label" class CDATA #IMPLIED > <!-- An e-mail address. --> <!ELEMENT email (%text;)*> <!ATTLIST email address CDATA #IMPLIED > <!-- A URL. --> <!ELEMENT url EMPTY> <!ATTLIST url url CDATA #IMPLIED > <!-- A reference to a URL. The text contained appears in the output. --> <!ELEMENT uref (%text;)*> <!ATTLIST uref url CDATA #REQUIRED > <!-- A reference to a project. The text contained appears in the output. --> <!ELEMENT prjref (%text;)*> <!ATTLIST prjref prjname CDATA #IMPLIED file CDATA #IMPLIED > <!--***** Anchors. *****--> <!-- An anchor for a general reference. The text contained appears in the output. If the id attribute is omitted, the text is used in its place. --> <!ELEMENT label (%text;)*> <!ATTLIST label id CDATA #IMPLIED > <!-- An entry for the general index. The text that is contained appears in the index, and never in the text itself. If the id attribute is omitted, the text is used in its place. --> <!ELEMENT entry (%text;)*> <!ATTLIST entry id CDATA #IMPLIED > <!-- OBSOLETE ... do not use --> <!ELEMENT GNUstep EMPTY> <!ELEMENT OpenStep EMPTY> <!ELEMENT NotOpenStep EMPTY> <!ELEMENT MacOS-X EMPTY> <!ELEMENT NotMacOS-X EMPTY> <!-- OBSOLETE ... do not use --> <!ENTITY % standard "GNUstep | OpenStep | NotOpenStep | MacOS-X | NotMacOS-X"> <!-- OBSOLETE ... do not use --> <!ELEMENT standards (%standard;)*> <!--***** Argument elements. *****--> <!-- An argument. --> <!ELEMENT arg (#PCDATA)*> <!ATTLIST arg type CDATA #IMPLIED > <!-- Denotes that the rest of the arguments is a variable list, like in printf(). --> <!ELEMENT vararg EMPTY> <!--***** Method elements. *****--> <!-- A component for a method selector. --> <!ELEMENT sel (#PCDATA)*> <!-- A method. If there is no DESC, it is understood that the element is used to override some information from the same method in the superclass. If factory not set, instance method --> <!ELEMENT method (((sel, arg?), (sel, arg)*, vararg?), desc?, standards?)> <!ATTLIST method type CDATA #IMPLIED factory %boolean; "no" init %boolean; "no" override (subclass|dummy|never) #IMPLIED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!--***** Elements for definitions of classes, functions, etc. *****--> <!-- Show what header file something lives in. --> <!ELEMENT declared (#PCDATA)*> <!-- A macro definition. --> <!ELEMENT macro ((arg*, vararg?), declared?, desc?, standards?)> <!ATTLIST macro name CDATA #REQUIRED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- A type definition. --> <!ELEMENT type (declared?, desc?, standards?)> <!ATTLIST type name CDATA #REQUIRED type CDATA #REQUIRED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Variable definition. VALUE may be set for a constant or a default value --> <!ELEMENT variable (declared?, desc?, standards?)> <!ATTLIST variable name CDATA #REQUIRED type CDATA #REQUIRED value CDATA #IMPLIED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Ivariable definition. --> <!ELEMENT ivariable (desc?, standards?)> <!ATTLIST ivariable name CDATA #REQUIRED type CDATA #REQUIRED validity (public|package|protected|private) "public" gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Constant definition. VALUE may be set for a constant or a default value --> <!ELEMENT constant (declared?, desc?, standards?)> <!ATTLIST constant name CDATA #REQUIRED type CDATA #REQUIRED value CDATA #IMPLIED role (except|defaults|notify|key) #IMPLIED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- A function definition. --> <!ELEMENT function ((arg*, vararg?), declared?, desc?, standards?)> <!ATTLIST function name CDATA #REQUIRED type CDATA #REQUIRED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Protocol definition. --> <!ELEMENT protocol (declared?, conform*, desc?, method*, standards?)> <!ATTLIST protocol name CDATA #REQUIRED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Category definition. --> <!ELEMENT category (declared?, conform*, desc?, method*, standards?)> <!ATTLIST category name CDATA #REQUIRED class CDATA #REQUIRED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!-- Show a protocol a class conforms to. --> <!ELEMENT conform (#PCDATA)*> <!ELEMENT class (declared?, conform*, desc?, ivariable*, method*, standards?)> <!ATTLIST class name CDATA #REQUIRED super CDATA #IMPLIED gvadd CDATA #IMPLIED gvdep CDATA #IMPLIED gvrem CDATA #IMPLIED ovadd CDATA #IMPLIED ovdep CDATA #IMPLIED ovrem CDATA #IMPLIED > <!--***** Elements for definitions of EOModels, etc. *****--> <!-- a dictionary Item. --> <!ELEMENT dictionaryItem (%block;)*> <!ATTLIST dictionaryItem key CDATA #REQUIRED value CDATA #IMPLIED > <!-- a dictionary --> <!ELEMENT dictionary (dictionaryItem+)> <!ELEMENT EOConnectionDictionary (dictionaryItem+)> <!ELEMENT EOUserDictionary (dictionaryItem+)> <!--***** Elements for definitions of EOModels, etc. *****--> <!-- EORelationshipComponent --> <!ELEMENT EORelationshipComponent (EORelationshipComponent*)> <!ATTLIST EORelationshipComponent definition CDATA #REQUIRED > <!-- EOJoin --> <!ELEMENT EOJoin (desc?)> <!ATTLIST EOJoin relationshipName CDATA #IMPLIED joinOperator CDATA #REQUIRED joinSemantic CDATA #REQUIRED sourceAttribute CDATA #REQUIRED destinationAttribute CDATA #REQUIRED > <!-- EORelationship --> <!ELEMENT EORelationship ((EORelationshipComponent | (EOJoin*)), EOUserDictionary?, desc?)> <!ATTLIST EORelationship entityName CDATA #REQUIRED destinationEntityName CDATA #REQUIRED name CDATA #REQUIRED isToMany CDATA #IMPLIED > <!-- EOAttributeRef --> <!ELEMENT EOAttributeRef EMPTY> <!ATTLIST EOAttributeRef name CDATA #REQUIRED > <!-- EOPrimaryKeyAttributes --> <!ELEMENT EOPrimaryKeyAttributes (EOAttributeRef+)> <!-- EOClassProperties --> <!ELEMENT EOClassProperties ((EOAttributeRef)+)> <!-- EOAttributesUsedForLocking --> <!ELEMENT EOAttributesUsedForLocking (EOAttributeRef+)> <!-- EOAttribute --> <!ELEMENT EOAttribute (EOUserDictionary?, desc?)> <!ATTLIST EOAttribute columnName CDATA #IMPLIED definition CDATA #IMPLIED externalType CDATA #IMPLIED name CDATA #REQUIRED valueClassName CDATA #IMPLIED valueType CDATA #IMPLIED entityName CDATA #IMPLIED isReadOnly CDATA #IMPLIED isDerived CDATA #IMPLIED isFlattened CDATA #IMPLIED > <!-- EOEntity --> <!ELEMENT EOEntity (EOAttribute*, EOAttributesUsedForLocking?, EOClassProperties?, EOPrimaryKeyAttributes?, EORelationship*, EOUserDictionary?, desc?)> <!ATTLIST EOEntity name CDATA #REQUIRED externalName CDATA #IMPLIED className CDATA #IMPLIED modelName CDATA #IMPLIED isReadOnly CDATA #IMPLIED > <!-- EOModel --> <!ELEMENT EOModel (EOConnectionDictionary?, (EOEntity+ | list), EOUserDictionary?, desc?)> <!ATTLIST EOModel name CDATA #REQUIRED version CDATA #IMPLIED adaptorName CDATA #REQUIRED adaptorClassName CDATA #REQUIRED > <!--***** Elements for ordinary block level elements. *****--> <!-- A line break. --> <!ELEMENT br EMPTY> <!-- A paragraph. --> <!ELEMENT p (%text;)*> <!-- An example. --> <!ELEMENT example (#PCDATA)*> <!ATTLIST example caption CDATA #IMPLIED > <!-- An embedded object. If it is of a type that the SGML processor cannot handle, then use the content, which is ignored otherwise. refer - method of referring to object (default is file) src - the reference to the object type - Internet media type of the objec title - optional title describing object --> <!ELEMENT embed (%block;)*> <!ATTLIST embed refer (file|url) #IMPLIED src CDATA #REQUIRED type CDATA #IMPLIED title CDATA #IMPLIED > <!--***** Elements for document structure such as chapters. *****--> <!-- A heading for chapters, sections, ... --> <!ELEMENT heading (%text;)*> <!-- A subsubsection. --> <!ELEMENT subsubsect (%defblock;)*> <!ATTLIST subsubsect id CDATA #IMPLIED > <!-- A subsection. --> <!ELEMENT subsect (%defblock; | subsubsect)*> <!ATTLIST subsect id CDATA #IMPLIED > <!-- A section. --> <!ELEMENT section (%defblock; | subsect)*> <!ATTLIST section id CDATA #IMPLIED > <!-- A chapter. --> <!ELEMENT chapter (%defblock; | section)*> <!ATTLIST chapter id CDATA #IMPLIED > <!--***** Elements that make searching for things easier. *****--> <!-- Table of contents. --> <!ELEMENT contents EMPTY> <!-- Index ... generates an index of the specified type of elements. 'scope' determines whether the index is generated for the current file or for the whole of the current project, or for everything the software can find (global) ... if the document is processed in a standalone manner, the scope if always file. For method or ivariable indexing, if the index is inside a class, protocol, or category, only indexes for that unit should be generated. 'type' determines the type of entry listed in the index. The 'title' type really only makes sense for a project scope index as it produces a list of the files in the project (by title). --> <!ELEMENT index EMPTY> <!ATTLIST index type (class | category | protocol | method | ivariable | function | type | macro | variable | constant | EOModel | EOEntity | label | title | tool) "label" scope (file | project | global) "file" style ( normal | bare ) "normal" target CDATA #IMPLIED > <!--***** Elements that describe the document itself. *****--> <!-- Copyright of the document. --> <!ELEMENT copy (%text;)*> <!-- An abstract. --> <!ELEMENT abstract (%text;)*> <!-- The version of the document. --> <!ELEMENT version (%text;)*> <!-- The date the document was written. --> <!ELEMENT date (%text;)*> <!-- An author. --> <!ELEMENT author (email?, url?, desc?)> <!ATTLIST author name CDATA #REQUIRED > <!-- The title of the document. --> <!ELEMENT title (%text;)*> <!--***** The topmost structures for the document body. *****--> <!-- Unnumbered parts appearing in the front, such as a preface. --> <!ELEMENT front (contents?, chapter*)> <!-- Unnumbered parts appearing in the back, such as an afterword and/or indices. --> <!ELEMENT back (chapter*, index*)> <!--***** The topmost structures for the document. *****--> <!-- The head containing general information about the document. --> <!ELEMENT head (title, author*, version?, date?, abstract?, copy?)> <!-- The main part of the document. --> <!ELEMENT body (front?, chapter+, back?)> <!--**********--> <!-- The entire document. --> <!ELEMENT gsdoc (head, body)> <!ATTLIST gsdoc base CDATA #IMPLIED next CDATA #IMPLIED prev CDATA #IMPLIED up CDATA #IMPLIED stylesheeturl CDATA #IMPLIED >
{ "pile_set_name": "Github" }
{pkgs, config, ...}: with pkgs.lib; let ids = config.ids; users = config.users; userOpts = { name, config, ... }: { options = { name = mkOption { type = with types; uniq string; description = "The name of the user account. If undefined, the name of the attribute set will be used."; }; description = mkOption { type = with types; uniq string; default = ""; description = "A short description of the user account."; }; uid = mkOption { type = with types; uniq (nullOr int); default = null; description = "The account UID. If undefined, NixOS will select a free UID."; }; group = mkOption { type = with types; uniq string; default = "nogroup"; description = "The user's primary group."; }; extraGroups = mkOption { type = types.listOf types.string; default = []; description = "The user's auxiliary groups."; }; home = mkOption { type = with types; uniq string; default = "/var/empty"; description = "The user's home directory."; }; shell = mkOption { type = with types; uniq string; default = "/run/current-system/sw/sbin/nologin"; description = "The path to the user's shell."; }; createHome = mkOption { type = types.bool; default = false; description = "If true, the home directory will be created automatically."; }; useDefaultShell = mkOption { type = types.bool; default = false; description = "If true, the user's shell will be set to <literal>users.defaultUserShell</literal>."; }; password = mkOption { type = with types; uniq (nullOr string); default = null; description = "The user's password. If undefined, no password is set for the user. Warning: do not set confidential information here because this data would be readable by all. This option should only be used for public account such as guest."; }; isSystemUser = mkOption { type = types.bool; default = true; description = "Indicates if the user is a system user or not."; }; createUser = mkOption { type = types.bool; default = true; description = " Indicates if the user should be created automatically as a local user. Set this to false if the user for instance is an LDAP user. NixOS will then not modify any of the basic properties for the user account. "; }; isAlias = mkOption { type = types.bool; default = false; description = "If true, the UID of this user is not required to be unique and can thus alias another user."; }; }; config = { name = mkDefault name; uid = mkDefault (attrByPath [name] null ids.uids); shell = mkIf config.useDefaultShell (mkDefault users.defaultUserShell); }; }; groupOpts = { name, config, ... }: { options = { name = mkOption { type = with types; uniq string; description = "The name of the group. If undefined, the name of the attribute set will be used."; }; gid = mkOption { type = with types; uniq (nullOr int); default = null; description = "The GID of the group. If undefined, NixOS will select a free GID."; }; }; config = { name = mkDefault name; gid = mkDefault (attrByPath [name] null ids.gids); }; }; # Note: the 'X' in front of the password is to distinguish between # having an empty password, and not having a password. serializedUser = u: "${u.name}\n${u.description}\n${if u.uid != null then toString u.uid else ""}\n${u.group}\n${toString (concatStringsSep "," u.extraGroups)}\n${u.home}\n${u.shell}\n${toString u.createHome}\n${if u.password != null then "X" + u.password else ""}\n${toString u.isSystemUser}\n${toString u.createUser}\n${toString u.isAlias}\n"; usersFile = pkgs.writeText "users" ( let p = partition (u: u.isAlias) (attrValues config.users.extraUsers); in concatStrings (map serializedUser p.wrong ++ map serializedUser p.right)); in { ###### interface options = { users.extraUsers = mkOption { default = {}; type = types.loaOf types.optionSet; example = { alice = { uid = 1234; description = "Alice"; home = "/home/alice"; createHome = true; group = "users"; extraGroups = ["wheel"]; shell = "/bin/sh"; password = "foobar"; }; }; description = '' Additional user accounts to be created automatically by the system. This can also be used to set options for root. ''; options = [ userOpts ]; }; users.extraGroups = mkOption { default = {}; example = { students.gid = 1001; hackers = { }; }; type = types.loaOf types.optionSet; description = '' Additional groups to be created automatically by the system. ''; options = [ groupOpts ]; }; }; ###### implementation config = { users.extraUsers = { root = { description = "System administrator"; home = "/root"; shell = config.users.defaultUserShell; group = "root"; }; nobody = { description = "Unprivileged account (don't use!)"; }; }; users.extraGroups = { root = { }; wheel = { }; disk = { }; kmem = { }; tty = { }; floppy = { }; uucp = { }; lp = { }; cdrom = { }; tape = { }; audio = { }; video = { }; dialout = { }; nogroup = { }; users = { }; nixbld = { }; utmp = { }; adm = { }; # expected by journald }; system.activationScripts.rootPasswd = stringAfter [ "etc" ] '' # If there is no password file yet, create a root account with an # empty password. if ! test -e /etc/passwd; then rootHome=/root touch /etc/passwd; chmod 0644 /etc/passwd touch /etc/group; chmod 0644 /etc/group touch /etc/shadow; chmod 0600 /etc/shadow # Can't use useradd, since it complains that it doesn't know us # (bootstrap problem!). echo "root:x:0:0:System administrator:$rootHome:${config.users.defaultUserShell}" >> /etc/passwd echo "root::::::::" >> /etc/shadow fi ''; system.activationScripts.users = stringAfter [ "groups" ] '' echo "updating users..." cat ${usersFile} | while true; do read name || break read description read uid read group read extraGroups read home read shell read createHome read password read isSystemUser read createUser read isAlias if [ -z "$createUser" ]; then continue fi if ! curEnt=$(getent passwd "$name"); then useradd ''${isSystemUser:+--system} \ --comment "$description" \ ''${uid:+--uid $uid} \ --gid "$group" \ --groups "$extraGroups" \ --home "$home" \ --shell "$shell" \ ''${createHome:+--create-home} \ ''${isAlias:+--non-unique} \ "$name" if test "''${password:0:1}" = 'X'; then (echo "''${password:1}"; echo "''${password:1}") | ${pkgs.shadow}/bin/passwd "$name" fi else #echo "updating user $name..." oldIFS="$IFS"; IFS=:; set -- $curEnt; IFS="$oldIFS" prevUid=$3 prevHome=$6 # Don't change the home directory if it's the same to prevent # unnecessary warnings about logged in users. if test "$prevHome" = "$home"; then unset home; fi usermod \ --comment "$description" \ --gid "$group" \ --groups "$extraGroups" \ ''${home:+--home "$home"} \ --shell "$shell" \ "$name" fi done ''; system.activationScripts.groups = stringAfter [ "rootPasswd" "binsh" "etc" "var" ] '' echo "updating groups..." createGroup() { name="$1" gid="$2" if ! curEnt=$(getent group "$name"); then groupadd --system \ ''${gid:+--gid $gid} \ "$name" fi } ${flip concatMapStrings (attrValues config.users.extraGroups) (g: '' createGroup '${g.name}' '${toString g.gid}' '')} ''; }; }
{ "pile_set_name": "Github" }
/* The MIT License (MIT) Copyright (c) 2018 Helix Toolkit contributors */ using SharpDX.Direct2D1; using System; #if !NETFX_CORE namespace HelixToolkit.Wpf.SharpDX #else #if CORE namespace HelixToolkit.SharpDX.Core #else namespace HelixToolkit.UWP #endif #endif { namespace Model.Scene2D { using Core2D; public abstract class ShapeNode2D : SceneNode2D { public Brush Fill { set { (RenderCore as ShapeRenderCore2DBase).FillBrush = value; } get { return (RenderCore as ShapeRenderCore2DBase).FillBrush; } } public Brush Stroke { set { (RenderCore as ShapeRenderCore2DBase).StrokeBrush = value; } get { return (RenderCore as ShapeRenderCore2DBase).StrokeBrush; } } private CapStyle strokeDashCap = CapStyle.Flat; public CapStyle StrokeDashCap { set { if (SetAffectsRender(ref strokeDashCap, value)) { strokeStyleChanged = true; } } get { return strokeDashCap; } } private CapStyle strokeStartLineCap = CapStyle.Flat; public CapStyle StrokeStartLineCap { set { if (SetAffectsRender(ref strokeStartLineCap, value)) { strokeStyleChanged = true; } } get { return strokeStartLineCap; } } private CapStyle strokeEndLineCap = CapStyle.Flat; public CapStyle StrokeEndLineCap { set { if (SetAffectsRender(ref strokeEndLineCap, value)) { strokeStyleChanged = true; } } get { return strokeEndLineCap; } } private DashStyle strokeDashStyle = DashStyle.Solid; public DashStyle StrokeDashStyle { set { if (SetAffectsRender(ref strokeDashStyle, value)) { strokeStyleChanged = true; } } get { return strokeDashStyle; } } private float strokeDashOffset = 0; public float StrokeDashOffset { set { if (SetAffectsRender(ref strokeDashOffset, value)) { strokeStyleChanged = true; } } get { return strokeDashOffset; } } private LineJoin strokeLineJoin = LineJoin.Miter; public LineJoin StrokeLineJoin { set { if (SetAffectsRender(ref strokeLineJoin, value)) { strokeStyleChanged = true; } } get { return strokeLineJoin; } } private float strokeMiterLimit = 1; public float StrokeMiterLimit { set { if (SetAffectsRender(ref strokeMiterLimit, value)) { strokeStyleChanged = true; } } get { return strokeMiterLimit; } } public float StrokeThickness { set { (RenderCore as ShapeRenderCore2DBase).StrokeWidth = value; } get { return (RenderCore as ShapeRenderCore2DBase).StrokeWidth; } } private float[] strokeDashArray; public float[] StrokeDashArray { set { if (SetAffectsRender(ref strokeDashArray, value)) { strokeStyleChanged = true; } } get { return strokeDashArray; } } private bool strokeStyleChanged = true; protected ShapeRenderCore2DBase shapeRenderable; protected override RenderCore2D CreateRenderCore() { shapeRenderable = CreateShapeRenderCore(); return shapeRenderable; } protected abstract ShapeRenderCore2DBase CreateShapeRenderCore(); protected override bool OnAttach(IRenderHost host) { if (base.OnAttach(host)) { strokeStyleChanged = true; return true; } else { return false; } } public override void Update(RenderContext2D context) { base.Update(context); if (strokeStyleChanged) { shapeRenderable.StrokeStyle = new StrokeStyle(context.DeviceContext.Factory, new StrokeStyleProperties() { DashCap = this.StrokeDashCap, StartCap = StrokeStartLineCap, EndCap = StrokeEndLineCap, DashOffset = StrokeDashOffset, LineJoin = StrokeLineJoin, MiterLimit = Math.Max(1, (float)StrokeMiterLimit), DashStyle = StrokeDashStyle }, StrokeDashArray == null ? new float[0] : StrokeDashArray); strokeStyleChanged = false; } } } } }
{ "pile_set_name": "Github" }
<?php /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * @category Zend * @package Zend_Db * @subpackage Adapter * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: Db2.php 24593 2012-01-05 20:35:02Z matthew $ * */ /** * @see Zend_Db */ require_once 'Zend/Db.php'; /** * @see Zend_Db_Adapter_Abstract */ require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Statement_Db2 */ require_once 'Zend/Db/Statement/Db2.php'; /** * @package Zend_Db * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract { /** * User-provided configuration. * * Basic keys are: * * username => (string) Connect to the database as this username. * password => (string) Password associated with the username. * host => (string) What host to connect to (default 127.0.0.1) * dbname => (string) The name of the database to user * protocol => (string) Protocol to use, defaults to "TCPIP" * port => (integer) Port number to use for TCP/IP if protocol is "TCPIP" * persistent => (boolean) Set TRUE to use a persistent connection (db2_pconnect) * os => (string) This should be set to 'i5' if the db is on an os400/i5 * schema => (string) The default schema the connection should use * * @var array */ protected $_config = array( 'dbname' => null, 'username' => null, 'password' => null, 'host' => 'localhost', 'port' => '50000', 'protocol' => 'TCPIP', 'persistent' => false, 'os' => null, 'schema' => null ); /** * Execution mode * * @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) */ protected $_execute_mode = DB2_AUTOCOMMIT_ON; /** * Default class name for a DB statement. * * @var string */ protected $_defaultStmtClass = 'Zend_Db_Statement_Db2'; protected $_isI5 = false; /** * Keys are UPPERCASE SQL datatypes or the constants * Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE, or Zend_Db::FLOAT_TYPE. * * Values are: * 0 = 32-bit integer * 1 = 64-bit integer * 2 = float or decimal * * @var array Associative array of datatypes to values 0, 1, or 2. */ protected $_numericDataTypes = array( Zend_Db::INT_TYPE => Zend_Db::INT_TYPE, Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE, Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE, 'INTEGER' => Zend_Db::INT_TYPE, 'SMALLINT' => Zend_Db::INT_TYPE, 'BIGINT' => Zend_Db::BIGINT_TYPE, 'DECIMAL' => Zend_Db::FLOAT_TYPE, 'NUMERIC' => Zend_Db::FLOAT_TYPE ); /** * Creates a connection resource. * * @return void */ protected function _connect() { if (is_resource($this->_connection)) { // connection already exists return; } if (!extension_loaded('ibm_db2')) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception('The IBM DB2 extension is required for this adapter but the extension is not loaded'); } $this->_determineI5(); if ($this->_config['persistent']) { // use persistent connection $conn_func_name = 'db2_pconnect'; } else { // use "normal" connection $conn_func_name = 'db2_connect'; } if (!isset($this->_config['driver_options']['autocommit'])) { // set execution mode $this->_config['driver_options']['autocommit'] = &$this->_execute_mode; } if (isset($this->_config['options'][Zend_Db::CASE_FOLDING])) { $caseAttrMap = array( Zend_Db::CASE_NATURAL => DB2_CASE_NATURAL, Zend_Db::CASE_UPPER => DB2_CASE_UPPER, Zend_Db::CASE_LOWER => DB2_CASE_LOWER ); $this->_config['driver_options']['DB2_ATTR_CASE'] = $caseAttrMap[$this->_config['options'][Zend_Db::CASE_FOLDING]]; } if ($this->_isI5 && isset($this->_config['driver_options']['i5_naming'])) { if ($this->_config['driver_options']['i5_naming']) { $this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_ON; } else { $this->_config['driver_options']['i5_naming'] = DB2_I5_NAMING_OFF; } } if ($this->_config['host'] !== 'localhost' && !$this->_isI5) { // if the host isn't localhost, use extended connection params $dbname = 'DRIVER={IBM DB2 ODBC DRIVER}' . ';DATABASE=' . $this->_config['dbname'] . ';HOSTNAME=' . $this->_config['host'] . ';PORT=' . $this->_config['port'] . ';PROTOCOL=' . $this->_config['protocol'] . ';UID=' . $this->_config['username'] . ';PWD=' . $this->_config['password'] .';'; $this->_connection = $conn_func_name( $dbname, null, null, $this->_config['driver_options'] ); } else { // host is localhost, so use standard connection params $this->_connection = $conn_func_name( $this->_config['dbname'], $this->_config['username'], $this->_config['password'], $this->_config['driver_options'] ); } // check the connection if (!$this->_connection) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception(db2_conn_errormsg(), db2_conn_error()); } } /** * Test if a connection is active * * @return boolean */ public function isConnected() { return ((bool) (is_resource($this->_connection) && get_resource_type($this->_connection) == 'DB2 Connection')); } /** * Force the connection to close. * * @return void */ public function closeConnection() { if ($this->isConnected()) { db2_close($this->_connection); } $this->_connection = null; } /** * Returns an SQL statement for preparation. * * @param string $sql The SQL statement with placeholders. * @return Zend_Db_Statement_Db2 */ public function prepare($sql) { $this->_connect(); $stmtClass = $this->_defaultStmtClass; if (!class_exists($stmtClass)) { require_once 'Zend/Loader.php'; Zend_Loader::loadClass($stmtClass); } $stmt = new $stmtClass($this, $sql); $stmt->setFetchMode($this->_fetchMode); return $stmt; } /** * Gets the execution mode * * @return int the execution mode (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF) */ public function _getExecuteMode() { return $this->_execute_mode; } /** * @param integer $mode * @return void */ public function _setExecuteMode($mode) { switch ($mode) { case DB2_AUTOCOMMIT_OFF: case DB2_AUTOCOMMIT_ON: $this->_execute_mode = $mode; db2_autocommit($this->_connection, $mode); break; default: /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("execution mode not supported"); break; } } /** * Quote a raw string. * * @param string $value Raw string * @return string Quoted string */ protected function _quote($value) { if (is_int($value) || is_float($value)) { return $value; } /** * Use db2_escape_string() if it is present in the IBM DB2 extension. * But some supported versions of PHP do not include this function, * so fall back to default quoting in the parent class. */ if (function_exists('db2_escape_string')) { return "'" . db2_escape_string($value) . "'"; } return parent::_quote($value); } /** * @return string */ public function getQuoteIdentifierSymbol() { $this->_connect(); $info = db2_server_info($this->_connection); if ($info) { $identQuote = $info->IDENTIFIER_QUOTE_CHAR; } else { // db2_server_info() does not return result on some i5 OS version if ($this->_isI5) { $identQuote ="'"; } } return $identQuote; } /** * Returns a list of the tables in the database. * @param string $schema OPTIONAL * @return array */ public function listTables($schema = null) { $this->_connect(); if ($schema === null && $this->_config['schema'] != null) { $schema = $this->_config['schema']; } $tables = array(); if (!$this->_isI5) { if ($schema) { $stmt = db2_tables($this->_connection, null, $schema); } else { $stmt = db2_tables($this->_connection); } while ($row = db2_fetch_assoc($stmt)) { $tables[] = $row['TABLE_NAME']; } } else { $tables = $this->_i5listTables($schema); } return $tables; } /** * Returns the column descriptions for a table. * * The return value is an associative array keyed by the column name, * as returned by the RDBMS. * * The value of each array element is an associative array * with the following keys: * * SCHEMA_NAME => string; name of database or schema * TABLE_NAME => string; * COLUMN_NAME => string; column name * COLUMN_POSITION => number; ordinal position of column in table * DATA_TYPE => string; SQL datatype name of column * DEFAULT => string; default expression of column, null if none * NULLABLE => boolean; true if column can have nulls * LENGTH => number; length of CHAR/VARCHAR * SCALE => number; scale of NUMERIC/DECIMAL * PRECISION => number; precision of NUMERIC/DECIMAL * UNSIGNED => boolean; unsigned property of an integer type * DB2 not supports UNSIGNED integer. * PRIMARY => boolean; true if column is part of the primary key * PRIMARY_POSITION => integer; position of column in primary key * IDENTITY => integer; true if column is auto-generated with unique values * * @param string $tableName * @param string $schemaName OPTIONAL * @return array */ public function describeTable($tableName, $schemaName = null) { // Ensure the connection is made so that _isI5 is set $this->_connect(); if ($schemaName === null && $this->_config['schema'] != null) { $schemaName = $this->_config['schema']; } if (!$this->_isI5) { $sql = "SELECT DISTINCT c.tabschema, c.tabname, c.colname, c.colno, c.typename, c.default, c.nulls, c.length, c.scale, c.identity, tc.type AS tabconsttype, k.colseq FROM syscat.columns c LEFT JOIN (syscat.keycoluse k JOIN syscat.tabconst tc ON (k.tabschema = tc.tabschema AND k.tabname = tc.tabname AND tc.type = 'P')) ON (c.tabschema = k.tabschema AND c.tabname = k.tabname AND c.colname = k.colname) WHERE " . $this->quoteInto('UPPER(c.tabname) = UPPER(?)', $tableName); if ($schemaName) { $sql .= $this->quoteInto(' AND UPPER(c.tabschema) = UPPER(?)', $schemaName); } $sql .= " ORDER BY c.colno"; } else { // DB2 On I5 specific query $sql = "SELECT DISTINCT C.TABLE_SCHEMA, C.TABLE_NAME, C.COLUMN_NAME, C.ORDINAL_POSITION, C.DATA_TYPE, C.COLUMN_DEFAULT, C.NULLS ,C.LENGTH, C.SCALE, LEFT(C.IDENTITY,1), LEFT(tc.TYPE, 1) AS tabconsttype, k.COLSEQ FROM QSYS2.SYSCOLUMNS C LEFT JOIN (QSYS2.syskeycst k JOIN QSYS2.SYSCST tc ON (k.TABLE_SCHEMA = tc.TABLE_SCHEMA AND k.TABLE_NAME = tc.TABLE_NAME AND LEFT(tc.type,1) = 'P')) ON (C.TABLE_SCHEMA = k.TABLE_SCHEMA AND C.TABLE_NAME = k.TABLE_NAME AND C.COLUMN_NAME = k.COLUMN_NAME) WHERE " . $this->quoteInto('UPPER(C.TABLE_NAME) = UPPER(?)', $tableName); if ($schemaName) { $sql .= $this->quoteInto(' AND UPPER(C.TABLE_SCHEMA) = UPPER(?)', $schemaName); } $sql .= " ORDER BY C.ORDINAL_POSITION FOR FETCH ONLY"; } $desc = array(); $stmt = $this->query($sql); /** * To avoid case issues, fetch using FETCH_NUM */ $result = $stmt->fetchAll(Zend_Db::FETCH_NUM); /** * The ordering of columns is defined by the query so we can map * to variables to improve readability */ $tabschema = 0; $tabname = 1; $colname = 2; $colno = 3; $typename = 4; $default = 5; $nulls = 6; $length = 7; $scale = 8; $identityCol = 9; $tabconstType = 10; $colseq = 11; foreach ($result as $key => $row) { list ($primary, $primaryPosition, $identity) = array(false, null, false); if ($row[$tabconstType] == 'P') { $primary = true; $primaryPosition = $row[$colseq]; } /** * In IBM DB2, an column can be IDENTITY * even if it is not part of the PRIMARY KEY. */ if ($row[$identityCol] == 'Y') { $identity = true; } // only colname needs to be case adjusted $desc[$this->foldCase($row[$colname])] = array( 'SCHEMA_NAME' => $this->foldCase($row[$tabschema]), 'TABLE_NAME' => $this->foldCase($row[$tabname]), 'COLUMN_NAME' => $this->foldCase($row[$colname]), 'COLUMN_POSITION' => (!$this->_isI5) ? $row[$colno]+1 : $row[$colno], 'DATA_TYPE' => $row[$typename], 'DEFAULT' => $row[$default], 'NULLABLE' => (bool) ($row[$nulls] == 'Y'), 'LENGTH' => $row[$length], 'SCALE' => $row[$scale], 'PRECISION' => ($row[$typename] == 'DECIMAL' ? $row[$length] : 0), 'UNSIGNED' => false, 'PRIMARY' => $primary, 'PRIMARY_POSITION' => $primaryPosition, 'IDENTITY' => $identity ); } return $desc; } /** * Return the most recent value from the specified sequence in the database. * This is supported only on RDBMS brands that support sequences * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null. * * @param string $sequenceName * @return string */ public function lastSequenceId($sequenceName) { $this->_connect(); if (!$this->_isI5) { $quotedSequenceName = $this->quoteIdentifier($sequenceName, true); $sql = 'SELECT PREVVAL FOR ' . $quotedSequenceName . ' AS VAL FROM SYSIBM.SYSDUMMY1'; } else { $quotedSequenceName = $sequenceName; $sql = 'SELECT PREVVAL FOR ' . $this->quoteIdentifier($sequenceName, true) . ' AS VAL FROM QSYS2.QSQPTABL'; } $value = $this->fetchOne($sql); return (string) $value; } /** * Generate a new value from the specified sequence in the database, and return it. * This is supported only on RDBMS brands that support sequences * (e.g. Oracle, PostgreSQL, DB2). Other RDBMS brands return null. * * @param string $sequenceName * @return string */ public function nextSequenceId($sequenceName) { $this->_connect(); $sql = 'SELECT NEXTVAL FOR '.$this->quoteIdentifier($sequenceName, true).' AS VAL FROM SYSIBM.SYSDUMMY1'; $value = $this->fetchOne($sql); return (string) $value; } /** * Gets the last ID generated automatically by an IDENTITY/AUTOINCREMENT column. * * As a convention, on RDBMS brands that support sequences * (e.g. Oracle, PostgreSQL, DB2), this method forms the name of a sequence * from the arguments and returns the last id generated by that sequence. * On RDBMS brands that support IDENTITY/AUTOINCREMENT columns, this method * returns the last value generated for such a column, and the table name * argument is disregarded. * * The IDENTITY_VAL_LOCAL() function gives the last generated identity value * in the current process, even if it was for a GENERATED column. * * @param string $tableName OPTIONAL * @param string $primaryKey OPTIONAL * @param string $idType OPTIONAL used for i5 platform to define sequence/idenity unique value * @return string */ public function lastInsertId($tableName = null, $primaryKey = null, $idType = null) { $this->_connect(); if ($this->_isI5) { return (string) $this->_i5LastInsertId($tableName, $idType); } if ($tableName !== null) { $sequenceName = $tableName; if ($primaryKey) { $sequenceName .= "_$primaryKey"; } $sequenceName .= '_seq'; return $this->lastSequenceId($sequenceName); } $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1'; $value = $this->fetchOne($sql); return (string) $value; } /** * Begin a transaction. * * @return void */ protected function _beginTransaction() { $this->_setExecuteMode(DB2_AUTOCOMMIT_OFF); } /** * Commit a transaction. * * @return void */ protected function _commit() { if (!db2_commit($this->_connection)) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception( db2_conn_errormsg($this->_connection), db2_conn_error($this->_connection)); } $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); } /** * Rollback a transaction. * * @return void */ protected function _rollBack() { if (!db2_rollback($this->_connection)) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception( db2_conn_errormsg($this->_connection), db2_conn_error($this->_connection)); } $this->_setExecuteMode(DB2_AUTOCOMMIT_ON); } /** * Set the fetch mode. * * @param integer $mode * @return void * @throws Zend_Db_Adapter_Db2_Exception */ public function setFetchMode($mode) { switch ($mode) { case Zend_Db::FETCH_NUM: // seq array case Zend_Db::FETCH_ASSOC: // assoc array case Zend_Db::FETCH_BOTH: // seq+assoc array case Zend_Db::FETCH_OBJ: // object $this->_fetchMode = $mode; break; case Zend_Db::FETCH_BOUND: // bound to PHP variable /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception('FETCH_BOUND is not supported yet'); break; default: /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("Invalid fetch mode '$mode' specified"); break; } } /** * Adds an adapter-specific LIMIT clause to the SELECT statement. * * @param string $sql * @param integer $count * @param integer $offset OPTIONAL * @return string */ public function limit($sql, $count, $offset = 0) { $count = intval($count); if ($count <= 0) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument count=$count is not valid"); } $offset = intval($offset); if ($offset < 0) { /** * @see Zend_Db_Adapter_Db2_Exception */ require_once 'Zend/Db/Adapter/Db2/Exception.php'; throw new Zend_Db_Adapter_Db2_Exception("LIMIT argument offset=$offset is not valid"); } if ($offset == 0) { $limit_sql = $sql . " FETCH FIRST $count ROWS ONLY"; return $limit_sql; } /** * DB2 does not implement the LIMIT clause as some RDBMS do. * We have to simulate it with subqueries and ROWNUM. * Unfortunately because we use the column wildcard "*", * this puts an extra column into the query result set. */ $limit_sql = "SELECT z2.* FROM ( SELECT ROW_NUMBER() OVER() AS \"ZEND_DB_ROWNUM\", z1.* FROM ( " . $sql . " ) z1 ) z2 WHERE z2.zend_db_rownum BETWEEN " . ($offset+1) . " AND " . ($offset+$count); return $limit_sql; } /** * Check if the adapter supports real SQL parameters. * * @param string $type 'positional' or 'named' * @return bool */ public function supportsParameters($type) { if ($type == 'positional') { return true; } // if its 'named' or anything else return false; } /** * Retrieve server version in PHP style * * @return string */ public function getServerVersion() { $this->_connect(); $server_info = db2_server_info($this->_connection); if ($server_info !== false) { $version = $server_info->DBMS_VER; if ($this->_isI5) { $version = (int) substr($version, 0, 2) . '.' . (int) substr($version, 2, 2) . '.' . (int) substr($version, 4); } return $version; } else { return null; } } /** * Return whether or not this is running on i5 * * @return bool */ public function isI5() { if ($this->_isI5 === null) { $this->_determineI5(); } return (bool) $this->_isI5; } /** * Check the connection parameters according to verify * type of used OS * * @return void */ protected function _determineI5() { // first us the compiled flag. $this->_isI5 = (php_uname('s') == 'OS400') ? true : false; // if this is set, then us it if (isset($this->_config['os'])){ if (strtolower($this->_config['os']) === 'i5') { $this->_isI5 = true; } else { // any other value passed in, its null $this->_isI5 = false; } } } /** * Db2 On I5 specific method * * Returns a list of the tables in the database . * Used only for DB2/400. * * @return array */ protected function _i5listTables($schema = null) { //list of i5 libraries. $tables = array(); if ($schema) { $tablesStatement = db2_tables($this->_connection, null, $schema); while ($rowTables = db2_fetch_assoc($tablesStatement) ) { if ($rowTables['TABLE_NAME'] !== null) { $tables[] = $rowTables['TABLE_NAME']; } } } else { $schemaStatement = db2_tables($this->_connection); while ($schema = db2_fetch_assoc($schemaStatement)) { if ($schema['TABLE_SCHEM'] !== null) { // list of the tables which belongs to the selected library $tablesStatement = db2_tables($this->_connection, NULL, $schema['TABLE_SCHEM']); if (is_resource($tablesStatement)) { while ($rowTables = db2_fetch_assoc($tablesStatement) ) { if ($rowTables['TABLE_NAME'] !== null) { $tables[] = $rowTables['TABLE_NAME']; } } } } } } return $tables; } protected function _i5LastInsertId($objectName = null, $idType = null) { if ($objectName === null) { $sql = 'SELECT IDENTITY_VAL_LOCAL() AS VAL FROM QSYS2.QSQPTABL'; $value = $this->fetchOne($sql); return $value; } if (strtoupper($idType) === 'S'){ //check i5_lib option $sequenceName = $objectName; return $this->lastSequenceId($sequenceName); } //returns last identity value for the specified table //if (strtoupper($idType) === 'I') { $tableName = $objectName; return $this->fetchOne('SELECT IDENTITY_VAL_LOCAL() from ' . $this->quoteIdentifier($tableName)); } }
{ "pile_set_name": "Github" }
'use strict'; var clear = require('es5-ext/array/#/clear') , eIndexOf = require('es5-ext/array/#/e-index-of') , setPrototypeOf = require('es5-ext/object/set-prototype-of') , callable = require('es5-ext/object/valid-callable') , d = require('d') , ee = require('event-emitter') , Symbol = require('es6-symbol') , iterator = require('es6-iterator/valid-iterable') , forOf = require('es6-iterator/for-of') , Iterator = require('./lib/iterator') , isNative = require('./is-native-implemented') , call = Function.prototype.call , defineProperty = Object.defineProperty, getPrototypeOf = Object.getPrototypeOf , SetPoly, getValues, NativeSet; if (isNative) NativeSet = Set; module.exports = SetPoly = function Set(/*iterable*/) { var iterable = arguments[0], self; if (!(this instanceof SetPoly)) throw new TypeError('Constructor requires \'new\''); if (isNative && setPrototypeOf) self = setPrototypeOf(new NativeSet(), getPrototypeOf(this)); else self = this; if (iterable != null) iterator(iterable); defineProperty(self, '__setData__', d('c', [])); if (!iterable) return self; forOf(iterable, function (value) { if (eIndexOf.call(this, value) !== -1) return; this.push(value); }, self.__setData__); return self; }; if (isNative) { if (setPrototypeOf) setPrototypeOf(SetPoly, NativeSet); SetPoly.prototype = Object.create(NativeSet.prototype, { constructor: d(SetPoly) }); } ee(Object.defineProperties(SetPoly.prototype, { add: d(function (value) { if (this.has(value)) return this; this.emit('_add', this.__setData__.push(value) - 1, value); return this; }), clear: d(function () { if (!this.__setData__.length) return; clear.call(this.__setData__); this.emit('_clear'); }), delete: d(function (value) { var index = eIndexOf.call(this.__setData__, value); if (index === -1) return false; this.__setData__.splice(index, 1); this.emit('_delete', index, value); return true; }), entries: d(function () { return new Iterator(this, 'key+value'); }), forEach: d(function (cb/*, thisArg*/) { var thisArg = arguments[1], iterator, result, value; callable(cb); iterator = this.values(); result = iterator._next(); while (result !== undefined) { value = iterator._resolve(result); call.call(cb, thisArg, value, value, this); result = iterator._next(); } }), has: d(function (value) { return (eIndexOf.call(this.__setData__, value) !== -1); }), keys: d(getValues = function () { return this.values(); }), size: d.gs(function () { return this.__setData__.length; }), values: d(function () { return new Iterator(this); }), toString: d(function () { return '[object Set]'; }) })); defineProperty(SetPoly.prototype, Symbol.iterator, d(getValues)); defineProperty(SetPoly.prototype, Symbol.toStringTag, d('c', 'Set'));
{ "pile_set_name": "Github" }
import os import vaping.plugins.fping_mtr from vaping import plugin expect_verbose = { "10.130.133.1 : 273.89 298.10 322.58": { "host": "10.130.133.1", "min": 273.89, "max": 322.58, "avg": 298.19, "cnt": 3, "loss": 0.0, # "last" : 302.58, }, "10.130.133.2 : 100 - 50": { "host": "10.130.133.2", "min": 50.0, "max": 100.0, "avg": 75.0, "cnt": 3, "loss": 0.333, }, "10.130.133.2 : - - -": {"host": "10.130.133.2", "cnt": 3, "loss": 1,}, "example.com: Temporary failure in name resolution": {}, } def assert_parsed(data, parsed): # dump in json format for easily adding expected print( "echo \\\n'{}'\\\n > {}/{}.expected".format( data.dumps(parsed), data.path, data.name ) ) assert data.expected == parsed def test_run_probe(config_dir): config_dir = os.path.join(config_dir, "fping_mtr") daemon = vaping.daemon.Vaping(config_dir=config_dir) probes = daemon.config.get("probes", None) mtr = plugin.get_probe(probes[0], daemon.plugin_context) msg = mtr.probe() print(msg) def test_parse_traceroute(data_mtr_traceroute): mtr = vaping.plugin.get_plugin_class("fping_mtr")({}, None) print(data_mtr_traceroute.input) print(data_mtr_traceroute.expected) print("=======") hosts = mtr.parse_traceroute(data_mtr_traceroute.input.splitlines()) print(f"HOSTS: {hosts}") # XXX need to refactor to properly test if host and hosts not in host assert_parsed(data_mtr_traceroute, hosts)
{ "pile_set_name": "Github" }
/** * This file is copyright 2017 State of the Netherlands (Ministry of Interior Affairs and Kingdom Relations). * It is made available under the terms of the GNU Affero General Public License, version 3 as published by the Free Software Foundation. * The project of which this file is part, may be found at https://github.com/MinBZK/operatieBRP. */ package nl.bzk.brp.preview.model; import java.util.ArrayList; import java.util.List; import org.codehaus.jackson.annotate.JsonIgnore; import org.springframework.util.StringUtils; public class HuwelijkBerichtRequest extends AbstractBerichtRequest { private final Datum datumAanvang = new Datum(); private Plaats plaats; private Persoon persoon1; private Persoon persoon2; @Override public OndersteundeBijhoudingsTypes getSoortBijhouding() { return OndersteundeBijhoudingsTypes.HUWELIJK; } @Override public List<Integer> creeerBsnLijst() { List<Integer> resultaat = new ArrayList<Integer>(); resultaat.add(persoon1.getBsn()); resultaat.add(persoon2.getBsn()); return resultaat; } @Override public String creeerBerichtTekst() { String format = "Huwelijk op %s%s tussen %s en %s."; return String.format(format, getDatumAanvangTekst(), getPlaatsTekst(), persoon1.getNaamTekst(), persoon2.getNaamTekst()); } public int getDatumAanvang() { return datumAanvang.getDecimalen(); } @JsonIgnore public String getDatumAanvangTekst() { return datumAanvang.getTekst(); } public void setDatumAanvang(final int datumAanvang) { this.datumAanvang.setDecimalen(datumAanvang); } public Plaats getPlaats() { return plaats; } @JsonIgnore public String getPlaatsTekst() { return hasPlaats() ? "" : (" te " + plaats.getNaam()); } private boolean hasPlaats() { return plaats == null || !StringUtils.hasText(plaats.getNaam()); } public void setPlaats(final Plaats plaats) { this.plaats = plaats; } public Persoon getPersoon1() { return persoon1; } public void setPersoon1(final Persoon persoon1) { this.persoon1 = persoon1; } public Persoon getPersoon2() { return persoon2; } public void setPersoon2(final Persoon persoon2) { this.persoon2 = persoon2; } }
{ "pile_set_name": "Github" }
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource":[ "arn:aws:s3:::YOUR_BUCKET_GOES_HERE", "arn:aws:s3:::YOUR_BUCKET_GOES_HERE/*" ] }, { "Effect":"Allow", "Action":[ "ec2:ModifySnapshotAttribute", "ec2:CopySnapshot", "ec2:RegisterImage", "ec2:Describe*" ], "Resource":"*" } ] }
{ "pile_set_name": "Github" }
fileFormatVersion: 2 guid: b994edfef39184843958eb2298681372 timeCreated: 1490183878 licenseType: Pro MonoImporter: serializedVersion: 2 defaultReferences: [] executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant:
{ "pile_set_name": "Github" }
/* Copyright 2008, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * curve25519-donna: Curve25519 elliptic curve, public key function * * http://code.google.com/p/curve25519-donna/ * * Adam Langley <[email protected]> * * Derived from public domain C code by Daniel J. Bernstein <[email protected]> * * More information about curve25519 can be found here * http://cr.yp.to/ecdh.html * * djb's sample implementation of curve25519 is written in a special assembly * language called qhasm and uses the floating point registers. * * This is, almost, a clean room reimplementation from the curve25519 paper. It * uses many of the tricks described therein. Only the crecip function is taken * from the sample implementation. */ #include "orconfig.h" #include <string.h> #include "torint.h" typedef uint8_t u8; typedef int32_t s32; typedef int64_t limb; /* Field element representation: * * Field elements are written as an array of signed, 64-bit limbs, least * significant first. The value of the field element is: * x[0] + 2^26·x[1] + x^51·x[2] + 2^102·x[3] + ... * * i.e. the limbs are 26, 25, 26, 25, ... bits wide. */ /* Sum two numbers: output += in */ static void fsum(limb *output, const limb *in) { unsigned i; for (i = 0; i < 10; i += 2) { output[0+i] = output[0+i] + in[0+i]; output[1+i] = output[1+i] + in[1+i]; } } /* Find the difference of two numbers: output = in - output * (note the order of the arguments!). */ static void fdifference(limb *output, const limb *in) { unsigned i; for (i = 0; i < 10; ++i) { output[i] = in[i] - output[i]; } } /* Multiply a number by a scalar: output = in * scalar */ static void fscalar_product(limb *output, const limb *in, const limb scalar) { unsigned i; for (i = 0; i < 10; ++i) { output[i] = in[i] * scalar; } } /* Multiply two numbers: output = in2 * in * * output must be distinct to both inputs. The inputs are reduced coefficient * form, the output is not. * * output[x] <= 14 * the largest product of the input limbs. */ static void fproduct(limb *output, const limb *in2, const limb *in) { output[0] = ((limb) ((s32) in2[0])) * ((s32) in[0]); output[1] = ((limb) ((s32) in2[0])) * ((s32) in[1]) + ((limb) ((s32) in2[1])) * ((s32) in[0]); output[2] = 2 * ((limb) ((s32) in2[1])) * ((s32) in[1]) + ((limb) ((s32) in2[0])) * ((s32) in[2]) + ((limb) ((s32) in2[2])) * ((s32) in[0]); output[3] = ((limb) ((s32) in2[1])) * ((s32) in[2]) + ((limb) ((s32) in2[2])) * ((s32) in[1]) + ((limb) ((s32) in2[0])) * ((s32) in[3]) + ((limb) ((s32) in2[3])) * ((s32) in[0]); output[4] = ((limb) ((s32) in2[2])) * ((s32) in[2]) + 2 * (((limb) ((s32) in2[1])) * ((s32) in[3]) + ((limb) ((s32) in2[3])) * ((s32) in[1])) + ((limb) ((s32) in2[0])) * ((s32) in[4]) + ((limb) ((s32) in2[4])) * ((s32) in[0]); output[5] = ((limb) ((s32) in2[2])) * ((s32) in[3]) + ((limb) ((s32) in2[3])) * ((s32) in[2]) + ((limb) ((s32) in2[1])) * ((s32) in[4]) + ((limb) ((s32) in2[4])) * ((s32) in[1]) + ((limb) ((s32) in2[0])) * ((s32) in[5]) + ((limb) ((s32) in2[5])) * ((s32) in[0]); output[6] = 2 * (((limb) ((s32) in2[3])) * ((s32) in[3]) + ((limb) ((s32) in2[1])) * ((s32) in[5]) + ((limb) ((s32) in2[5])) * ((s32) in[1])) + ((limb) ((s32) in2[2])) * ((s32) in[4]) + ((limb) ((s32) in2[4])) * ((s32) in[2]) + ((limb) ((s32) in2[0])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[0]); output[7] = ((limb) ((s32) in2[3])) * ((s32) in[4]) + ((limb) ((s32) in2[4])) * ((s32) in[3]) + ((limb) ((s32) in2[2])) * ((s32) in[5]) + ((limb) ((s32) in2[5])) * ((s32) in[2]) + ((limb) ((s32) in2[1])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[1]) + ((limb) ((s32) in2[0])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[0]); output[8] = ((limb) ((s32) in2[4])) * ((s32) in[4]) + 2 * (((limb) ((s32) in2[3])) * ((s32) in[5]) + ((limb) ((s32) in2[5])) * ((s32) in[3]) + ((limb) ((s32) in2[1])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[1])) + ((limb) ((s32) in2[2])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[2]) + ((limb) ((s32) in2[0])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[0]); output[9] = ((limb) ((s32) in2[4])) * ((s32) in[5]) + ((limb) ((s32) in2[5])) * ((s32) in[4]) + ((limb) ((s32) in2[3])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[3]) + ((limb) ((s32) in2[2])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[2]) + ((limb) ((s32) in2[1])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[1]) + ((limb) ((s32) in2[0])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[0]); output[10] = 2 * (((limb) ((s32) in2[5])) * ((s32) in[5]) + ((limb) ((s32) in2[3])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[3]) + ((limb) ((s32) in2[1])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[1])) + ((limb) ((s32) in2[4])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[4]) + ((limb) ((s32) in2[2])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[2]); output[11] = ((limb) ((s32) in2[5])) * ((s32) in[6]) + ((limb) ((s32) in2[6])) * ((s32) in[5]) + ((limb) ((s32) in2[4])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[4]) + ((limb) ((s32) in2[3])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[3]) + ((limb) ((s32) in2[2])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[2]); output[12] = ((limb) ((s32) in2[6])) * ((s32) in[6]) + 2 * (((limb) ((s32) in2[5])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[5]) + ((limb) ((s32) in2[3])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[3])) + ((limb) ((s32) in2[4])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[4]); output[13] = ((limb) ((s32) in2[6])) * ((s32) in[7]) + ((limb) ((s32) in2[7])) * ((s32) in[6]) + ((limb) ((s32) in2[5])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[5]) + ((limb) ((s32) in2[4])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[4]); output[14] = 2 * (((limb) ((s32) in2[7])) * ((s32) in[7]) + ((limb) ((s32) in2[5])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[5])) + ((limb) ((s32) in2[6])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[6]); output[15] = ((limb) ((s32) in2[7])) * ((s32) in[8]) + ((limb) ((s32) in2[8])) * ((s32) in[7]) + ((limb) ((s32) in2[6])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[6]); output[16] = ((limb) ((s32) in2[8])) * ((s32) in[8]) + 2 * (((limb) ((s32) in2[7])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[7])); output[17] = ((limb) ((s32) in2[8])) * ((s32) in[9]) + ((limb) ((s32) in2[9])) * ((s32) in[8]); output[18] = 2 * ((limb) ((s32) in2[9])) * ((s32) in[9]); } /* Reduce a long form to a short form by taking the input mod 2^255 - 19. * * On entry: |output[i]| < 14*2^54 * On exit: |output[0..8]| < 280*2^54 */ static void freduce_degree(limb *output) { /* Each of these shifts and adds ends up multiplying the value by 19. * * For output[0..8], the absolute entry value is < 14*2^54 and we add, at * most, 19*14*2^54 thus, on exit, |output[0..8]| < 280*2^54. */ output[8] += output[18] << 4; output[8] += output[18] << 1; output[8] += output[18]; output[7] += output[17] << 4; output[7] += output[17] << 1; output[7] += output[17]; output[6] += output[16] << 4; output[6] += output[16] << 1; output[6] += output[16]; output[5] += output[15] << 4; output[5] += output[15] << 1; output[5] += output[15]; output[4] += output[14] << 4; output[4] += output[14] << 1; output[4] += output[14]; output[3] += output[13] << 4; output[3] += output[13] << 1; output[3] += output[13]; output[2] += output[12] << 4; output[2] += output[12] << 1; output[2] += output[12]; output[1] += output[11] << 4; output[1] += output[11] << 1; output[1] += output[11]; output[0] += output[10] << 4; output[0] += output[10] << 1; output[0] += output[10]; } #if (-1 & 3) != 3 #error "This code only works on a two's complement system" #endif /* return v / 2^26, using only shifts and adds. * * On entry: v can take any value. */ static inline limb div_by_2_26(const limb v) { /* High word of v; no shift needed. */ const uint32_t highword = (uint32_t) (((uint64_t) v) >> 32); /* Set to all 1s if v was negative; else set to 0s. */ const int32_t sign = ((int32_t) highword) >> 31; /* Set to 0x3ffffff if v was negative; else set to 0. */ const int32_t roundoff = ((uint32_t) sign) >> 6; /* Should return v / (1<<26) */ return (v + roundoff) >> 26; } /* return v / (2^25), using only shifts and adds. * * On entry: v can take any value. */ static inline limb div_by_2_25(const limb v) { /* High word of v; no shift needed*/ const uint32_t highword = (uint32_t) (((uint64_t) v) >> 32); /* Set to all 1s if v was negative; else set to 0s. */ const int32_t sign = ((int32_t) highword) >> 31; /* Set to 0x1ffffff if v was negative; else set to 0. */ const int32_t roundoff = ((uint32_t) sign) >> 7; /* Should return v / (1<<25) */ return (v + roundoff) >> 25; } #if 0 /* return v / (2^25), using only shifts and adds. * * On entry: v can take any value. */ static inline s32 div_s32_by_2_25(const s32 v) { const s32 roundoff = ((uint32_t)(v >> 31)) >> 7; return (v + roundoff) >> 25; } #endif /* Reduce all coefficients of the short form input so that |x| < 2^26. * * On entry: |output[i]| < 280*2^54 */ static void freduce_coefficients(limb *output) { unsigned i; output[10] = 0; for (i = 0; i < 10; i += 2) { limb over = div_by_2_26(output[i]); /* The entry condition (that |output[i]| < 280*2^54) means that over is, at * most, 280*2^28 in the first iteration of this loop. This is added to the * next limb and we can approximate the resulting bound of that limb by * 281*2^54. */ output[i] -= over << 26; output[i+1] += over; /* For the first iteration, |output[i+1]| < 281*2^54, thus |over| < * 281*2^29. When this is added to the next limb, the resulting bound can * be approximated as 281*2^54. * * For subsequent iterations of the loop, 281*2^54 remains a conservative * bound and no overflow occurs. */ over = div_by_2_25(output[i+1]); output[i+1] -= over << 25; output[i+2] += over; } /* Now |output[10]| < 281*2^29 and all other coefficients are reduced. */ output[0] += output[10] << 4; output[0] += output[10] << 1; output[0] += output[10]; output[10] = 0; /* Now output[1..9] are reduced, and |output[0]| < 2^26 + 19*281*2^29 * So |over| will be no more than 2^16. */ { limb over = div_by_2_26(output[0]); output[0] -= over << 26; output[1] += over; } /* Now output[0,2..9] are reduced, and |output[1]| < 2^25 + 2^16 < 2^26. The * bound on |output[1]| is sufficient to meet our needs. */ } /* A helpful wrapper around fproduct: output = in * in2. * * On entry: |in[i]| < 2^27 and |in2[i]| < 2^27. * * output must be distinct to both inputs. The output is reduced degree * (indeed, one need only provide storage for 10 limbs) and |output[i]| < 2^26. */ static void fmul(limb *output, const limb *in, const limb *in2) { limb t[19]; fproduct(t, in, in2); /* |t[i]| < 14*2^54 */ freduce_degree(t); freduce_coefficients(t); /* |t[i]| < 2^26 */ memcpy(output, t, sizeof(limb) * 10); } /* Square a number: output = in**2 * * output must be distinct from the input. The inputs are reduced coefficient * form, the output is not. * * output[x] <= 14 * the largest product of the input limbs. */ static void fsquare_inner(limb *output, const limb *in) { output[0] = ((limb) ((s32) in[0])) * ((s32) in[0]); output[1] = 2 * ((limb) ((s32) in[0])) * ((s32) in[1]); output[2] = 2 * (((limb) ((s32) in[1])) * ((s32) in[1]) + ((limb) ((s32) in[0])) * ((s32) in[2])); output[3] = 2 * (((limb) ((s32) in[1])) * ((s32) in[2]) + ((limb) ((s32) in[0])) * ((s32) in[3])); output[4] = ((limb) ((s32) in[2])) * ((s32) in[2]) + 4 * ((limb) ((s32) in[1])) * ((s32) in[3]) + 2 * ((limb) ((s32) in[0])) * ((s32) in[4]); output[5] = 2 * (((limb) ((s32) in[2])) * ((s32) in[3]) + ((limb) ((s32) in[1])) * ((s32) in[4]) + ((limb) ((s32) in[0])) * ((s32) in[5])); output[6] = 2 * (((limb) ((s32) in[3])) * ((s32) in[3]) + ((limb) ((s32) in[2])) * ((s32) in[4]) + ((limb) ((s32) in[0])) * ((s32) in[6]) + 2 * ((limb) ((s32) in[1])) * ((s32) in[5])); output[7] = 2 * (((limb) ((s32) in[3])) * ((s32) in[4]) + ((limb) ((s32) in[2])) * ((s32) in[5]) + ((limb) ((s32) in[1])) * ((s32) in[6]) + ((limb) ((s32) in[0])) * ((s32) in[7])); output[8] = ((limb) ((s32) in[4])) * ((s32) in[4]) + 2 * (((limb) ((s32) in[2])) * ((s32) in[6]) + ((limb) ((s32) in[0])) * ((s32) in[8]) + 2 * (((limb) ((s32) in[1])) * ((s32) in[7]) + ((limb) ((s32) in[3])) * ((s32) in[5]))); output[9] = 2 * (((limb) ((s32) in[4])) * ((s32) in[5]) + ((limb) ((s32) in[3])) * ((s32) in[6]) + ((limb) ((s32) in[2])) * ((s32) in[7]) + ((limb) ((s32) in[1])) * ((s32) in[8]) + ((limb) ((s32) in[0])) * ((s32) in[9])); output[10] = 2 * (((limb) ((s32) in[5])) * ((s32) in[5]) + ((limb) ((s32) in[4])) * ((s32) in[6]) + ((limb) ((s32) in[2])) * ((s32) in[8]) + 2 * (((limb) ((s32) in[3])) * ((s32) in[7]) + ((limb) ((s32) in[1])) * ((s32) in[9]))); output[11] = 2 * (((limb) ((s32) in[5])) * ((s32) in[6]) + ((limb) ((s32) in[4])) * ((s32) in[7]) + ((limb) ((s32) in[3])) * ((s32) in[8]) + ((limb) ((s32) in[2])) * ((s32) in[9])); output[12] = ((limb) ((s32) in[6])) * ((s32) in[6]) + 2 * (((limb) ((s32) in[4])) * ((s32) in[8]) + 2 * (((limb) ((s32) in[5])) * ((s32) in[7]) + ((limb) ((s32) in[3])) * ((s32) in[9]))); output[13] = 2 * (((limb) ((s32) in[6])) * ((s32) in[7]) + ((limb) ((s32) in[5])) * ((s32) in[8]) + ((limb) ((s32) in[4])) * ((s32) in[9])); output[14] = 2 * (((limb) ((s32) in[7])) * ((s32) in[7]) + ((limb) ((s32) in[6])) * ((s32) in[8]) + 2 * ((limb) ((s32) in[5])) * ((s32) in[9])); output[15] = 2 * (((limb) ((s32) in[7])) * ((s32) in[8]) + ((limb) ((s32) in[6])) * ((s32) in[9])); output[16] = ((limb) ((s32) in[8])) * ((s32) in[8]) + 4 * ((limb) ((s32) in[7])) * ((s32) in[9]); output[17] = 2 * ((limb) ((s32) in[8])) * ((s32) in[9]); output[18] = 2 * ((limb) ((s32) in[9])) * ((s32) in[9]); } /* fsquare sets output = in^2. * * On entry: The |in| argument is in reduced coefficients form and |in[i]| < * 2^27. * * On exit: The |output| argument is in reduced coefficients form (indeed, one * need only provide storage for 10 limbs) and |out[i]| < 2^26. */ static void fsquare(limb *output, const limb *in) { limb t[19]; fsquare_inner(t, in); /* |t[i]| < 14*2^54 because the largest product of two limbs will be < * 2^(27+27) and fsquare_inner adds together, at most, 14 of those * products. */ freduce_degree(t); freduce_coefficients(t); /* |t[i]| < 2^26 */ memcpy(output, t, sizeof(limb) * 10); } /* Take a little-endian, 32-byte number and expand it into polynomial form */ static void fexpand(limb *output, const u8 *input) { #define F(n,start,shift,mask) \ output[n] = ((((limb) input[start + 0]) | \ ((limb) input[start + 1]) << 8 | \ ((limb) input[start + 2]) << 16 | \ ((limb) input[start + 3]) << 24) >> shift) & mask; F(0, 0, 0, 0x3ffffff); F(1, 3, 2, 0x1ffffff); F(2, 6, 3, 0x3ffffff); F(3, 9, 5, 0x1ffffff); F(4, 12, 6, 0x3ffffff); F(5, 16, 0, 0x1ffffff); F(6, 19, 1, 0x3ffffff); F(7, 22, 3, 0x1ffffff); F(8, 25, 4, 0x3ffffff); F(9, 28, 6, 0x1ffffff); #undef F } #if (-32 >> 1) != -16 #error "This code only works when >> does sign-extension on negative numbers" #endif /* s32_eq returns 0xffffffff iff a == b and zero otherwise. */ static s32 s32_eq(s32 a, s32 b) { a = ~(a ^ b); a &= a << 16; a &= a << 8; a &= a << 4; a &= a << 2; a &= a << 1; return a >> 31; } /* s32_gte returns 0xffffffff if a >= b and zero otherwise, where a and b are * both non-negative. */ static s32 s32_gte(s32 a, s32 b) { a -= b; /* a >= 0 iff a >= b. */ return ~(a >> 31); } /* Take a fully reduced polynomial form number and contract it into a * little-endian, 32-byte array. * * On entry: |input_limbs[i]| < 2^26 */ static void fcontract(u8 *output, limb *input_limbs) { int i; int j; s32 input[10]; s32 mask; /* |input_limbs[i]| < 2^26, so it's valid to convert to an s32. */ for (i = 0; i < 10; i++) { input[i] = (s32) input_limbs[i]; } for (j = 0; j < 2; ++j) { for (i = 0; i < 9; ++i) { if ((i & 1) == 1) { /* This calculation is a time-invariant way to make input[i] * non-negative by borrowing from the next-larger limb. */ const s32 mask = input[i] >> 31; const s32 carry = -((input[i] & mask) >> 25); input[i] = input[i] + (carry << 25); input[i+1] = input[i+1] - carry; } else { const s32 mask = input[i] >> 31; const s32 carry = -((input[i] & mask) >> 26); input[i] = input[i] + (carry << 26); input[i+1] = input[i+1] - carry; } } /* There's no greater limb for input[9] to borrow from, but we can multiply * by 19 and borrow from input[0], which is valid mod 2^255-19. */ { const s32 mask = input[9] >> 31; const s32 carry = -((input[9] & mask) >> 25); input[9] = input[9] + (carry << 25); input[0] = input[0] - (carry * 19); } /* After the first iteration, input[1..9] are non-negative and fit within * 25 or 26 bits, depending on position. However, input[0] may be * negative. */ } /* The first borrow-propagation pass above ended with every limb except (possibly) input[0] non-negative. If input[0] was negative after the first pass, then it was because of a carry from input[9]. On entry, input[9] < 2^26 so the carry was, at most, one, since (2**26-1) >> 25 = 1. Thus input[0] >= -19. In the second pass, each limb is decreased by at most one. Thus the second borrow-propagation pass could only have wrapped around to decrease input[0] again if the first pass left input[0] negative *and* input[1] through input[9] were all zero. In that case, input[1] is now 2^25 - 1, and this last borrow-propagation step will leave input[1] non-negative. */ { const s32 mask = input[0] >> 31; const s32 carry = -((input[0] & mask) >> 26); input[0] = input[0] + (carry << 26); input[1] = input[1] - carry; } /* All input[i] are now non-negative. However, there might be values between * 2^25 and 2^26 in a limb which is, nominally, 25 bits wide. */ for (j = 0; j < 2; j++) { for (i = 0; i < 9; i++) { if ((i & 1) == 1) { const s32 carry = input[i] >> 25; input[i] &= 0x1ffffff; input[i+1] += carry; } else { const s32 carry = input[i] >> 26; input[i] &= 0x3ffffff; input[i+1] += carry; } } { const s32 carry = input[9] >> 25; input[9] &= 0x1ffffff; input[0] += 19*carry; } } /* If the first carry-chain pass, just above, ended up with a carry from * input[9], and that caused input[0] to be out-of-bounds, then input[0] was * < 2^26 + 2*19, because the carry was, at most, two. * * If the second pass carried from input[9] again then input[0] is < 2*19 and * the input[9] -> input[0] carry didn't push input[0] out of bounds. */ /* It still remains the case that input might be between 2^255-19 and 2^255. * In this case, input[1..9] must take their maximum value and input[0] must * be >= (2^255-19) & 0x3ffffff, which is 0x3ffffed. */ mask = s32_gte(input[0], 0x3ffffed); for (i = 1; i < 10; i++) { if ((i & 1) == 1) { mask &= s32_eq(input[i], 0x1ffffff); } else { mask &= s32_eq(input[i], 0x3ffffff); } } /* mask is either 0xffffffff (if input >= 2^255-19) and zero otherwise. Thus * this conditionally subtracts 2^255-19. */ input[0] -= mask & 0x3ffffed; for (i = 1; i < 10; i++) { if ((i & 1) == 1) { input[i] -= mask & 0x1ffffff; } else { input[i] -= mask & 0x3ffffff; } } input[1] <<= 2; input[2] <<= 3; input[3] <<= 5; input[4] <<= 6; input[6] <<= 1; input[7] <<= 3; input[8] <<= 4; input[9] <<= 6; #define F(i, s) \ output[s+0] |= input[i] & 0xff; \ output[s+1] = (input[i] >> 8) & 0xff; \ output[s+2] = (input[i] >> 16) & 0xff; \ output[s+3] = (input[i] >> 24) & 0xff; output[0] = 0; output[16] = 0; F(0,0); F(1,3); F(2,6); F(3,9); F(4,12); F(5,16); F(6,19); F(7,22); F(8,25); F(9,28); #undef F } /* Input: Q, Q', Q-Q' * Output: 2Q, Q+Q' * * x2 z3: long form * x3 z3: long form * x z: short form, destroyed * xprime zprime: short form, destroyed * qmqp: short form, preserved * * On entry and exit, the absolute value of the limbs of all inputs and outputs * are < 2^26. */ static void fmonty(limb *x2, limb *z2, /* output 2Q */ limb *x3, limb *z3, /* output Q + Q' */ limb *x, limb *z, /* input Q */ limb *xprime, limb *zprime, /* input Q' */ const limb *qmqp /* input Q - Q' */) { limb origx[10], origxprime[10], zzz[19], xx[19], zz[19], xxprime[19], zzprime[19], zzzprime[19], xxxprime[19]; memcpy(origx, x, 10 * sizeof(limb)); fsum(x, z); /* |x[i]| < 2^27 */ fdifference(z, origx); /* does x - z */ /* |z[i]| < 2^27 */ memcpy(origxprime, xprime, sizeof(limb) * 10); fsum(xprime, zprime); /* |xprime[i]| < 2^27 */ fdifference(zprime, origxprime); /* |zprime[i]| < 2^27 */ fproduct(xxprime, xprime, z); /* |xxprime[i]| < 14*2^54: the largest product of two limbs will be < * 2^(27+27) and fproduct adds together, at most, 14 of those products. * (Approximating that to 2^58 doesn't work out.) */ fproduct(zzprime, x, zprime); /* |zzprime[i]| < 14*2^54 */ freduce_degree(xxprime); freduce_coefficients(xxprime); /* |xxprime[i]| < 2^26 */ freduce_degree(zzprime); freduce_coefficients(zzprime); /* |zzprime[i]| < 2^26 */ memcpy(origxprime, xxprime, sizeof(limb) * 10); fsum(xxprime, zzprime); /* |xxprime[i]| < 2^27 */ fdifference(zzprime, origxprime); /* |zzprime[i]| < 2^27 */ fsquare(xxxprime, xxprime); /* |xxxprime[i]| < 2^26 */ fsquare(zzzprime, zzprime); /* |zzzprime[i]| < 2^26 */ fproduct(zzprime, zzzprime, qmqp); /* |zzprime[i]| < 14*2^52 */ freduce_degree(zzprime); freduce_coefficients(zzprime); /* |zzprime[i]| < 2^26 */ memcpy(x3, xxxprime, sizeof(limb) * 10); memcpy(z3, zzprime, sizeof(limb) * 10); fsquare(xx, x); /* |xx[i]| < 2^26 */ fsquare(zz, z); /* |zz[i]| < 2^26 */ fproduct(x2, xx, zz); /* |x2[i]| < 14*2^52 */ freduce_degree(x2); freduce_coefficients(x2); /* |x2[i]| < 2^26 */ fdifference(zz, xx); // does zz = xx - zz /* |zz[i]| < 2^27 */ memset(zzz + 10, 0, sizeof(limb) * 9); fscalar_product(zzz, zz, 121665); /* |zzz[i]| < 2^(27+17) */ /* No need to call freduce_degree here: fscalar_product doesn't increase the degree of its input. */ freduce_coefficients(zzz); /* |zzz[i]| < 2^26 */ fsum(zzz, xx); /* |zzz[i]| < 2^27 */ fproduct(z2, zz, zzz); /* |z2[i]| < 14*2^(26+27) */ freduce_degree(z2); freduce_coefficients(z2); /* |z2|i| < 2^26 */ } /* Conditionally swap two reduced-form limb arrays if 'iswap' is 1, but leave * them unchanged if 'iswap' is 0. Runs in data-invariant time to avoid * side-channel attacks. * * NOTE that this function requires that 'iswap' be 1 or 0; other values give * wrong results. Also, the two limb arrays must be in reduced-coefficient, * reduced-degree form: the values in a[10..19] or b[10..19] aren't swapped, * and all all values in a[0..9],b[0..9] must have magnitude less than * INT32_MAX. */ static void swap_conditional(limb a[19], limb b[19], limb iswap) { unsigned i; const s32 swap = (s32) -iswap; for (i = 0; i < 10; ++i) { const s32 x = swap & ( ((s32)a[i]) ^ ((s32)b[i]) ); a[i] = ((s32)a[i]) ^ x; b[i] = ((s32)b[i]) ^ x; } } /* Calculates nQ where Q is the x-coordinate of a point on the curve * * resultx/resultz: the x coordinate of the resulting curve point (short form) * n: a little endian, 32-byte number * q: a point of the curve (short form) */ static void cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) { limb a[19] = {0}, b[19] = {1}, c[19] = {1}, d[19] = {0}; limb *nqpqx = a, *nqpqz = b, *nqx = c, *nqz = d, *t; limb e[19] = {0}, f[19] = {1}, g[19] = {0}, h[19] = {1}; limb *nqpqx2 = e, *nqpqz2 = f, *nqx2 = g, *nqz2 = h; unsigned i, j; memcpy(nqpqx, q, sizeof(limb) * 10); for (i = 0; i < 32; ++i) { u8 byte = n[31 - i]; for (j = 0; j < 8; ++j) { const limb bit = byte >> 7; swap_conditional(nqx, nqpqx, bit); swap_conditional(nqz, nqpqz, bit); fmonty(nqx2, nqz2, nqpqx2, nqpqz2, nqx, nqz, nqpqx, nqpqz, q); swap_conditional(nqx2, nqpqx2, bit); swap_conditional(nqz2, nqpqz2, bit); t = nqx; nqx = nqx2; nqx2 = t; t = nqz; nqz = nqz2; nqz2 = t; t = nqpqx; nqpqx = nqpqx2; nqpqx2 = t; t = nqpqz; nqpqz = nqpqz2; nqpqz2 = t; byte <<= 1; } } memcpy(resultx, nqx, sizeof(limb) * 10); memcpy(resultz, nqz, sizeof(limb) * 10); } // ----------------------------------------------------------------------------- // Shamelessly copied from djb's code // ----------------------------------------------------------------------------- static void crecip(limb *out, const limb *z) { limb z2[10]; limb z9[10]; limb z11[10]; limb z2_5_0[10]; limb z2_10_0[10]; limb z2_20_0[10]; limb z2_50_0[10]; limb z2_100_0[10]; limb t0[10]; limb t1[10]; int i; /* 2 */ fsquare(z2,z); /* 4 */ fsquare(t1,z2); /* 8 */ fsquare(t0,t1); /* 9 */ fmul(z9,t0,z); /* 11 */ fmul(z11,z9,z2); /* 22 */ fsquare(t0,z11); /* 2^5 - 2^0 = 31 */ fmul(z2_5_0,t0,z9); /* 2^6 - 2^1 */ fsquare(t0,z2_5_0); /* 2^7 - 2^2 */ fsquare(t1,t0); /* 2^8 - 2^3 */ fsquare(t0,t1); /* 2^9 - 2^4 */ fsquare(t1,t0); /* 2^10 - 2^5 */ fsquare(t0,t1); /* 2^10 - 2^0 */ fmul(z2_10_0,t0,z2_5_0); /* 2^11 - 2^1 */ fsquare(t0,z2_10_0); /* 2^12 - 2^2 */ fsquare(t1,t0); /* 2^20 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t0,t1); fsquare(t1,t0); } /* 2^20 - 2^0 */ fmul(z2_20_0,t1,z2_10_0); /* 2^21 - 2^1 */ fsquare(t0,z2_20_0); /* 2^22 - 2^2 */ fsquare(t1,t0); /* 2^40 - 2^20 */ for (i = 2;i < 20;i += 2) { fsquare(t0,t1); fsquare(t1,t0); } /* 2^40 - 2^0 */ fmul(t0,t1,z2_20_0); /* 2^41 - 2^1 */ fsquare(t1,t0); /* 2^42 - 2^2 */ fsquare(t0,t1); /* 2^50 - 2^10 */ for (i = 2;i < 10;i += 2) { fsquare(t1,t0); fsquare(t0,t1); } /* 2^50 - 2^0 */ fmul(z2_50_0,t0,z2_10_0); /* 2^51 - 2^1 */ fsquare(t0,z2_50_0); /* 2^52 - 2^2 */ fsquare(t1,t0); /* 2^100 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); } /* 2^100 - 2^0 */ fmul(z2_100_0,t1,z2_50_0); /* 2^101 - 2^1 */ fsquare(t1,z2_100_0); /* 2^102 - 2^2 */ fsquare(t0,t1); /* 2^200 - 2^100 */ for (i = 2;i < 100;i += 2) { fsquare(t1,t0); fsquare(t0,t1); } /* 2^200 - 2^0 */ fmul(t1,t0,z2_100_0); /* 2^201 - 2^1 */ fsquare(t0,t1); /* 2^202 - 2^2 */ fsquare(t1,t0); /* 2^250 - 2^50 */ for (i = 2;i < 50;i += 2) { fsquare(t0,t1); fsquare(t1,t0); } /* 2^250 - 2^0 */ fmul(t0,t1,z2_50_0); /* 2^251 - 2^1 */ fsquare(t1,t0); /* 2^252 - 2^2 */ fsquare(t0,t1); /* 2^253 - 2^3 */ fsquare(t1,t0); /* 2^254 - 2^4 */ fsquare(t0,t1); /* 2^255 - 2^5 */ fsquare(t1,t0); /* 2^255 - 21 */ fmul(out,t1,z11); } int curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint); int curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint) { limb bp[10], x[10], z[11], zmone[10]; uint8_t e[32]; int i; for (i = 0; i < 32; ++i) e[i] = secret[i]; e[0] &= 248; e[31] &= 127; e[31] |= 64; fexpand(bp, basepoint); cmult(x, z, e, bp); crecip(zmone, z); fmul(z, x, zmone); fcontract(mypublic, z); return 0; }
{ "pile_set_name": "Github" }
form=五律 tags= 万事皆可了, 有诗门最深。 古人难得志, 吾子苦留心。 野叠凉云朵, 苔重怪木阴。 他年立名字, 笑我老双林。
{ "pile_set_name": "Github" }
tell application "iTerm" create window with default profile tell current session of current window delay 2 write text "rm alien-minimal-1.4.1" delay 2 write text "asciinema rec alien-minimal-1.4.1" delay 5 write text "AM_VERSIONS_PROMPT=(RUBY RUBY_S PYTHON JAVA GO NODE PHP ELIXIR)" delay 2 write text "" delay 2 write text "" delay 2 write text "AM_VERSIONS_PROMPT=(RUBY_S JAVA NODE ELIXIR)" delay 2 write text "cd /tmp/am-demo" delay 2 write text "touch stash && git add stash" delay 2 write text "git stash push -m stash stash" delay 2 write text "false" delay 2 write text "true" delay 2 write text "unset AM_VERSIONS_PROMPT" delay 2 write text "source venv/bin/activate" delay 2 write text "export AM_PROMPT_START_TAG='--> '" delay 2 write text "export AM_PROMPT_END_TAG=' $'" delay 2 write text "false" delay 2 write text "true" delay 2 write text "export AM_ERROR_ON_START_TAG=1" delay 2 write text "false" delay 2 write text "true" delay 2 write text "unset AM_PROMPT_START_TAG AM_PROMPT_END_TAG" delay 2 write text "export AM_SHOW_FULL_DIR=1" delay 2 write text "export AM_SHOW_FULL_DIR=0" delay 2 write text "false" delay 2 write text "true" delay 2 write text "export AM_HIDE_EXIT_CODE=1" delay 2 write text "false" delay 2 write text "true" delay 2 write text "deactivate" delay 2 write text "touch stash && git add stash" delay 2 write text "git stash push -m stash2 stash" delay 2 write text "git stash pop" delay 2 write text "git rm stash && rm stash" delay 2 write text "git stash pop" delay 2 write text "git rm stash && rm stash" delay 2 write text "exit" delay 2 write text "exit" end tell end tell
{ "pile_set_name": "Github" }
/* Copyright (C) 2014, The University of Texas at Austin This file is part of libflame and is available under the 3-Clause BSD license, which can be found in the LICENSE file at the top-level directory, or at http://opensource.org/licenses/BSD-3-Clause */ #include "FLAME.h" #ifdef FLA_ENABLE_NON_CRITICAL_CODE FLA_Error FLA_Gemm_hh_unb_var5( FLA_Obj alpha, FLA_Obj A, FLA_Obj B, FLA_Obj beta, FLA_Obj C ) { FLA_Obj AT, A0, AB, a1t, A2; FLA_Obj BL, BR, B0, b1, B2; FLA_Scal_external( beta, C ); FLA_Part_2x1( A, &AT, &AB, 0, FLA_TOP ); FLA_Part_1x2( B, &BL, &BR, 0, FLA_LEFT ); while ( FLA_Obj_length( AT ) < FLA_Obj_length( A ) ){ FLA_Repart_2x1_to_3x1( AT, &A0, /* ** */ /* *** */ &a1t, AB, &A2, 1, FLA_BOTTOM ); FLA_Repart_1x2_to_1x3( BL, /**/ BR, &B0, /**/ &b1, &B2, 1, FLA_RIGHT ); /*------------------------------------------------------------*/ /* C = a1t' * b1' + C */ FLA_Gerc_external( FLA_CONJUGATE, FLA_CONJUGATE, alpha, a1t, b1, C ); /*------------------------------------------------------------*/ FLA_Cont_with_3x1_to_2x1( &AT, A0, a1t, /* ** */ /* *** */ &AB, A2, FLA_TOP ); FLA_Cont_with_1x3_to_1x2( &BL, /**/ &BR, B0, b1, /**/ B2, FLA_LEFT ); } return FLA_SUCCESS; } #endif
{ "pile_set_name": "Github" }
using ETLBox.Connection; using ETLBox.Exceptions; using ETLBox.Helper; using System; using System.Collections.Generic; using System.Linq; namespace ETLBox.ControlFlow.Tasks { /// <summary> /// Calculates a hash value of the database. It will use only the schemas given in the property SchemaName for the calculation. /// The hash calcualtion is based only on the user tables in the schema. /// </summary> /// <example> /// <code> /// CalculateDatabaseHashTask.Calculate(new List&lt;string&gt;() { "demo", "dbo" }); /// </code> /// </example> public class CalculateDatabaseHashTask : ControlFlowTask { /// <inheritdoc/> public override string TaskName => $"Calculate hash value for schema(s) {SchemaNamesAsString}"; /// <summary> /// Runs the sql code to execute the database hash /// </summary> public void Execute() { if (ConnectionType != ConnectionManagerType.SqlServer) throw new ETLBoxNotSupportedException("This task is only supported for SqlServer!"); List<string> allColumns = new List<string>(); new SqlTask(this, Sql) { Actions = new List<Action<object>>() { col => allColumns.Add((string)col) } } .ExecuteReader(); DatabaseHash = HashHelper.CreateChar40Hash(String.Join("|", allColumns)); } /// <summary> /// List of schema names that should be included in the database hash calculation /// </summary> public List<string> SchemaNames { get; set; } /// <summary> /// A unique hash value that can identify a database based on it's object /// </summary> public string DatabaseHash { get; private set; } string SchemaNamesAsString => String.Join(",", SchemaNames.Select(name => $"'{name}'")); /// <summary> /// The sql code generated to calculate the database hash value /// </summary> public string Sql => $@" SELECT sch.name + '.' + tbls.name + N'|' + cols.name + N'|' + typ.name + N'|' + CAST(cols.max_length AS nvarchar(20))+ N'|' + CAST(cols.precision AS nvarchar(20)) + N'|' + CAST(cols.scale AS nvarchar(20)) + N'|' + CAST(cols.is_nullable AS nvarchar(3)) + N'|' + CAST(cols.is_identity AS nvarchar(3))+ N'|' + CAST(cols.is_computed AS nvarchar(3)) AS FullColumnName FROM sys.columns cols INNER join sys.tables tbls ON cols.object_id = tbls.object_id INNER join sys.schemas sch ON sch.schema_id = tbls.schema_id INNER join sys.types typ ON typ.user_type_id = cols.user_type_id WHERE tbls.type = 'U' AND sch.name IN ({SchemaNamesAsString}) ORDER BY sch.name, tbls.name, cols.column_id "; public CalculateDatabaseHashTask() { } public CalculateDatabaseHashTask(List<string> schemaNames) : this() { this.SchemaNames = schemaNames; } public CalculateDatabaseHashTask Calculate() { Execute(); return this; } /// <summary> /// Calculates the hash of a database based on the existing database objects (Sql Server only) /// </summary> /// <param name="schemaNames">List of schema names that should be included in the hash calculation</param> /// <returns>A unique hash values for the schema</returns> public static string Calculate(List<string> schemaNames) => new CalculateDatabaseHashTask(schemaNames).Calculate().DatabaseHash; /// <summary> /// /// Calculates the hash of a database based on the existing database objects (Sql Server only) /// </summary> /// <param name="connectionManager">The connection manager of the database you want to connect</param> /// <param name="schemaNames">List of schema names that should be included in the hash calculation</param> /// <returns>A unique hash values for the schema</returns> public static string Calculate(IConnectionManager connectionManager, List<string> schemaNames) => new CalculateDatabaseHashTask(schemaNames) { ConnectionManager = connectionManager }.Calculate().DatabaseHash; } }
{ "pile_set_name": "Github" }
<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta content="IE=edge" http-equiv="X-UA-Compatible"> <meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport"> <meta name="theme-color" content="#4285f4"> <title>{$config["appName"]}</title> <!-- css --> <link href="/theme/material/css/base.min.css" rel="stylesheet"> <link href="/theme/material/css/project.min.css" rel="stylesheet"> <link href="https://fonts.loli.net/css?family=Roboto:300,300italic,400,400italic,500,500italic|Material+Icons" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/material.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/gh/DataTables/[email protected]/media/css/dataTables.material.min.css" rel="stylesheet"> <!-- js --> <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> <!-- favicon --> <!-- ... --> <style> body { position: relative; } .table-responsive { background: white; } .dropdown-menu.dropdown-menu-right a { color: #212121; } a[href='#ui_menu'] { color: #212121; } </style> </head> <body class="page-brand"> <header class="header header-red header-transparent header-waterfall ui-header"> <ul class="nav nav-list pull-left"> <div> <a data-toggle="menu" href="#ui_menu"> <span class="icon icon-lg">menu</span> </a> </div> </ul> <ul class="nav nav-list pull-right"> <div class="dropdown margin-right"> <a class="dropdown-toggle padding-left-no padding-right-no" data-toggle="dropdown"> {if $user->isLogin} <span class="access-hide">{$user->user_name}</span> <span class="avatar avatar-sm"><img alt="alt text for John Smith avatar" src="{$user->gravatar}"></span> </a> <ul class="dropdown-menu dropdown-menu-right"> <li> <a class="waves-attach" href="/user/"><span class="icon icon-lg margin-right">account_box</span>用户中心</a> </li> <li> <a class="waves-attach" href="/user/logout"><span class="icon icon-lg margin-right">exit_to_app</span>登出</a> </li> </ul> {else} <span class="access-hide">未登录</span> <span class="avatar avatar-sm"><img alt="alt text for John Smith avatar" src="/theme/material/images/users/avatar-001.jpg"></span> </a> <ul class="dropdown-menu dropdown-menu-right"> <li> <a class="waves-attach" href="/auth/login"><span class="icon icon-lg margin-right">account_box</span>登录</a> </li> <li> <a class="waves-attach" href="/auth/register"><span class="icon icon-lg margin-right">pregnant_woman</span>注册</a> </li> </ul> {/if} </div> </ul> </header> <nav aria-hidden="true" class="menu menu-left nav-drawer nav-drawer-md" id="ui_menu" tabindex="-1"> <div class="menu-scroll"> <div class="menu-content"> <a class="menu-logo" href="/"><i class="icon icon-lg">person_pin</i>&nbsp;管理面板</a> <ul class="nav"> <li> <a class="waves-attach" data-toggle="collapse" href="#ui_menu_me">我的</a> <ul class="menu-collapse collapse in" id="ui_menu_me"> <li><a href="/admin"><i class="icon icon-lg">business_center</i>&nbsp;系统概览</a></li> <li><a href="/admin/announcement"><i class="icon icon-lg">announcement</i>&nbsp;公告管理</a></li> <li><a href="/admin/ticket"><i class="icon icon-lg">question_answer</i>&nbsp;工单管理</a></li> <li><a href="/admin/auto"><i class="icon icon-lg">flash_auto</i>&nbsp;下发命令</a></li> </ul> <a class="waves-attach" data-toggle="collapse" href="#ui_menu_node">节点</a> <ul class="menu-collapse collapse in" id="ui_menu_node"> <li><a href="/admin/node"><i class="icon icon-lg">router</i>&nbsp;节点列表</a></li> <li><a href="/admin/trafficlog"><i class="icon icon-lg">traffic</i>&nbsp;流量记录</a></li> <li><a href="/admin/block"><i class="icon icon-lg">dialer_sip</i>&nbsp;已封禁IP</a></li> <li><a href="/admin/unblock"><i class="icon icon-lg">dialer_sip</i>&nbsp;已解封IP</a></li> </ul> <a class="waves-attach" data-toggle="collapse" href="#ui_menu_user">用户</a> <ul class="menu-collapse collapse in" id="ui_menu_user"> <li><a href="/admin/user"><i class="icon icon-lg">supervisor_account</i>&nbsp;用户列表</a></li> <li><a href="/admin/relay"><i class="icon icon-lg">compare_arrows</i>&nbsp;中转规则</a></li> <li><a href="/admin/invite"><i class="icon icon-lg">loyalty</i>&nbsp;邀请与返利</a></li> <li><a href="/admin/login"><i class="icon icon-lg">text_fields</i>&nbsp;登录记录</a></li> <li><a href="/admin/alive"><i class="icon icon-lg">important_devices</i>&nbsp;在线IP</a></li> </ul> <a class="waves-attach" data-toggle="collapse" href="#ui_menu_detect">审计</a> <ul class="menu-collapse collapse in" id="ui_menu_detect"> <li><a href="/admin/detect"><i class="icon icon-lg">account_balance</i>&nbsp;审计规则</a></li> <li><a href="/admin/detect/log"><i class="icon icon-lg">assignment_late</i>&nbsp;审计记录</a></li> </ul> <a class="waves-attach" data-toggle="collapse" href="#ui_menu_trade">交易</a> <ul class="menu-collapse collapse in" id="ui_menu_trade"> <li><a href="/admin/code"><i class="icon icon-lg">code</i>&nbsp;充值{if $config['enable_donate']=='true'}与捐赠{/if}记录</a></li> <li><a href="/admin/shop"><i class="icon icon-lg">shop</i>&nbsp;商品</a></li> <li><a href="/admin/coupon"><i class="icon icon-lg">card_giftcard</i>&nbsp;优惠码</a></li> <li><a href="/admin/bought"><i class="icon icon-lg">shopping_cart</i>&nbsp;购买记录</a></li> {if $config['payment_system']=='chenAlipay'} <li><a href="/admin/editConfig"><i class="icon icon-lg">shopping_cart</i>&nbsp;支付设置</a></li> {/if} </ul> <li><a href="/user"><i class="icon icon-lg">person</i>&nbsp;用户中心</a></li> </li> </ul> </div> </div> </nav>
{ "pile_set_name": "Github" }
<!-- Creator : groff version 1.21 --> <!-- CreationDate: Sun Jul 29 12:12:01 2012 --> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta name="generator" content="groff -Thtml, see www.gnu.org"> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta name="Content-Style" content="text/css"> <style type="text/css"> p { margin-top: 0; margin-bottom: 0; vertical-align: top } pre { margin-top: 0; margin-bottom: 0; vertical-align: top } table { margin-top: 0; margin-bottom: 0; vertical-align: top } h1 { text-align: center } </style> <title>TIFFFieldName</title> </head> <body> <h1 align="center">TIFFFieldName</h1> <a href="#NAME">NAME</a><br> <a href="#SYNOPSIS">SYNOPSIS</a><br> <a href="#DESCRIPTION">DESCRIPTION</a><br> <a href="#RETURN VALUES">RETURN VALUES</a><br> <a href="#SEE ALSO">SEE ALSO</a><br> <hr> <h2>NAME <a name="NAME"></a> </h2> <p style="margin-left:11%; margin-top: 1em">TIFFFieldName &minus; Get TIFF field name from field information</p> <h2>SYNOPSIS <a name="SYNOPSIS"></a> </h2> <p style="margin-left:11%; margin-top: 1em"><b>#include &lt;tiffio.h&gt;</b></p> <p style="margin-left:11%; margin-top: 1em"><b>const char* TIFFFieldName(const TIFFField*</b> <i>fip</i><b>)</b></p> <h2>DESCRIPTION <a name="DESCRIPTION"></a> </h2> <p style="margin-left:11%; margin-top: 1em"><b>TIFFFieldName</b> returns the textual name for a TIFF field.</p> <p style="margin-left:11%; margin-top: 1em"><i>fip</i> is a field information pointer previously returned by <b>TIFFFindField</b>, <b>TIFFFieldWithTag</b>, or <b>TIFFFieldWithName</b>.</p> <h2>RETURN VALUES <a name="RETURN VALUES"></a> </h2> <p style="margin-left:11%; margin-top: 1em"><b>TIFFFieldName</b> returns a constant C string.</p> <h2>SEE ALSO <a name="SEE ALSO"></a> </h2> <p style="margin-left:11%; margin-top: 1em"><b>libtiff</b>(3TIFF),</p> <p style="margin-left:11%; margin-top: 1em">Libtiff library home page: <b>http://www.remotesensing.org/libtiff/</b></p> <hr> </body> </html>
{ "pile_set_name": "Github" }
/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.jsmpp.util; /** * String type values. * * @author uudashr * @version 1.0 * @since 1.0 * */ public enum StringType { /** * String delimited by null value. */ C_OCTEC_STRING, /** * String that determined by the length. */ OCTET_STRING; }
{ "pile_set_name": "Github" }
cd C:\adt32\eclipse\workspace\AppTFPNoGUIGraphicsBridgeDemo7\bin C:\adt32\sdk\platform-tools\adb logcat cd .. pause
{ "pile_set_name": "Github" }
<template> <div class="app-container"> <div class="filter-wrap mb-3"> <div> <el-button v-permission="'/auth/user/add'" type="primary" size="small" icon="el-icon-edit" @click="handleCreate"> 新增 </el-button> </div> <div style="display: flex"> <el-input v-model.trim="listQuery.criteria" placeholder="用户名称" size="small" style="width: 200px;" clearable class="mr-3" @keyup.enter.native="handleFilter" /> <el-button v-waves type="primary" icon="el-icon-search" @click="handleFilter"> 搜索 </el-button> </div> </div> <el-card> <m-table :data="tableInfo1.list" :columns="tableInfo1.columns" /> <pagination v-show="listQuery.total>0" :total="listQuery.total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="getList" /> </el-card> <el-dialog width="830px" :visible.sync="dialogFormVisible"> <div slot="title"> <span class="dialog-custom-title" v-html="dialogTitle" /></div> <el-transfer ref="transfer" v-model="roleData" filterable filter-placeholder="请输入角色名称" :data="roleList" :props="defaultProps" :titles="titles" /> <div slot="footer" class="dialog-footer"> <el-button @click="dialogFormVisible = false"> 取消 </el-button> <el-button type="primary" @click="submitForm()"> 确认 </el-button> </div> </el-dialog> <el-dialog width="830px" :title="dialog2.title" :visible.sync="dialog2.dialogFormVisible"> <m-form :ref-obj.sync="formInfo.ref" :data="formInfo.data" :field-list="formInfo.fieldList" :rules="formInfo.rules" /> <div slot="footer" class="dialog-footer"> <el-button @click="dialog2.dialogFormVisible = false"> 取消 </el-button> <el-button type="primary" @click="saveForm()"> 确认 </el-button> </div> </el-dialog> </div> </template> <script type="script" lang="js"> import * as api from '@/api/auth' import Pagination from '@/components/Pagination' import MTable from '@/components/MTable' import MForm from '@/components/MForm' export default { name: 'PageUserList', components: { Pagination, MTable, MForm }, data() { const checkUserId = (rule, value, callback) => { if (!value) { return callback(new Error('用户名不能为空')) } // setTimeout(() => { // if (!/^(-)[1-9][0-9]*$/.test(value)) { // callback(new Error('只能输入负数')) // } else { // callback() // } // }, 300) callback() } const repeatPasswordValidate = (rule, value, callback) => { if (value === '') { callback(new Error('请再次输入确认密码')) } else if (value !== this.formInfo.data.passwordMd5) { callback(new Error('两次输入的密码不一样')) } else { callback() } } return { tableInfo1: { list: [], columns: [{ prop: 'id', label: '用户ID' }, { prop: 'username', label: '用户名' }, { prop: 'email', label: '邮箱' }, { prop: 'screenName', label: '别名' }, { prop: 'created', label: '创建时间' }, { prop: 'logged', label: '最后登录时间' }, { prop: 'options', label: '操作', width: 230, align: 'center', icon: 'edit', options: [ { type: 'primary', label: '编辑', code: '/auth/user/update', event: this.handleUser }, { type: 'primary', label: '分配角色', code: '/auth/user/assign/role', event: this.handleRoles } ] } ] }, listQuery: { pageNum: 1, pageSize: this.$static.DEFAULT_PAGE_SIZE, criteria: '', total: 0 }, dialogFormVisible: false, defaultProps: { key: 'id', label: 'roleName' }, roleData: [], roleList: [], titles: ['全部', '已选'], userId: null, dialogTitle: '', activeTab: 'first', formInfo: { ref: null, data: {}, rules: [], fieldList: [{ type: 'input', prop: 'username', label: '用户名', required: true, validator: checkUserId }, { type: 'input', prop: 'email', label: '邮箱', required: true, validatorType: 'email' }, { type: 'input', prop: 'screenName', label: '别名', required: false }, { type: 'password', prop: 'passwordMd5', label: '密码', required: true }, { type: 'password', prop: 'repeatPassword', label: '确认密码', required: true, validator: repeatPasswordValidate } ] }, dialog2: { dialogFormVisible: false, title: '新增用户', dialogStatus: '' } } }, watch: { 'dialog2.dialogFormVisible'(val) { const formInfo = this.formInfo if (!val) { // 表单验证初始化 if (formInfo.ref) { formInfo.ref.resetFields() } this.resetForm() } } }, created() { // 初始化验证规则 this.formInfo.rules = this.$initRules(this.formInfo.fieldList) // 初始化表单数据 this.formInfo.data = this.$initData(this.formInfo.fieldList) // 初始化普通用户 this.getList() // 获取角色 api.getRoleList({ pageSize: -1 }).then(res => { this.roleList = res.data.list this.roleList.map(item => (item.roleName = `【${item.projectType}】${item.roleName}`)) }) }, mounted() {}, methods: { /** * 获取列表数据 */ getList() { api.getUserList(this.listQuery).then(res => { this.tableInfo1.list = res.data.list || [] this.listQuery.total = res.data.total this.listQuery.pageSize = res.data.pageSize }) }, getCurrentList(page) { this.listQuery.pageNum = page.page this.listQuery.pageSize = page.limit this.getList() }, /** * 搜索 */ handleFilter() { this.listQuery.pageNum = 1 this.getList() }, handleRoles(row) { this.roleData = [] this.userId = null this.dialogTitle = `为<i>#${row.username}#</i>分配角色` api.getRoleList({ userId: row.id, pageSize: -1 }).then(res => { this.dialogFormVisible = true setTimeout(() => this.$refs.transfer.clearQuery('left') && this.$refs.transfer.clearQuery('right'), 0) this.userId = row.id const result = res.data.list || [] result.forEach(item => this.roleData.push(item.id)) }) }, submitForm() { api.saveRoles({ id: this.userId, roleIds: this.roleData }).then(res => { if (res.code === 0) { this.dialogFormVisible = false this.msgTips('success', '成功', '角色分配成功') } else { this.msgTips('error', '角色分配失败', res.msg) } }) }, /** * 打开新增弹窗 ToB */ handleCreate() { this.dialog2.dialogFormVisible = true this.dialog2.title = '新增' }, /** * 打开编辑弹窗 ToB */ handleUser(row) { this.resetForm() this.dialog2.title = '编辑' this.dialog2.dialogFormVisible = true api.getUserSingle(row.id).then(res => { if (res.code === 0) { const result = res.data this.formInfo.data['id'] = result.id Object.keys(this.formInfo.data).forEach(key => { if (result[key]) { this.formInfo.data[key] = result[key] } }) } else { this.$message({ message: res.msg, type: 'error' }) } }) }, /** * 新增数据 */ createData(params) { const data = { ...params } api.addUser(data).then(res => { if (res.code === 0) { this.dialog2.dialogFormVisible = false this.msgTips('success', '成功', '新增成功') this.listQuery.pageNum = 1 this.getList() } else { this.msgTips('error', '失败', res.msg) } }) }, /** * 更新数据 */ updateData(params) { const data = { ...params } api.updateUserSingle(data).then(res => { if (res.code === 0) { this.dialog2.dialogFormVisible = false this.msgTips('success', '成功', '更新成功') this.getList() } else { this.msgTips('error', '失败', res.msg) } }) }, /** * 提交表单 */ saveForm() { this.formInfo.ref.validate((valid) => { if (valid) { if (this.formInfo.data.id) { this.updateData(this.formInfo.data) } else { this.createData(this.formInfo.data) } } }) }, /** * 数据重置 */ resetForm() { this.formInfo.data = this.$initData(this.formInfo.fieldList) }, /** * 消息提示 */ msgTips(type, title, msg) { this.$notify({ title: title, message: msg, type: type, duration: 2000 }) } } } </script> <style lang="scss" scoped> .dialog-custom-title { ::v-deep i { font-style: normal; color: #1890ff; } } </style>
{ "pile_set_name": "Github" }
//===- llvm/unittest/Support/formatted_raw_ostream_test.cpp ---------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #include "llvm/Support/FormattedStream.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" using namespace llvm; namespace { TEST(formatted_raw_ostreamTest, Test_Tell) { // Check offset when underlying stream has buffer contents. SmallString<128> A; raw_svector_ostream B(A); formatted_raw_ostream C(B); char tmp[100] = ""; for (unsigned i = 0; i != 3; ++i) { C.write(tmp, 100); EXPECT_EQ(100*(i+1), (unsigned) C.tell()); } } }
{ "pile_set_name": "Github" }
%YAML 1.1 %TAG !u! tag:unity3d.com,2011: --- !u!114 &11400000 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 0} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 1a9f92409454067439c2e802923148cf, type: 3} m_Name: Sound Entry - Human Male Kiss m_EditorClassIdentifier: soundReference: {fileID: 11400000, guid: 9c01542db10d5bc46819a6f11752769e, type: 2} settings: {fileID: 11400000, guid: ee786aa39eb585e4484003f75910c3e9, type: 2} audioClip: {fileID: 8300000, guid: cf110c4acd05d8444b6c6f8d8444ae45, type: 3} volumeModifier: 0.5
{ "pile_set_name": "Github" }
<?php /** * Basic CakePHP functionality. * * Handles loading of core files needed on every request * * CakePHP(tm) : Rapid Development Framework (http://cakephp.org) * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * * Licensed under The MIT License * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project * @package Cake * @since CakePHP(tm) v 0.2.9 * @license http://www.opensource.org/licenses/mit-license.php MIT License */ define('TIME_START', microtime(true)); if (!defined('E_DEPRECATED')) { define('E_DEPRECATED', 8192); } if (!defined('E_USER_DEPRECATED')) { define('E_USER_DEPRECATED', E_USER_NOTICE); } error_reporting(E_ALL & ~E_DEPRECATED); if (!defined('CAKE_CORE_INCLUDE_PATH')) { define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(__FILE__))); } if (!defined('CORE_PATH')) { define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } if (!defined('WEBROOT_DIR')) { define('WEBROOT_DIR', 'webroot'); } /** * Path to the cake directory. */ define('CAKE', CORE_PATH . 'Cake' . DS); /** * Path to the application's directory. */ if (!defined('APP')) { define('APP', ROOT . DS . APP_DIR . DS); } /** * Path to the application's libs directory. */ define('APPLIBS', APP . 'Lib' . DS); /** * Path to the public CSS directory. */ if (!defined('CSS')) { define('CSS', WWW_ROOT . 'css' . DS); } /** * Path to the public JavaScript directory. */ if (!defined('JS')) { define('JS', WWW_ROOT . 'js' . DS); } /** * Path to the public images directory. */ if (!defined('IMAGES')) { define('IMAGES', WWW_ROOT . 'img' . DS); } /** * Path to the tests directory. */ if (!defined('TESTS')) { define('TESTS', APP . 'Test' . DS); } /** * Path to the temporary files directory. */ if (!defined('TMP')) { define('TMP', APP . 'tmp' . DS); } /** * Path to the logs directory. */ if (!defined('LOGS')) { define('LOGS', TMP . 'logs' . DS); } /** * Path to the cache files directory. It can be shared between hosts in a multi-server setup. */ if (!defined('CACHE')) { define('CACHE', TMP . 'cache' . DS); } /** * Path to the vendors directory. */ if (!defined('VENDORS')) { define('VENDORS', ROOT . DS . 'vendors' . DS); } /** * Web path to the public images directory. */ if (!defined('IMAGES_URL')) { define('IMAGES_URL', 'img/'); } /** * Web path to the CSS files directory. */ if (!defined('CSS_URL')) { define('CSS_URL', 'css/'); } /** * Web path to the js files directory. */ if (!defined('JS_URL')) { define('JS_URL', 'js/'); } require CAKE . 'basics.php'; require CAKE . 'Core' . DS . 'App.php'; require CAKE . 'Error' . DS . 'exceptions.php'; spl_autoload_register(array('App', 'load')); App::uses('ErrorHandler', 'Error'); App::uses('Configure', 'Core'); App::uses('CakePlugin', 'Core'); App::uses('Cache', 'Cache'); App::uses('Object', 'Core'); App::uses('Multibyte', 'I18n'); /** * Full URL prefix */ if (!defined('FULL_BASE_URL')) { $s = null; if (env('HTTPS')) { $s = 's'; } $httpHost = env('HTTP_HOST'); if (isset($httpHost)) { define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost); Configure::write('App.fullBaseUrl', FULL_BASE_URL); } unset($httpHost, $s); } Configure::write('App.imageBaseUrl', IMAGES_URL); Configure::write('App.cssBaseUrl', CSS_URL); Configure::write('App.jsBaseUrl', JS_URL); App::$bootstrapping = true; Configure::bootstrap(isset($boot) ? $boot : true); if (function_exists('mb_internal_encoding')) { $encoding = Configure::read('App.encoding'); if (!empty($encoding)) { mb_internal_encoding($encoding); } if (!empty($encoding) && function_exists('mb_regex_encoding')) { mb_regex_encoding($encoding); } } if (!function_exists('mb_stripos')) { /** * Find position of first occurrence of a case-insensitive string. * * @param string $haystack The string from which to get the position of the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false * if $needle is not found. */ function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return Multibyte::stripos($haystack, $needle, $offset); } } if (!function_exists('mb_stristr')) { /** * Finds first occurrence of a string within another, case insensitive. * * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or false if $needle is not found. */ function mb_stristr($haystack, $needle, $part = false, $encoding = null) { return Multibyte::stristr($haystack, $needle, $part); } } if (!function_exists('mb_strlen')) { /** * Get string length. * * @param string $string The string being checked for length. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer The number of characters in string $string having character encoding encoding. * A multi-byte character is counted as 1. */ function mb_strlen($string, $encoding = null) { return Multibyte::strlen($string); } } if (!function_exists('mb_strpos')) { /** * Find position of first occurrence of a string. * * @param string $haystack The string being checked. * @param string $needle The position counted from the beginning of haystack. * @param integer $offset The search offset. If it is not specified, 0 is used. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. * If $needle is not found, it returns false. */ function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return Multibyte::strpos($haystack, $needle, $offset); } } if (!function_exists('mb_strrchr')) { /** * Finds the last occurrence of a character in a string within another. * * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ function mb_strrchr($haystack, $needle, $part = false, $encoding = null) { return Multibyte::strrchr($haystack, $needle, $part); } } if (!function_exists('mb_strrichr')) { /** * Finds the last occurrence of a character in a string within another, case insensitive. * * @param string $haystack The string from which to get the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param boolean $part Determines which portion of $haystack this function returns. * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, * Default value is false. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack. or false if $needle is not found. */ function mb_strrichr($haystack, $needle, $part = false, $encoding = null) { return Multibyte::strrichr($haystack, $needle, $part); } } if (!function_exists('mb_strripos')) { /** * Finds position of last occurrence of a string within another, case insensitive * * @param string $haystack The string from which to get the position of the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset The position in $haystack to start searching. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, * or false if $needle is not found. */ function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return Multibyte::strripos($haystack, $needle, $offset); } } if (!function_exists('mb_strrpos')) { /** * Find position of last occurrence of a string in a string. * * @param string $haystack The string being checked, for the last occurrence of $needle. * @param string $needle The string to find in $haystack. * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. * Negative values will stop searching at an arbitrary point prior to the end of the string. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. * If $needle is not found, it returns false. */ function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return Multibyte::strrpos($haystack, $needle, $offset); } } if (!function_exists('mb_strstr')) { /** * Finds first occurrence of a string within another * * @param string $haystack The string from which to get the first occurrence of $needle. * @param string $needle The string to find in $haystack * @param boolean $part Determines which portion of $haystack this function returns. * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, * Default value is FALSE. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string|boolean The portion of $haystack, or true if $needle is not found. */ function mb_strstr($haystack, $needle, $part = false, $encoding = null) { return Multibyte::strstr($haystack, $needle, $part); } } if (!function_exists('mb_strtolower')) { /** * Make a string lowercase * * @param string $string The string being lowercased. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string with all alphabetic characters converted to lowercase. */ function mb_strtolower($string, $encoding = null) { return Multibyte::strtolower($string); } } if (!function_exists('mb_strtoupper')) { /** * Make a string uppercase * * @param string $string The string being uppercased. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string with all alphabetic characters converted to uppercase. */ function mb_strtoupper($string, $encoding = null) { return Multibyte::strtoupper($string); } } if (!function_exists('mb_substr_count')) { /** * Count the number of substring occurrences * * @param string $haystack The string being checked. * @param string $needle The string being found. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return integer The number of times the $needle substring occurs in the $haystack string. */ function mb_substr_count($haystack, $needle, $encoding = null) { return Multibyte::substrCount($haystack, $needle); } } if (!function_exists('mb_substr')) { /** * Get part of string * * @param string $string The string being checked. * @param integer $start The first position used in $string. * @param integer $length The maximum length of the returned string. * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. * @return string The portion of $string specified by the $string and $length parameters. */ function mb_substr($string, $start, $length = null, $encoding = null) { return Multibyte::substr($string, $start, $length); } } if (!function_exists('mb_encode_mimeheader')) { /** * Encode string for MIME header * * @param string $str The string being encoded * @param string $charset specifies the name of the character set in which str is represented in. * The default value is determined by the current NLS setting (mbstring.language). * @param string $transfer_encoding specifies the scheme of MIME encoding. * It should be either "B" (Base64) or "Q" (Quoted-Printable). Falls back to "B" if not given. * @param string $linefeed specifies the EOL (end-of-line) marker with which * mb_encode_mimeheader() performs line-folding * (a » RFC term, the act of breaking a line longer than a certain length into multiple lines. * The length is currently hard-coded to 74 characters). Falls back to "\r\n" (CRLF) if not given. * @param integer $indent [definition unknown and appears to have no affect] * @return string A converted version of the string represented in ASCII. */ function mb_encode_mimeheader($str, $charset = 'UTF-8', $transferEncoding = 'B', $linefeed = "\r\n", $indent = 1) { return Multibyte::mimeEncode($str, $charset, $linefeed); } }
{ "pile_set_name": "Github" }
package com.wythe.mall.activity; import android.os.Bundle; import android.view.View; import android.widget.TextView; import com.wythe.mall.R; import com.wythe.mall.utils.GotoActivity; import com.wythe.mall.view.MyEditText; /** * Created by wythe on 2016/7/10. */ public class FindPasswordMessageCodeActivity extends BaseActivity { private TextView tvTip,tvAccountTip; private MyEditText etMessageCode; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_find_password_input_message_code); initView(); } @Override protected void initView() { super.initView(); super.setNormalTitle(R.string.find_password); tvTip = (TextView) findViewById(R.id.tip); tvAccountTip = (TextView) findViewById(R.id.account_name_tip); etMessageCode = (MyEditText) findViewById(R.id.input_message_code); findViewById(R.id.next_button).setOnClickListener(this); findViewById(R.id.get_verify_code).setOnClickListener(this); } @Override public void onClick(View v) { super.onClick(v); switch (v.getId()){ case R.id.next_button:{ //TODO 检查验证码并跳转到最终充值密码页面 GotoActivity.gotoActiviy(FindPasswordMessageCodeActivity.this,FindPasswordModifyPasswordActivity.class); break; } case R.id.get_verify_code:{ //TODO 重新发送验证码 break; } } } }
{ "pile_set_name": "Github" }
<?php /** * @package Joomla.Site * @subpackage com_content * * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; JHtml::addIncludePath(JPATH_COMPONENT . '/helpers'); JHtml::addIncludePath(T3_PATH . '/html/com_content'); JHtml::addIncludePath(dirname(dirname(__FILE__))); JHtml::_('behavior.caption'); ?> <div class="archive<?php echo $this->pageclass_sfx; ?>"> <?php if ($this->params->get('show_page_heading', 1)) : ?> <div class="page-header"> <h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1> </div> <?php endif; ?> <form id="adminForm" action="<?php echo JRoute::_('index.php') ?>" method="post" class="form-inline"> <fieldset class="filters"> <div class="filter-search form-group"> <?php if ($this->params->get('filter_field') != 'hide') : ?> <div class="form-group"> <label class="filter-search-lbl" for="filter-search"><?php echo JText::_('COM_CONTENT_' . $this->params->get('filter_field') . '_FILTER_LABEL') . '&#160;'; ?></label> <input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->filter); ?>" class="form-control col-sm-2" onchange="document.getElementById('adminForm').submit();"/> </div> <?php endif; ?> <?php echo $this->form->monthField; ?> <?php echo $this->form->yearField; ?> <?php echo $this->form->limitField; ?> </div> <button type="submit" class="btn btn-primary"><?php echo JText::_('JGLOBAL_FILTER_BUTTON'); ?></button> <input type="hidden" name="view" value="archive"/> <input type="hidden" name="option" value="com_content"/> <input type="hidden" name="limitstart" value="0"/> </fieldset> <?php echo $this->loadTemplate('items'); ?> </form> </div>
{ "pile_set_name": "Github" }
{ "type": "excalidraw", "version": 2, "source": "https://excalidraw.com", "elements": [ { "type": "text", "version": 137, "versionNonce": 1707748325, "isDeleted": false, "id": "o9-ugmQsi6z6M0k9Q4ijw", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 619, "y": 304, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 238, "height": 32, "seed": 1349359589, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.getCanonicalLocales", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 20, "versionNonce": 2038122629, "isDeleted": false, "id": "6k13Zx4eRwAGNkFfH0Y8q", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 354.5, "y": 409, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 147, "height": 32, "seed": 1613737995, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.PluralRules", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 318, "versionNonce": 2049106145, "isDeleted": false, "id": "8JU_rpvx7MfwgqhErMnuj", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 148.5, "y": 687, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 235, "height": 32, "seed": 1696542283, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.RelativeTimeFormat", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 43, "versionNonce": 853307691, "isDeleted": false, "id": "zhrH4GALW-FOtpySVgx-q", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 799.5, "y": 406, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 103, "height": 32, "seed": 514487147, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.Locale", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 115, "versionNonce": 1634975941, "isDeleted": false, "id": "w9XvzMllLfvOn1deWsoIb", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 569.5, "y": 412, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 173, "height": 32, "seed": 1718717893, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.DisplayNames", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 223, "versionNonce": 1719157807, "isDeleted": false, "id": "lnz2EAa32ZjkSTSCDSQVC", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 347.5, "y": 543, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 175, "height": 32, "seed": 732189413, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.NumberFormat", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "text", "version": 104, "versionNonce": 1866669157, "isDeleted": false, "id": "qZR72Ok_NQrQGZp802E0q", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 954.5, "y": 405, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 147, "height": 32, "seed": 901849131, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.ListFormat", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "arrow", "version": 133, "versionNonce": 55597029, "isDeleted": false, "id": "Rmaj7D2Ylf6ixejzosIfI", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 593.7951605800539, "y": 332.9488447237946, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 144.7951605800539, "height": 75.0511552762054, "seed": 1134049733, "groupIds": [], "points": [ [ 0, 0 ], [ -144.7951605800539, 75.0511552762054 ] ] }, { "type": "arrow", "version": 227, "versionNonce": 1398155055, "isDeleted": false, "id": "4Q9MqGqoxmosaxUakowQ8", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 377.66183958612385, "y": 590.8586617831141, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 99.78746498446463, "height": 82.365678012371, "seed": 1703564427, "groupIds": [], "points": [ [ 0, 0 ], [ -99.78746498446463, 82.365678012371 ] ] }, { "type": "arrow", "version": 46, "versionNonce": 935529291, "isDeleted": false, "id": "KgQhYlzhjHyduUI9xJ8ii", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 660.1746351854131, "y": 348.0985772971064, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 11.17463518541308, "height": 64.90142270289363, "seed": 1899584011, "groupIds": [], "points": [ [ 0, 0 ], [ -11.17463518541308, 64.90142270289363 ] ] }, { "type": "arrow", "version": 45, "versionNonce": 452776805, "isDeleted": false, "id": "rQltDFwVOgI_ze5EjYR5t", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 791.479036701098, "y": 346.6198090807535, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 45.52096329890196, "height": 60.3801909192465, "seed": 1557263909, "groupIds": [], "points": [ [ 0, 0 ], [ 45.52096329890196, 60.3801909192465 ] ] }, { "type": "arrow", "version": 28, "versionNonce": 1604882085, "isDeleted": false, "id": "WFy9XDr8AYhcX-54VLA_N", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 876, "y": 331, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 116, "height": 69, "seed": 1048068459, "groupIds": [], "points": [ [ 0, 0 ], [ 116, 69 ] ] }, { "type": "text", "version": 197, "versionNonce": 1308769263, "isDeleted": false, "id": "wU6q-18jJJ_8YhXv-1uKQ", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 478, "y": 686, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 212, "height": 32, "seed": 106787643, "groupIds": [], "fontSize": 20, "fontFamily": 1, "text": "Intl.DateTimeFormat", "baseline": 23, "textAlign": "left", "verticalAlign": "top" }, { "type": "arrow", "version": 94, "versionNonce": 1507186881, "isDeleted": false, "id": "x7M2r6i4CyQ6KaNx1mw_r", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "angle": 0, "x": 499, "y": 599, "strokeColor": "#000000", "backgroundColor": "transparent", "width": 60, "height": 68, "seed": 2068784571, "groupIds": [], "points": [ [ 0, 0 ], [ 60, 68 ] ] }, { "id": "1xaKOH-wh-NF5xS7H73pq", "type": "arrow", "x": 418, "y": 461, "width": 5, "height": 71, "angle": 0, "strokeColor": "#000000", "backgroundColor": "transparent", "fillStyle": "hachure", "strokeWidth": 1, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "groupIds": [], "seed": 966905807, "version": 33, "versionNonce": 262197711, "isDeleted": false, "points": [ [ 0, 0 ], [ 5, 71 ] ], "lastCommittedPoint": null } ], "appState": { "viewBackgroundColor": "#ffffff", "gridSize": null } }
{ "pile_set_name": "Github" }
--- method: GET headers: Authorization: AWS4-HMAC-SHA256 Credential=access/20091028/us-east-1/greengrass/aws4_request, SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date, Signature=? Host: greengrass.us-east-1.amazonaws.com Content-Type: application/x-www-form-urlencoded; charset=utf-8 X-Amz-Content-SHA256: abcdef X-Amz-Date: 20091028T223200Z body: ''
{ "pile_set_name": "Github" }
import React, { Component } from 'react' import { Button, Confirm } from 'semantic-ui-react' class ConfirmExampleHeader extends Component { state = { open: false } show = () => this.setState({ open: true }) handleConfirm = () => this.setState({ open: false }) handleCancel = () => this.setState({ open: false }) render() { return ( <div> <Button onClick={this.show}>Show</Button> <Confirm open={this.state.open} header='This is a custom header' onCancel={this.handleCancel} onConfirm={this.handleConfirm} /> </div> ) } } export default ConfirmExampleHeader
{ "pile_set_name": "Github" }
package vandy.mooc.common; /** * The base interface that an operations ("Ops") class can implement * so that it can be notified automatically by the GenericAsyncTask * framework during the AsyncTask processing. */ public interface GenericAsyncTaskOps<Params, Progress, Result> { /** * Called in the UI thread prior to running doInBackground() in a * background thread. */ // @@ Commented out until Android supports default methods in interfaces.. // default void onPreExecute() {} /** * Called in a background thread to process the @a params. */ @SuppressWarnings("unchecked") Result doInBackground(Params... params); /** * Called in the UI thread to process the @a result. */ void onPostExecute(Result result); }
{ "pile_set_name": "Github" }
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #ifndef MS_APP_CENTER_ERRORS_H #define MS_APP_CENTER_ERRORS_H #import <Foundation/Foundation.h> #define MS_APP_CENTER_BASE_DOMAIN @"com.Microsoft.AppCenter." NS_ASSUME_NONNULL_BEGIN #pragma mark - Domain static NSString *const kMSACErrorDomain = MS_APP_CENTER_BASE_DOMAIN @"ErrorDomain"; #pragma mark - General // Error codes. NS_ENUM(NSInteger){MSACLogInvalidContainerErrorCode = 1, MSACCanceledErrorCode = 2, MSACDisabledErrorCode = 3}; // Error descriptions. static NSString const *kMSACLogInvalidContainerErrorDesc = @"Invalid log container."; static NSString const *kMSACCanceledErrorDesc = @"The operation was canceled."; static NSString const *kMSACDisabledErrorDesc = @"The service is disabled."; #pragma mark - Connection // Error codes. NS_ENUM(NSInteger){MSACConnectionPausedErrorCode = 100, MSACConnectionHttpErrorCode = 101}; // Error descriptions. static NSString const *kMSACConnectionHttpErrorDesc = @"An HTTP error occured."; static NSString const *kMSACConnectionPausedErrorDesc = @"Canceled, connection paused with log deletion."; // Error user info keys. static NSString const *kMSACConnectionHttpCodeErrorKey = @"MSACConnectionHttpCode"; NS_ASSUME_NONNULL_END #endif
{ "pile_set_name": "Github" }
package com.epam.ngb.cli.manager.command.handler.simple; import static com.epam.ngb.cli.manager.command.CommandManager.SERVER_VERSION_PROPERTY; import java.util.List; import java.util.Properties; import com.epam.ngb.cli.app.ApplicationOptions; import com.epam.ngb.cli.app.ConfigurationLoader; import com.epam.ngb.cli.manager.command.handler.Command; import com.epam.ngb.cli.manager.command.handler.http.FileRegistrationHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Command(type = Command.Type.SIMPLE, command = {"version"}) public class VersionCommandHandler extends AbstractSimpleCommandHandler { private static final Logger LOGGER = LoggerFactory.getLogger(FileRegistrationHandler.class); @Override public void parseAndVerifyArguments(List<String> arguments, ApplicationOptions options) { if (!arguments.isEmpty()) { LOGGER.debug("Version command doesn't consume arguments. " + "All input arguments will be ignored."); } } @Override public int runCommand() { ConfigurationLoader loader = new ConfigurationLoader(); Properties properties = loader.loadServerConfiguration(null); LOGGER.info(properties.getProperty(SERVER_VERSION_PROPERTY)); return 0; } }
{ "pile_set_name": "Github" }
/*--------------------------------------------------------*\ | | | hprose | | | | Official WebSite: https://hprose.com | | | | encoding/encoder.go | | | | LastModified: Apr 12, 2020 | | Author: Ma Bingyao <[email protected]> | | | \*________________________________________________________*/ package encoding import ( "io" "math/big" "reflect" "unsafe" "github.com/modern-go/reflect2" ) // An Encoder writes hprose data to an output stream type Encoder struct { addr *Encoder // of receiver, to detect copies by value buf []byte off int refer *encoderRefer ref map[reflect.Type]int last int Writer io.Writer Error error } // NewEncoder create an encoder object func NewEncoder(w io.Writer) *Encoder { return &Encoder{Writer: w} } func (enc *Encoder) copyCheck() { if enc.addr == nil { // This hack works around a failing of Go's escape analysis // that was causing enc to escape and be heap allocated. // See issue 23382. // TODO: once issue 7921 is fixed, this should be reverted to // just "enc.addr = enc". enc.addr = (*Encoder)(reflect2.NoEscape(unsafe.Pointer(enc))) } else if enc.addr != enc { panic("hprose/encoding: illegal use of non-zero Encoder copied by value") } } func (enc *Encoder) fastWriteValue(v interface{}) (ok bool) { ok = true switch v := v.(type) { case nil: enc.WriteNil() case int: enc.WriteInt(v) case int8: enc.WriteInt8(v) case int16: enc.WriteInt16(v) case int32: enc.WriteInt32(v) case int64: enc.WriteInt64(v) case uint: enc.WriteUint(v) case uint8: enc.WriteUint8(v) case uint16: enc.WriteUint16(v) case uint32: enc.WriteUint32(v) case uint64: enc.WriteUint64(v) case uintptr: enc.WriteUint64(uint64(v)) case bool: enc.WriteBool(v) case float32: enc.WriteFloat32(v) case float64: enc.WriteFloat64(v) case complex64: enc.WriteComplex64(v) case complex128: enc.WriteComplex128(v) case big.Int: enc.WriteBigInt(&v) case big.Float: enc.WriteBigFloat(&v) case big.Rat: enc.WriteBigRat(&v) case error: enc.WriteError(v) default: ok = false } return } func (enc *Encoder) writeValue(v interface{}, encode func(m ValueEncoder, v interface{})) { if enc.fastWriteValue(v) { return } t := reflect.TypeOf(v) kind := t.Kind() switch kind { case reflect.Ptr, reflect.Map, reflect.Slice, reflect.Interface: if reflect.ValueOf(v).IsNil() { enc.WriteNil() return } } if valenc := getOtherEncoder(t); valenc != nil { encode(valenc, v) return } switch kind { case reflect.Int: enc.WriteInt(*(*int)(reflect2.PtrOf(v))) case reflect.Int8: enc.WriteInt8(*(*int8)(reflect2.PtrOf(v))) case reflect.Int16: enc.WriteInt16(*(*int16)(reflect2.PtrOf(v))) case reflect.Int32: enc.WriteInt32(*(*int32)(reflect2.PtrOf(v))) case reflect.Int64: enc.WriteInt64(*(*int64)(reflect2.PtrOf(v))) case reflect.Uint: enc.WriteUint(*(*uint)(reflect2.PtrOf(v))) case reflect.Uint8: enc.WriteUint8(*(*uint8)(reflect2.PtrOf(v))) case reflect.Uint16: enc.WriteUint16(*(*uint16)(reflect2.PtrOf(v))) case reflect.Uint32: enc.WriteUint32(*(*uint32)(reflect2.PtrOf(v))) case reflect.Uint64, reflect.Uintptr: enc.WriteUint64(*(*uint64)(reflect2.PtrOf(v))) case reflect.Bool: enc.WriteBool(*(*bool)(reflect2.PtrOf(v))) case reflect.Float32: enc.WriteFloat32(*(*float32)(reflect2.PtrOf(v))) case reflect.Float64: enc.WriteFloat64(*(*float64)(reflect2.PtrOf(v))) case reflect.Complex64: enc.WriteComplex64(*(*complex64)(reflect2.PtrOf(v))) case reflect.Complex128: enc.WriteComplex128(*(*complex128)(reflect2.PtrOf(v))) case reflect.String: encode(strenc, v) case reflect.Array: enc.WriteArray(v) case reflect.Struct: getStructEncoder(t).Write(enc, v) case reflect.Slice: enc.WriteSlice(v) case reflect.Map: enc.WriteMap(v) case reflect.Ptr: encode(ptrenc, v) default: enc.Error = UnsupportedTypeError{reflect.TypeOf(v)} enc.WriteNil() } } func (enc *Encoder) encode(v interface{}) { enc.writeValue(v, func(valenc ValueEncoder, v interface{}) { valenc.Encode(enc, v) }) } func (enc *Encoder) write(v interface{}) { enc.writeValue(v, func(valenc ValueEncoder, v interface{}) { valenc.Write(enc, v) }) } // Flush writes the encoding data from buf to Writer func (enc *Encoder) Flush() (err error) { if enc.Error != nil { return enc.Error } if enc.Writer != nil && enc.off < len(enc.buf) { _, err = enc.Writer.Write(enc.buf[enc.off:]) enc.off = len(enc.buf) } return } // Encode writes the hprose encoding of v to stream // if v is already written to stream, it will writes it as reference func (enc *Encoder) Encode(v interface{}) (err error) { enc.copyCheck() enc.encode(v) return enc.Flush() } // Write writes the hprose encoding of v to stream // if v is already written to stream, it will writes it as value func (enc *Encoder) Write(v interface{}) (err error) { enc.copyCheck() enc.write(v) return enc.Flush() } // Bytes returns the accumulated bytes. func (enc *Encoder) Bytes() []byte { return enc.buf } // String returns the accumulated string. func (enc *Encoder) String() string { return *(*string)(unsafe.Pointer(&enc.buf)) } // WriteReference of v to stream func (enc *Encoder) WriteReference(v interface{}) bool { if !enc.IsSimple() { return enc.refer.Write(enc, v) } return false } // WriteStringReference of v to stream func (enc *Encoder) WriteStringReference(s string) bool { if !enc.IsSimple() { return enc.refer.WriteString(enc, s) } return false } // SetReference of v func (enc *Encoder) SetReference(v interface{}) { if !enc.IsSimple() { switch reflect.TypeOf(v).Kind() { case reflect.Ptr: enc.refer.Set(v) default: enc.refer.AddCount(1) } } } func (enc *Encoder) setReference(v interface{}) { if !enc.IsSimple() { enc.refer.Set(v) } } // SetStringReference of v func (enc *Encoder) SetStringReference(s string) { if !enc.IsSimple() { enc.refer.SetString(s) } } // AddReferenceCount n func (enc *Encoder) AddReferenceCount(n int) { if !enc.IsSimple() { enc.refer.AddCount(n) } } // WriteStructType of t to stream with action func (enc *Encoder) WriteStructType(t reflect.Type, action func()) (r int) { if enc.ref == nil { enc.ref = make(map[reflect.Type]int) } if r, ok := enc.ref[t]; ok { return r } action() r = enc.last enc.last++ enc.ref[t] = r return } // Reset the value reference and struct type reference func (enc *Encoder) Reset() *Encoder { if !enc.IsSimple() { enc.refer.Reset() } enc.ref = nil enc.last = 0 return enc } // Simple resets the encoder to simple mode or not func (enc *Encoder) Simple(simple bool) *Encoder { if simple { enc.refer = nil } else { enc.refer = &encoderRefer{} } enc.ref = nil enc.last = 0 return enc } // IsSimple returns the encoder is in simple mode or not func (enc *Encoder) IsSimple() bool { return nil == enc.refer } // WriteNil to encoder func (enc *Encoder) WriteNil() { enc.buf = append(enc.buf, TagNull) } func (enc *Encoder) writeHead(n int, tag byte) { enc.buf = append(enc.buf, tag) if n > 0 { enc.buf = AppendUint64(enc.buf, uint64(n)) } enc.buf = append(enc.buf, TagOpenbrace) } // WriteListHead to encoder, n is the count of elements in list func (enc *Encoder) WriteListHead(n int) { enc.writeHead(n, TagList) } // WriteMapHead to encoder, n is the count of elements in map func (enc *Encoder) WriteMapHead(n int) { enc.writeHead(n, TagMap) } // WriteObjectHead to encoder, r is the reference number of struct func (enc *Encoder) WriteObjectHead(r int) { enc.buf = append(enc.buf, TagObject) enc.buf = AppendUint64(enc.buf, uint64(r)) enc.buf = append(enc.buf, TagOpenbrace) } // WriteFoot of list or map to encoder func (enc *Encoder) WriteFoot() { enc.buf = append(enc.buf, TagClosebrace) } // EncodeReference to encoder func (enc *Encoder) EncodeReference(valenc ValueEncoder, v interface{}) { if reflect2.IsNil(v) { enc.WriteNil() } else if ok := enc.WriteReference(v); !ok { valenc.Write(enc, v) } } // WriteTag to encoder func (enc *Encoder) WriteTag(tag byte) { enc.buf = append(enc.buf, tag) }
{ "pile_set_name": "Github" }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_10-ea) on Mon Apr 22 19:45:41 PDT 2013 --> <meta http-equiv="Content-Type" content="text/html" charset="UTF-8"> <title>Uses of Interface com.fasterxml.jackson.core.SerializableString (Jackson-core 2.2.0 API)</title> <meta name="date" content="2013-04-22"> <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="Uses of Interface com.fasterxml.jackson.core.SerializableString (Jackson-core 2.2.0 API)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-all.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?com/fasterxml/jackson/core/class-use/SerializableString.html" target="_top">Frames</a></li> <li><a href="SerializableString.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h2 title="Uses of Interface com.fasterxml.jackson.core.SerializableString" class="title">Uses of Interface<br>com.fasterxml.jackson.core.SerializableString</h2> </div> <div class="classUseContainer"> <ul class="blockList"> <li class="blockList"> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation"> <caption><span>Packages that use <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Package</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="#com.fasterxml.jackson.core">com.fasterxml.jackson.core</a></td> <td class="colLast"> <div class="block">Main public API classes of the core streaming JSON processor: most importantly <a href="../../../../../com/fasterxml/jackson/core/JsonFactory.html" title="class in com.fasterxml.jackson.core"><code>JsonFactory</code></a> used for constructing JSON parser (<a href="../../../../../com/fasterxml/jackson/core/JsonParser.html" title="class in com.fasterxml.jackson.core"><code>JsonParser</code></a>) and generator (<a href="../../../../../com/fasterxml/jackson/core/JsonParser.html" title="class in com.fasterxml.jackson.core"><code>JsonParser</code></a>) instances.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#com.fasterxml.jackson.core.base">com.fasterxml.jackson.core.base</a></td> <td class="colLast"> <div class="block">Base classes used by concrete Parser and Generator implementations; contain functionality that is not specific to JSON or input abstraction (byte vs char).</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="#com.fasterxml.jackson.core.io">com.fasterxml.jackson.core.io</a></td> <td class="colLast">&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="#com.fasterxml.jackson.core.json">com.fasterxml.jackson.core.json</a></td> <td class="colLast"> <div class="block">JSON-specific parser and generator implementation classes that Jackson defines and uses.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="#com.fasterxml.jackson.core.util">com.fasterxml.jackson.core.util</a></td> <td class="colLast"> <div class="block">Utility classes used by Jackson Core functionality.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"> <ul class="blockList"> <li class="blockList"><a name="com.fasterxml.jackson.core"> <!-- --> </a> <h3>Uses of <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a> in <a href="../../../../../com/fasterxml/jackson/core/package-summary.html">com.fasterxml.jackson.core</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation"> <caption><span>Fields in <a href="../../../../../com/fasterxml/jackson/core/package-summary.html">com.fasterxml.jackson.core</a> declared as <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Field and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>protected <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></code></td> <td class="colLast"><span class="strong">JsonFactory.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonFactory.html#_rootValueSeparator">_rootValueSeparator</a></strong></code> <div class="block">Separator used between root-level values, if any; null indicates "do not add separator".</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../com/fasterxml/jackson/core/package-summary.html">com.fasterxml.jackson.core</a> with parameters of type <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>boolean</code></td> <td class="colLast"><span class="strong">JsonParser.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonParser.html#nextFieldName(com.fasterxml.jackson.core.SerializableString)">nextFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;str)</code> <div class="block">Method that fetches next token (as if calling <a href="../../../../../com/fasterxml/jackson/core/JsonParser.html#nextToken()"><code>JsonParser.nextToken()</code></a>) and verifies whether it is <a href="../../../../../com/fasterxml/jackson/core/JsonToken.html#FIELD_NAME"><code>JsonToken.FIELD_NAME</code></a> with specified name and returns result of that comparison.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html" title="class in com.fasterxml.jackson.core">JsonGenerator</a></code></td> <td class="colLast"><span class="strong">JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#setRootValueSeparator(com.fasterxml.jackson.core.SerializableString)">setRootValueSeparator</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;sep)</code> <div class="block">Method that allows overriding String used for separating root-level JSON values (default is single space character)</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code>abstract void</code></td> <td class="colLast"><span class="strong">JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#writeFieldName(com.fasterxml.jackson.core.SerializableString)">writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code> <div class="block">Method similar to <a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#writeFieldName(java.lang.String)"><code>JsonGenerator.writeFieldName(String)</code></a>, main difference being that it may perform better as some of processing (such as quoting of certain characters, or encoding into external encoding if supported by generator) can be done just once and reused for later calls.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#writeRaw(com.fasterxml.jackson.core.SerializableString)">writeRaw</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;raw)</code> <div class="block">Method that will force generator to copy input text verbatim with <b>no</b> modifications (including that no escaping is done and no separators are added even if context [array, object] would otherwise require such).</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><code>abstract void</code></td> <td class="colLast"><span class="strong">JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#writeString(com.fasterxml.jackson.core.SerializableString)">writeString</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code> <div class="block">Method similar to <a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html#writeString(java.lang.String)"><code>JsonGenerator.writeString(String)</code></a>, but that takes <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core"><code>SerializableString</code></a> which can make this potentially more efficient to call as generator may be able to reuse quoted and/or encoded representation.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="com.fasterxml.jackson.core.base"> <!-- --> </a> <h3>Uses of <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a> in <a href="../../../../../com/fasterxml/jackson/core/base/package-summary.html">com.fasterxml.jackson.core.base</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../com/fasterxml/jackson/core/base/package-summary.html">com.fasterxml.jackson.core.base</a> with parameters of type <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">GeneratorBase.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/base/GeneratorBase.html#writeFieldName(com.fasterxml.jackson.core.SerializableString)">writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">GeneratorBase.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/base/GeneratorBase.html#writeString(com.fasterxml.jackson.core.SerializableString)">writeString</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code>&nbsp;</td> </tr> </tbody> </table> </li> <li class="blockList"><a name="com.fasterxml.jackson.core.io"> <!-- --> </a> <h3>Uses of <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a> in <a href="../../../../../com/fasterxml/jackson/core/io/package-summary.html">com.fasterxml.jackson.core.io</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing classes, and an explanation"> <caption><span>Classes in <a href="../../../../../com/fasterxml/jackson/core/io/package-summary.html">com.fasterxml.jackson.core.io</a> that implement <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Class and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>class&nbsp;</code></td> <td class="colLast"><code><strong><a href="../../../../../com/fasterxml/jackson/core/io/SerializedString.html" title="class in com.fasterxml.jackson.core.io">SerializedString</a></strong></code> <div class="block">String token that can lazily serialize String contained and then reuse that serialization later on.</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../com/fasterxml/jackson/core/io/package-summary.html">com.fasterxml.jackson.core.io</a> that return <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>abstract <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></code></td> <td class="colLast"><span class="strong">CharacterEscapes.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/io/CharacterEscapes.html#getEscapeSequence(int)">getEscapeSequence</a></strong>(int&nbsp;ch)</code> <div class="block">Method generators can call to get lookup table for determining exact escape sequence to use for given character.</div> </td> </tr> </tbody> </table> </li> <li class="blockList"><a name="com.fasterxml.jackson.core.json"> <!-- --> </a> <h3>Uses of <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a> in <a href="../../../../../com/fasterxml/jackson/core/json/package-summary.html">com.fasterxml.jackson.core.json</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation"> <caption><span>Fields in <a href="../../../../../com/fasterxml/jackson/core/json/package-summary.html">com.fasterxml.jackson.core.json</a> declared as <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Field and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>protected <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#_currentEscape">_currentEscape</a></strong></code> <div class="block">When custom escapes are used, this member variable is used internally to hold a reference to currently used escape</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><code>protected <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></code></td> <td class="colLast"><span class="strong">JsonGeneratorImpl.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/JsonGeneratorImpl.html#_rootValueSeparator">_rootValueSeparator</a></strong></code> <div class="block">Separator to use, if any, between root-level values.</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../com/fasterxml/jackson/core/json/package-summary.html">com.fasterxml.jackson.core.json</a> with parameters of type <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>protected void</code></td> <td class="colLast"><span class="strong">UTF8JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8JsonGenerator.html#_writeFieldName(com.fasterxml.jackson.core.SerializableString)">_writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#_writeFieldName(com.fasterxml.jackson.core.SerializableString, boolean)">_writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name, boolean&nbsp;commaBefore)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>protected void</code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#_writePPFieldName(com.fasterxml.jackson.core.SerializableString, boolean)">_writePPFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name, boolean&nbsp;commaBefore)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>protected void</code></td> <td class="colLast"><span class="strong">UTF8JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8JsonGenerator.html#_writePPFieldName(com.fasterxml.jackson.core.SerializableString, boolean)">_writePPFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name, boolean&nbsp;commaBefore)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>boolean</code></td> <td class="colLast"><span class="strong">UTF8StreamJsonParser.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8StreamJsonParser.html#nextFieldName(com.fasterxml.jackson.core.SerializableString)">nextFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;str)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html" title="class in com.fasterxml.jackson.core">JsonGenerator</a></code></td> <td class="colLast"><span class="strong">JsonGeneratorImpl.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/JsonGeneratorImpl.html#setRootValueSeparator(com.fasterxml.jackson.core.SerializableString)">setRootValueSeparator</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;sep)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#writeFieldName(com.fasterxml.jackson.core.SerializableString)">writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">UTF8JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8JsonGenerator.html#writeFieldName(com.fasterxml.jackson.core.SerializableString)">writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#writeRaw(com.fasterxml.jackson.core.SerializableString)">writeRaw</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">UTF8JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8JsonGenerator.html#writeRaw(com.fasterxml.jackson.core.SerializableString)">writeRaw</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">WriterBasedJsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.html#writeString(com.fasterxml.jackson.core.SerializableString)">writeString</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;sstr)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">UTF8JsonGenerator.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/json/UTF8JsonGenerator.html#writeString(com.fasterxml.jackson.core.SerializableString)">writeString</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code>&nbsp;</td> </tr> </tbody> </table> </li> <li class="blockList"><a name="com.fasterxml.jackson.core.util"> <!-- --> </a> <h3>Uses of <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a> in <a href="../../../../../com/fasterxml/jackson/core/util/package-summary.html">com.fasterxml.jackson.core.util</a></h3> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing fields, and an explanation"> <caption><span>Fields in <a href="../../../../../com/fasterxml/jackson/core/util/package-summary.html">com.fasterxml.jackson.core.util</a> declared as <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Field and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code>protected <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></code></td> <td class="colLast"><span class="strong">DefaultPrettyPrinter.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html#_rootSeparator">_rootSeparator</a></strong></code> <div class="block">String printed between root-level values, if any.</div> </td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation"> <caption><span>Methods in <a href="../../../../../com/fasterxml/jackson/core/util/package-summary.html">com.fasterxml.jackson.core.util</a> with parameters of type <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Modifier and Type</th> <th class="colLast" scope="col">Method and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><code><a href="../../../../../com/fasterxml/jackson/core/JsonGenerator.html" title="class in com.fasterxml.jackson.core">JsonGenerator</a></code></td> <td class="colLast"><span class="strong">JsonGeneratorDelegate.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/JsonGeneratorDelegate.html#setRootValueSeparator(com.fasterxml.jackson.core.SerializableString)">setRootValueSeparator</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;sep)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code><a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html" title="class in com.fasterxml.jackson.core.util">DefaultPrettyPrinter</a></code></td> <td class="colLast"><span class="strong">DefaultPrettyPrinter.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html#withRootSeparator(com.fasterxml.jackson.core.SerializableString)">withRootSeparator</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;rootSeparator)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">JsonGeneratorDelegate.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/JsonGeneratorDelegate.html#writeFieldName(com.fasterxml.jackson.core.SerializableString)">writeFieldName</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;name)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">JsonGeneratorDelegate.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/JsonGeneratorDelegate.html#writeRaw(com.fasterxml.jackson.core.SerializableString)">writeRaw</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;raw)</code>&nbsp;</td> </tr> <tr class="altColor"> <td class="colFirst"><code>void</code></td> <td class="colLast"><span class="strong">JsonGeneratorDelegate.</span><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/JsonGeneratorDelegate.html#writeString(com.fasterxml.jackson.core.SerializableString)">writeString</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;text)</code>&nbsp;</td> </tr> </tbody> </table> <table border="0" cellpadding="3" cellspacing="0" summary="Use table, listing constructors, and an explanation"> <caption><span>Constructors in <a href="../../../../../com/fasterxml/jackson/core/util/package-summary.html">com.fasterxml.jackson.core.util</a> with parameters of type <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a></span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colOne" scope="col">Constructor and Description</th> </tr> <tbody> <tr class="altColor"> <td class="colLast"><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html#DefaultPrettyPrinter(com.fasterxml.jackson.core.util.DefaultPrettyPrinter, com.fasterxml.jackson.core.SerializableString)">DefaultPrettyPrinter</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html" title="class in com.fasterxml.jackson.core.util">DefaultPrettyPrinter</a>&nbsp;base, <a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;rootSeparator)</code>&nbsp;</td> </tr> <tr class="rowColor"> <td class="colLast"><code><strong><a href="../../../../../com/fasterxml/jackson/core/util/DefaultPrettyPrinter.html#DefaultPrettyPrinter(com.fasterxml.jackson.core.SerializableString)">DefaultPrettyPrinter</a></strong>(<a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">SerializableString</a>&nbsp;rootSeparator)</code> <div class="block">Constructor that specifies separator String to use between root values; if null, no separator is printed.</div> </td> </tr> </tbody> </table> </li> </ul> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../../../../overview-summary.html">Overview</a></li> <li><a href="../package-summary.html">Package</a></li> <li><a href="../../../../../com/fasterxml/jackson/core/SerializableString.html" title="interface in com.fasterxml.jackson.core">Class</a></li> <li class="navBarCell1Rev">Use</li> <li><a href="../package-tree.html">Tree</a></li> <li><a href="../../../../../deprecated-list.html">Deprecated</a></li> <li><a href="../../../../../index-all.html">Index</a></li> <li><a href="../../../../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li>Prev</li> <li>Next</li> </ul> <ul class="navList"> <li><a href="../../../../../index.html?com/fasterxml/jackson/core/class-use/SerializableString.html" target="_top">Frames</a></li> <li><a href="SerializableString.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../../../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> <p class="legalCopy"><small>Copyright &#169; 2012-2013 <a href="http://fasterxml.com/">FasterXML</a>. All Rights Reserved.</small></p> </body> </html>
{ "pile_set_name": "Github" }
script( src=theme.google_adsense.js_src data-ad-client=theme.google_adsense.client async="" )&attributes(dataPjax)
{ "pile_set_name": "Github" }
// This file is part of DSpellCheck Plug-in for Notepad++ // Copyright (C)2019 Sergey Semushin <[email protected]> // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma once #include "StaticDialog/StaticDialog.h" class AboutDlg : public StaticDialog { public: void init(HINSTANCE h_inst, HWND parent) override; void do_dialog(); void update_compiler_version(); protected: INT_PTR WINAPI run_dlg_proc (UINT message, WPARAM w_param, LPARAM l_param) override; };
{ "pile_set_name": "Github" }
# # Copyright (c) 2018 Gregory L. Dietsche <[email protected]> # This is free software, licensed under the MIT License # # # IMPORTANT: if this file is not working, make sure that dnsmasq is able to READ it! # #204.79.197.220 strict.bing.com #::FFFF:CC4F:C5DC strict.bing.com 204.79.197.220 bing.com www.bing.com ::FFFF:CC4F:C5DC bing.com www.bing.com
{ "pile_set_name": "Github" }
// Copyright ©2013 The Gonum Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mat import ( "math" "gonum.org/v1/gonum/blas" "gonum.org/v1/gonum/blas/blas64" "gonum.org/v1/gonum/floats" "gonum.org/v1/gonum/lapack" "gonum.org/v1/gonum/lapack/lapack64" ) // Matrix is the basic matrix interface type. type Matrix interface { // Dims returns the dimensions of a Matrix. Dims() (r, c int) // At returns the value of a matrix element at row i, column j. // It will panic if i or j are out of bounds for the matrix. At(i, j int) float64 // T returns the transpose of the Matrix. Whether T returns a copy of the // underlying data is implementation dependent. // This method may be implemented using the Transpose type, which // provides an implicit matrix transpose. T() Matrix } // allMatrix represents the extra set of methods that all mat Matrix types // should satisfy. This is used to enforce compile-time consistency between the // Dense types, especially helpful when adding new features. type allMatrix interface { Reseter IsEmpty() bool Zero() } // denseMatrix represents the extra set of methods that all Dense Matrix types // should satisfy. This is used to enforce compile-time consistency between the // Dense types, especially helpful when adding new features. type denseMatrix interface { DiagView() Diagonal Tracer } var ( _ Matrix = Transpose{} _ Untransposer = Transpose{} ) // Transpose is a type for performing an implicit matrix transpose. It implements // the Matrix interface, returning values from the transpose of the matrix within. type Transpose struct { Matrix Matrix } // At returns the value of the element at row i and column j of the transposed // matrix, that is, row j and column i of the Matrix field. func (t Transpose) At(i, j int) float64 { return t.Matrix.At(j, i) } // Dims returns the dimensions of the transposed matrix. The number of rows returned // is the number of columns in the Matrix field, and the number of columns is // the number of rows in the Matrix field. func (t Transpose) Dims() (r, c int) { c, r = t.Matrix.Dims() return r, c } // T performs an implicit transpose by returning the Matrix field. func (t Transpose) T() Matrix { return t.Matrix } // Untranspose returns the Matrix field. func (t Transpose) Untranspose() Matrix { return t.Matrix } // Untransposer is a type that can undo an implicit transpose. type Untransposer interface { // Note: This interface is needed to unify all of the Transpose types. In // the mat methods, we need to test if the Matrix has been implicitly // transposed. If this is checked by testing for the specific Transpose type // then the behavior will be different if the user uses T() or TTri() for a // triangular matrix. // Untranspose returns the underlying Matrix stored for the implicit transpose. Untranspose() Matrix } // UntransposeBander is a type that can undo an implicit band transpose. type UntransposeBander interface { // Untranspose returns the underlying Banded stored for the implicit transpose. UntransposeBand() Banded } // UntransposeTrier is a type that can undo an implicit triangular transpose. type UntransposeTrier interface { // Untranspose returns the underlying Triangular stored for the implicit transpose. UntransposeTri() Triangular } // UntransposeTriBander is a type that can undo an implicit triangular banded // transpose. type UntransposeTriBander interface { // Untranspose returns the underlying Triangular stored for the implicit transpose. UntransposeTriBand() TriBanded } // Mutable is a matrix interface type that allows elements to be altered. type Mutable interface { // Set alters the matrix element at row i, column j to v. // It will panic if i or j are out of bounds for the matrix. Set(i, j int, v float64) Matrix } // A RowViewer can return a Vector reflecting a row that is backed by the matrix // data. The Vector returned will have length equal to the number of columns. type RowViewer interface { RowView(i int) Vector } // A RawRowViewer can return a slice of float64 reflecting a row that is backed by the matrix // data. type RawRowViewer interface { RawRowView(i int) []float64 } // A ColViewer can return a Vector reflecting a column that is backed by the matrix // data. The Vector returned will have length equal to the number of rows. type ColViewer interface { ColView(j int) Vector } // A RawColViewer can return a slice of float64 reflecting a column that is backed by the matrix // data. type RawColViewer interface { RawColView(j int) []float64 } // A ClonerFrom can make a copy of a into the receiver, overwriting the previous value of the // receiver. The clone operation does not make any restriction on shape and will not cause // shadowing. type ClonerFrom interface { CloneFrom(a Matrix) } // A Reseter can reset the matrix so that it can be reused as the receiver of a dimensionally // restricted operation. This is commonly used when the matrix is being used as a workspace // or temporary matrix. // // If the matrix is a view, using Reset may result in data corruption in elements outside // the view. Similarly, if the matrix shares backing data with another variable, using // Reset may lead to unexpected changes in data values. type Reseter interface { Reset() } // A Copier can make a copy of elements of a into the receiver. The submatrix copied // starts at row and column 0 and has dimensions equal to the minimum dimensions of // the two matrices. The number of row and columns copied is returned. // Copy will copy from a source that aliases the receiver unless the source is transposed; // an aliasing transpose copy will panic with the exception for a special case when // the source data has a unitary increment or stride. type Copier interface { Copy(a Matrix) (r, c int) } // A Grower can grow the size of the represented matrix by the given number of rows and columns. // Growing beyond the size given by the Caps method will result in the allocation of a new // matrix and copying of the elements. If Grow is called with negative increments it will // panic with ErrIndexOutOfRange. type Grower interface { Caps() (r, c int) Grow(r, c int) Matrix } // A BandWidther represents a banded matrix and can return the left and right half-bandwidths, k1 and // k2. type BandWidther interface { BandWidth() (k1, k2 int) } // A RawMatrixSetter can set the underlying blas64.General used by the receiver. There is no restriction // on the shape of the receiver. Changes to the receiver's elements will be reflected in the blas64.General.Data. type RawMatrixSetter interface { SetRawMatrix(a blas64.General) } // A RawMatrixer can return a blas64.General representation of the receiver. Changes to the blas64.General.Data // slice will be reflected in the original matrix, changes to the Rows, Cols and Stride fields will not. type RawMatrixer interface { RawMatrix() blas64.General } // A RawVectorer can return a blas64.Vector representation of the receiver. Changes to the blas64.Vector.Data // slice will be reflected in the original matrix, changes to the Inc field will not. type RawVectorer interface { RawVector() blas64.Vector } // A NonZeroDoer can call a function for each non-zero element of the receiver. // The parameters of the function are the element indices and its value. type NonZeroDoer interface { DoNonZero(func(i, j int, v float64)) } // A RowNonZeroDoer can call a function for each non-zero element of a row of the receiver. // The parameters of the function are the element indices and its value. type RowNonZeroDoer interface { DoRowNonZero(i int, fn func(i, j int, v float64)) } // A ColNonZeroDoer can call a function for each non-zero element of a column of the receiver. // The parameters of the function are the element indices and its value. type ColNonZeroDoer interface { DoColNonZero(j int, fn func(i, j int, v float64)) } // untranspose untransposes a matrix if applicable. If a is an Untransposer, then // untranspose returns the underlying matrix and true. If it is not, then it returns // the input matrix and false. func untranspose(a Matrix) (Matrix, bool) { if ut, ok := a.(Untransposer); ok { return ut.Untranspose(), true } return a, false } // untransposeExtract returns an untransposed matrix in a built-in matrix type. // // The untransposed matrix is returned unaltered if it is a built-in matrix type. // Otherwise, if it implements a Raw method, an appropriate built-in type value // is returned holding the raw matrix value of the input. If neither of these // is possible, the untransposed matrix is returned. func untransposeExtract(a Matrix) (Matrix, bool) { ut, trans := untranspose(a) switch m := ut.(type) { case *DiagDense, *SymBandDense, *TriBandDense, *BandDense, *TriDense, *SymDense, *Dense, *VecDense: return m, trans // TODO(btracey): Add here if we ever have an equivalent of RawDiagDense. case RawSymBander: rsb := m.RawSymBand() if rsb.Uplo != blas.Upper { return ut, trans } var sb SymBandDense sb.SetRawSymBand(rsb) return &sb, trans case RawTriBander: rtb := m.RawTriBand() if rtb.Diag == blas.Unit { return ut, trans } var tb TriBandDense tb.SetRawTriBand(rtb) return &tb, trans case RawBander: var b BandDense b.SetRawBand(m.RawBand()) return &b, trans case RawTriangular: rt := m.RawTriangular() if rt.Diag == blas.Unit { return ut, trans } var t TriDense t.SetRawTriangular(rt) return &t, trans case RawSymmetricer: rs := m.RawSymmetric() if rs.Uplo != blas.Upper { return ut, trans } var s SymDense s.SetRawSymmetric(rs) return &s, trans case RawMatrixer: var d Dense d.SetRawMatrix(m.RawMatrix()) return &d, trans case RawVectorer: var v VecDense v.SetRawVector(m.RawVector()) return &v, trans default: return ut, trans } } // TODO(btracey): Consider adding CopyCol/CopyRow if the behavior seems useful. // TODO(btracey): Add in fast paths to Row/Col for the other concrete types // (TriDense, etc.) as well as relevant interfaces (RowColer, RawRowViewer, etc.) // Col copies the elements in the jth column of the matrix into the slice dst. // The length of the provided slice must equal the number of rows, unless the // slice is nil in which case a new slice is first allocated. func Col(dst []float64, j int, a Matrix) []float64 { r, c := a.Dims() if j < 0 || j >= c { panic(ErrColAccess) } if dst == nil { dst = make([]float64, r) } else { if len(dst) != r { panic(ErrColLength) } } aU, aTrans := untranspose(a) if rm, ok := aU.(RawMatrixer); ok { m := rm.RawMatrix() if aTrans { copy(dst, m.Data[j*m.Stride:j*m.Stride+m.Cols]) return dst } blas64.Copy(blas64.Vector{N: r, Inc: m.Stride, Data: m.Data[j:]}, blas64.Vector{N: r, Inc: 1, Data: dst}, ) return dst } for i := 0; i < r; i++ { dst[i] = a.At(i, j) } return dst } // Row copies the elements in the ith row of the matrix into the slice dst. // The length of the provided slice must equal the number of columns, unless the // slice is nil in which case a new slice is first allocated. func Row(dst []float64, i int, a Matrix) []float64 { r, c := a.Dims() if i < 0 || i >= r { panic(ErrColAccess) } if dst == nil { dst = make([]float64, c) } else { if len(dst) != c { panic(ErrRowLength) } } aU, aTrans := untranspose(a) if rm, ok := aU.(RawMatrixer); ok { m := rm.RawMatrix() if aTrans { blas64.Copy(blas64.Vector{N: c, Inc: m.Stride, Data: m.Data[i:]}, blas64.Vector{N: c, Inc: 1, Data: dst}, ) return dst } copy(dst, m.Data[i*m.Stride:i*m.Stride+m.Cols]) return dst } for j := 0; j < c; j++ { dst[j] = a.At(i, j) } return dst } // Cond returns the condition number of the given matrix under the given norm. // The condition number must be based on the 1-norm, 2-norm or ∞-norm. // Cond will panic with matrix.ErrShape if the matrix has zero size. // // BUG(btracey): The computation of the 1-norm and ∞-norm for non-square matrices // is innacurate, although is typically the right order of magnitude. See // https://github.com/xianyi/OpenBLAS/issues/636. While the value returned will // change with the resolution of this bug, the result from Cond will match the // condition number used internally. func Cond(a Matrix, norm float64) float64 { m, n := a.Dims() if m == 0 || n == 0 { panic(ErrShape) } var lnorm lapack.MatrixNorm switch norm { default: panic("mat: bad norm value") case 1: lnorm = lapack.MaxColumnSum case 2: var svd SVD ok := svd.Factorize(a, SVDNone) if !ok { return math.Inf(1) } return svd.Cond() case math.Inf(1): lnorm = lapack.MaxRowSum } if m == n { // Use the LU decomposition to compute the condition number. var lu LU lu.factorize(a, lnorm) return lu.Cond() } if m > n { // Use the QR factorization to compute the condition number. var qr QR qr.factorize(a, lnorm) return qr.Cond() } // Use the LQ factorization to compute the condition number. var lq LQ lq.factorize(a, lnorm) return lq.Cond() } // Det returns the determinant of the matrix a. In many expressions using LogDet // will be more numerically stable. func Det(a Matrix) float64 { det, sign := LogDet(a) return math.Exp(det) * sign } // Dot returns the sum of the element-wise product of a and b. // Dot panics if the matrix sizes are unequal. func Dot(a, b Vector) float64 { la := a.Len() lb := b.Len() if la != lb { panic(ErrShape) } if arv, ok := a.(RawVectorer); ok { if brv, ok := b.(RawVectorer); ok { return blas64.Dot(arv.RawVector(), brv.RawVector()) } } var sum float64 for i := 0; i < la; i++ { sum += a.At(i, 0) * b.At(i, 0) } return sum } // Equal returns whether the matrices a and b have the same size // and are element-wise equal. func Equal(a, b Matrix) bool { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { return false } aU, aTrans := untranspose(a) bU, bTrans := untranspose(b) if rma, ok := aU.(RawMatrixer); ok { if rmb, ok := bU.(RawMatrixer); ok { ra := rma.RawMatrix() rb := rmb.RawMatrix() if aTrans == bTrans { for i := 0; i < ra.Rows; i++ { for j := 0; j < ra.Cols; j++ { if ra.Data[i*ra.Stride+j] != rb.Data[i*rb.Stride+j] { return false } } } return true } for i := 0; i < ra.Rows; i++ { for j := 0; j < ra.Cols; j++ { if ra.Data[i*ra.Stride+j] != rb.Data[j*rb.Stride+i] { return false } } } return true } } if rma, ok := aU.(RawSymmetricer); ok { if rmb, ok := bU.(RawSymmetricer); ok { ra := rma.RawSymmetric() rb := rmb.RawSymmetric() // Symmetric matrices are always upper and equal to their transpose. for i := 0; i < ra.N; i++ { for j := i; j < ra.N; j++ { if ra.Data[i*ra.Stride+j] != rb.Data[i*rb.Stride+j] { return false } } } return true } } if ra, ok := aU.(*VecDense); ok { if rb, ok := bU.(*VecDense); ok { // If the raw vectors are the same length they must either both be // transposed or both not transposed (or have length 1). for i := 0; i < ra.mat.N; i++ { if ra.mat.Data[i*ra.mat.Inc] != rb.mat.Data[i*rb.mat.Inc] { return false } } return true } } for i := 0; i < ar; i++ { for j := 0; j < ac; j++ { if a.At(i, j) != b.At(i, j) { return false } } } return true } // EqualApprox returns whether the matrices a and b have the same size and contain all equal // elements with tolerance for element-wise equality specified by epsilon. Matrices // with non-equal shapes are not equal. func EqualApprox(a, b Matrix, epsilon float64) bool { ar, ac := a.Dims() br, bc := b.Dims() if ar != br || ac != bc { return false } aU, aTrans := untranspose(a) bU, bTrans := untranspose(b) if rma, ok := aU.(RawMatrixer); ok { if rmb, ok := bU.(RawMatrixer); ok { ra := rma.RawMatrix() rb := rmb.RawMatrix() if aTrans == bTrans { for i := 0; i < ra.Rows; i++ { for j := 0; j < ra.Cols; j++ { if !floats.EqualWithinAbsOrRel(ra.Data[i*ra.Stride+j], rb.Data[i*rb.Stride+j], epsilon, epsilon) { return false } } } return true } for i := 0; i < ra.Rows; i++ { for j := 0; j < ra.Cols; j++ { if !floats.EqualWithinAbsOrRel(ra.Data[i*ra.Stride+j], rb.Data[j*rb.Stride+i], epsilon, epsilon) { return false } } } return true } } if rma, ok := aU.(RawSymmetricer); ok { if rmb, ok := bU.(RawSymmetricer); ok { ra := rma.RawSymmetric() rb := rmb.RawSymmetric() // Symmetric matrices are always upper and equal to their transpose. for i := 0; i < ra.N; i++ { for j := i; j < ra.N; j++ { if !floats.EqualWithinAbsOrRel(ra.Data[i*ra.Stride+j], rb.Data[i*rb.Stride+j], epsilon, epsilon) { return false } } } return true } } if ra, ok := aU.(*VecDense); ok { if rb, ok := bU.(*VecDense); ok { // If the raw vectors are the same length they must either both be // transposed or both not transposed (or have length 1). for i := 0; i < ra.mat.N; i++ { if !floats.EqualWithinAbsOrRel(ra.mat.Data[i*ra.mat.Inc], rb.mat.Data[i*rb.mat.Inc], epsilon, epsilon) { return false } } return true } } for i := 0; i < ar; i++ { for j := 0; j < ac; j++ { if !floats.EqualWithinAbsOrRel(a.At(i, j), b.At(i, j), epsilon, epsilon) { return false } } } return true } // LogDet returns the log of the determinant and the sign of the determinant // for the matrix that has been factorized. Numerical stability in product and // division expressions is generally improved by working in log space. func LogDet(a Matrix) (det float64, sign float64) { // TODO(btracey): Add specialized routines for TriDense, etc. var lu LU lu.Factorize(a) return lu.LogDet() } // Max returns the largest element value of the matrix A. // Max will panic with matrix.ErrShape if the matrix has zero size. func Max(a Matrix) float64 { r, c := a.Dims() if r == 0 || c == 0 { panic(ErrShape) } // Max(A) = Max(Aᵀ) aU, _ := untranspose(a) switch m := aU.(type) { case RawMatrixer: rm := m.RawMatrix() max := math.Inf(-1) for i := 0; i < rm.Rows; i++ { for _, v := range rm.Data[i*rm.Stride : i*rm.Stride+rm.Cols] { if v > max { max = v } } } return max case RawTriangular: rm := m.RawTriangular() // The max of a triangular is at least 0 unless the size is 1. if rm.N == 1 { return rm.Data[0] } max := 0.0 if rm.Uplo == blas.Upper { for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride+i : i*rm.Stride+rm.N] { if v > max { max = v } } } return max } for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride : i*rm.Stride+i+1] { if v > max { max = v } } } return max case RawSymmetricer: rm := m.RawSymmetric() if rm.Uplo != blas.Upper { panic(badSymTriangle) } max := math.Inf(-1) for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride+i : i*rm.Stride+rm.N] { if v > max { max = v } } } return max default: r, c := aU.Dims() max := math.Inf(-1) for i := 0; i < r; i++ { for j := 0; j < c; j++ { v := aU.At(i, j) if v > max { max = v } } } return max } } // Min returns the smallest element value of the matrix A. // Min will panic with matrix.ErrShape if the matrix has zero size. func Min(a Matrix) float64 { r, c := a.Dims() if r == 0 || c == 0 { panic(ErrShape) } // Min(A) = Min(Aᵀ) aU, _ := untranspose(a) switch m := aU.(type) { case RawMatrixer: rm := m.RawMatrix() min := math.Inf(1) for i := 0; i < rm.Rows; i++ { for _, v := range rm.Data[i*rm.Stride : i*rm.Stride+rm.Cols] { if v < min { min = v } } } return min case RawTriangular: rm := m.RawTriangular() // The min of a triangular is at most 0 unless the size is 1. if rm.N == 1 { return rm.Data[0] } min := 0.0 if rm.Uplo == blas.Upper { for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride+i : i*rm.Stride+rm.N] { if v < min { min = v } } } return min } for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride : i*rm.Stride+i+1] { if v < min { min = v } } } return min case RawSymmetricer: rm := m.RawSymmetric() if rm.Uplo != blas.Upper { panic(badSymTriangle) } min := math.Inf(1) for i := 0; i < rm.N; i++ { for _, v := range rm.Data[i*rm.Stride+i : i*rm.Stride+rm.N] { if v < min { min = v } } } return min default: r, c := aU.Dims() min := math.Inf(1) for i := 0; i < r; i++ { for j := 0; j < c; j++ { v := aU.At(i, j) if v < min { min = v } } } return min } } // Norm returns the specified (induced) norm of the matrix a. See // https://en.wikipedia.org/wiki/Matrix_norm for the definition of an induced norm. // // Valid norms are: // 1 - The maximum absolute column sum // 2 - Frobenius norm, the square root of the sum of the squares of the elements. // Inf - The maximum absolute row sum. // Norm will panic with ErrNormOrder if an illegal norm order is specified and // with matrix.ErrShape if the matrix has zero size. func Norm(a Matrix, norm float64) float64 { r, c := a.Dims() if r == 0 || c == 0 { panic(ErrShape) } aU, aTrans := untranspose(a) var work []float64 switch rma := aU.(type) { case RawMatrixer: rm := rma.RawMatrix() n := normLapack(norm, aTrans) if n == lapack.MaxColumnSum { work = getFloats(rm.Cols, false) defer putFloats(work) } return lapack64.Lange(n, rm, work) case RawTriangular: rm := rma.RawTriangular() n := normLapack(norm, aTrans) if n == lapack.MaxRowSum || n == lapack.MaxColumnSum { work = getFloats(rm.N, false) defer putFloats(work) } return lapack64.Lantr(n, rm, work) case RawSymmetricer: rm := rma.RawSymmetric() n := normLapack(norm, aTrans) if n == lapack.MaxRowSum || n == lapack.MaxColumnSum { work = getFloats(rm.N, false) defer putFloats(work) } return lapack64.Lansy(n, rm, work) case *VecDense: rv := rma.RawVector() switch norm { default: panic(ErrNormOrder) case 1: if aTrans { imax := blas64.Iamax(rv) return math.Abs(rma.At(imax, 0)) } return blas64.Asum(rv) case 2: return blas64.Nrm2(rv) case math.Inf(1): if aTrans { return blas64.Asum(rv) } imax := blas64.Iamax(rv) return math.Abs(rma.At(imax, 0)) } } switch norm { default: panic(ErrNormOrder) case 1: var max float64 for j := 0; j < c; j++ { var sum float64 for i := 0; i < r; i++ { sum += math.Abs(a.At(i, j)) } if sum > max { max = sum } } return max case 2: var sum float64 for i := 0; i < r; i++ { for j := 0; j < c; j++ { v := a.At(i, j) sum += v * v } } return math.Sqrt(sum) case math.Inf(1): var max float64 for i := 0; i < r; i++ { var sum float64 for j := 0; j < c; j++ { sum += math.Abs(a.At(i, j)) } if sum > max { max = sum } } return max } } // normLapack converts the float64 norm input in Norm to a lapack.MatrixNorm. func normLapack(norm float64, aTrans bool) lapack.MatrixNorm { switch norm { case 1: n := lapack.MaxColumnSum if aTrans { n = lapack.MaxRowSum } return n case 2: return lapack.Frobenius case math.Inf(1): n := lapack.MaxRowSum if aTrans { n = lapack.MaxColumnSum } return n default: panic(ErrNormOrder) } } // Sum returns the sum of the elements of the matrix. func Sum(a Matrix) float64 { var sum float64 aU, _ := untranspose(a) switch rma := aU.(type) { case RawSymmetricer: rm := rma.RawSymmetric() for i := 0; i < rm.N; i++ { // Diagonals count once while off-diagonals count twice. sum += rm.Data[i*rm.Stride+i] var s float64 for _, v := range rm.Data[i*rm.Stride+i+1 : i*rm.Stride+rm.N] { s += v } sum += 2 * s } return sum case RawTriangular: rm := rma.RawTriangular() var startIdx, endIdx int for i := 0; i < rm.N; i++ { // Start and end index for this triangle-row. switch rm.Uplo { case blas.Upper: startIdx = i endIdx = rm.N case blas.Lower: startIdx = 0 endIdx = i + 1 default: panic(badTriangle) } for _, v := range rm.Data[i*rm.Stride+startIdx : i*rm.Stride+endIdx] { sum += v } } return sum case RawMatrixer: rm := rma.RawMatrix() for i := 0; i < rm.Rows; i++ { for _, v := range rm.Data[i*rm.Stride : i*rm.Stride+rm.Cols] { sum += v } } return sum case *VecDense: rm := rma.RawVector() for i := 0; i < rm.N; i++ { sum += rm.Data[i*rm.Inc] } return sum default: r, c := a.Dims() for i := 0; i < r; i++ { for j := 0; j < c; j++ { sum += a.At(i, j) } } return sum } } // A Tracer can compute the trace of the matrix. Trace must panic if the // matrix is not square. type Tracer interface { Trace() float64 } // Trace returns the trace of the matrix. Trace will panic if the // matrix is not square. If a is a Tracer, its Trace method will be // used to calculate the matrix trace. func Trace(a Matrix) float64 { m, _ := untransposeExtract(a) if t, ok := m.(Tracer); ok { return t.Trace() } r, c := a.Dims() if r != c { panic(ErrSquare) } var v float64 for i := 0; i < r; i++ { v += a.At(i, i) } return v } func min(a, b int) int { if a < b { return a } return b } func max(a, b int) int { if a > b { return a } return b } // use returns a float64 slice with l elements, using f if it // has the necessary capacity, otherwise creating a new slice. func use(f []float64, l int) []float64 { if l <= cap(f) { return f[:l] } return make([]float64, l) } // useZeroed returns a float64 slice with l elements, using f if it // has the necessary capacity, otherwise creating a new slice. The // elements of the returned slice are guaranteed to be zero. func useZeroed(f []float64, l int) []float64 { if l <= cap(f) { f = f[:l] zero(f) return f } return make([]float64, l) } // zero zeros the given slice's elements. func zero(f []float64) { for i := range f { f[i] = 0 } } // useInt returns an int slice with l elements, using i if it // has the necessary capacity, otherwise creating a new slice. func useInt(i []int, l int) []int { if l <= cap(i) { return i[:l] } return make([]int, l) }
{ "pile_set_name": "Github" }
#include "preamble-with-implicit-import-A.h" // Typo is defined in B, which is not imported. void useTypeFromB(Typo *);
{ "pile_set_name": "Github" }
package org.aisen.android.network.task; import android.content.res.Resources; import android.text.TextUtils; import org.aisen.android.R; import org.aisen.android.common.context.GlobalContext; /** * 应用的异常申明<br/> * 1、包含四种基本环境类型错误申明<br/> * 2、业务类型异常,如果没有设置msg字段,请初始化Declare获取msg信息 * */ public class TaskException extends Exception { private static final long serialVersionUID = -6262214243381380676L; public enum TaskError { // 网络错误 failIOError, // 无网络链接 noneNetwork, // 连接超时 timeout, // 响应超时 socketTimeout, // 返回数据不合法 resultIllegal } private String code; private String msg = ""; private static IExceptionDeclare exceptionDeclare; public TaskException(String code) { this.code = code; } public TaskException(String code, String msg) { this(code); this.msg = msg; } public String getCode() { return code; } @Override public String getMessage() { if (!TextUtils.isEmpty(msg)) return msg + ""; if (!TextUtils.isEmpty(code) && exceptionDeclare != null) { String msg = exceptionDeclare.checkCode(code); if (!TextUtils.isEmpty(msg)) { return msg + ""; } } try { if (GlobalContext.getInstance() != null) { Resources res = GlobalContext.getInstance().getResources(); TaskError error = TaskError.valueOf(code); if (error == TaskError.noneNetwork || error == TaskError.failIOError) msg = res.getString(R.string.comm_error_none_network); else if (error == TaskError.socketTimeout || error == TaskError.timeout) msg = res.getString(R.string.comm_error_timeout); else if (error == TaskError.resultIllegal) msg = res.getString(R.string.comm_error_result_illegal); if (!TextUtils.isEmpty(msg)) return msg + ""; } } catch (Exception e) { } return super.getMessage() + ""; } public static void config(IExceptionDeclare declare) { TaskException.exceptionDeclare = declare; } public static void checkResponse(String response) throws TaskException { if (TaskException.exceptionDeclare != null) TaskException.exceptionDeclare.checkResponse(response); } }
{ "pile_set_name": "Github" }
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.netbeans.modules.visual.apichanges; import org.netbeans.modules.visual.framework.VisualTestCase; import org.netbeans.api.visual.animator.AnimatorEvent; import org.netbeans.api.visual.animator.AnimatorListener; import org.netbeans.api.visual.widget.Scene; import org.netbeans.api.visual.widget.Widget; import javax.swing.*; import java.awt.*; import java.lang.reflect.InvocationTargetException; import org.netbeans.junit.RandomlyFails; /** * Test for #99048 - Animator listener is needed * @author David Kaspar */ public class AnimatorListenerTest extends VisualTestCase { public AnimatorListenerTest (String name) { super (name); } @Override protected boolean runInEQ() { return false; } @RandomlyFails public void testAnimatorListener () throws InterruptedException, InvocationTargetException { Scene[] scene = { null }; SwingUtilities.invokeAndWait (new Runnable() { @Override public void run () { scene[0] = initScene(); } }); final JFrame[] frame = new JFrame[1]; SwingUtilities.invokeAndWait (new Runnable() { @Override public void run () { frame[0] = showFrame (scene[0]); } }); Thread.sleep (2000); SwingUtilities.invokeAndWait (new Runnable() { @Override public void run () { frame[0].setVisible (false); frame[0].dispose (); } }); compareReferenceFiles (); } private Scene initScene() { final Scene scene = new Scene (); Widget widget = new Widget (scene); scene.addChild (widget); AnimatorListener listener = new AnimatorListener() { public void animatorStarted (AnimatorEvent event) { getRef ().println ("Animator started"); } public void animatorReset (AnimatorEvent event) { getRef ().println ("Animator reset"); } public void animatorFinished (AnimatorEvent event) { getRef ().println ("Animator finished"); } public void animatorPreTick (AnimatorEvent event) { if (event.getProgress () >= 1.0) getRef ().println ("Animator pre-tick: " + event.getProgress ()); } public void animatorPostTick (AnimatorEvent event) { if (event.getProgress () >= 1.0) getRef ().println ("Animator post-tick: " + event.getProgress ()); } }; scene.getSceneAnimator ().getPreferredLocationAnimator ().addAnimatorListener (listener); widget.setPreferredLocation (new Point (0, 0)); scene.getSceneAnimator ().animatePreferredLocation (widget, new Point (100, 100)); return scene; } }
{ "pile_set_name": "Github" }
--- layout: global title: Spark Streaming + Flume Integration Guide --- [Apache Flume](https://flume.apache.org/) is a distributed, reliable, and available service for efficiently collecting, aggregating, and moving large amounts of log data. Here we explain how to configure Flume and Spark Streaming to receive data from Flume. There are two approaches to this. ## Approach 1: Flume-style Push-based Approach Flume is designed to push data between Flume agents. In this approach, Spark Streaming essentially sets up a receiver that acts an Avro agent for Flume, to which Flume can push the data. Here are the configuration steps. #### General Requirements Choose a machine in your cluster such that - When your Flume + Spark Streaming application is launched, one of the Spark workers must run on that machine. - Flume can be configured to push data to a port on that machine. Due to the push model, the streaming application needs to be up, with the receiver scheduled and listening on the chosen port, for Flume to be able push data. #### Configuring Flume Configure Flume agent to send data to an Avro sink by having the following in the configuration file. agent.sinks = avroSink agent.sinks.avroSink.type = avro agent.sinks.avroSink.channel = memoryChannel agent.sinks.avroSink.hostname = <chosen machine's hostname> agent.sinks.avroSink.port = <chosen port on the machine> See the [Flume's documentation](https://flume.apache.org/documentation.html) for more information about configuring Flume agents. #### Configuring Spark Streaming Application 1. **Linking:** In your SBT/Maven project definition, link your streaming application against the following artifact (see [Linking section](streaming-programming-guide.html#linking) in the main programming guide for further information). groupId = org.apache.spark artifactId = spark-streaming-flume_{{site.SCALA_BINARY_VERSION}} version = {{site.SPARK_VERSION_SHORT}} 2. **Programming:** In the streaming application code, import `FlumeUtils` and create input DStream as follows. <div class="codetabs"> <div data-lang="scala" markdown="1"> import org.apache.spark.streaming.flume._ val flumeStream = FlumeUtils.createStream(streamingContext, [chosen machine's hostname], [chosen port]) See the [API docs](api/scala/index.html#org.apache.spark.streaming.flume.FlumeUtils$) and the [example]({{site.SPARK_GITHUB_URL}}/tree/master/examples/src/main/scala/org/apache/spark/examples/streaming/FlumeEventCount.scala). </div> <div data-lang="java" markdown="1"> import org.apache.spark.streaming.flume.*; JavaReceiverInputDStream<SparkFlumeEvent> flumeStream = FlumeUtils.createStream(streamingContext, [chosen machine's hostname], [chosen port]); See the [API docs](api/java/index.html?org/apache/spark/streaming/flume/FlumeUtils.html) and the [example]({{site.SPARK_GITHUB_URL}}/tree/master/examples/src/main/java/org/apache/spark/examples/streaming/JavaFlumeEventCount.java). </div> <div data-lang="python" markdown="1"> from pyspark.streaming.flume import FlumeUtils flumeStream = FlumeUtils.createStream(streamingContext, [chosen machine's hostname], [chosen port]) By default, the Python API will decode Flume event body as UTF8 encoded strings. You can specify your custom decoding function to decode the body byte arrays in Flume events to any arbitrary data type. See the [API docs](api/python/pyspark.streaming.html#pyspark.streaming.flume.FlumeUtils) and the [example]({{site.SPARK_GITHUB_URL}}/blob/v{{site.SPARK_VERSION_SHORT}}/examples/src/main/python/streaming/flume_wordcount.py). </div> </div> Note that the hostname should be the same as the one used by the resource manager in the cluster (Mesos, YARN or Spark Standalone), so that resource allocation can match the names and launch the receiver in the right machine. 3. **Deploying:** As with any Spark applications, `spark-submit` is used to launch your application. However, the details are slightly different for Scala/Java applications and Python applications. For Scala and Java applications, if you are using SBT or Maven for project management, then package `spark-streaming-flume_{{site.SCALA_BINARY_VERSION}}` and its dependencies into the application JAR. Make sure `spark-core_{{site.SCALA_BINARY_VERSION}}` and `spark-streaming_{{site.SCALA_BINARY_VERSION}}` are marked as `provided` dependencies as those are already present in a Spark installation. Then use `spark-submit` to launch your application (see [Deploying section](streaming-programming-guide.html#deploying-applications) in the main programming guide). For Python applications which lack SBT/Maven project management, `spark-streaming-flume_{{site.SCALA_BINARY_VERSION}}` and its dependencies can be directly added to `spark-submit` using `--packages` (see [Application Submission Guide](submitting-applications.html)). That is, ./bin/spark-submit --packages org.apache.spark:spark-streaming-flume_{{site.SCALA_BINARY_VERSION}}:{{site.SPARK_VERSION_SHORT}} ... Alternatively, you can also download the JAR of the Maven artifact `spark-streaming-flume-assembly` from the [Maven repository](http://search.maven.org/#search|ga|1|a%3A%22spark-streaming-flume-assembly_{{site.SCALA_BINARY_VERSION}}%22%20AND%20v%3A%22{{site.SPARK_VERSION_SHORT}}%22) and add it to `spark-submit` with `--jars`. ## Approach 2: Pull-based Approach using a Custom Sink Instead of Flume pushing data directly to Spark Streaming, this approach runs a custom Flume sink that allows the following. - Flume pushes data into the sink, and the data stays buffered. - Spark Streaming uses a [reliable Flume receiver](streaming-programming-guide.html#receiver-reliability) and transactions to pull data from the sink. Transactions succeed only after data is received and replicated by Spark Streaming. This ensures stronger reliability and [fault-tolerance guarantees](streaming-programming-guide.html#fault-tolerance-semantics) than the previous approach. However, this requires configuring Flume to run a custom sink. Here are the configuration steps. #### General Requirements Choose a machine that will run the custom sink in a Flume agent. The rest of the Flume pipeline is configured to send data to that agent. Machines in the Spark cluster should have access to the chosen machine running the custom sink. #### Configuring Flume Configuring Flume on the chosen machine requires the following two steps. 1. **Sink JARs**: Add the following JARs to Flume's classpath (see [Flume's documentation](https://flume.apache.org/documentation.html) to see how) in the machine designated to run the custom sink . (i) *Custom sink JAR*: Download the JAR corresponding to the following artifact (or [direct link](http://search.maven.org/remotecontent?filepath=org/apache/spark/spark-streaming-flume-sink_{{site.SCALA_BINARY_VERSION}}/{{site.SPARK_VERSION_SHORT}}/spark-streaming-flume-sink_{{site.SCALA_BINARY_VERSION}}-{{site.SPARK_VERSION_SHORT}}.jar)). groupId = org.apache.spark artifactId = spark-streaming-flume-sink_{{site.SCALA_BINARY_VERSION}} version = {{site.SPARK_VERSION_SHORT}} (ii) *Scala library JAR*: Download the Scala library JAR for Scala {{site.SCALA_VERSION}}. It can be found with the following artifact detail (or, [direct link](http://search.maven.org/remotecontent?filepath=org/scala-lang/scala-library/{{site.SCALA_VERSION}}/scala-library-{{site.SCALA_VERSION}}.jar)). groupId = org.scala-lang artifactId = scala-library version = {{site.SCALA_VERSION}} (iii) *Commons Lang 3 JAR*: Download the Commons Lang 3 JAR. It can be found with the following artifact detail (or, [direct link](http://search.maven.org/remotecontent?filepath=org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar)). groupId = org.apache.commons artifactId = commons-lang3 version = 3.5 2. **Configuration file**: On that machine, configure Flume agent to send data to an Avro sink by having the following in the configuration file. agent.sinks = spark agent.sinks.spark.type = org.apache.spark.streaming.flume.sink.SparkSink agent.sinks.spark.hostname = <hostname of the local machine> agent.sinks.spark.port = <port to listen on for connection from Spark> agent.sinks.spark.channel = memoryChannel Also make sure that the upstream Flume pipeline is configured to send the data to the Flume agent running this sink. See the [Flume's documentation](https://flume.apache.org/documentation.html) for more information about configuring Flume agents. #### Configuring Spark Streaming Application 1. **Linking:** In your SBT/Maven project definition, link your streaming application against the `spark-streaming-flume_{{site.SCALA_BINARY_VERSION}}` (see [Linking section](streaming-programming-guide.html#linking) in the main programming guide). 2. **Programming:** In the streaming application code, import `FlumeUtils` and create input DStream as follows. <div class="codetabs"> <div data-lang="scala" markdown="1"> import org.apache.spark.streaming.flume._ val flumeStream = FlumeUtils.createPollingStream(streamingContext, [sink machine hostname], [sink port]) </div> <div data-lang="java" markdown="1"> import org.apache.spark.streaming.flume.*; JavaReceiverInputDStream<SparkFlumeEvent>flumeStream = FlumeUtils.createPollingStream(streamingContext, [sink machine hostname], [sink port]); </div> <div data-lang="python" markdown="1"> from pyspark.streaming.flume import FlumeUtils addresses = [([sink machine hostname 1], [sink port 1]), ([sink machine hostname 2], [sink port 2])] flumeStream = FlumeUtils.createPollingStream(streamingContext, addresses) By default, the Python API will decode Flume event body as UTF8 encoded strings. You can specify your custom decoding function to decode the body byte arrays in Flume events to any arbitrary data type. See the [API docs](api/python/pyspark.streaming.html#pyspark.streaming.flume.FlumeUtils). </div> </div> See the Scala example [FlumePollingEventCount]({{site.SPARK_GITHUB_URL}}/tree/master/examples/src/main/scala/org/apache/spark/examples/streaming/FlumePollingEventCount.scala). Note that each input DStream can be configured to receive data from multiple sinks. 3. **Deploying:** This is same as the first approach.
{ "pile_set_name": "Github" }
################################################################################ # # exempi # ################################################################################ EXEMPI_VERSION = 2.4.5 EXEMPI_SOURCE = exempi-$(EXEMPI_VERSION).tar.bz2 EXEMPI_SITE = https://libopenraw.freedesktop.org/download EXEMPI_INSTALL_STAGING = YES EXEMPI_CONF_OPTS = --disable-unittest EXEMPI_DEPENDENCIES = host-pkgconf expat zlib \ $(if $(BR2_PACKAGE_LIBICONV),libiconv) EXEMPI_LICENSE = BSD-3-Clause EXEMPI_LICENSE_FILES = COPYING $(eval $(autotools-package))
{ "pile_set_name": "Github" }
// mksyscall.pl -l32 -openbsd -tags openbsd,386 syscall_bsd.go syscall_openbsd.go syscall_openbsd_386.go // Code generated by the command above; see README.md. DO NOT EDIT. // +build openbsd,386 package unix import ( "syscall" "unsafe" ) var _ syscall.Errno // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getgroups(ngid int, gid *_Gid_t) (n int, err error) { r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func setgroups(ngid int, gid *_Gid_t) (err error) { _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) { r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0) wpid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) { r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) { _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func socket(domain int, typ int, proto int) (fd int, err error) { r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto)) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) { _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) { _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) { _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen))) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Shutdown(s int, how int) (err error) { _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) { _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) { r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) { r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { var _p0 unsafe.Pointer if len(mib) > 0 { _p0 = unsafe.Pointer(&mib[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func utimes(path string, timeval *[2]Timeval) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func futimes(fd int, timeval *[2]Timeval) (err error) { _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func fcntl(fd int, cmd int, arg int) (val int, err error) { r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg)) val = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func poll(fds *PollFd, nfds int, timeout int) (n int, err error) { r0, _, e1 := Syscall(SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Madvise(b []byte, behav int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MADVISE, uintptr(_p0), uintptr(len(b)), uintptr(behav)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mlock(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MLOCK, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mlockall(flags int) (err error) { _, _, e1 := Syscall(SYS_MLOCKALL, uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mprotect(b []byte, prot int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MPROTECT, uintptr(_p0), uintptr(len(b)), uintptr(prot)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Msync(b []byte, flags int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MSYNC, uintptr(_p0), uintptr(len(b)), uintptr(flags)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Munlock(b []byte) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { _p0 = unsafe.Pointer(&b[0]) } else { _p0 = unsafe.Pointer(&_zero) } _, _, e1 := Syscall(SYS_MUNLOCK, uintptr(_p0), uintptr(len(b)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Munlockall() (err error) { _, _, e1 := Syscall(SYS_MUNLOCKALL, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func pipe(p *[2]_C_int) (err error) { _, _, e1 := RawSyscall(SYS_PIPE, uintptr(unsafe.Pointer(p)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func getdents(fd int, buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getcwd(buf []byte) (n int, err error) { var _p0 unsafe.Pointer if len(buf) > 0 { _p0 = unsafe.Pointer(&buf[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS___GETCWD, uintptr(_p0), uintptr(len(buf)), 0) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Adjtime(delta *Timeval, olddelta *Timeval) (err error) { _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chflags(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chmod(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Chroot(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Close(fd int) (err error) { _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Dup(fd int) (nfd int, err error) { r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0) nfd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Dup2(from int, to int) (err error) { _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Exit(code int) { Syscall(SYS_EXIT, uintptr(code), 0, 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FACCESSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchdir(fd int) (err error) { _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchflags(fd int, flags int) (err error) { _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchmod(fd int, mode uint32) (err error) { _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FCHMODAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fchown(fd int, uid int, gid int) (err error) { _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Flock(fd int, how int) (err error) { _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fpathconf(fd int, name int) (val int, err error) { r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0) val = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstat(fd int, stat *Stat_t) (err error) { _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fstatfs(fd int, stat *Statfs_t) (err error) { _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Fsync(fd int) (err error) { _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Ftruncate(fd int, length int64) (err error) { _, _, e1 := Syscall6(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getegid() (egid int) { r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0) egid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Geteuid() (uid int) { r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0) uid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getgid() (gid int) { r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0) gid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpgid(pid int) (pgid int, err error) { r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0) pgid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpgrp() (pgrp int) { r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) pgrp = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpid() (pid int) { r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) pid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getppid() (ppid int) { r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0) ppid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getpriority(which int, who int) (prio int, err error) { r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0) prio = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getrtable() (rtable int, err error) { r0, _, e1 := RawSyscall(SYS_GETRTABLE, 0, 0, 0) rtable = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getsid(pid int) (sid int, err error) { r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0) sid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Gettimeofday(tv *Timeval) (err error) { _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Getuid() (uid int) { r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0) uid = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Issetugid() (tainted bool) { r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0) tainted = bool(r0 != 0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Kill(pid int, signum syscall.Signal) (err error) { _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Kqueue() (fd int, err error) { r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Lchown(path string, uid int, gid int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Link(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(link) if err != nil { return } _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Listen(s int, backlog int) (err error) { _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Lstat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkdir(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mkfifo(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Mknod(path string, mode uint32, dev int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Nanosleep(time *Timespec, leftover *Timespec) (err error) { _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Open(path string, mode int, perm uint32) (fd int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm)) fd = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pathconf(path string, name int) (val int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0) val = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pread(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Pwrite(fd int, p []byte, offset int64) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func read(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Readlink(path string, buf []byte) (n int, err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 unsafe.Pointer if len(buf) > 0 { _p1 = unsafe.Pointer(&buf[0]) } else { _p1 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Rename(from string, to string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(from) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(to) if err != nil { return } _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Revoke(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Rmdir(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Seek(fd int, offset int64, whence int) (newoffset int64, err error) { r0, r1, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(offset>>32), uintptr(whence), 0) newoffset = int64(int64(r1)<<32 | int64(r0)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) { _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setegid(egid int) (err error) { _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Seteuid(euid int) (err error) { _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setgid(gid int) (err error) { _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setlogin(name string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(name) if err != nil { return } _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setpgid(pid int, pgid int) (err error) { _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setpriority(which int, who int, prio int) (err error) { _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setregid(rgid int, egid int) (err error) { _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setreuid(ruid int, euid int) (err error) { _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setresgid(rgid int, egid int, sgid int) (err error) { _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setresuid(ruid int, euid int, suid int) (err error) { _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid)) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setrlimit(which int, lim *Rlimit) (err error) { _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setrtable(rtable int) (err error) { _, _, e1 := RawSyscall(SYS_SETRTABLE, uintptr(rtable), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setsid() (pid int, err error) { r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0) pid = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Settimeofday(tp *Timeval) (err error) { _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Setuid(uid int) (err error) { _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Stat(path string, stat *Stat_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Statfs(path string, stat *Statfs_t) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Symlink(path string, link string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } var _p1 *byte _p1, err = BytePtrFromString(link) if err != nil { return } _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Sync() (err error) { _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Truncate(path string, length int64) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Umask(newmask int) (oldmask int) { r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0) oldmask = int(r0) return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Unlink(path string) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func Unmount(path string, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func write(fd int, p []byte) (n int, err error) { var _p0 unsafe.Pointer if len(p) > 0 { _p0 = unsafe.Pointer(&p[0]) } else { _p0 = unsafe.Pointer(&_zero) } r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p))) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) { r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), uintptr(pos>>32), 0) ret = uintptr(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func munmap(addr uintptr, length uintptr) (err error) { _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func readlen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func writelen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf)) n = int(r0) if e1 != 0 { err = errnoErr(e1) } return } // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) if err != nil { return } _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flags), 0, 0) if e1 != 0 { err = errnoErr(e1) } return }
{ "pile_set_name": "Github" }
var convert = require('./convert'), func = convert('difference', require('../difference')); func.placeholder = require('./placeholder'); module.exports = func;
{ "pile_set_name": "Github" }
/****************************************************************************** * Spine Runtimes License Agreement * Last updated January 1, 2020. Replaces all prior versions. * * Copyright (c) 2013-2020, Esoteric Software LLC * * Integration of the Spine Runtimes into software or otherwise creating * derivative works of the Spine Runtimes is permitted under the terms and * conditions of Section 2 of the Spine Editor License Agreement: * http://esotericsoftware.com/spine-editor-license * * Otherwise, it is permitted to integrate the Spine Runtimes into software * or otherwise create derivative works of the Spine Runtimes (collectively, * "Products"), provided that each user of the Products must obtain their own * Spine Editor license and redistribution of the Products in any form must * include this license and copyright notice. * * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "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 ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) 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 * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ #include <spine/MeshAttachment.h> #include <spine/extension.h> #include <stdio.h> void _spMeshAttachment_dispose (spAttachment* attachment) { spMeshAttachment* self = SUB_CAST(spMeshAttachment, attachment); FREE(self->path); FREE(self->uvs); if (!self->parentMesh) { _spVertexAttachment_deinit(SUPER(self)); FREE(self->regionUVs); FREE(self->triangles); FREE(self->edges); } else _spAttachment_deinit(attachment); FREE(self); } spAttachment* _spMeshAttachment_copy (spAttachment* attachment) { spMeshAttachment* copy; spMeshAttachment* self = SUB_CAST(spMeshAttachment, attachment); if (self->parentMesh) return SUPER(SUPER(spMeshAttachment_newLinkedMesh(self))); copy = spMeshAttachment_create(attachment->name); copy->rendererObject = self->rendererObject; copy->regionU = self->regionU; copy->regionV = self->regionV; copy->regionU2 = self->regionU2; copy->regionV2 = self->regionV2; copy->regionRotate = self->regionRotate; copy->regionDegrees = self->regionDegrees; copy->regionOffsetX = self->regionOffsetX; copy->regionOffsetY = self->regionOffsetY; copy->regionWidth = self->regionWidth; copy->regionHeight = self->regionHeight; copy->regionOriginalWidth = self->regionOriginalWidth; copy->regionOriginalHeight = self->regionOriginalHeight; MALLOC_STR(copy->path, self->path); spColor_setFromColor(&copy->color, &self->color); spVertexAttachment_copyTo(SUPER(self), SUPER(copy)); copy->regionUVs = MALLOC(float, SUPER(self)->worldVerticesLength); memcpy(copy->regionUVs, self->regionUVs, SUPER(self)->worldVerticesLength * sizeof(float)); copy->uvs = MALLOC(float, SUPER(self)->worldVerticesLength); memcpy(copy->uvs, self->uvs, SUPER(self)->worldVerticesLength * sizeof(float)); copy->trianglesCount = self->trianglesCount; copy->triangles = MALLOC(unsigned short, self->trianglesCount); memcpy(copy->triangles, self->triangles, self->trianglesCount * sizeof(short)); copy->hullLength = self->hullLength; if (self->edgesCount > 0) { copy->edgesCount = self->edgesCount; copy->edges = MALLOC(int, self->edgesCount); memcpy(copy->edges, self->edges, self->edgesCount * sizeof(int)); } copy->width = self->width; copy->height = self->height; return SUPER(SUPER(copy)); } spMeshAttachment* spMeshAttachment_newLinkedMesh (spMeshAttachment* self) { spMeshAttachment* copy = spMeshAttachment_create(self->super.super.name); copy->rendererObject = self->rendererObject; copy->regionU = self->regionU; copy->regionV = self->regionV; copy->regionU2 = self->regionU2; copy->regionV2 = self->regionV2; copy->regionRotate = self->regionRotate; copy->regionDegrees = self->regionDegrees; copy->regionOffsetX = self->regionOffsetX; copy->regionOffsetY = self->regionOffsetY; copy->regionWidth = self->regionWidth; copy->regionHeight = self->regionHeight; copy->regionOriginalWidth = self->regionOriginalWidth; copy->regionOriginalHeight = self->regionOriginalHeight; MALLOC_STR(copy->path, self->path); spColor_setFromColor(&copy->color, &self->color); copy->super.deformAttachment = self->super.deformAttachment; spMeshAttachment_setParentMesh(copy, self->parentMesh ? self->parentMesh : self); spMeshAttachment_updateUVs(copy); return copy; } spMeshAttachment* spMeshAttachment_create (const char* name) { spMeshAttachment* self = NEW(spMeshAttachment); _spVertexAttachment_init(SUPER(self)); spColor_setFromFloats(&self->color, 1, 1, 1, 1); _spAttachment_init(SUPER(SUPER(self)), name, SP_ATTACHMENT_MESH, _spMeshAttachment_dispose, _spMeshAttachment_copy); return self; } void spMeshAttachment_updateUVs (spMeshAttachment* self) { int i, n; float* uvs; float u, v, width, height; int verticesLength = SUPER(self)->worldVerticesLength; FREE(self->uvs); uvs = self->uvs = MALLOC(float, verticesLength); n = verticesLength; u = self->regionU; v = self->regionV; switch (self->regionDegrees) { case 90: { float textureWidth = self->regionHeight / (self->regionU2 - self->regionU); float textureHeight = self->regionWidth / (self->regionV2 - self->regionV); u -= (self->regionOriginalHeight - self->regionOffsetY - self->regionHeight) / textureWidth; v -= (self->regionOriginalWidth - self->regionOffsetX - self->regionWidth) / textureHeight; width = self->regionOriginalHeight / textureWidth; height = self->regionOriginalWidth / textureHeight; for (i = 0; i < n; i += 2) { uvs[i] = u + self->regionUVs[i + 1] * width; uvs[i + 1] = v + (1 - self->regionUVs[i]) * height; } return; } case 180: { float textureWidth = self->regionWidth / (self->regionU2 - self->regionU); float textureHeight = self->regionHeight / (self->regionV2 - self->regionV); u -= (self->regionOriginalWidth - self->regionOffsetX - self->regionWidth) / textureWidth; v -= self->regionOffsetY / textureHeight; width = self->regionOriginalWidth / textureWidth; height = self->regionOriginalHeight / textureHeight; for (i = 0; i < n; i += 2) { uvs[i] = u + (1 - self->regionUVs[i]) * width; uvs[i + 1] = v + (1 - self->regionUVs[i + 1]) * height; } return; } case 270: { float textureHeight = self->regionHeight / (self->regionV2 - self->regionV); float textureWidth = self->regionWidth / (self->regionU2 - self->regionU); u -= self->regionOffsetY / textureWidth; v -= self->regionOffsetX / textureHeight; width = self->regionOriginalHeight / textureWidth; height = self->regionOriginalWidth / textureHeight; for (i = 0; i < n; i += 2) { uvs[i] = u + (1 - self->regionUVs[i + 1]) * width; uvs[i + 1] = v + self->regionUVs[i] * height; } return; } default: { float textureWidth = self->regionWidth / (self->regionU2 - self->regionU); float textureHeight = self->regionHeight / (self->regionV2 - self->regionV); u -= self->regionOffsetX / textureWidth; v -= (self->regionOriginalHeight - self->regionOffsetY - self->regionHeight) / textureHeight; width = self->regionOriginalWidth / textureWidth; height = self->regionOriginalHeight / textureHeight; for (i = 0; i < n; i += 2) { uvs[i] = u + self->regionUVs[i] * width; uvs[i + 1] = v + self->regionUVs[i + 1] * height; } } } } void spMeshAttachment_setParentMesh (spMeshAttachment* self, spMeshAttachment* parentMesh) { CONST_CAST(spMeshAttachment*, self->parentMesh) = parentMesh; if (parentMesh) { self->super.bones = parentMesh->super.bones; self->super.bonesCount = parentMesh->super.bonesCount; self->super.vertices = parentMesh->super.vertices; self->super.verticesCount = parentMesh->super.verticesCount; self->regionUVs = parentMesh->regionUVs; self->triangles = parentMesh->triangles; self->trianglesCount = parentMesh->trianglesCount; self->hullLength = parentMesh->hullLength; self->super.worldVerticesLength = parentMesh->super.worldVerticesLength; self->edges = parentMesh->edges; self->edgesCount = parentMesh->edgesCount; self->width = parentMesh->width; self->height = parentMesh->height; } }
{ "pile_set_name": "Github" }
<?php namespace Guzzle\Http\Exception; use Guzzle\Common\Exception\GuzzleException; /** * Http exception interface */ interface HttpException extends GuzzleException {}
{ "pile_set_name": "Github" }
defmodule Example.Application do # See https://hexdocs.pm/elixir/Application.html # for more information on OTP Applications @moduledoc false use Application def start(_type, _args) do # List all child processes to be supervised children = [ # Start the Ecto repository Example.Repo, # Start the endpoint when the application starts ExampleWeb.Endpoint, # Starts a worker by calling: Example.Worker.start_link(arg) # {Example.Worker, arg}, ] # See https://hexdocs.pm/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Example.Supervisor] Supervisor.start_link(children, opts) end # Tell Phoenix to update the endpoint configuration # whenever the application is updated. def config_change(changed, _new, removed) do ExampleWeb.Endpoint.config_change(changed, removed) :ok end end
{ "pile_set_name": "Github" }
var Uint8Array = require('../').Uint8Array; var ua = new Uint8Array(5); ua[1] = 256 + 55; console.log(ua[1]);
{ "pile_set_name": "Github" }
//----------------------------------------------------------------------------- // Copyright (c) 2012 GarageGames, LLC // // 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 "platform/platform.h" #include "T3D/decal/decalSphere.h" #include "scene/zones/sceneZoneSpaceManager.h" #include "T3D/decal/decalInstance.h" F32 DecalSphere::smDistanceTolerance = 30.0f; F32 DecalSphere::smRadiusTolerance = 40.0f; //----------------------------------------------------------------------------- bool DecalSphere::tryAddItem( DecalInstance* inst ) { // If we are further away from the center than our tolerance // allows, don't use this sphere. // // Note that we take the distance from the nearest point on the // bounding sphere rather than the distance to the center of the // decal. This takes decal sizes into account and generally works // better. const F32 distCenterToCenter = ( mWorldSphere.center - inst->mPosition ).len(); const F32 distBoundsToCenter = distCenterToCenter - inst->mSize / 2.f; if( distBoundsToCenter > smDistanceTolerance ) return false; // Also, if adding the current decal to the sphere would make // it larger than our radius tolerance, don't use it. const F32 newRadius = distCenterToCenter + inst->mSize / 2.f + 0.5f; if( newRadius > mWorldSphere.radius && newRadius > smRadiusTolerance ) return false; // Otherwise, go with this sphere and add the item to it. mItems.push_back( inst ); // Update the sphere bounds, if necessary. if( newRadius > mWorldSphere.radius ) updateWorldSphere(); return true; } //----------------------------------------------------------------------------- void DecalSphere::updateWorldSphere() { AssertFatal( mItems.size() >= 1, "DecalSphere::updateWorldSphere - Sphere is empty!" ); Box3F aabb( mItems[ 0 ]->getWorldBox() ); const U32 numItems = mItems.size(); for( U32 i = 1; i < numItems; ++ i ) aabb.intersect( mItems[ i ]->getWorldBox() ); mWorldSphere = aabb.getBoundingSphere(); // Clear the zoning data so that it gets recomputed. mZones.clear(); } //----------------------------------------------------------------------------- void DecalSphere::updateZoning( SceneZoneSpaceManager* zoneManager ) { mZones.clear(); // If there's only a single zone in the world, it must be the // outdoor zone, so there's no point maintaining zoning information // on all the decalspheres. if( zoneManager->getNumZones() == 1 ) return; // Otherwise query the scene graph for all zones that intersect with the // AABB around our world sphere. Box3F aabb( mWorldSphere.radius ); aabb.setCenter( mWorldSphere.center ); zoneManager->findZones( aabb, mZones ); }
{ "pile_set_name": "Github" }
# RNN原理 # 循环神经网络(RNN)原理通俗解释 ## 1.RNN怎么来的? 循环神经网络的应用场景比较多,比如暂时能写论文,写程序,写诗,但是,(总是会有但是的),但是他们现在还不能正常使用,学习出来的东西没有逻辑,所以要想真正让它更有用,路还很远。 这是一般的神经网络应该有的结构:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171119130251741.jpg) 既然我们已经有了人工神经网络和卷积神经网络,为什么还要循环神经网络?  原因很简单,无论是卷积神经网络,还是人工神经网络,他们的前提假设都是: 元素之间是相互独立的,**输入与输出也是独立的**,比如猫和狗。  但现实世界中,很多元素都是相互连接的,比如股票随时间的变化,一个人说了: 我喜欢旅游,其中最喜欢的地方是云南,以后有机会一定要去___这里填空,人应该都知道是填“云南“。因为我们是根据上下文的内容推断出来的,但机会要做到这一步就相当得难了。因此,就有了现在的循环神经网络,他的本质是**: 像人一样拥有记忆的能力。**因此,他的输出就依赖于当前的输入和记忆。 ## 2.RNN的网络结构及原理 它的网络结构如下:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171129184524844.jpg) 其中每个圆圈可以看作是一个单元,而且每个单元做的事情也是一样的,因此可以折叠呈左半图的样子。用一句话解释RNN,就是**一个单元结构重复使用**。 RNN是一个序列到序列的模型,假设![-w88](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570321772488.jpg)是一个输入: “我是中国“,那么![-w54](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570322195709.jpg)就应该对应”是”,”中国”这两个,预测下一个词最有可能是什么?就是![-w31](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570322451341.jpg)应该是”人”的概率比较大。 因此,我们可以做这样的定义: ![-w416](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570322822857.jpg) 。因为我们当前时刻的输出是由记忆和当前时刻的输入决定的,就像你现在大四,你的知识是由大四学到的知识(当前输入)和大三以及大三以前学到的东西的(记忆)的结合,RNN在这点上也类似,神经网络最擅长做的就是通过一系列参数把很多内容整合到一起,然后学习这个参数,因此就定义了RNN的基础: ![-w200](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570322981095.jpg) 大家可能会很好奇,为什么还要加一个f()函数,其实这个函数是神经网络中的激活函数,但为什么要加上它呢?  举个例子,假如你在大学学了非常好的解题方法,那你初中那时候的解题方法还要用吗?显然是不用了的。RNN的想法也一样,既然我能记忆了,那我当然是只记重要的信息啦,其他不重要的,就肯定会忘记,是吧。但是在神经网络中什么最适合过滤信息呀?肯定是激活函数嘛,因此在这里就套用一个激活函数,来做一个非线性映射,来过滤信息,这个激活函数可能为tanh,也可为其他。 假设你大四快毕业了,要参加考研,请问你参加考研是不是先记住你学过的内容然后去考研,还是直接带几本书去参加考研呢?很显然嘛,那RNN的想法就是预测的时候带着当前时刻的记忆 去预测。假如你要预测“我是中国“的下一个词出现的概率,这里已经很显然了,运用softmax来预测每个词出现的概率再合适不过了,但预测不能直接带用一个矩阵来预测呀,所有预测的时候还要带一个权重矩阵V,用公式表示为: ![-w160](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570323546017.jpg) 其中![-w21](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570323768890.jpg)就表示时刻t的输出。 RNN中的结构细节:   1.可以把St当作隐状态,捕捉了之前时间点上的信息。就像你去考研一样,考的时候记住了你能记住的所有信息。  2.Ot是由当前时间以及之前所有的记忆得到的。就是你考研之后做的考试卷子,是用你的记忆得到的。  3.很可惜的是,St并不能捕捉之前所有时间点的信息。就像你考研不能记住所有的英语单词一样。  4.和卷积神经网络一样,这里的网络中每个cell都共享了一组参数(U,V,W),这样就能极大的降低计算量了。  5.Ot在很多情况下都是不存在的,因为很多任务,比如文本情感分析,都是只关注最后的结果的。就像考研之后选择学校,学校不会管你到底怎么努力,怎么心酸的准备考研,而只关注你最后考了多少分。 ## 3.RNN的改进1: 双向RNN 在有些情况,比如有一部电视剧,在第三集的时候才出现的人物,现在让预测一下在第三集中出现的人物名字,你用前面两集的内容是预测不出来的,所以你需要用到第四,第五集的内容来预测第三集的内容,这就是双向RNN的想法。如图是双向RNN的图解:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/bi-directional-rnn.png)  ![-w347](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570324711246.jpg) 这里的![-w50](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570324937386.jpg)做的是一个拼接,如果他们都是1000x1维的,拼接在一起就是1000x2维的了。 双向RNN需要的内存是单向RNN的两倍,因为在同一时间点,双向RNN需要保存两个方向上的权重参数,在分类的时候,需要同时输入两个隐藏层输出的信息。 ## 4.RNN的改进2: 深层双向RNN 深层双向RNN 与双向RNN相比,多了几个隐藏层,因为他的想法是很多信息记一次记不下来,比如你去考研,复习考研英语的时候,背英语单词一定不会就看一次就记住了所有要考的考研单词吧,你应该也是带着先前几次背过的单词,然后选择那些背过,但不熟的内容,或者没背过的单词来背吧。 深层双向RNN就是基于这么一个想法,他的输入有两方面,第一就是前一时刻的隐藏层传过来的信息![-w41](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570325271812.jpg),和当前时刻上一隐藏层传过来的信息![-w167](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570325458791.jpg),包括前向和后向的。  ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/deep-bi-directional-rnn.png) 我们用公式来表示是这样的:  ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/deep-bi-directional-rnn-hidden-layer.png)  然后再利用最后一层来进行分类,分类公式如下:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/deep-bi-directional-rnn-classification.png) ### 4.1 Pyramidal RNN 其他类似的网络还有Pyramidal RNN:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171221152506461.jpg) 我们现在有一个很长的输入序列,可以看到这是一个双向的RNN,上图是谷歌的W.Chan做的一个测试,它原先要做的是语音识别,他要用序列到序列的模型做语音识别,序列到序列就是说,输入一个序列然后就输出一个序列。 由图我们发现,上一层的两个输出,作为当前层的输入,如果是非常长的序列的话,这样做的话,每一层的序列都比上一层要短,但当前层的输入f(x)也会随之增多,貌似看一起相互抵消,运算量并没有什么改进。 但我们知道,对于一层来说,它是从前往后转的,比如要预测一个股市的变化,以天为单位,假如要预测明天的股市变化,你就要用今天,以及今天之前的所有数据,我们暂时无法只用昨天的数据,不用今天的数据,预测明天的数据,也即是说,预测必须具有连续性。  但每一层的f运算是可以并行的,从这个角度来看,运算量还是可以接受的,特别是在原始输入序列较短的时候还是有优势的。 ## 5.RNN的训练-BPTT 如前面我们讲的,如果要预测t时刻的输出,我们必须先利用上一时刻(t-1)的记忆和当前时刻的输入,得到t时刻的记忆: ![-w202](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570325921406.jpg) 然后利用当前时刻的记忆,通过softmax分类器输出每个词出现的概率: ![-w144](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570326059642.jpg) 为了找出模型最好的参数,U,W,V,我们就要知道当前参数得到的结果怎么样,因此就要定义我们的损失函数,用交叉熵损失函数: ![-w252](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570326336949.jpg) 其中![-w14](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570326853547.jpg) t时刻的标准答案,是一个只有一个是1,其他都是0的向量; ![-w19](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570326727679.jpg)是我们预测出来的结果,与![-w14](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570327422935.jpg) 的维度一样,但它是一个概率向量,里面是每个词出现的概率。因为对结果的影响,肯定不止一个时刻,因此需要把所有时刻的造成的损失都加起来: ![-w300](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570327570018.jpg) ![](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171130091040277.jpg) 如图所示,你会发现每个cell都会有一个损失,我们已经定义好了损失函数,接下来就是熟悉的一步了,那就是根据损失函数利用SGD来求解最优参数,在CNN中使用反向传播BP算法来求解最优参数,但在RNN就要用到BPTT,它和BP算法的本质区别,也是CNN和RNN的本质区别: CNN没有记忆功能,它的输出仅依赖与输入,但RNN有记忆功能,它的输出不仅依赖与当前输入,还依赖与当前的记忆。这个记忆是序列到序列的,也就是当前时刻收到上一时刻的影响,比如股市的变化。 因此,在对参数求偏导的时候,对当前时刻求偏导,一定会涉及前一时刻,我们用例子看一下: ![](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171130091956686.jpg) 假设我们对E3的W求偏导: 它的损失首先来源于预测的输出![-w19](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570327881131.jpg) ,预测的输出又是来源于当前时刻的记忆s3,当前的记忆又是来源于当前的输出和截止到上一时刻的记忆: ![-w170](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570328132196.jpg) 因此,根据链式法则可以有: ![-w172](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570328255432.jpg) 但是,你会发现,![-w145](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570328436386.jpg) ,也就是s2里面的函数还包含了W,因此,这个链式法则还没到底,就像图上画的那样,所以真正的链式法则是这样的:   ![这里写图片描述](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171130094236429.jpg)  我们要把当前时刻造成的损失,和以往每个时刻造成的损失加起来,因为我们每一个时刻都用到了权重参数W。和以往的网络不同,一般的网络,比如人工神经网络,参数是不同享的,但在循环神经网络,和CNN一样,设立了参数共享机制,来降低模型的计算量。 ## 6.RNN与CNN的结合应用: 看图说话 在图像处理中,目前做的最好的是CNN,而自然语言处理中,表现比较好的是RNN,因此,我们能否把他们结合起来,一起用呢?那就是看图说话了,这个原理也比较简单,举个小栗子: 假设我们有CNN的模型训练了一个网络结构,比如是这个 ![](http://data.apachecn.org/img/AiLearning/dl/RNN原理/20171129213601819.jpg) 最后我们不是要分类嘛,那在分类前,是不是已经拿到了图像的特征呀,那我们能不能把图像的特征拿出来,放到RNN的输入里,让他学习呢? 之前的RNN是这样的: ![-w238](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570328705596.jpg) 我们把图像的特征加在里面,可以得到: ![-w266](http://data.apachecn.org/img/AiLearning/dl/RNN原理/15570328817086.jpg) 其中的X就是图像的特征。如果用的是上面的CNN网络,X应该是一个4096X1的向量。 注: 这个公式只在第一步做,后面每次更新就没有V了,因为给RNN数据只在第一次迭代的时候给。 ## 7.RNN项目练手 RNN可以写歌词,写诗等,这有个项目可以玩玩,还不错。  [Tensorflow实现RNN](https://github.com/hzy46/Char-RNN-TensorFlow)
{ "pile_set_name": "Github" }
program testpost; (* Program to test HTTP POST variables *) {$INCLUDE curltest.inc} uses curlobj; var MyCurl:tCurl; Name, Color, Food:string; begin Write('Enter your nickname: '); ReadLn(Name); Write('Your favorite color: '); ReadLn(Color); Write('Your favorite food: '); ReadLn(Food); MyCurl:=tCurl.Create(nil); MyCurl.URL:='http://curlpas.sourceforge.net/tests/testpost.php'; MyCurl.PostFields:= 'NAME=' + Name + '&COLOR=' + Color + '&FOOD=' + Food; if not MyCurl.Perform then WriteLn(MyCurl.ErrorString); MyCurl.Free; end.
{ "pile_set_name": "Github" }
// Copyright 2018 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. package impl import ( "bytes" "compress/gzip" "io/ioutil" "sync" "google.golang.org/protobuf/internal/filedesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" ) // Every enum and message type generated by protoc-gen-go since commit 2fc053c5 // on February 25th, 2016 has had a method to get the raw descriptor. // Types that were not generated by protoc-gen-go or were generated prior // to that version are not supported. // // The []byte returned is the encoded form of a FileDescriptorProto message // compressed using GZIP. The []int is the path from the top-level file // to the specific message or enum declaration. type ( enumV1 interface { EnumDescriptor() ([]byte, []int) } messageV1 interface { Descriptor() ([]byte, []int) } ) var legacyFileDescCache sync.Map // map[*byte]protoreflect.FileDescriptor // legacyLoadFileDesc unmarshals b as a compressed FileDescriptorProto message. // // This assumes that b is immutable and that b does not refer to part of a // concatenated series of GZIP files (which would require shenanigans that // rely on the concatenation properties of both protobufs and GZIP). // File descriptors generated by protoc-gen-go do not rely on that property. func legacyLoadFileDesc(b []byte) protoreflect.FileDescriptor { // Fast-path: check whether we already have a cached file descriptor. if fd, ok := legacyFileDescCache.Load(&b[0]); ok { return fd.(protoreflect.FileDescriptor) } // Slow-path: decompress and unmarshal the file descriptor proto. zr, err := gzip.NewReader(bytes.NewReader(b)) if err != nil { panic(err) } b2, err := ioutil.ReadAll(zr) if err != nil { panic(err) } fd := filedesc.Builder{ RawDescriptor: b2, FileRegistry: resolverOnly{protoregistry.GlobalFiles}, // do not register back to global registry }.Build().File if fd, ok := legacyFileDescCache.LoadOrStore(&b[0], fd); ok { return fd.(protoreflect.FileDescriptor) } return fd } type resolverOnly struct { reg *protoregistry.Files } func (r resolverOnly) FindFileByPath(path string) (protoreflect.FileDescriptor, error) { return r.reg.FindFileByPath(path) } func (r resolverOnly) FindDescriptorByName(name protoreflect.FullName) (protoreflect.Descriptor, error) { return r.reg.FindDescriptorByName(name) } func (resolverOnly) RegisterFile(protoreflect.FileDescriptor) error { return nil }
{ "pile_set_name": "Github" }
// Download the Node helper library from twilio.com/docs/node/install // These consts are your accountSid and authToken from https://www.twilio.com/console const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; const authToken = 'your_auth_token'; const client = require('twilio')(accountSid, authToken); client .conferences('CFbbe4632a3c49700934481addd5ce1659') .participants('CA386025c9bf5d6052a1d1ea42b4d16662') .fetch(participant => console.log(participant));
{ "pile_set_name": "Github" }
Manifest-Version: 1.0
{ "pile_set_name": "Github" }
// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package websocket import ( "bytes" "context" "crypto/tls" "errors" "io" "io/ioutil" "net" "net/http" "net/http/httptrace" "net/url" "strings" "time" ) // ErrBadHandshake is returned when the server response to opening handshake is // invalid. var ErrBadHandshake = errors.New("websocket: bad handshake") var errInvalidCompression = errors.New("websocket: invalid compression negotiation") // NewClient creates a new client connection using the given net connection. // The URL u specifies the host and request URI. Use requestHeader to specify // the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies // (Cookie). Use the response.Header to get the selected subprotocol // (Sec-WebSocket-Protocol) and cookies (Set-Cookie). // // If the WebSocket handshake fails, ErrBadHandshake is returned along with a // non-nil *http.Response so that callers can handle redirects, authentication, // etc. // // Deprecated: Use Dialer instead. func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) { d := Dialer{ ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize, NetDial: func(net, addr string) (net.Conn, error) { return netConn, nil }, } return d.Dial(u.String(), requestHeader) } // A Dialer contains options for connecting to WebSocket server. type Dialer struct { // NetDial specifies the dial function for creating TCP connections. If // NetDial is nil, net.Dial is used. NetDial func(network, addr string) (net.Conn, error) // NetDialContext specifies the dial function for creating TCP connections. If // NetDialContext is nil, net.DialContext is used. NetDialContext func(ctx context.Context, network, addr string) (net.Conn, error) // Proxy specifies a function to return a proxy for a given // Request. If the function returns a non-nil error, the // request is aborted with the provided error. // If Proxy is nil or returns a nil *URL, no proxy is used. Proxy func(*http.Request) (*url.URL, error) // TLSClientConfig specifies the TLS configuration to use with tls.Client. // If nil, the default configuration is used. TLSClientConfig *tls.Config // HandshakeTimeout specifies the duration for the handshake to complete. HandshakeTimeout time.Duration // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer // size is zero, then a useful default size is used. The I/O buffer sizes // do not limit the size of the messages that can be sent or received. ReadBufferSize, WriteBufferSize int // WriteBufferPool is a pool of buffers for write operations. If the value // is not set, then write buffers are allocated to the connection for the // lifetime of the connection. // // A pool is most useful when the application has a modest volume of writes // across a large number of connections. // // Applications should use a single pool for each unique value of // WriteBufferSize. WriteBufferPool BufferPool // Subprotocols specifies the client's requested subprotocols. Subprotocols []string // EnableCompression specifies if the client should attempt to negotiate // per message compression (RFC 7692). Setting this value to true does not // guarantee that compression will be supported. Currently only "no context // takeover" modes are supported. EnableCompression bool // Jar specifies the cookie jar. // If Jar is nil, cookies are not sent in requests and ignored // in responses. Jar http.CookieJar } // Dial creates a new client connection by calling DialContext with a background context. func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) { return d.DialContext(context.Background(), urlStr, requestHeader) } var errMalformedURL = errors.New("malformed ws or wss URL") func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) { hostPort = u.Host hostNoPort = u.Host if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") { hostNoPort = hostNoPort[:i] } else { switch u.Scheme { case "wss": hostPort += ":443" case "https": hostPort += ":443" default: hostPort += ":80" } } return hostPort, hostNoPort } // DefaultDialer is a dialer with all fields set to the default values. var DefaultDialer = &Dialer{ Proxy: http.ProxyFromEnvironment, HandshakeTimeout: 45 * time.Second, } // nilDialer is dialer to use when receiver is nil. var nilDialer = *DefaultDialer // DialContext creates a new client connection. Use requestHeader to specify the // origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie). // Use the response.Header to get the selected subprotocol // (Sec-WebSocket-Protocol) and cookies (Set-Cookie). // // The context will be used in the request and in the Dialer // // If the WebSocket handshake fails, ErrBadHandshake is returned along with a // non-nil *http.Response so that callers can handle redirects, authentication, // etcetera. The response body may not contain the entire response and does not // need to be closed by the application. func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) { if d == nil { d = &nilDialer } challengeKey, err := generateChallengeKey() if err != nil { return nil, nil, err } u, err := url.Parse(urlStr) if err != nil { return nil, nil, err } switch u.Scheme { case "ws": u.Scheme = "http" case "wss": u.Scheme = "https" default: return nil, nil, errMalformedURL } if u.User != nil { // User name and password are not allowed in websocket URIs. return nil, nil, errMalformedURL } req := &http.Request{ Method: "GET", URL: u, Proto: "HTTP/1.1", ProtoMajor: 1, ProtoMinor: 1, Header: make(http.Header), Host: u.Host, } req = req.WithContext(ctx) // Set the cookies present in the cookie jar of the dialer if d.Jar != nil { for _, cookie := range d.Jar.Cookies(u) { req.AddCookie(cookie) } } // Set the request headers using the capitalization for names and values in // RFC examples. Although the capitalization shouldn't matter, there are // servers that depend on it. The Header.Set method is not used because the // method canonicalizes the header names. req.Header["Upgrade"] = []string{"websocket"} req.Header["Connection"] = []string{"Upgrade"} req.Header["Sec-WebSocket-Key"] = []string{challengeKey} req.Header["Sec-WebSocket-Version"] = []string{"13"} if len(d.Subprotocols) > 0 { req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")} } for k, vs := range requestHeader { switch { case k == "Host": if len(vs) > 0 { req.Host = vs[0] } case k == "Upgrade" || k == "Connection" || k == "Sec-Websocket-Key" || k == "Sec-Websocket-Version" || k == "Sec-Websocket-Extensions" || (k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0): return nil, nil, errors.New("websocket: duplicate header not allowed: " + k) case k == "Sec-Websocket-Protocol": req.Header["Sec-WebSocket-Protocol"] = vs default: req.Header[k] = vs } } if d.EnableCompression { req.Header["Sec-WebSocket-Extensions"] = []string{"permessage-deflate; server_no_context_takeover; client_no_context_takeover"} } if d.HandshakeTimeout != 0 { var cancel func() ctx, cancel = context.WithTimeout(ctx, d.HandshakeTimeout) defer cancel() } // Get network dial function. var netDial func(network, add string) (net.Conn, error) if d.NetDialContext != nil { netDial = func(network, addr string) (net.Conn, error) { return d.NetDialContext(ctx, network, addr) } } else if d.NetDial != nil { netDial = d.NetDial } else { netDialer := &net.Dialer{} netDial = func(network, addr string) (net.Conn, error) { return netDialer.DialContext(ctx, network, addr) } } // If needed, wrap the dial function to set the connection deadline. if deadline, ok := ctx.Deadline(); ok { forwardDial := netDial netDial = func(network, addr string) (net.Conn, error) { c, err := forwardDial(network, addr) if err != nil { return nil, err } err = c.SetDeadline(deadline) if err != nil { c.Close() return nil, err } return c, nil } } // If needed, wrap the dial function to connect through a proxy. if d.Proxy != nil { proxyURL, err := d.Proxy(req) if err != nil { return nil, nil, err } if proxyURL != nil { dialer, err := proxy_FromURL(proxyURL, netDialerFunc(netDial)) if err != nil { return nil, nil, err } netDial = dialer.Dial } } hostPort, hostNoPort := hostPortNoPort(u) trace := httptrace.ContextClientTrace(ctx) if trace != nil && trace.GetConn != nil { trace.GetConn(hostPort) } netConn, err := netDial("tcp", hostPort) if trace != nil && trace.GotConn != nil { trace.GotConn(httptrace.GotConnInfo{ Conn: netConn, }) } if err != nil { return nil, nil, err } defer func() { if netConn != nil { netConn.Close() } }() if u.Scheme == "https" { cfg := cloneTLSConfig(d.TLSClientConfig) if cfg.ServerName == "" { cfg.ServerName = hostNoPort } tlsConn := tls.Client(netConn, cfg) netConn = tlsConn var err error if trace != nil { err = doHandshakeWithTrace(trace, tlsConn, cfg) } else { err = doHandshake(tlsConn, cfg) } if err != nil { return nil, nil, err } } conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize, d.WriteBufferPool, nil, nil) if err := req.Write(netConn); err != nil { return nil, nil, err } if trace != nil && trace.GotFirstResponseByte != nil { if peek, err := conn.br.Peek(1); err == nil && len(peek) == 1 { trace.GotFirstResponseByte() } } resp, err := http.ReadResponse(conn.br, req) if err != nil { return nil, nil, err } if d.Jar != nil { if rc := resp.Cookies(); len(rc) > 0 { d.Jar.SetCookies(u, rc) } } if resp.StatusCode != 101 || !strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") || !strings.EqualFold(resp.Header.Get("Connection"), "upgrade") || resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) { // Before closing the network connection on return from this // function, slurp up some of the response to aid application // debugging. buf := make([]byte, 1024) n, _ := io.ReadFull(resp.Body, buf) resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n])) return nil, resp, ErrBadHandshake } for _, ext := range parseExtensions(resp.Header) { if ext[""] != "permessage-deflate" { continue } _, snct := ext["server_no_context_takeover"] _, cnct := ext["client_no_context_takeover"] if !snct || !cnct { return nil, resp, errInvalidCompression } conn.newCompressionWriter = compressNoContextTakeover conn.newDecompressionReader = decompressNoContextTakeover break } resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{})) conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol") netConn.SetDeadline(time.Time{}) netConn = nil // to avoid close in defer. return conn, resp, nil } func doHandshake(tlsConn *tls.Conn, cfg *tls.Config) error { if err := tlsConn.Handshake(); err != nil { return err } if !cfg.InsecureSkipVerify { if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil { return err } } return nil }
{ "pile_set_name": "Github" }
import Argo import Foundation extension URL: Argo.Decodable { public static func decode(_ json: JSON) -> Decoded<URL> { return String.decode(json).flatMap { .fromOptional(URL(string: $0)) } } }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">{ "Info": [ { "IsSuccess": "True", "InAddress": "高雄市三民區十全一路105號1樓", "InSRS": "EPSG:4326", "InFuzzyType": "[單雙號機制]+[最近門牌號機制]", "InFuzzyBuffer": "0", "InIsOnlyFullMatch": "False", "InIsLockCounty": "True", "InIsLockTown": "False", "InIsLockVillage": "False", "InIsLockRoadSection": "False", "InIsLockLane": "False", "InIsLockAlley": "False", "InIsLockArea": "False", "InIsSameNumber_SubNumber": "True", "InCanIgnoreVillage": "True", "InCanIgnoreNeighborhood": "True", "InReturnMaxCount": "0", "OutTotal": "1", "OutMatchType": "完全比對", "OutMatchCode": "[高雄市]\tFULL:1", "OutTraceInfo": "[高雄市]\t { 完全比對 } 找到符合的門牌地址" } ], "AddressList": [ { "FULL_ADDR": "高雄市三民區德智里16鄰十全一路105號", "COUNTY": "高雄市", "TOWN": "三民區", "VILLAGE": "德智里", "NEIGHBORHOOD": "16鄰", "ROAD": "十全一路", "SECTION": "", "LANE": "", "ALLEY": "", "SUB_ALLEY": "", "TONG": "", "NUMBER": "105號", "X": 120.310519, "Y": 22.644774 } ] }</string>
{ "pile_set_name": "Github" }
Our goal is to encourage frictionless contributions to the project. In order to achieve that, we use Unprotocols [C4 process](https://rfc.unprotocols.org/spec:1/C4). Please read it, it will answer a lot of questions. Our goal is to merge pull requests as quickly as possible and make new stable releases regularly. It is highly recommended to watch [Pieter Hintjens' talk on building open source communities](https://www.youtube.com/watch?v=uzxcILudFWM) as well as read his [book on the same matter](https://www.gitbook.com/book/hintjens/social-architecture/details). The code style is defined as per [IntelliJ IDEA 15 XML code style file](es4j-intellij-code-style.xml) # Submitting an issue According to [development process](https://rfc.unprotocols.org/spec:1/C4#24-development-process), the issue should describe a documented and provable. What this means is that an issue should trive to have a clear, understandable problem statement. Just like a patch, it SHOULD be titled "Problem: ..." and have a detailed description describing evidence behind it, be it a bug or a feature request, or a longer term "exploratory" issue. # Preparing a patch According to [patch requirements](https://rfc.unprotocols.org/spec:1/C4#23-patch-requirements), the patch should be a minimal and accurate answer to exactly one identified and agreed problem. A patch commit message must consist of a single short (less than 50 characters) line stating the problem ("Problem: ...") being solved, followed by a blank line and then the proposed solution ("Solution: ..."). ``` Problem: short problem statement Optional longer explanation of the problem that this patch addresses, giving necessary details for the reader to be able to understand it better. Solution: explanation of the solution to the problem. Could be longer than one line. ```
{ "pile_set_name": "Github" }
// // This file is auto-generated. Please don't modify it! // package org.opencv.features2d; import java.lang.String; import org.opencv.features2d.AKAZE; import org.opencv.features2d.Feature2D; // C++: class AKAZE //javadoc: AKAZE public class AKAZE extends Feature2D { protected AKAZE(long addr) { super(addr); } // internal usage only public static AKAZE __fromPtr__(long addr) { return new AKAZE(addr); } public static final int DESCRIPTOR_KAZE_UPRIGHT = 2, DESCRIPTOR_KAZE = 3, DESCRIPTOR_MLDB_UPRIGHT = 4, DESCRIPTOR_MLDB = 5; // // C++: static Ptr_AKAZE create(int descriptor_type = AKAZE::DESCRIPTOR_MLDB, int descriptor_size = 0, int descriptor_channels = 3, float threshold = 0.001f, int nOctaves = 4, int nOctaveLayers = 4, int diffusivity = KAZE::DIFF_PM_G2) // //javadoc: AKAZE::create(descriptor_type, descriptor_size, descriptor_channels, threshold, nOctaves, nOctaveLayers, diffusivity) public static AKAZE create(int descriptor_type, int descriptor_size, int descriptor_channels, float threshold, int nOctaves, int nOctaveLayers, int diffusivity) { AKAZE retVal = AKAZE.__fromPtr__(create_0(descriptor_type, descriptor_size, descriptor_channels, threshold, nOctaves, nOctaveLayers, diffusivity)); return retVal; } //javadoc: AKAZE::create() public static AKAZE create() { AKAZE retVal = AKAZE.__fromPtr__(create_1()); return retVal; } // // C++: String getDefaultName() // //javadoc: AKAZE::getDefaultName() public String getDefaultName() { String retVal = getDefaultName_0(nativeObj); return retVal; } // // C++: double getThreshold() // //javadoc: AKAZE::getThreshold() public double getThreshold() { double retVal = getThreshold_0(nativeObj); return retVal; } // // C++: int getDescriptorChannels() // //javadoc: AKAZE::getDescriptorChannels() public int getDescriptorChannels() { int retVal = getDescriptorChannels_0(nativeObj); return retVal; } // // C++: int getDescriptorSize() // //javadoc: AKAZE::getDescriptorSize() public int getDescriptorSize() { int retVal = getDescriptorSize_0(nativeObj); return retVal; } // // C++: int getDescriptorType() // //javadoc: AKAZE::getDescriptorType() public int getDescriptorType() { int retVal = getDescriptorType_0(nativeObj); return retVal; } // // C++: int getDiffusivity() // //javadoc: AKAZE::getDiffusivity() public int getDiffusivity() { int retVal = getDiffusivity_0(nativeObj); return retVal; } // // C++: int getNOctaveLayers() // //javadoc: AKAZE::getNOctaveLayers() public int getNOctaveLayers() { int retVal = getNOctaveLayers_0(nativeObj); return retVal; } // // C++: int getNOctaves() // //javadoc: AKAZE::getNOctaves() public int getNOctaves() { int retVal = getNOctaves_0(nativeObj); return retVal; } // // C++: void setDescriptorChannels(int dch) // //javadoc: AKAZE::setDescriptorChannels(dch) public void setDescriptorChannels(int dch) { setDescriptorChannels_0(nativeObj, dch); return; } // // C++: void setDescriptorSize(int dsize) // //javadoc: AKAZE::setDescriptorSize(dsize) public void setDescriptorSize(int dsize) { setDescriptorSize_0(nativeObj, dsize); return; } // // C++: void setDescriptorType(int dtype) // //javadoc: AKAZE::setDescriptorType(dtype) public void setDescriptorType(int dtype) { setDescriptorType_0(nativeObj, dtype); return; } // // C++: void setDiffusivity(int diff) // //javadoc: AKAZE::setDiffusivity(diff) public void setDiffusivity(int diff) { setDiffusivity_0(nativeObj, diff); return; } // // C++: void setNOctaveLayers(int octaveLayers) // //javadoc: AKAZE::setNOctaveLayers(octaveLayers) public void setNOctaveLayers(int octaveLayers) { setNOctaveLayers_0(nativeObj, octaveLayers); return; } // // C++: void setNOctaves(int octaves) // //javadoc: AKAZE::setNOctaves(octaves) public void setNOctaves(int octaves) { setNOctaves_0(nativeObj, octaves); return; } // // C++: void setThreshold(double threshold) // //javadoc: AKAZE::setThreshold(threshold) public void setThreshold(double threshold) { setThreshold_0(nativeObj, threshold); return; } @Override protected void finalize() throws Throwable { delete(nativeObj); } // C++: static Ptr_AKAZE create(int descriptor_type = AKAZE::DESCRIPTOR_MLDB, int descriptor_size = 0, int descriptor_channels = 3, float threshold = 0.001f, int nOctaves = 4, int nOctaveLayers = 4, int diffusivity = KAZE::DIFF_PM_G2) private static native long create_0(int descriptor_type, int descriptor_size, int descriptor_channels, float threshold, int nOctaves, int nOctaveLayers, int diffusivity); private static native long create_1(); // C++: String getDefaultName() private static native String getDefaultName_0(long nativeObj); // C++: double getThreshold() private static native double getThreshold_0(long nativeObj); // C++: int getDescriptorChannels() private static native int getDescriptorChannels_0(long nativeObj); // C++: int getDescriptorSize() private static native int getDescriptorSize_0(long nativeObj); // C++: int getDescriptorType() private static native int getDescriptorType_0(long nativeObj); // C++: int getDiffusivity() private static native int getDiffusivity_0(long nativeObj); // C++: int getNOctaveLayers() private static native int getNOctaveLayers_0(long nativeObj); // C++: int getNOctaves() private static native int getNOctaves_0(long nativeObj); // C++: void setDescriptorChannels(int dch) private static native void setDescriptorChannels_0(long nativeObj, int dch); // C++: void setDescriptorSize(int dsize) private static native void setDescriptorSize_0(long nativeObj, int dsize); // C++: void setDescriptorType(int dtype) private static native void setDescriptorType_0(long nativeObj, int dtype); // C++: void setDiffusivity(int diff) private static native void setDiffusivity_0(long nativeObj, int diff); // C++: void setNOctaveLayers(int octaveLayers) private static native void setNOctaveLayers_0(long nativeObj, int octaveLayers); // C++: void setNOctaves(int octaves) private static native void setNOctaves_0(long nativeObj, int octaves); // C++: void setThreshold(double threshold) private static native void setThreshold_0(long nativeObj, double threshold); // native support for java finalize() private static native void delete(long nativeObj); }
{ "pile_set_name": "Github" }
Mitmachen • Re: Raspberry Pi ============================ Date: 2014-01-02 23:28:26 Also ich muss wohl dieser Tage Asche (abgefackelter Feuerwerkskörper) auf mein Haupt streuen:\ \ Seit RaspberryPi nicht mehr per Wlan am Netz hängt, läuft es überraschend gut. RasPi2, der die Usb-Festplatte für YaCy nutzt, ist die Tage mit Crawln über 500.000 Urls gekommen. Der RasPi1, alles auf SD-Karte, ist bei über 200.000 Urls. Das hat im Vergleich aber nichts zu sagen, da die Crawling-Aufgaben unterschiedlich waren und vom Inhalt abhängig sind.\ \ Inzwischen hab ich die Crawls alle abgeschaltet und es läuft nur der DHT-Transfer. Dessen Rate ist aber nicht zu verachten. Darüber müssen die URLs ja nur einsortiert werden. Das scheint wenig Prozessorlast zu benötigen.\ \ Da ich zwischenzeitlich immer versucht habe, die Versionen auf den aktuellsten Entwicklungsversionen zu halten, können die Fortschritte auch mit den Änderungen dort zusammenhängen. Weiß ich nicht. Aber irgendwann früher war mir auch schon mal aufgefallen, dass Wlan beim RasPi sehr an der Performance zehrt.\ \ Mein Hetzner VServer ist für die Tests ein interessantes Vergleichsobjekt, da mir dort genau so wenig Ram zurVerfügung steht, wie beim RasPi. Die Festplattensschnittstelle und der eine Prozessorkern sind leistungsfähiger, sodass die Crawl- und URL-Zuwachsraten steiler sind und vielleicht auch bei etwas Swappen die Performance sicher besser ist. Aber die Index-Grenzen sollten vergleichbar sein. Folgender Wert wird also auch für die beiden RasPis interessant: Ab um die 3Mio URLs wurde mir das Hetznersystem instabil. Startet man den Crawl mit der Hand mehrfach wieder, ist dann irgendwann der Speicher zu klein und es crasht oder die Webschnittstelle reagiert nicht mehr. Durch den Proxy-Fehler der letzten Dev-Versionen ist mir der Index recht schnell angestiegen, ohne dass ich das anhalten konnte. Das Sicherheitsloch soll inzwischen geschlossen wurden sein.\ \ Alles in allem müssten die RasPi also auch bis in die 2Mio URLs kommen. Mal sehen. Ich bin gespannt.\ \ Ein Problem am Rande: Die Konfiguration des der Java-Engine zu Verfügung stehenden Ram ist ne schwierige Sache. Für xmx wird nur der Heap in seinem Maximum festgelegt. Java nutzt aber auch Ram, der nicht über den Heap verwaltet wird. Und dessen Wert kommt auf den Gesamtspeicherbedarf dazu. Für YaCy sind aus meinen Beobachtungen heraus wenigstens 150MByte zum Heap dazuzurechnen. Mir ist unklar, ob das unabhängig von der Größe des Index bzw. DHT ist.\ \ Soweit für heute bzgl. RasPi.\ \ Den CubieTruck hab ich bei gut 1Mio URLs angehalten. Ab jetzt soll er sich über DHT-Transfer mit Daten füllen. Wie die beiden RasPis auch. Die Vorgabe für den Heap habe ich trotz der zur Verfügung stehenden 2GByte Ram vorerst auf 600MByte festgelegt. Ich will sehen, wie viel Ram nach längerer Laufzeit tatsächlich verwendet wird und wie er auf die Grenze reagiert. Danach schraub ich das dann langsam hoch, bis die 2 Gbyte umfassend genutzt werden.\ \ Viele Grüße\ Frank Statistik: Verfasst von [fherb](http://forum.yacy-websuche.de/memberlist.php?mode=viewprofile&u=9031) --- Do Jan 02, 2014 11:28 pm ------------------------------------------------------------------------
{ "pile_set_name": "Github" }
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="85.333336dp" android:height="85.333336dp" android:viewportWidth="85.333336" android:viewportHeight="85.333336"> <path android:pathData="M85.3333,42.6667C85.3333,66.2307 66.2307,85.3333 42.6667,85.3333 19.1027,85.3333 0,66.2307 0,42.6667 0,19.1027 19.1027,0 42.6667,0 66.2307,0 85.3333,19.1027 85.3333,42.6667" android:fillColor="#495672" android:strokeColor="#00000000" android:fillType="nonZero" android:fillAlpha="1"/> <path android:pathData="m25.4531,62.7083 l0.7516,0.7511c0.8989,0.8989 2.3563,0.8989 3.2552,-0L51.714,44.964c-2.7572,-0.6009 -5.2921,-1.9667 -7.3348,-4.0099 -2.0912,-2.0905 -3.4167,-4.6557 -4.0021,-7.3511L21.5979,55.5973c-0.8989,0.8991 -0.8989,2.3563 0,3.2553l1.0272,1.0276 -2.7057,2.7057c-0.7813,0.7807 -0.7813,2.0473 0,2.828 0.3905,0.3907 0.902,0.586 1.414,0.586 0.512,-0 1.0235,-0.1953 1.414,-0.586l2.7057,-2.7057" android:fillColor="#ffffff" android:strokeColor="#00000000" android:fillType="nonZero" android:fillAlpha="1"/> <path android:pathData="m47.4047,20.6656c-0.0011,-0.0031 -0.002,-0.0063 -0.0025,-0.0093 -0.0828,0.0869 -0.1537,0.1807 -0.2333,0.2692 -0.1677,0.1855 -0.3349,0.3719 -0.4896,0.5647 -0.0959,0.1203 -0.1833,0.2443 -0.274,0.3672 -0.1479,0.1995 -0.2943,0.3995 -0.4281,0.6057 -0.0807,0.1244 -0.1541,0.252 -0.2297,0.3785 -0.1301,0.2172 -0.2583,0.4349 -0.3733,0.6579 -0.062,0.1199 -0.1172,0.2417 -0.1751,0.3636 -0.114,0.2396 -0.2255,0.4807 -0.3235,0.726 -0.0437,0.1099 -0.0807,0.2213 -0.1213,0.3317 -0.0957,0.2636 -0.188,0.5276 -0.2651,0.7953 -0.0297,0.1011 -0.0521,0.2027 -0.0787,0.3041 -0.0729,0.2803 -0.1421,0.5615 -0.1948,0.8459 -0.0187,0.1 -0.0301,0.2016 -0.0463,0.3021 -0.0459,0.288 -0.0891,0.576 -0.1147,0.8661 -0.0093,0.1041 -0.0093,0.2088 -0.0161,0.3135 -0.0183,0.2928 -0.0355,0.5849 -0.0328,0.8781 0.0005,0.0355 0.0047,0.0709 0.0052,0.1063 0.026,1.4745 0.3172,2.9432 0.874,4.3317 0.0145,0.0371 0.0255,0.0756 0.0405,0.112 0.1235,0.2989 0.2663,0.5917 0.4141,0.8823 0.0333,0.0647 0.0604,0.1313 0.0943,0.1953 0.1563,0.2937 0.3307,0.5792 0.5125,0.8615 0.0339,0.0527 0.0624,0.1073 0.0968,0.1595 0.4417,0.6624 0.9537,1.2921 1.5385,1.8771 0.2985,0.2984 0.6084,0.5781 0.9281,0.8391 0.0032,0.002 0.0063,0.0041 0.0089,0.0067 0.3088,0.2511 0.6276,0.4844 0.9536,0.7011 0.0792,0.0521 0.1615,0.0959 0.2412,0.1464 0.2577,0.1625 0.5176,0.3219 0.7843,0.4635 0.1037,0.0553 0.2109,0.1005 0.3161,0.1521 0.2532,0.1251 0.5063,0.2489 0.7657,0.3552 0.1099,0.0453 0.2229,0.0808 0.3343,0.1229 0.2615,0.0979 0.5229,0.1959 0.7891,0.2755 0.1177,0.0355 0.2381,0.0605 0.3568,0.0923 0.2641,0.0703 0.5281,0.1411 0.7953,0.1943 0.1511,0.0297 0.3036,0.0453 0.4552,0.0692 0.2385,0.0376 0.4771,0.0797 0.7177,0.1037 0.338,0.0328 0.6781,0.0463 1.0177,0.0511 0.0593,0.0009 0.1187,0.0083 0.1781,0.0083 0.0015,-0 0.0031,0.0005 0.0047,0.0005 0.3849,-0 0.7697,-0.0224 1.1531,-0.0588 0.1251,-0.0115 0.2489,-0.0324 0.374,-0.048 0.2531,-0.0317 0.5052,-0.0677 0.7563,-0.1156 0.1489,-0.0281 0.2968,-0.0631 0.4453,-0.0969 0.2224,-0.0509 0.4432,-0.1067 0.6635,-0.1703 0.1495,-0.0432 0.2989,-0.0896 0.4475,-0.1391 0.2156,-0.0708 0.4287,-0.1505 0.6405,-0.2344 0.1396,-0.0547 0.2787,-0.1093 0.4163,-0.1692 0.2208,-0.0969 0.4369,-0.2041 0.652,-0.3141 0.1193,-0.0615 0.2401,-0.1187 0.3573,-0.1839 0.2349,-0.1296 0.4629,-0.2728 0.6907,-0.4192 0.09,-0.0584 0.1828,-0.1109 0.2713,-0.1719 0.2667,-0.1813 0.5255,-0.3781 0.7801,-0.5828 0.0417,-0.0339 0.0855,-0.0631 0.1271,-0.0975 0.0183,-0.0151 0.0385,-0.0276 0.0568,-0.0432 -0.002,-0.0005 -0.0041,-0.0016 -0.0068,-0.0021 -3.7509,-1.2119 -7.1943,-3.2875 -10.0619,-6.1552 -3.3371,-3.3375 -5.5141,-7.39 -6.5871,-11.6656" android:fillColor="#ffffff" android:strokeColor="#00000000" android:fillType="nonZero" android:fillAlpha="1"/> <path android:pathData="m67.3719,34.0901c0.0547,-0.1229 0.1099,-0.2453 0.1604,-0.3699 0.1047,-0.2557 0.198,-0.5145 0.2844,-0.7755 0.0287,-0.0865 0.0609,-0.1719 0.0875,-0.2588 0.2333,-0.7589 0.388,-1.5349 0.4699,-2.3183 0.0005,-0.0041 0.0011,-0.0079 0.0011,-0.012 0.3671,-3.5317 -0.7912,-7.1907 -3.4991,-9.8984 -2.388,-2.3876 -5.5176,-3.5813 -8.6473,-3.5813 -0.7969,-0 -1.5912,0.0964 -2.3756,0.2527 -0.0421,0.0088 -0.0848,0.014 -0.1276,0.0229 -0.3036,0.064 -0.6031,0.1448 -0.9025,0.2323 -0.1344,0.0391 -0.2693,0.0771 -0.4027,0.1213 -0.2557,0.0844 -0.5083,0.1765 -0.7588,0.2776 -0.1672,0.0677 -0.3317,0.1412 -0.4964,0.2161 -0.1552,0.0708 -0.3151,0.126 -0.4677,0.2037 0.0011,0.0067 0.0032,0.0129 0.0043,0.0197 0.7369,4.1932 2.7093,8.2115 5.9484,11.4505 2.8833,2.8833 6.3875,4.7505 10.0792,5.6511 0.0041,0.0009 0.0083,0.0025 0.0125,0.0036 0.0411,-0.0697 0.0744,-0.1427 0.1145,-0.2131 0.074,-0.1307 0.1437,-0.2629 0.2125,-0.3957 0.1077,-0.2073 0.2083,-0.4167 0.3031,-0.6287" android:fillColor="#ffffff" android:strokeColor="#00000000" android:fillType="nonZero" android:fillAlpha="1"/> </vector>
{ "pile_set_name": "Github" }
{ "accountLinkingWhitelistedDomains": null, "asin": "B01MDLG0YL", "averageRating": 2.7, "canDisable": true, "capabilities": null, "category": null, "description": "This skill relies on you having an account on www.starfishmint.com/mp3. This account links up with alexa app as part of enabling this skil. You need to further link your account to microsoft one drive on www.starfishmint.com/mp3. As part of linking one drive Apps/Starfish folder in one drive is created. Now you can upload your mp3 files to this folder. Please make sure you don't put any other files or create any sub folders in this folder.\n\nNow sit back and ask alexa to start playing your music by saying alexa ask starfish song to play", "enablement": null, "exampleInteractions": [ "alexa open starfish audio", "alexa ask starfish audio to play", "alexa ask starfish audio to begin music" ], "firstReleaseDate": 1477557989.013, "homepageLinkText": null, "homepageLinkUrl": null, "id": "amzn1.ask.skill.0e9a7fa7-7703-427a-88d9-44f80cd5a5e9", "imageAltText": "Starfish Audio icon", "imageUrl": "https://github.com/dale3h/alexa-skills-list/raw/master/skills/B01MDLG0YL/skill_icon", "inAppPurchasingSupported": false, "launchPhrase": "starfish audio", "name": "Starfish Audio", "numberOfReviews": 5, "pamsPartnerId": "5dKBnDMvolKwOITaLyVfY3u6t", "permissions": null, "privacyPolicyUrl": "http://www.starfishmint.com/policy/privacy-starfish-mp3.html", "shortDescription": "Play your own music stored on microsoft one drive. You can store .mp3 files in one drive and play on alexa enabled devices", "skillTypes": null, "stage": "live", "termsOfUseUrl": "http://www.starfishmint.com/policy/terms-starfish-mp3.html", "vendorId": "M2XGOZ7WO0MD3W", "vendorName": "Rai Integration Ltd" }
{ "pile_set_name": "Github" }
<!DOCTYPE html> <html ng-app="demoapp"> <head> <script src="../bower_components/openlayers/ol.js"></script> <script src="../bower_components/angular/angular.min.js"></script> <script src="../bower_components/angular-sanitize/angular-sanitize.min.js"></script> <script src="../dist/angular-openlayers-directive.js"></script> <link rel="stylesheet" href="../bower_components/openlayers/ol.css" /> <script> var app = angular.module("demoapp", ["openlayers-directive"]); app.controller("DemoController", [ '$scope', function($scope) { angular.extend($scope, { london: { lat: 51.505, lon: -0.09, zoom: 8 }, defaults: { layers: { main: { source: { type: 'OSM', url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' } } }, interactions: { mouseWheelZoom: true }, controls: { zoom: false, rotate: false, attribution: false }, loadTilesWhileAnimating: true, loadTilesWhileInteracting: true } }); } ]); </script> </head> <body ng-controller="DemoController"> <openlayers ol-center="london" ol-defaults="defaults" width="100%" height="400px"></openlayers> <h1>Custom parameters example</h1> <p>These are the custom properties applied in this map:</p> <pre ng-bind="defaults | json"></pre> </body> </html>
{ "pile_set_name": "Github" }
### MacDeploy ### For Snow Leopard (which uses [Python 2.6](http://www.python.org/download/releases/2.6/)), you will need the param_parser package: sudo easy_install argparse This script should not be run manually, instead, after building as usual: make deploy During the process, the disk image window will pop up briefly where the fancy settings are applied. This is normal, please do not interfere. When finished, it will produce `Bitcoin-Unlimited.dmg`.
{ "pile_set_name": "Github" }
diff -uri linux-2.6.32.14.orig/block/Kconfig linux-2.6.32.14.new.00/block/Kconfig --- linux-2.6.32.14.orig/block/Kconfig 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/block/Kconfig 2010-06-11 17:05:53.000000000 +0200 @@ -77,6 +77,8 @@ T10/SCSI Data Integrity Field or the T13/ATA External Path Protection. If in doubt, say N. +source block/mars/kernel/Kconfig + config BLK_CGROUP bool depends on CGROUPS diff -uri linux-2.6.32.14.orig/block/Makefile linux-2.6.32.14.new.00/block/Makefile --- linux-2.6.32.14.orig/block/Makefile 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/block/Makefile 2010-06-11 17:10:46.000000000 +0200 @@ -15,3 +15,5 @@ obj-$(CONFIG_BLOCK_COMPAT) += compat_ioctl.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += blk-integrity.o + +obj-$(CONFIG_MARS) += mars/kernel/ \ No newline at end of file --- linux-2.6.32.14.orig/fs/aio.c 2010-05-31 14:09:40.000000000 +0200 +++ linux-2.6.32.14.new.00/fs/aio.c 2011-01-26 16:02:44.000000000 +0100 @@ -1267,6 +1268,7 @@ out: return ret; } +EXPORT_SYMBOL(sys_io_setup); /* sys_io_destroy: * Destroy the aio_context specified. May cancel any outstanding @@ -1284,6 +1286,7 @@ pr_debug("EINVAL: io_destroy: invalid context id\n"); return -EINVAL; } +EXPORT_SYMBOL(sys_io_destroy); static void aio_advance_iovec(struct kiocb *iocb, ssize_t ret) { @@ -1674,6 +1677,7 @@ put_ioctx(ctx); return i ? i : ret; } +EXPORT_SYMBOL(sys_io_submit); /* lookup_kiocb * Finds a given iocb for cancellation. @@ -1753,6 +1757,7 @@ return ret; } +EXPORT_SYMBOL(sys_io_cancel); /* io_getevents: * Attempts to read at least min_nr events and up to nr events from @@ -1784,3 +1789,4 @@ asmlinkage_protect(5, ret, ctx_id, min_nr, nr, events, timeout); return ret; } +EXPORT_SYMBOL(sys_io_getevents); diff -uri linux-2.6.32.14.orig/fs/open.c linux-2.6.32.14.new.00/fs/open.c --- linux-2.6.32.14.orig/fs/open.c 2010-05-31 14:09:40.000000000 +0200 +++ linux-2.6.32.14.new.00/fs/open.c 2011-02-28 12:36:20.000000000 +0100 @@ -719,6 +719,7 @@ { return do_fchmodat(AT_FDCWD, filename, mode, AT_SYMLINK_NOFOLLOW); } +EXPORT_SYMBOL(sys_chmod); static int chown_common(struct dentry * dentry, uid_t user, gid_t group) { @@ -810,6 +811,7 @@ out: return error; } +EXPORT_SYMBOL(sys_lchown); SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) { diff -uri linux-2.6.32.14.orig/fs/utimes.c linux-2.6.32.14.new.00/fs/utimes.c --- linux-2.6.32.14.orig/fs/utimes.c 2010-05-31 14:09:40.000000000 +0200 +++ linux-2.6.32.14.new.00/fs/utimes.c 2011-02-25 12:40:00.000000000 +0100 @@ -1,3 +1,4 @@ +#include <linux/module.h> #include <linux/compiler.h> #include <linux/file.h> #include <linux/fs.h> @@ -176,6 +177,7 @@ out: return error; } +EXPORT_SYMBOL(do_utimes); SYSCALL_DEFINE4(utimensat, int, dfd, char __user *, filename, struct timespec __user *, utimes, int, flags) diff -uri linux-2.6.32.14.orig/include/linux/major.h linux-2.6.32.14.new.00/include/linux/major.h --- linux-2.6.32.14.orig/include/linux/major.h 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/include/linux/major.h 2010-06-13 10:08:53.000000000 +0200 @@ -146,6 +146,7 @@ #define UNIX98_PTY_SLAVE_MAJOR (UNIX98_PTY_MASTER_MAJOR+UNIX98_PTY_MAJOR_COUNT) #define DRBD_MAJOR 147 +#define MARS_MAJOR 148 #define RTF_MAJOR 150 #define RAW_MAJOR 162 diff -uri linux-2.6.32.14.orig/include/linux/sched.h linux-2.6.32.14.new.00/include/linux/sched.h --- linux-2.6.32.14.orig/include/linux/sched.h 2010-05-31 14:09:46.000000000 +0200 +++ linux-2.6.32.14.new.00/include/linux/sched.h 2010-07-29 15:37:05.000000000 +0200 @@ -1429,6 +1429,9 @@ /* mutex deadlock detection */ struct mutex_waiter *blocked_on; #endif +#ifdef CONFIG_DEBUG_SPINLOCK + atomic_t lock_count; +#endif #ifdef CONFIG_TRACE_IRQFLAGS unsigned int irq_events; int hardirqs_enabled; diff -uri linux-2.6.32.14.orig/lib/debug_locks.c linux-2.6.32.14.new.00/lib/debug_locks.c --- linux-2.6.32.14.orig/lib/debug_locks.c 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/lib/debug_locks.c 2010-12-10 17:08:44.000000000 +0100 @@ -45,3 +45,4 @@ } return 0; } +EXPORT_SYMBOL(debug_locks_off); diff -uri linux-2.6.32.14.orig/mm/init-mm.c linux-2.6.32.14.new.00/mm/init-mm.c --- linux-2.6.32.14.orig/mm/init-mm.c 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/mm/init-mm.c 2011-01-26 16:53:17.000000000 +0100 @@ -4,6 +4,8 @@ #include <linux/spinlock.h> #include <linux/list.h> #include <linux/cpumask.h> +#include <linux/module.h> +#include <linux/sched.h> #include <asm/atomic.h> #include <asm/pgtable.h> @@ -17,4 +19,10 @@ .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(init_mm.mmlist), .cpu_vm_mask = CPU_MASK_ALL, +#ifdef CONFIG_AIO + .ioctx_lock = __SPIN_LOCK_UNLOCKED(init_mm.ioctx_lock), + .ioctx_list = HLIST_HEAD_INIT, + .get_unmapped_area = arch_get_unmapped_area, +#endif }; +EXPORT_SYMBOL(init_mm); diff -uri linux-2.6.32.14.orig/mm/mmu_context.c linux-2.6.32.14.new.00/mm/mmu_context.c --- linux-2.6.32.14.orig/mm/mmu_context.c 2010-05-26 23:29:57.000000000 +0200 +++ linux-2.6.32.14.new.00/mm/mmu_context.c 2010-11-16 17:12:01.000000000 +0100 @@ -6,6 +6,7 @@ #include <linux/mm.h> #include <linux/mmu_context.h> #include <linux/sched.h> +#include <linux/module.h> #include <asm/mmu_context.h> @@ -37,6 +38,7 @@ if (active_mm != mm) mmdrop(active_mm); } +EXPORT_SYMBOL(use_mm); /* * unuse_mm @@ -56,3 +58,4 @@ enter_lazy_tlb(mm, tsk); task_unlock(tsk); } +EXPORT_SYMBOL(unuse_mm); diff -uri linux-2.6.32.14.orig/mm/page_alloc.c linux-2.6.32.14.new.00/mm/page_alloc.c --- linux-2.6.32.14.orig/mm/page_alloc.c 2010-05-31 14:09:46.000000000 +0200 +++ linux-2.6.32.14.new.00/mm/page_alloc.c 2011-03-07 14:47:16.000000000 +0100 @@ -122,6 +122,7 @@ }; int min_free_kbytes = 1024; +EXPORT_SYMBOL(min_free_kbytes); static unsigned long __meminitdata nr_kernel_pages; static unsigned long __meminitdata nr_all_pages; @@ -4769,6 +4770,7 @@ /* update totalreserve_pages */ calculate_totalreserve_pages(); } +EXPORT_SYMBOL(setup_per_zone_wmarks); /* * The inactive anon list should be small enough that the VM never has to
{ "pile_set_name": "Github" }
package de.metas.jax.rs.oneway; import java.util.HashMap; import java.util.Map; import javax.ws.rs.core.Response; import de.metas.jax.rs.TestPojo; /* * #%L * de.metas.jax.rs * %% * Copyright (C) 2016 metas GmbH * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-2.0.html>. * #L% */ public class TestService implements ITestService { private static final Map<Integer, TestPojo> map = new HashMap<Integer, TestPojo>(); @Override public Response addTestPojo(final TestPojo testPojo) { addTestPojoOneWayReturnsVoid(testPojo); return Response.ok().build(); } @Override public Response addTestPojoOneWay(final TestPojo testPojo) { addTestPojoOneWayReturnsVoid(testPojo); return Response.ok().build(); } @Override public void addTestPojoOneWayReturnsVoid(final TestPojo testPojo) { addTestPojoReturnsVoid(testPojo); } @Override public void addTestPojoReturnsVoid(TestPojo testPojo) { testPojo.setProcessedByService(ITestService.class.getSimpleName()); map.put(testPojo.getId(), testPojo); } }
{ "pile_set_name": "Github" }