text
stringlengths
2
99.9k
meta
dict
# THIS FILE CONTAINS LOCALIZATION KEYS : date and number formats, number precisions, # number separators and all non-textual values depending on the language. # These values must not reach the translator, so they are separated in this file. # # More info here: https://translation.io/blog/gettext-is-better-than-rails-i18n#localization # # You can edit and/or add new localization keys here, they won't be touched by Translation.io. # # If you want to add a new localization key prefix, use the option described here: # https://github.com/translation/rails#custom-localization-key-prefixes # --- tr: support: array: last_word_connector: " ve " two_words_connector: " ve " words_connector: ", " date: formats: default: "%d.%m.%Y" long: "%e %B %Y, %A" short: "%e %b" order: - :day - :month - :year number: currency: format: delimiter: "." format: "%n %u" precision: 2 separator: "," significant: false strip_insignificant_zeros: false unit: "₺" format: delimiter: "." precision: 2 separator: "," significant: false strip_insignificant_zeros: false human: decimal_units: format: "%n %u" units: unit: '' format: delimiter: "." precision: 3 significant: true strip_insignificant_zeros: true storage_units: format: "%n %u" percentage: format: delimiter: '' format: "%%n" precision: format: delimiter: "." time: formats: default: "%a %d.%b.%y %H:%M" long: "%e %B %Y, %A, %H:%M" short: "%e %B, %H:%M"
{ "pile_set_name": "Github" }
//===-- sanitizer_syscall_linux_x86_64.inc ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Implementations of internal_syscall and internal_iserror for Linux/x86_64. // //===----------------------------------------------------------------------===// #define SYSCALL(name) __NR_ ## name static uptr internal_syscall(u64 nr) { u64 retval; asm volatile("syscall" : "=a"(retval) : "a"(nr) : "rcx", "r11", "memory", "cc"); return retval; } template <typename T1> static uptr internal_syscall(u64 nr, T1 arg1) { u64 retval; asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1) : "rcx", "r11", "memory", "cc"); return retval; } template <typename T1, typename T2> static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2) { u64 retval; asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), "S"((u64)arg2) : "rcx", "r11", "memory", "cc"); return retval; } template <typename T1, typename T2, typename T3> static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3) { u64 retval; asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), "S"((u64)arg2), "d"((u64)arg3) : "rcx", "r11", "memory", "cc"); return retval; } template <typename T1, typename T2, typename T3, typename T4> static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4) { u64 retval; asm volatile("mov %5, %%r10;" "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4) : "rcx", "r11", "r10", "memory", "cc"); return retval; } template <typename T1, typename T2, typename T3, typename T4, typename T5> static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) { u64 retval; asm volatile("mov %5, %%r10;" "mov %6, %%r8;" "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5) : "rcx", "r11", "r10", "r8", "memory", "cc"); return retval; } template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) { u64 retval; asm volatile("mov %5, %%r10;" "mov %6, %%r8;" "mov %7, %%r9;" "syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1), "S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5), "r"((u64)arg6) : "rcx", "r11", "r10", "r8", "r9", "memory", "cc"); return retval; } bool internal_iserror(uptr retval, int *rverrno) { if (retval >= (uptr)-4095) { if (rverrno) *rverrno = -retval; return true; } return false; }
{ "pile_set_name": "Github" }
# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. from datetime import date, datetime, time import doctest import new import unittest from pytz import timezone from babel import dates from babel.util import FixedOffsetTimezone class DateTimeFormatTestCase(unittest.TestCase): def test_quarter_format(self): d = date(2006, 6, 8) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('2', fmt['Q']) self.assertEqual('2nd quarter', fmt['QQQQ']) d = date(2006, 12, 31) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('Q4', fmt['QQQ']) def test_month_context(self): d = date(2006, 1, 8) fmt = dates.DateTimeFormat(d, locale='cs_CZ') self.assertEqual('1', fmt['MMM']) fmt = dates.DateTimeFormat(d, locale='cs_CZ') self.assertEqual('1.', fmt['LLL']) def test_abbreviated_month_alias(self): d = date(2006, 3, 8) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual(u'Mär', fmt['LLL']) def test_week_of_year_first(self): d = date(2006, 1, 8) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('1', fmt['w']) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('02', fmt['ww']) def test_week_of_year_first_with_year(self): d = date(2006, 1, 1) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('52', fmt['w']) self.assertEqual('2005', fmt['YYYY']) def test_week_of_year_last(self): d = date(2005, 12, 26) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('52', fmt['w']) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('53', fmt['ww']) def test_week_of_month_first(self): d = date(2006, 1, 8) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('1', fmt['W']) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('2', fmt['W']) def test_week_of_month_last(self): d = date(2006, 1, 29) fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('4', fmt['W']) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('5', fmt['W']) def test_day_of_year(self): d = date(2007, 4, 1) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('91', fmt['D']) def test_day_of_year_first(self): d = date(2007, 1, 1) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('001', fmt['DDD']) def test_day_of_year_last(self): d = date(2007, 12, 31) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('365', fmt['DDD']) def test_day_of_week_in_month(self): d = date(2007, 4, 15) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('3', fmt['F']) def test_day_of_week_in_month_first(self): d = date(2007, 4, 1) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('1', fmt['F']) def test_day_of_week_in_month_last(self): d = date(2007, 4, 29) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('5', fmt['F']) def test_local_day_of_week(self): d = date(2007, 4, 1) # a sunday fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('7', fmt['e']) # monday is first day of week fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('01', fmt['ee']) # sunday is first day of week fmt = dates.DateTimeFormat(d, locale='dv_MV') self.assertEqual('03', fmt['ee']) # friday is first day of week d = date(2007, 4, 2) # a monday fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('1', fmt['e']) # monday is first day of week fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('02', fmt['ee']) # sunday is first day of week fmt = dates.DateTimeFormat(d, locale='dv_MV') self.assertEqual('04', fmt['ee']) # friday is first day of week def test_local_day_of_week_standalone(self): d = date(2007, 4, 1) # a sunday fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('7', fmt['c']) # monday is first day of week fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('1', fmt['c']) # sunday is first day of week fmt = dates.DateTimeFormat(d, locale='dv_MV') self.assertEqual('3', fmt['c']) # friday is first day of week d = date(2007, 4, 2) # a monday fmt = dates.DateTimeFormat(d, locale='de_DE') self.assertEqual('1', fmt['c']) # monday is first day of week fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('2', fmt['c']) # sunday is first day of week fmt = dates.DateTimeFormat(d, locale='dv_MV') self.assertEqual('4', fmt['c']) # friday is first day of week def test_fractional_seconds(self): t = time(15, 30, 12, 34567) fmt = dates.DateTimeFormat(t, locale='en_US') self.assertEqual('3457', fmt['SSSS']) def test_fractional_seconds_zero(self): t = time(15, 30, 0) fmt = dates.DateTimeFormat(t, locale='en_US') self.assertEqual('0000', fmt['SSSS']) def test_milliseconds_in_day(self): t = time(15, 30, 12, 345000) fmt = dates.DateTimeFormat(t, locale='en_US') self.assertEqual('55812345', fmt['AAAA']) def test_milliseconds_in_day_zero(self): d = time(0, 0, 0) fmt = dates.DateTimeFormat(d, locale='en_US') self.assertEqual('0000', fmt['AAAA']) def test_timezone_rfc822(self): tz = timezone('Europe/Berlin') t = time(15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(t, locale='de_DE') self.assertEqual('+0100', fmt['Z']) def test_timezone_gmt(self): tz = timezone('Europe/Berlin') t = time(15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(t, locale='de_DE') self.assertEqual('GMT+01:00', fmt['ZZZZ']) def test_timezone_no_uncommon(self): tz = timezone('Europe/Paris') dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(dt, locale='fr_CA') self.assertEqual('France', fmt['v']) def test_timezone_with_uncommon(self): tz = timezone('Europe/Paris') dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(dt, locale='fr_CA') self.assertEqual('HEC', fmt['V']) def test_timezone_location_format(self): tz = timezone('Europe/Paris') dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(dt, locale='fr_FR') self.assertEqual('France', fmt['VVVV']) def test_timezone_walltime_short(self): tz = timezone('Europe/Paris') t = time(15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(t, locale='fr_FR') self.assertEqual('HEC', fmt['v']) def test_timezone_walltime_long(self): tz = timezone('Europe/Paris') t = time(15, 30, tzinfo=tz) fmt = dates.DateTimeFormat(t, locale='fr_FR') self.assertEqual(u'heure d’Europe centrale', fmt['vvvv']) def test_hour_formatting(self): l = 'en_US' t = time(0, 0, 0) self.assertEqual(dates.format_time(t, 'h a', locale=l), '12 AM') self.assertEqual(dates.format_time(t, 'H', locale=l), '0') self.assertEqual(dates.format_time(t, 'k', locale=l), '24') self.assertEqual(dates.format_time(t, 'K a', locale=l), '0 AM') t = time(12, 0, 0) self.assertEqual(dates.format_time(t, 'h a', locale=l), '12 PM') self.assertEqual(dates.format_time(t, 'H', locale=l), '12') self.assertEqual(dates.format_time(t, 'k', locale=l), '12') self.assertEqual(dates.format_time(t, 'K a', locale=l), '0 PM') class FormatDateTestCase(unittest.TestCase): def test_with_time_fields_in_pattern(self): self.assertRaises(AttributeError, dates.format_date, date(2007, 04, 01), "yyyy-MM-dd HH:mm", locale='en_US') def test_with_time_fields_in_pattern_and_datetime_param(self): self.assertRaises(AttributeError, dates.format_date, datetime(2007, 04, 01, 15, 30), "yyyy-MM-dd HH:mm", locale='en_US') class FormatTimeTestCase(unittest.TestCase): def test_with_naive_datetime_and_tzinfo(self): string = dates.format_time(datetime(2007, 4, 1, 15, 30), 'long', tzinfo=timezone('US/Eastern'), locale='en') self.assertEqual('11:30:00 AM EDT', string) def test_with_date_fields_in_pattern(self): self.assertRaises(AttributeError, dates.format_time, date(2007, 04, 01), "yyyy-MM-dd HH:mm", locale='en_US') def test_with_date_fields_in_pattern_and_datetime_param(self): self.assertRaises(AttributeError, dates.format_time, datetime(2007, 04, 01, 15, 30), "yyyy-MM-dd HH:mm", locale='en_US') class TimeZoneAdjustTestCase(unittest.TestCase): def _utc(self): UTC = FixedOffsetTimezone(0, 'UTC') def fake_localize(self, dt, is_dst=False): raise NotImplementedError() UTC.localize = new.instancemethod(fake_localize, UTC, UTC.__class__) # This is important to trigger the actual bug (#257) self.assertEqual(False, hasattr(UTC, 'normalize')) return UTC def test_can_format_time_with_non_pytz_timezone(self): # regression test for #257 utc = self._utc() t = datetime(2007, 4, 1, 15, 30, tzinfo=utc) formatted_time = dates.format_time(t, 'long', tzinfo=utc, locale='en') self.assertEqual('3:30:00 PM +0000', formatted_time) def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(dates)) suite.addTest(unittest.makeSuite(DateTimeFormatTestCase)) suite.addTest(unittest.makeSuite(FormatDateTestCase)) suite.addTest(unittest.makeSuite(FormatTimeTestCase)) suite.addTest(unittest.makeSuite(TimeZoneAdjustTestCase)) return suite if __name__ == '__main__': unittest.main(defaultTest='suite')
{ "pile_set_name": "Github" }
/* * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */ #include <u.h> #include <libc.h> #include <draw.h> /* * This code (and the devdraw interface) will have to change * if we ever get bitmaps with ldepth > 3, because the * colormap will have to be written in chunks */ void writecolmap(Display *d, RGB *m) { int i, n, fd; char buf[64], *t; uint32_t r, g, b; sprint(buf, "/dev/draw/%d/colormap", d->dirno); fd = open(buf, OWRITE); if(fd < 0) drawerror(d, "writecolmap: open colormap failed"); t = malloc(8192); if (t == nil) drawerror(d, "writecolmap: no memory"); n = 0; for(i = 0; i < 256; i++) { r = m[i].red>>24; g = m[i].green>>24; b = m[i].blue>>24; n += sprint(t+n, "%d %lu %lu %lu\n", 255-i, r, g, b); } i = write(fd, t, n); free(t); close(fd); if(i != n) drawerror(d, "writecolmap: bad write"); }
{ "pile_set_name": "Github" }
/* * Copyright (c) 2012 Mans Rullgard * * This file is part of FFmpeg. * * FFmpeg 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. * * FFmpeg 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 FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "libavutil/arm/asm.S" function ff_sbr_sum64x5_neon, export=1 push {lr} add r1, r0, # 64*4 add r2, r0, #128*4 add r3, r0, #192*4 add lr, r0, #256*4 mov r12, #64 1: vld1.32 {q0}, [r0,:128] vld1.32 {q1}, [r1,:128]! vadd.f32 q0, q0, q1 vld1.32 {q2}, [r2,:128]! vadd.f32 q0, q0, q2 vld1.32 {q3}, [r3,:128]! vadd.f32 q0, q0, q3 vld1.32 {q8}, [lr,:128]! vadd.f32 q0, q0, q8 vst1.32 {q0}, [r0,:128]! subs r12, #4 bgt 1b pop {pc} endfunc function ff_sbr_sum_square_neon, export=1 vmov.f32 q0, #0.0 1: vld1.32 {q1}, [r0,:128]! vmla.f32 q0, q1, q1 subs r1, r1, #2 bgt 1b vadd.f32 d0, d0, d1 vpadd.f32 d0, d0, d0 NOVFP vmov.32 r0, d0[0] bx lr endfunc function ff_sbr_neg_odd_64_neon, export=1 mov r1, r0 vmov.i32 q8, #1<<31 vld2.32 {q0,q1}, [r0,:128]! veor q1, q1, q8 vld2.32 {q2,q3}, [r0,:128]! .rept 3 vst2.32 {q0,q1}, [r1,:128]! veor q3, q3, q8 vld2.32 {q0,q1}, [r0,:128]! vst2.32 {q2,q3}, [r1,:128]! veor q1, q1, q8 vld2.32 {q2,q3}, [r0,:128]! .endr veor q3, q3, q8 vst2.32 {q0,q1}, [r1,:128]! vst2.32 {q2,q3}, [r1,:128]! bx lr endfunc function ff_sbr_qmf_pre_shuffle_neon, export=1 add r1, r0, #60*4 add r2, r0, #64*4 vld1.32 {d0}, [r0,:64]! vst1.32 {d0}, [r2,:64]! mov r3, #-16 mov r12, #24 vmov.i32 q8, #1<<31 vld1.32 {q0}, [r1,:128], r3 vld1.32 {d2}, [r0,:64]! 1: vld1.32 {d3,d4}, [r0,:128]! vrev64.32 q0, q0 vld1.32 {q9}, [r1,:128], r3 veor q0, q0, q8 vld1.32 {d5,d6}, [r0,:128]! vswp d0, d1 vrev64.32 q9, q9 vst2.32 {q0,q1}, [r2,:64]! vmov q10, q2 veor q9, q9, q8 vmov d2, d6 vswp d18, d19 vld1.32 {q0}, [r1,:128], r3 vst2.32 {q9,q10}, [r2,:64]! subs r12, r12, #8 bgt 1b vld1.32 {d3,d4}, [r0,:128]! vrev64.32 q0, q0 vld1.32 {q9}, [r1,:128], r3 veor q0, q0, q8 vld1.32 {d5}, [r0,:64]! vswp d0, d1 vrev64.32 q9, q9 vst2.32 {q0,q1}, [r2,:64]! vswp d4, d5 veor q1, q9, q8 vst2.32 {d3,d5}, [r2,:64]! vst2.32 {d2[0],d4[0]}, [r2,:64]! bx lr endfunc function ff_sbr_qmf_post_shuffle_neon, export=1 add r2, r1, #60*4 mov r3, #-16 mov r12, #32 vmov.i32 q8, #1<<31 vld1.32 {q0}, [r2,:128], r3 vld1.32 {q1}, [r1,:128]! 1: pld [r2, #-32] vrev64.32 q0, q0 vswp d2, d3 veor q0, q0, q8 vld1.32 {q2}, [r2,:128], r3 vld1.32 {q3}, [r1,:128]! vst2.32 {d1,d3}, [r0,:128]! vst2.32 {d0,d2}, [r0,:128]! pld [r2, #-32] vrev64.32 q2, q2 vswp d6, d7 veor q2, q2, q8 vld1.32 {q0}, [r2,:128], r3 vld1.32 {q1}, [r1,:128]! vst2.32 {d5,d7}, [r0,:128]! vst2.32 {d4,d6}, [r0,:128]! subs r12, r12, #8 bgt 1b bx lr endfunc function ff_sbr_qmf_deint_neg_neon, export=1 add r1, r1, #60*4 add r2, r0, #62*4 mov r3, #-16 mov r12, #32 vmov.i32 d2, #1<<31 1: vld2.32 {d0,d1}, [r1,:128], r3 veor d0, d0, d2 vrev64.32 d1, d1 vst1.32 {d0}, [r2,:64] vst1.32 {d1}, [r0,:64]! sub r2, r2, #8 subs r12, r12, #2 bgt 1b bx lr endfunc function ff_sbr_qmf_deint_bfly_neon, export=1 push {lr} add r2, r2, #60*4 add r3, r0, #124*4 mov r12, #64 mov lr, #-16 1: vld1.32 {q0}, [r1,:128]! vld1.32 {q1}, [r2,:128], lr vrev64.32 q2, q0 vrev64.32 q3, q1 vadd.f32 d3, d4, d3 vadd.f32 d2, d5, d2 vsub.f32 d0, d0, d7 vsub.f32 d1, d1, d6 vst1.32 {q1}, [r3,:128], lr vst1.32 {q0}, [r0,:128]! subs r12, r12, #4 bgt 1b pop {pc} endfunc function ff_sbr_hf_g_filt_neon, export=1 ldr r12, [sp] add r1, r1, r12, lsl #3 mov r12, #40*2*4 sub r3, r3, #1 vld2.32 {d2[],d3[]},[r2,:64]! vld1.32 {d0}, [r1,:64], r12 1: vld1.32 {d1}, [r1,:64], r12 vmul.f32 q3, q0, q1 vld2.32 {d2[],d3[]},[r2,:64]! vld1.32 {d0}, [r1,:64], r12 vst1.32 {q3}, [r0,:64]! subs r3, r3, #2 bgt 1b it lt bxlt lr vmul.f32 d0, d0, d2 vst1.32 {d0}, [r0,:64]! bx lr endfunc function ff_sbr_hf_gen_neon, export=1 NOVFP vld1.32 {d1[]}, [sp,:32] VFP vdup.32 d1, d0[0] vmul.f32 d0, d1, d1 vld1.32 {d3}, [r2,:64] vld1.32 {d2}, [r3,:64] vmul.f32 q0, q0, q1 ldrd r2, r3, [sp, #4*!HAVE_VFP_ARGS] vtrn.32 d0, d1 vneg.f32 d18, d1 vtrn.32 d18, d1 add r0, r0, r2, lsl #3 add r1, r1, r2, lsl #3 sub r1, r1, #2*8 sub r3, r3, r2 vld1.32 {q1}, [r1,:128]! 1: vld1.32 {q3}, [r1,:128]! vrev64.32 q2, q1 vmov q8, q3 vrev64.32 d20, d3 vrev64.32 d21, d6 vmla.f32 q3, q1, d0[0] vmla.f32 d6, d4, d18 vmla.f32 d7, d20, d18 vmla.f32 d6, d3, d0[1] vmla.f32 d7, d16, d0[1] vmla.f32 d6, d5, d1 vmla.f32 d7, d21, d1 vmov q1, q8 vst1.32 {q3}, [r0,:128]! subs r3, r3, #2 bgt 1b bx lr endfunc function ff_sbr_autocorrelate_neon, export=1 vld1.32 {q0}, [r0,:128]! vmov.f32 q1, #0.0 vmov.f32 q3, #0.0 vmov.f32 d20, #0.0 vmul.f32 d21, d1, d1 vmov q8, q0 vmov q11, q0 mov r12, #36 1: vld1.32 {q2}, [r0,:128]! vrev64.32 q12, q2 vmla.f32 q10, q2, q2 vmla.f32 d2, d1, d4 vmla.f32 d3, d1, d24 vmla.f32 d6, d0, d4 vmla.f32 d7, d0, d24 vmla.f32 d2, d4, d5 vmla.f32 d3, d4, d25 vmla.f32 d6, d1, d5 vmla.f32 d7, d1, d25 vmov q0, q2 subs r12, r12, #2 bgt 1b vld1.32 {q2}, [r0,:128]! vrev64.32 q12, q2 vmla.f32 d2, d1, d4 vmla.f32 d3, d1, d24 vmla.f32 d6, d0, d4 vmla.f32 d7, d0, d24 vadd.f32 d20, d20, d21 vrev64.32 d18, d17 vmla.f32 d6, d1, d5 vmla.f32 d7, d1, d25 vmov q0, q1 vmla.f32 d0, d16, d17 vmla.f32 d1, d16, d18 vmla.f32 d2, d4, d5 vmla.f32 d3, d4, d25 vneg.f32 s15, s15 vmov d21, d20 vpadd.f32 d0, d0, d2 vpadd.f32 d7, d6, d7 vtrn.32 d1, d3 vsub.f32 d6, d1, d3 vmla.f32 d20, d22, d22 vmla.f32 d21, d4, d4 vtrn.32 d0, d6 vpadd.f32 d20, d20, d21 vst1.32 {q3}, [r1,:128]! vst1.32 {d20[1]}, [r1,:32] add r1, r1, #2*4 vst1.32 {d0}, [r1,:64] add r1, r1, #4*4 vst1.32 {d20[0]}, [r1,:32] bx lr endfunc function ff_sbr_hf_apply_noise_0_neon, export=1 vmov.i32 d3, #0 .Lhf_apply_noise_0: push {r4,lr} movrelx r4, X(ff_sbr_noise_table) ldr r12, [sp, #12] add r3, r3, #1 bfc r3, #9, #23 sub r12, r12, #1 1: add lr, r4, r3, lsl #3 vld2.32 {q0}, [r0,:64] vld2.32 {q3}, [lr,:64] vld1.32 {d2}, [r1,:64]! vld1.32 {d18}, [r2,:64]! vceq.f32 d16, d2, #0 veor d2, d2, d3 vmov q2, q0 vmla.f32 d0, d6, d18 vmla.f32 d1, d7, d18 vadd.f32 d4, d4, d2 add r3, r3, #2 bfc r3, #9, #23 vbif d0, d4, d16 vbif d1, d5, d16 vst2.32 {q0}, [r0,:64]! subs r12, r12, #2 bgt 1b blt 2f add lr, r4, r3, lsl #3 vld1.32 {d0}, [r0,:64] vld1.32 {d6}, [lr,:64] vld1.32 {d2[]}, [r1,:32]! vld1.32 {d3[]}, [r2,:32]! vceq.f32 d4, d2, #0 veor d2, d2, d3 vmov d1, d0 vmla.f32 d0, d6, d3 vadd.f32 s2, s2, s4 vbif d0, d1, d4 vst1.32 {d0}, [r0,:64]! 2: pop {r4,pc} endfunc function ff_sbr_hf_apply_noise_1_neon, export=1 ldr r12, [sp] push {r4,lr} lsl r12, r12, #31 eor lr, r12, #1<<31 vmov d3, r12, lr .Lhf_apply_noise_1: movrelx r4, X(ff_sbr_noise_table) ldr r12, [sp, #12] add r3, r3, #1 bfc r3, #9, #23 sub r12, r12, #1 1: add lr, r4, r3, lsl #3 vld2.32 {q0}, [r0,:64] vld2.32 {q3}, [lr,:64] vld1.32 {d2}, [r1,:64]! vld1.32 {d18}, [r2,:64]! vceq.f32 d16, d2, #0 veor d2, d2, d3 vmov q2, q0 vmla.f32 d0, d6, d18 vmla.f32 d1, d7, d18 vadd.f32 d5, d5, d2 add r3, r3, #2 bfc r3, #9, #23 vbif d0, d4, d16 vbif d1, d5, d16 vst2.32 {q0}, [r0,:64]! subs r12, r12, #2 bgt 1b blt 2f add lr, r4, r3, lsl #3 vld1.32 {d0}, [r0,:64] vld1.32 {d6}, [lr,:64] vld1.32 {d2[]}, [r1,:32]! vld1.32 {d18[]}, [r2,:32]! vceq.f32 d4, d2, #0 veor d2, d2, d3 vmov d1, d0 vmla.f32 d0, d6, d18 vadd.f32 s3, s3, s5 vbif d0, d1, d4 vst1.32 {d0}, [r0,:64]! 2: pop {r4,pc} endfunc function ff_sbr_hf_apply_noise_2_neon, export=1 vmov.i32 d3, #1<<31 b .Lhf_apply_noise_0 endfunc function ff_sbr_hf_apply_noise_3_neon, export=1 ldr r12, [sp] push {r4,lr} lsl r12, r12, #31 eor lr, r12, #1<<31 vmov d3, lr, r12 b .Lhf_apply_noise_1 endfunc
{ "pile_set_name": "Github" }
jsmin.exe <..\..\src\contract\dpos.js >..\..\src\contract\dpos.min.js jsmin.exe <..\..\src\contract\dpos_delegate.js >..\..\src\contract\dpos_delegate.min.js jsmin.exe <..\..\src\contract\cobuild.js >..\..\src\contract\cobuild.min.js
{ "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.hadoop.hbase.wal; import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.util.Pair; import org.apache.yetus.audience.InterfaceAudience; import org.apache.hbase.thirdparty.com.google.common.base.Preconditions; import org.apache.hbase.thirdparty.io.netty.channel.Channel; import org.apache.hbase.thirdparty.io.netty.channel.EventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoopGroup; import org.apache.hbase.thirdparty.io.netty.channel.socket.nio.NioSocketChannel; import org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultThreadFactory; /** * Helper class for passing netty event loop config to {@link AsyncFSWALProvider}. * @since 2.0.0 */ @InterfaceAudience.Private public final class NettyAsyncFSWALConfigHelper { private static final String EVENT_LOOP_CONFIG = "hbase.wal.async.event-loop.config"; private static final String CONFIG_NAME = "global-event-loop"; private static final Map<String, Pair<EventLoopGroup, Class<? extends Channel>>> EVENT_LOOP_CONFIG_MAP = new HashMap<>(); /** * Set the EventLoopGroup and channel class for {@code AsyncFSWALProvider}. */ public static void setEventLoopConfig(Configuration conf, EventLoopGroup group, Class<? extends Channel> channelClass) { Preconditions.checkNotNull(group, "group is null"); Preconditions.checkNotNull(channelClass, "channel class is null"); conf.set(EVENT_LOOP_CONFIG, CONFIG_NAME); EVENT_LOOP_CONFIG_MAP.put(CONFIG_NAME, Pair.<EventLoopGroup, Class<? extends Channel>> newPair(group, channelClass)); } static Pair<EventLoopGroup, Class<? extends Channel>> getEventLoopConfig(Configuration conf) { String name = conf.get(EVENT_LOOP_CONFIG); if (StringUtils.isBlank(name)) { // create new event loop group if config is empty return Pair.<EventLoopGroup, Class<? extends Channel>> newPair( new NioEventLoopGroup(0, new DefaultThreadFactory("AsyncFSWAL", true, Thread.MAX_PRIORITY)), NioSocketChannel.class); } return EVENT_LOOP_CONFIG_MAP.get(name); } private NettyAsyncFSWALConfigHelper() {} }
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.paypal.example.paypalandroidsdkexample"> <!-- WRITE_EXTERNAL_STORAGE permission is only used for testing purposes to store screenshots --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name="com.paypal.example.paypalandroidsdkexample.SampleActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
{ "pile_set_name": "Github" }
<?php // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. // See the LICENCE file in the repository root for full licence text. use Faker\Factory as Faker; use Illuminate\Database\Seeder; class EventSeeder extends Seeder { public function run() { // DB::table('osu_events')->delete(); App\Models\Event::unguard(); $beatmapCount = App\Models\Beatmap::count(); if ($beatmapCount === 0) { $this->command->info('Can\'t seed events due to having no beatmap data.'); return; } $faker = Faker::create(); $users = App\Models\User::all(); $generateEventText = function ($bm, $bms, $u, $rank) { switch ($bm->playmode) { case 0: $playmode = 'osu!'; break; case 1: $playmode = 'Taiko'; break; case 2: $playmode = 'Catch the Beat'; break; case 3: $playmode = 'osu!mania'; break; } $rank_letters = ['X', 'S', 'A']; $rank_letter = array_rand_val($rank_letters); $string = "<img src='/images/".$rank_letter."_small.png'/> <b><a href='/u/".$u->user_id."'>".$u->username.'</a></b> achieved rank #' .$rank." on <a href='/b/".$bm->beatmap_id."?m=0'>".$bms->artist.' - '.$bms->title .' ['.$bm->version.']'.'</a> ('.$playmode.')'; return $string; }; foreach ($users as $u) { if ($beatmapCount > 0) { $all_beatmaps = App\Models\Beatmap::orderByRaw('RAND()')->get(); for ($c = 0; $c < 4; $c++) { if ($all_beatmaps[$c]) { $bm = $all_beatmaps[$c]; $bms = App\Models\Beatmapset::find($bm->beatmapset_id); if (isset($bms)) { $is_rank_1 = $faker->boolean(20); if ($is_rank_1 === true) { $rank = 1; $epicfactor = 2; } else { $rank = strval(rand(1, 499)); $epicfactor = 1; } $txt = $generateEventText($bm, $bms, $u, $rank); $ev = $u->events()->save(App\Models\Event::create([ 'user_id' => $u->user_id, 'text' => $txt, 'text_clean' => $txt, 'epicfactor' => $epicfactor, 'beatmap_id' => $bm->beatmap_id, 'beatmapset_id' => $bm->beatmapset_id, 'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now ])); } } } } // end rank events // Create a random supporter/name change event $string = ''; switch (rand(1, 4)) { case 1: $string = "<b><a href='/u/".$u->user_id."'>".$u->username.'</a></b> has once again chosen to support osu! - thanks for your generosity!'; break; case 2: $string = "<b><a href='/u/".$u->user_id."'>".$u->username.'</a></b> has become an osu! supporter - thanks for your generosity!'; break; case 3: $string = "<b><a href='/u/".$u->user_id."'>".$u->username.'</a></b> has received the gift of osu! supporter!'; break; case 4: $string = "<b><a href='/u/".$u->user_id."'>".$faker->userName.'</a></b> has changed their username to '.$u->username.'!'; break; } $ev2 = $u->events()->save(App\Models\Event::create([ 'user_id' => $u->user_id, 'text' => $string, 'text_clean' => $string, 'epicfactor' => 1, 'date' => rand(1451606400, time()), // random timestamp between 01/01/2016 and now ])); } // END EVENTS App\Models\Event::reguard(); } }
{ "pile_set_name": "Github" }
# CS294-112 HW 1: Imitation Learning Dependencies: * Python **3.5** * Numpy version **1.14.5** * TensorFlow version **1.10.5** * MuJoCo version **1.50** and mujoco-py **1.50.1.56** * OpenAI Gym version **0.10.5** Once Python **3.5** is installed, you can install the remaining dependencies using `pip install -r requirements.txt`. **Note**: MuJoCo versions until 1.5 do not support NVMe disks therefore won't be compatible with recent Mac machines. There is a request for OpenAI to support it that can be followed [here](https://github.com/openai/gym/issues/638). **Note**: Students enrolled in the course will receive an email with their MuJoCo activation key. Please do **not** share this key. The only file that you need to look at is `run_expert.py`, which is code to load up an expert policy, run a specified number of roll-outs, and save out data. In `experts/`, the provided expert policies are: * Ant-v2.pkl * HalfCheetah-v2.pkl * Hopper-v2.pkl * Humanoid-v2.pkl * Reacher-v2.pkl * Walker2d-v2.pkl The name of the pickle file corresponds to the name of the gym environment.
{ "pile_set_name": "Github" }
/* Copyright The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto package v1beta1 import ( fmt "fmt" io "io" proto "github.com/gogo/protobuf/proto" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" math "math" math_bits "math/bits" reflect "reflect" strings "strings" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package func (m *PartialObjectMetadataList) Reset() { *m = PartialObjectMetadataList{} } func (*PartialObjectMetadataList) ProtoMessage() {} func (*PartialObjectMetadataList) Descriptor() ([]byte, []int) { return fileDescriptor_90ec10f86b91f9a8, []int{0} } func (m *PartialObjectMetadataList) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } func (m *PartialObjectMetadataList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } func (m *PartialObjectMetadataList) XXX_Merge(src proto.Message) { xxx_messageInfo_PartialObjectMetadataList.Merge(m, src) } func (m *PartialObjectMetadataList) XXX_Size() int { return m.Size() } func (m *PartialObjectMetadataList) XXX_DiscardUnknown() { xxx_messageInfo_PartialObjectMetadataList.DiscardUnknown(m) } var xxx_messageInfo_PartialObjectMetadataList proto.InternalMessageInfo func init() { proto.RegisterType((*PartialObjectMetadataList)(nil), "k8s.io.apimachinery.pkg.apis.meta.v1beta1.PartialObjectMetadataList") } func init() { proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto", fileDescriptor_90ec10f86b91f9a8) } var fileDescriptor_90ec10f86b91f9a8 = []byte{ // 317 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4b, 0xf3, 0x30, 0x1c, 0xc6, 0x9b, 0xf7, 0x65, 0x38, 0x3a, 0x04, 0xd9, 0x69, 0xee, 0x90, 0x0d, 0x4f, 0xf3, 0xb0, 0x84, 0x0d, 0x11, 0xc1, 0xdb, 0x6e, 0x82, 0xa2, 0xec, 0x28, 0x1e, 0x4c, 0xbb, 0xbf, 0x5d, 0xac, 0x69, 0x4a, 0xf2, 0xef, 0xc0, 0x9b, 0x1f, 0xc1, 0x8f, 0xb5, 0xe3, 0x8e, 0x03, 0x61, 0xb8, 0xf8, 0x45, 0x24, 0x5d, 0x15, 0x19, 0x0a, 0xbb, 0xf5, 0x79, 0xca, 0xef, 0x97, 0x27, 0x24, 0x1c, 0xa7, 0x67, 0x96, 0x49, 0xcd, 0xd3, 0x22, 0x02, 0x93, 0x01, 0x82, 0xe5, 0x33, 0xc8, 0x26, 0xda, 0xf0, 0xea, 0x87, 0xc8, 0xa5, 0x12, 0xf1, 0x54, 0x66, 0x60, 0x9e, 0x79, 0x9e, 0x26, 0xbe, 0xb0, 0x5c, 0x01, 0x0a, 0x3e, 0x1b, 0x44, 0x80, 0x62, 0xc0, 0x13, 0xc8, 0xc0, 0x08, 0x84, 0x09, 0xcb, 0x8d, 0x46, 0xdd, 0x3c, 0xde, 0xa0, 0xec, 0x27, 0xca, 0xf2, 0x34, 0xf1, 0x85, 0x65, 0x1e, 0x65, 0x15, 0xda, 0xee, 0x27, 0x12, 0xa7, 0x45, 0xc4, 0x62, 0xad, 0x78, 0xa2, 0x13, 0xcd, 0x4b, 0x43, 0x54, 0x3c, 0x94, 0xa9, 0x0c, 0xe5, 0xd7, 0xc6, 0xdc, 0x3e, 0xd9, 0x65, 0xd4, 0xf6, 0x9e, 0xf6, 0xe9, 0x5f, 0x94, 0x29, 0x32, 0x94, 0x0a, 0xb8, 0x8d, 0xa7, 0xa0, 0xc4, 0x36, 0x77, 0xf4, 0x46, 0xc2, 0xc3, 0x1b, 0x61, 0x50, 0x8a, 0xa7, 0xeb, 0xe8, 0x11, 0x62, 0xbc, 0x02, 0x14, 0x13, 0x81, 0xe2, 0x52, 0x5a, 0x6c, 0xde, 0x85, 0x75, 0x55, 0xe5, 0xd6, 0xbf, 0x2e, 0xe9, 0x35, 0x86, 0x8c, 0xed, 0x72, 0x71, 0xe6, 0x69, 0x6f, 0x1a, 0x1d, 0xcc, 0x57, 0x9d, 0xc0, 0xad, 0x3a, 0xf5, 0xaf, 0x66, 0xfc, 0x6d, 0x6c, 0xde, 0x87, 0x35, 0x89, 0xa0, 0x6c, 0x8b, 0x74, 0xff, 0xf7, 0x1a, 0xc3, 0xf3, 0xdd, 0xd4, 0xbf, 0xae, 0x1d, 0xed, 0x57, 0xe7, 0xd4, 0x2e, 0xbc, 0x71, 0xbc, 0x11, 0x8f, 0xfa, 0xf3, 0x35, 0x0d, 0x16, 0x6b, 0x1a, 0x2c, 0xd7, 0x34, 0x78, 0x71, 0x94, 0xcc, 0x1d, 0x25, 0x0b, 0x47, 0xc9, 0xd2, 0x51, 0xf2, 0xee, 0x28, 0x79, 0xfd, 0xa0, 0xc1, 0xed, 0x5e, 0xf5, 0x52, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x82, 0x5b, 0x80, 0x29, 0x02, 0x00, 0x00, } func (m *PartialObjectMetadataList) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } return dAtA[:n], nil } func (m *PartialObjectMetadataList) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } func (m *PartialObjectMetadataList) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { size, err := m.ListMeta.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } i -= size i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 if len(m.Items) > 0 { for iNdEx := len(m.Items) - 1; iNdEx >= 0; iNdEx-- { { size, err := m.Items[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } i -= size i = encodeVarintGenerated(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa } } return len(dAtA) - i, nil } func encodeVarintGenerated(dAtA []byte, offset int, v uint64) int { offset -= sovGenerated(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) return base } func (m *PartialObjectMetadataList) Size() (n int) { if m == nil { return 0 } var l int _ = l if len(m.Items) > 0 { for _, e := range m.Items { l = e.Size() n += 1 + l + sovGenerated(uint64(l)) } } l = m.ListMeta.Size() n += 1 + l + sovGenerated(uint64(l)) return n } func sovGenerated(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozGenerated(x uint64) (n int) { return sovGenerated(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (this *PartialObjectMetadataList) String() string { if this == nil { return "nil" } repeatedStringForItems := "[]PartialObjectMetadata{" for _, f := range this.Items { repeatedStringForItems += fmt.Sprintf("%v", f) + "," } repeatedStringForItems += "}" s := strings.Join([]string{`&PartialObjectMetadataList{`, `Items:` + repeatedStringForItems + `,`, `ListMeta:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.ListMeta), "ListMeta", "v1.ListMeta", 1), `&`, ``, 1) + `,`, `}`, }, "") return s } func valueToStringGenerated(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { return "nil" } pv := reflect.Indirect(rv).Interface() return fmt.Sprintf("*%v", pv) } func (m *PartialObjectMetadataList) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { preIndex := iNdEx var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= uint64(b&0x7F) << shift if b < 0x80 { break } } fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { return fmt.Errorf("proto: PartialObjectMetadataList: wiretype end group for non-group") } if fieldNum <= 0 { return fmt.Errorf("proto: PartialObjectMetadataList: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Items", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthGenerated } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } m.Items = append(m.Items, v1.PartialObjectMetadata{}) if err := m.Items[len(m.Items)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ListMeta", wireType) } var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenerated } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ msglen |= int(b&0x7F) << shift if b < 0x80 { break } } if msglen < 0 { return ErrInvalidLengthGenerated } postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenerated } if postIndex > l { return io.ErrUnexpectedEOF } if err := m.ListMeta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenerated(dAtA[iNdEx:]) if err != nil { return err } if skippy < 0 { return ErrInvalidLengthGenerated } if (iNdEx + skippy) < 0 { return ErrInvalidLengthGenerated } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } iNdEx += skippy } } if iNdEx > l { return io.ErrUnexpectedEOF } return nil } func skipGenerated(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 for iNdEx < l { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return 0, ErrIntOverflowGenerated } if iNdEx >= l { return 0, io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ wire |= (uint64(b) & 0x7F) << shift if b < 0x80 { break } } wireType := int(wire & 0x7) switch wireType { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { return 0, ErrIntOverflowGenerated } if iNdEx >= l { return 0, io.ErrUnexpectedEOF } iNdEx++ if dAtA[iNdEx-1] < 0x80 { break } } case 1: iNdEx += 8 case 2: var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { return 0, ErrIntOverflowGenerated } if iNdEx >= l { return 0, io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ length |= (int(b) & 0x7F) << shift if b < 0x80 { break } } if length < 0 { return 0, ErrInvalidLengthGenerated } iNdEx += length case 3: depth++ case 4: if depth == 0 { return 0, ErrUnexpectedEndOfGroupGenerated } depth-- case 5: iNdEx += 4 default: return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { return 0, ErrInvalidLengthGenerated } if depth == 0 { return iNdEx, nil } } return 0, io.ErrUnexpectedEOF } var ( ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group") )
{ "pile_set_name": "Github" }
# Contribute > Notice: `y` is the alias for `yarn`, `n` is the alias for `npm`. ## Set up Install dev deps after git clone the repo. ```bash $ y ``` change the package.json ```bash "scripts": { "dev": "cross-env PAGES_PATH='AccountCenter/src' umi dev", ... } ``` `'AccountCenter/src'` is you are going to running run dev ```bash $ y dev ```
{ "pile_set_name": "Github" }
SHELL = /bin/sh # V=0 quiet, V=1 verbose. other values don't work. V = 0 Q1 = $(V:1=) Q = $(Q1:0=@) ECHO1 = $(V:1=@:) ECHO = $(ECHO1:0=@echo) NULLCMD = : #### Start of system configuration section. #### srcdir = . topdir = /Users/liaoziyang/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 hdrdir = $(topdir) arch_hdrdir = /Users/liaoziyang/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-darwin16 PATH_SEPARATOR = : VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby prefix = $(DESTDIR)/Users/liaoziyang/.rvm/rubies/ruby-2.3.0 rubysitearchprefix = $(rubylibprefix)/$(sitearch) rubyarchprefix = $(rubylibprefix)/$(arch) rubylibprefix = $(libdir)/$(RUBY_BASE_NAME) exec_prefix = $(prefix) vendorarchhdrdir = $(vendorhdrdir)/$(sitearch) sitearchhdrdir = $(sitehdrdir)/$(sitearch) rubyarchhdrdir = $(rubyhdrdir)/$(arch) vendorhdrdir = $(rubyhdrdir)/vendor_ruby sitehdrdir = $(rubyhdrdir)/site_ruby rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME) vendorarchdir = $(vendorlibdir)/$(sitearch) vendorlibdir = $(vendordir)/$(ruby_version) vendordir = $(rubylibprefix)/vendor_ruby sitearchdir = $(DESTDIR)./.gem.20170622-11687-gxsh4o sitelibdir = $(DESTDIR)./.gem.20170622-11687-gxsh4o sitedir = $(rubylibprefix)/site_ruby rubyarchdir = $(rubylibdir)/$(arch) rubylibdir = $(rubylibprefix)/$(ruby_version) sitearchincludedir = $(includedir)/$(sitearch) archincludedir = $(includedir)/$(arch) sitearchlibdir = $(libdir)/$(sitearch) archlibdir = $(libdir)/$(arch) ridir = $(datarootdir)/$(RI_BASE_NAME) mandir = $(datarootdir)/man localedir = $(datarootdir)/locale libdir = $(exec_prefix)/lib psdir = $(docdir) pdfdir = $(docdir) dvidir = $(docdir) htmldir = $(docdir) infodir = $(datarootdir)/info docdir = $(datarootdir)/doc/$(PACKAGE) oldincludedir = $(DESTDIR)/usr/include includedir = $(SDKROOT)$(prefix)/include localstatedir = $(prefix)/var sharedstatedir = $(prefix)/com sysconfdir = $(prefix)/etc datadir = $(datarootdir) datarootdir = $(prefix)/share libexecdir = $(exec_prefix)/libexec sbindir = $(exec_prefix)/sbin bindir = $(exec_prefix)/bin archdir = $(rubyarchdir) CC = gcc CXX = g++ LIBRUBY = $(LIBRUBY_SO) LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME) LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation empty = OUTFLAG = -o $(empty) COUTFLAG = -o $(empty) RUBY_EXTCONF_H = cflags = $(optflags) $(debugflags) $(warnflags) cxxflags = $(optflags) $(debugflags) $(warnflags) optflags = -O3 -fno-fast-math debugflags = -ggdb3 warnflags = -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens CCDLFLAGS = -fno-common CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe -std=c99 -DNGLIB $(ARCH_FLAG) INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir) -I/usr/include/libxml2 -I/Users/liaoziyang/dev/Rails_QA/kyoma/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.0/ext/nokogiri DEFS = CPPFLAGS = -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags) CXXFLAGS = $(CCDLFLAGS) $(cxxflags) $(ARCH_FLAG) ldflags = -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib ARCH_FLAG = DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) LDSHARED = $(CC) -dynamic -bundle LDSHAREDXX = $(CXX) -dynamic -bundle AR = ar EXEEXT = RUBY_INSTALL_NAME = $(RUBY_BASE_NAME) RUBY_SO_NAME = ruby.2.3.0 RUBYW_INSTALL_NAME = RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version) RUBYW_BASE_NAME = rubyw RUBY_BASE_NAME = ruby arch = x86_64-darwin16 sitearch = $(arch) ruby_version = 2.3.0 ruby = $(bindir)/$(RUBY_BASE_NAME) RUBY = $(ruby) ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h RM = rm -f RM_RF = $(RUBY) -run -e rm -- -rf RMDIRS = rmdir -p MAKEDIRS = /usr/local/bin/gmkdir -p INSTALL = /usr/bin/install -c INSTALL_PROG = $(INSTALL) -m 0755 INSTALL_DATA = $(INSTALL) -m 644 COPY = cp TOUCH = exit > #### End of system configuration section. #### preload = libpath = . $(libdir) /usr/local/opt/libyaml/lib /usr/local/opt/readline/lib /usr/local/opt/libksba/lib /usr/local/opt/openssl/lib LIBPATH = -L. -L$(libdir) -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib DEFFILE = CLEANFILES = mkmf.log DISTCLEANFILES = DISTCLEANDIRS = extout = extout_prefix = target_prefix = LOCAL_LIBS = LIBS = $(LIBRUBYARG_SHARED) -lxml2 -lxml2 -lpthread -ldl -lobjc ORIG_SRCS = attribute.c char_ref.c error.c nokogumbo.c parser.c string_buffer.c string_piece.c tag.c tokenizer.c utf8.c util.c vector.c SRCS = $(ORIG_SRCS) OBJS = attribute.o char_ref.o error.o nokogumbo.o parser.o string_buffer.o string_piece.o tag.o tokenizer.o utf8.o util.o vector.o HDRS = $(srcdir)/attribute.h $(srcdir)/char_ref.h $(srcdir)/error.h $(srcdir)/gumbo.h $(srcdir)/insertion_mode.h $(srcdir)/parser.h $(srcdir)/string_buffer.h $(srcdir)/string_piece.h $(srcdir)/tag_enum.h $(srcdir)/tag_gperf.h $(srcdir)/tag_sizes.h $(srcdir)/tag_strings.h $(srcdir)/token_type.h $(srcdir)/tokenizer.h $(srcdir)/tokenizer_states.h $(srcdir)/utf8.h $(srcdir)/util.h $(srcdir)/vector.h TARGET = nokogumboc TARGET_NAME = nokogumboc TARGET_ENTRY = Init_$(TARGET_NAME) DLLIB = $(TARGET).bundle EXTSTATIC = STATIC_LIB = TIMESTAMP_DIR = . BINDIR = $(bindir) RUBYCOMMONDIR = $(sitedir)$(target_prefix) RUBYLIBDIR = $(sitelibdir)$(target_prefix) RUBYARCHDIR = $(sitearchdir)$(target_prefix) HDRDIR = $(rubyhdrdir)/ruby$(target_prefix) ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix) TARGET_SO = $(DLLIB) CLEANLIBS = $(TARGET).bundle CLEANOBJS = *.o *.bak all: $(DLLIB) static: $(STATIC_LIB) install-rb .PHONY: all install static install-so install-rb .PHONY: clean clean-so clean-static clean-rb clean-static:: clean-rb-default:: clean-rb:: clean-so:: clean: clean-so clean-static clean-rb-default clean-rb -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time distclean-rb-default:: distclean-rb:: distclean-so:: distclean-static:: distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES) -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true realclean: distclean install: install-so install-rb install-so: $(DLLIB) $(TIMESTAMP_DIR)/.RUBYARCHDIR.time $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR) clean-static:: -$(Q)$(RM) $(STATIC_LIB) install-rb: pre-install-rb install-rb-default install-rb-default: pre-install-rb-default pre-install-rb: Makefile pre-install-rb-default: Makefile pre-install-rb-default: @$(NULLCMD) $(TIMESTAMP_DIR)/.RUBYARCHDIR.time: $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR) $(Q) $(TOUCH) $@ site-install: site-install-so site-install-rb site-install-so: install-so site-install-rb: install-rb .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S .cc.o: $(ECHO) compiling $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< .cc.S: $(ECHO) translating $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< .mm.o: $(ECHO) compiling $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< .mm.S: $(ECHO) translating $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< .cxx.o: $(ECHO) compiling $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< .cxx.S: $(ECHO) translating $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< .cpp.o: $(ECHO) compiling $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $< .cpp.S: $(ECHO) translating $(<) $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $< .c.o: $(ECHO) compiling $(<) $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $< .c.S: $(ECHO) translating $(<) $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $< .m.o: $(ECHO) compiling $(<) $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $< .m.S: $(ECHO) translating $(<) $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $< $(DLLIB): $(OBJS) Makefile $(ECHO) linking shared-object $(DLLIB) -$(Q)$(RM) $(@) $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS) $(Q) $(POSTLINK) $(OBJS): $(HDRS) $(ruby_headers)
{ "pile_set_name": "Github" }
/* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * Test for Showdown markdown parser work with Nashorn. * * @test * @run */ var input = "\nThese should all be escaped:\n\n\\\n\n\`\n\n\*\n\n\_\n\n\{\n\n\}\n\n\[\n\n\]\n\n\(\n\n\)\n\n\#\n\n\+\n\n\-\n\n\.\n\n\!"; var output = converter.makeHtml(input); print(output);
{ "pile_set_name": "Github" }
<?php return array ( 'USD' => 'ABD Doları', 'USS' => 'ABD Doları (Aynı gün)', 'USN' => 'ABD Doları (Ertesi gün)', 'AFN' => 'Afganistan Afganisi', 'AFA' => 'Afganistan Afganisi (1927–2002)', 'DEM' => 'Alman Markı', 'ADP' => 'Andorra Pezetası', 'AOA' => 'Angola Kvanzası', 'AOK' => 'Angola Kvanzası (1977–1990)', 'AOR' => 'Angola Kvanzası Reajustado (1995–1999)', 'ARA' => 'Arjantin Australi', 'ARL' => 'Arjantin Peso Leyi (1970–1983)', 'ARS' => 'Arjantin Pesosu', 'ARM' => 'Arjantin Pesosu (1881–1970)', 'ARP' => 'Arjantin Pezosu (1983–1985)', 'ALL' => 'Arnavutluk Leki', 'ALK' => 'Arnavutluk Leki (1946–1965)', 'AWG' => 'Aruba Florini', 'XEU' => 'Avrupa Para Birimi', 'AUD' => 'Avustralya Doları', 'ATS' => 'Avusturya Şilini', 'AZN' => 'Azerbaycan Manatı', 'AZM' => 'Azerbaycan Manatı (1993–2006)', 'BSD' => 'Bahama Doları', 'BHD' => 'Bahreyn Dinarı', 'BDT' => 'Bangladeş Takası', 'BBD' => 'Barbados Doları', 'BZD' => 'Belize Doları', 'BEF' => 'Belçika Frangı', 'BEL' => 'Belçika Frangı (finansal)', 'BEC' => 'Belçika Frangı (konvertibl)', 'BMD' => 'Bermuda Doları', 'BYN' => 'Beyaz Rusya Rublesi', 'BYR' => 'Beyaz Rusya Rublesi (2000–2016)', 'BTN' => 'Bhutan Ngultrumu', 'AED' => 'Birleşik Arap Emirlikleri Dirhemi', 'BOB' => 'Bolivya Bolivyanosu', 'BOL' => 'Bolivya Bolivyanosu (1863–1963)', 'BOV' => 'Bolivya Mvdolu', 'BOP' => 'Bolivya Pezosu', 'BAD' => 'Bosna Hersek Dinarı', 'BWP' => 'Botsvana Pulası', 'BRC' => 'Brezilya Kruzadosu', 'BRR' => 'Brezilya Kruzeirosu', 'BRZ' => 'Brezilya Kruzeirosu (1942–1967)', 'BRE' => 'Brezilya Kruzeirosu (1990–1993)', 'BRL' => 'Brezilya Reali', 'BND' => 'Brunei Doları', 'BGN' => 'Bulgar Levası', 'BGO' => 'Bulgar Levası (1879–1952)', 'BGL' => 'Bulgar Levası (Hard)', 'BUK' => 'Burma Kyatı', 'BIF' => 'Burundi Frangı', 'XOF' => 'CFA Frangı BCEAO', 'XAF' => 'CFA Frangı BEAC', 'XPF' => 'CFP Frangı', 'CVE' => 'Cape Verde Esküdosu', 'KYD' => 'Cayman Adaları Doları', 'GIP' => 'Cebelitarık Lirası', 'DZD' => 'Cezayir Dinarı', 'DJF' => 'Cibuti Frangı', 'DKK' => 'Danimarka Kronu', 'DOP' => 'Dominik Pesosu', 'DDM' => 'Doğu Alman Markı', 'XCD' => 'Doğu Karayip Doları', 'ECS' => 'Ekvador Sukresi', 'ECV' => 'Ekvador Unidad de Valor Constante (UVC)', 'GQE' => 'Ekvator Ginesi Ekuelesi', 'SVC' => 'El Salvador Kolonu', 'IDR' => 'Endonezya Rupiahı', 'ERN' => 'Eritre Nakfası', 'AMD' => 'Ermenistan Dramı', 'MZM' => 'Eski Mozambik Metikali', 'ROL' => 'Eski Romen Leyi', 'SDD' => 'Eski Sudan Dinarı', 'SDP' => 'Eski Sudan Lirası', 'CSD' => 'Eski Sırbistan Dinarı', 'TRL' => 'Eski Türk Lirası', 'EEK' => 'Estonya Krunu', 'ETB' => 'Etiyopya Birri', 'EUR' => 'Euro', 'FKP' => 'Falkland Adaları Lirası', 'MAD' => 'Fas Dirhemi', 'MAF' => 'Fas Frangı', 'FJD' => 'Fiji Doları', 'PHP' => 'Filipinler Pesosu', 'FIM' => 'Fin Markkası', 'LUL' => 'Finansal Lüksemburg Frangı', 'XFO' => 'Fransız Altın Frangı', 'FRF' => 'Fransız Frangı', 'XFU' => 'Fransız UIC-Frangı', 'GMD' => 'Gambiya Dalasisi', 'GHS' => 'Gana Sedisi', 'GHC' => 'Gana Sedisi (1979–2007)', 'GNF' => 'Gine Frangı', 'GNS' => 'Gine Sylisi', 'GWP' => 'Gine-Bissau Pezosu', 'GTQ' => 'Guatemala Quetzalı', 'GYD' => 'Guyana Doları', 'MXP' => 'Gümüş Meksika Pezosu (1861–1992)', 'ZAR' => 'Güney Afrika Randı', 'ZAL' => 'Güney Afrika Randı (finansal)', 'KRH' => 'Güney Kore Hwanı (1953–1962)', 'KRW' => 'Güney Kore Wonu', 'KRO' => 'Güney Kore Wonu (1945–1953)', 'CYP' => 'Güney Kıbrıs Lirası', 'SSP' => 'Güney Sudan Lirası', 'GEK' => 'Gürcistan Kupon Larisi', 'GEL' => 'Gürcistan Larisi', 'HTG' => 'Haiti Gurdu', 'INR' => 'Hindistan Rupisi', 'ANG' => 'Hollanda Antilleri Guldeni', 'NLG' => 'Hollanda Florini', 'HNL' => 'Honduras Lempirası', 'HKD' => 'Hong Kong Doları', 'HRD' => 'Hırvatistan Dinarı', 'HRK' => 'Hırvatistan Kunası', 'IQD' => 'Irak Dinarı', 'JMD' => 'Jamaika Doları', 'JPY' => 'Japon Yeni', 'KHR' => 'Kamboçya Rieli', 'CAD' => 'Kanada Doları', 'QAR' => 'Katar Riyali', 'KZT' => 'Kazakistan Tengesi', 'KES' => 'Kenya Şilini', 'COP' => 'Kolombiya Pesosu', 'KMF' => 'Komorlar Frangı', 'CDF' => 'Kongo Frangı', 'BAM' => 'Konvertibl Bosna Hersek Markı', 'CUC' => 'Konvertibl Küba Pesosu', 'LUC' => 'Konvertibl Lüksemburg Frangı', 'YUN' => 'Konvertibl Yugoslav Dinarı', 'CRC' => 'Kosta Rika Kolonu', 'KWD' => 'Kuveyt Dinarı', 'KPW' => 'Kuzey Kore Wonu', 'CUP' => 'Küba Pesosu', 'KGS' => 'Kırgızistan Somu', 'LAK' => 'Laos Kipi', 'LSL' => 'Lesotho Lotisi', 'LVL' => 'Letonya Latı', 'LVR' => 'Letonya Rublesi', 'LRD' => 'Liberya Doları', 'LYD' => 'Libya Dinarı', 'LTL' => 'Litvanya Litası', 'LTT' => 'Litvanya Talonu', 'LBP' => 'Lübnan Lirası', 'LUF' => 'Lüksemburg Frangı', 'HUF' => 'Macar Forinti', 'MGA' => 'Madagaskar Ariarisi', 'MGF' => 'Madagaskar Frangı', 'MOP' => 'Makao Patakası', 'MKD' => 'Makedonya Dinarı', 'MKN' => 'Makedonya Dinarı (1992–1993)', 'MWK' => 'Malavi Kvaçası', 'MVR' => 'Maldiv Rufiyaası', 'MVP' => 'Maldiv Rupisi', 'MYR' => 'Malezya Ringgiti', 'MLF' => 'Mali Frangı', 'MTL' => 'Malta Lirası', 'MTP' => 'Malta Sterlini', 'MUR' => 'Mauritius Rupisi', 'MXN' => 'Meksika Pesosu', 'MXV' => 'Meksika Unidad de Inversion (UDI)', 'MDC' => 'Moldova Kuponu', 'MDL' => 'Moldova Leyi', 'MCF' => 'Monako Frangı', 'MRO' => 'Moritanya Ouguiyası', 'MZE' => 'Mozambik Esküdosu', 'MZN' => 'Mozambik Metikali', 'MNT' => 'Moğolistan Tugriki', 'MMK' => 'Myanmar Kyatı', 'EGP' => 'Mısır Lirası', 'NAD' => 'Namibya Doları', 'NPR' => 'Nepal Rupisi', 'NGN' => 'Nijerya Nairası', 'NIO' => 'Nikaragua Kordobası', 'NIC' => 'Nikaragua Kordobası (1988–1991)', 'NOK' => 'Norveç Kronu', 'PKR' => 'Pakistan Rupisi', 'PAB' => 'Panama Balboası', 'PGK' => 'Papua Yeni Gine Kinası', 'PYG' => 'Paraguay Guaranisi', 'PEN' => 'Peru Solü', 'PES' => 'Peru Solü (1863–1965)', 'PEI' => 'Peru İnti', 'PLN' => 'Polonya Zlotisi', 'PLZ' => 'Polonya Zlotisi (1950–1995)', 'PTE' => 'Portekiz Esküdosu', 'GWE' => 'Portekiz Ginesi Esküdosu', 'XRE' => 'RINET Fonları', 'RHD' => 'Rodezya Doları', 'RON' => 'Romen Leyi', 'RWF' => 'Ruanda Frangı', 'RUB' => 'Rus Rublesi', 'RUR' => 'Rus Rublesi (1991–1998)', 'SHP' => 'Saint Helena Lirası', 'WST' => 'Samoa Talası', 'SCR' => 'Seyşeller Rupisi', 'SLL' => 'Sierra Leone Leonesi', 'SGD' => 'Singapur Doları', 'SKK' => 'Slovak Korunası', 'SIT' => 'Slovenya Toları', 'SBD' => 'Solomon Adaları Doları', 'SOS' => 'Somali Şilini', 'BGM' => 'Sosyalist Bulgaristan Levası', 'SUR' => 'Sovyet Rublesi', 'LKR' => 'Sri Lanka Rupisi', 'SDG' => 'Sudan Lirası', 'SRD' => 'Surinam Doları', 'SRG' => 'Surinam Guldeni', 'SYP' => 'Suriye Lirası', 'SAR' => 'Suudi Arabistan Riyali', 'SZL' => 'Svaziland Lilangenisi', 'STD' => 'São Tomé ve Príncipe Dobrası', 'RSD' => 'Sırp Dinarı', 'TJR' => 'Tacikistan Rublesi', 'TJS' => 'Tacikistan Somonisi', 'TZS' => 'Tanzanya Şilini', 'THB' => 'Tayland Bahtı', 'TPE' => 'Timor Esküdosu', 'TOP' => 'Tonga Paʻangası', 'TTD' => 'Trinidad ve Tobago Doları', 'TND' => 'Tunus Dinarı', 'TRY' => 'Türk Lirası', 'TMT' => 'Türkmenistan Manatı', 'TMM' => 'Türkmenistan Manatı (1993–2009)', 'UGX' => 'Uganda Şilini', 'UGS' => 'Uganda Şilini (1966–1987)', 'UAH' => 'Ukrayna Grivnası', 'UAK' => 'Ukrayna Karbovanetz', 'OMR' => 'Umman Riyali', 'COU' => 'Unidad de Valor Real', 'UYI' => 'Uruguay Peso en Unidades Indexadas', 'UYU' => 'Uruguay Pesosu', 'UYP' => 'Uruguay Pezosu (1975–1993)', 'VUV' => 'Vanuatu Vatusu', 'VEF' => 'Venezuela Bolivarı', 'VEB' => 'Venezuela Bolivarı (1871–2008)', 'VND' => 'Vietnam Dongu', 'VNN' => 'Vietnam Dongu (1978–1985)', 'CHE' => 'WIR Avrosu', 'CHW' => 'WIR Frangı', 'YDD' => 'Yemen Dinarı', 'YER' => 'Yemen Riyali', 'AON' => 'Yeni Angola Kvanzası (1990–2000)', 'BYB' => 'Yeni Beyaz Rusya Rublesi (1994–1999)', 'BAN' => 'Yeni Bosna Hersek Dinarı (1994–1997)', 'BRN' => 'Yeni Brezilya Kruzadosu', 'BRB' => 'Yeni Brezilya Kruzeirosu (1967–1986)', 'TWD' => 'Yeni Tayvan Doları', 'YUM' => 'Yeni Yugoslav Dinarı', 'ZRN' => 'Yeni Zaire Zairesi', 'NZD' => 'Yeni Zelanda Doları', 'ILS' => 'Yeni İsrail Şekeli', 'YUD' => 'Yugoslav Dinarı (Hard)', 'GRD' => 'Yunan Drahmisi', 'ZRZ' => 'Zaire Zairesi', 'ZMW' => 'Zambiya Kvaçası', 'ZMK' => 'Zambiya Kvaçası (1968–2012)', 'ZWD' => 'Zimbabve Doları', 'ZWR' => 'Zimbabve Doları (2008)', 'ZWL' => 'Zimbabve Doları (2009)', 'CZK' => 'Çek Cumhuriyeti Korunası', 'CSK' => 'Çekoslavak Korunası (Hard)', 'CNX' => 'Çin Halk Cumhuriyeti Merkez Bankası Doları', 'CNY' => 'Çin Yuanı', 'UZS' => 'Özbekistan Somu', 'JOD' => 'Ürdün Dinarı', 'GBP' => 'İngiliz Sterlini', 'IRR' => 'İran Riyali', 'IEP' => 'İrlanda Lirası', 'ESP' => 'İspanyol Pezetası', 'ESA' => 'İspanyol Pezetası (A hesabı)', 'ESB' => 'İspanyol Pezetası (konvertibl hesap)', 'ILP' => 'İsrail Lirası', 'ILR' => 'İsrail Şekeli (1980–1985)', 'SEK' => 'İsveç Kronu', 'CHF' => 'İsviçre Frangı', 'ITL' => 'İtalyan Lireti', 'YUR' => 'İyileştirilmiş Yugoslav Dinarı (1992–1993)', 'ISK' => 'İzlanda Kronu', 'ISJ' => 'İzlanda Kronu (1918–1981)', 'CLE' => 'Şili Esküdosu', 'CLP' => 'Şili Pesosu', 'CLF' => 'Şili Unidades de Fomento', );
{ "pile_set_name": "Github" }
// Protocol Buffers - Google's data interchange format // Copyright 2015 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. #import <Foundation/Foundation.h> #import "GPBRuntimeTypes.h" NS_ASSUME_NONNULL_BEGIN //%PDDM-EXPAND DECLARE_ARRAYS() // This block of code is generated, do not edit it directly. #pragma mark - Int32 /** * Class used for repeated fields of int32_t values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBInt32Array : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBInt32Array. **/ + (instancetype)array; /** * Creates and initializes a GPBInt32Array with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBInt32Array with value in it. **/ + (instancetype)arrayWithValue:(int32_t)value; /** * Creates and initializes a GPBInt32Array with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBInt32Array with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBInt32Array *)array; /** * Creates and initializes a GPBInt32Array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBInt32Array with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBInt32Array. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBInt32Array with a copy of the values. **/ - (instancetype)initWithValues:(const int32_t [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBInt32Array with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBInt32Array *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBInt32Array with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (int32_t)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(int32_t)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBInt32Array *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - UInt32 /** * Class used for repeated fields of uint32_t values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBUInt32Array : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBUInt32Array. **/ + (instancetype)array; /** * Creates and initializes a GPBUInt32Array with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBUInt32Array with value in it. **/ + (instancetype)arrayWithValue:(uint32_t)value; /** * Creates and initializes a GPBUInt32Array with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBUInt32Array with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBUInt32Array *)array; /** * Creates and initializes a GPBUInt32Array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBUInt32Array with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBUInt32Array. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBUInt32Array with a copy of the values. **/ - (instancetype)initWithValues:(const uint32_t [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBUInt32Array with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBUInt32Array *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBUInt32Array with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (uint32_t)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(uint32_t value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(uint32_t)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const uint32_t [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBUInt32Array *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(uint32_t)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint32_t)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - Int64 /** * Class used for repeated fields of int64_t values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBInt64Array : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBInt64Array. **/ + (instancetype)array; /** * Creates and initializes a GPBInt64Array with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBInt64Array with value in it. **/ + (instancetype)arrayWithValue:(int64_t)value; /** * Creates and initializes a GPBInt64Array with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBInt64Array with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBInt64Array *)array; /** * Creates and initializes a GPBInt64Array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBInt64Array with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBInt64Array. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBInt64Array with a copy of the values. **/ - (instancetype)initWithValues:(const int64_t [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBInt64Array with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBInt64Array *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBInt64Array with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (int64_t)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(int64_t value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(int64_t)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const int64_t [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBInt64Array *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(int64_t)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int64_t)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - UInt64 /** * Class used for repeated fields of uint64_t values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBUInt64Array : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBUInt64Array. **/ + (instancetype)array; /** * Creates and initializes a GPBUInt64Array with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBUInt64Array with value in it. **/ + (instancetype)arrayWithValue:(uint64_t)value; /** * Creates and initializes a GPBUInt64Array with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBUInt64Array with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBUInt64Array *)array; /** * Creates and initializes a GPBUInt64Array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBUInt64Array with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBUInt64Array. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBUInt64Array with a copy of the values. **/ - (instancetype)initWithValues:(const uint64_t [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBUInt64Array with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBUInt64Array *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBUInt64Array with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (uint64_t)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(uint64_t value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(uint64_t)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const uint64_t [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBUInt64Array *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(uint64_t)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(uint64_t)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - Float /** * Class used for repeated fields of float values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBFloatArray : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBFloatArray. **/ + (instancetype)array; /** * Creates and initializes a GPBFloatArray with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBFloatArray with value in it. **/ + (instancetype)arrayWithValue:(float)value; /** * Creates and initializes a GPBFloatArray with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBFloatArray with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBFloatArray *)array; /** * Creates and initializes a GPBFloatArray with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBFloatArray with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBFloatArray. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBFloatArray with a copy of the values. **/ - (instancetype)initWithValues:(const float [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBFloatArray with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBFloatArray *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBFloatArray with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (float)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(float value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(float)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const float [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBFloatArray *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(float)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(float)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - Double /** * Class used for repeated fields of double values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBDoubleArray : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBDoubleArray. **/ + (instancetype)array; /** * Creates and initializes a GPBDoubleArray with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBDoubleArray with value in it. **/ + (instancetype)arrayWithValue:(double)value; /** * Creates and initializes a GPBDoubleArray with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBDoubleArray with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBDoubleArray *)array; /** * Creates and initializes a GPBDoubleArray with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBDoubleArray with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBDoubleArray. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBDoubleArray with a copy of the values. **/ - (instancetype)initWithValues:(const double [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBDoubleArray with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBDoubleArray *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBDoubleArray with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (double)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(double value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(double)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const double [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBDoubleArray *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(double)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(double)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - Bool /** * Class used for repeated fields of BOOL values. This performs better than * boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBBoolArray : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** * @return A newly instanced and empty GPBBoolArray. **/ + (instancetype)array; /** * Creates and initializes a GPBBoolArray with the single element given. * * @param value The value to be placed in the array. * * @return A newly instanced GPBBoolArray with value in it. **/ + (instancetype)arrayWithValue:(BOOL)value; /** * Creates and initializes a GPBBoolArray with the contents of the given * array. * * @param array Array with the contents to be put into the new array. * * @return A newly instanced GPBBoolArray with the contents of array. **/ + (instancetype)arrayWithValueArray:(GPBBoolArray *)array; /** * Creates and initializes a GPBBoolArray with the given capacity. * * @param count The capacity needed for the array. * * @return A newly instanced GPBBoolArray with a capacity of count. **/ + (instancetype)arrayWithCapacity:(NSUInteger)count; /** * @return A newly initialized and empty GPBBoolArray. **/ - (instancetype)init NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBBoolArray with a copy of the values. **/ - (instancetype)initWithValues:(const BOOL [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBBoolArray with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBBoolArray *)array; /** * Initializes the array with the given capacity. * * @param count The capacity needed for the array. * * @return A newly initialized GPBBoolArray with a capacity of count. **/ - (instancetype)initWithCapacity:(NSUInteger)count; /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (BOOL)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(BOOL value, NSUInteger idx, BOOL *stop))block; /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(BOOL)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const BOOL [__nullable])values count:(NSUInteger)count; /** * Adds the values from the given array to this array. * * @param array The array containing the elements to add to this array. **/ - (void)addValuesFromArray:(GPBBoolArray *)array; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(BOOL)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(BOOL)value; /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end #pragma mark - Enum /** * This class is used for repeated fields of int32_t values. This performs * better than boxing into NSNumbers in NSArrays. * * @note This class is not meant to be subclassed. **/ @interface GPBEnumArray : NSObject <NSCopying> /** The number of elements contained in the array. */ @property(nonatomic, readonly) NSUInteger count; /** The validation function to check if the enums are valid. */ @property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; /** * @return A newly instanced and empty GPBEnumArray. **/ + (instancetype)array; /** * Creates and initializes a GPBEnumArray with the enum validation function * given. * * @param func The enum validation function for the array. * * @return A newly instanced GPBEnumArray. **/ + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; /** * Creates and initializes a GPBEnumArray with the enum validation function * given and the single raw value given. * * @param func The enum validation function for the array. * @param value The raw value to add to this array. * * @return A newly instanced GPBEnumArray. **/ + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func rawValue:(int32_t)value; /** * Creates and initializes a GPBEnumArray that adds the elements from the * given array. * * @param array Array containing the values to add to the new array. * * @return A newly instanced GPBEnumArray. **/ + (instancetype)arrayWithValueArray:(GPBEnumArray *)array; /** * Creates and initializes a GPBEnumArray with the given enum validation * function and with the givencapacity. * * @param func The enum validation function for the array. * @param count The capacity needed for the array. * * @return A newly instanced GPBEnumArray with a capacity of count. **/ + (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func capacity:(NSUInteger)count; /** * Initializes the array with the given enum validation function. * * @param func The enum validation function for the array. * * @return A newly initialized GPBEnumArray with a copy of the values. **/ - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func NS_DESIGNATED_INITIALIZER; /** * Initializes the array, copying the given values. * * @param func The enum validation function for the array. * @param values An array with the values to put inside this array. * @param count The number of elements to copy into the array. * * @return A newly initialized GPBEnumArray with a copy of the values. **/ - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func rawValues:(const int32_t [__nullable])values count:(NSUInteger)count; /** * Initializes the array, copying the given values. * * @param array An array with the values to put inside this array. * * @return A newly initialized GPBEnumArray with a copy of the values. **/ - (instancetype)initWithValueArray:(GPBEnumArray *)array; /** * Initializes the array with the given capacity. * * @param func The enum validation function for the array. * @param count The capacity needed for the array. * * @return A newly initialized GPBEnumArray with a capacity of count. **/ - (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func capacity:(NSUInteger)count; // These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a // valid enumerator as defined by validationFunc. If the actual value is // desired, use "raw" version of the method. /** * Gets the value at the given index. * * @param index The index of the value to get. * * @return The value at the given index. **/ - (int32_t)valueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; // These methods bypass the validationFunc to provide access to values that were not // known at the time the binary was compiled. /** * Gets the raw enum value at the given index. * * @param index The index of the raw enum value to get. * * @return The raw enum value at the given index. **/ - (int32_t)rawValueAtIndex:(NSUInteger)index; /** * Enumerates the values on this array with the given block. * * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; /** * Enumerates the values on this array with the given block. * * @param opts Options to control the enumeration. * @param block The block to enumerate with. * **value**: The current value being enumerated. * **idx**: The index of the current value. * **stop**: A pointer to a boolean that when set stops the enumeration. **/ - (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(int32_t value, NSUInteger idx, BOOL *stop))block; // If value is not a valid enumerator as defined by validationFunc, these // methods will assert in debug, and will log in release and assign the value // to the default value. Use the rawValue methods below to assign non enumerator // values. /** * Adds a value to this array. * * @param value The value to add to this array. **/ - (void)addValue:(int32_t)value; /** * Adds values to this array. * * @param values The values to add to this array. * @param count The number of elements to add. **/ - (void)addValues:(const int32_t [__nullable])values count:(NSUInteger)count; /** * Inserts a value into the given position. * * @param value The value to add to this array. * @param index The index into which to insert the value. **/ - (void)insertValue:(int32_t)value atIndex:(NSUInteger)index; /** * Replaces the value at the given index with the given value. * * @param index The index for which to replace the value. * @param value The value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withValue:(int32_t)value; // These methods bypass the validationFunc to provide setting of values that were not // known at the time the binary was compiled. /** * Adds a raw enum value to this array. * * @note This method bypass the validationFunc to enable the setting of values that * were not known at the time the binary was compiled. * * @param value The raw enum value to add to the array. **/ - (void)addRawValue:(int32_t)value; /** * Adds raw enum values to this array. * * @note This method bypass the validationFunc to enable the setting of values that * were not known at the time the binary was compiled. * * @param array Array containing the raw enum values to add to this array. **/ - (void)addRawValuesFromArray:(GPBEnumArray *)array; /** * Adds raw enum values to this array. * * @note This method bypass the validationFunc to enable the setting of values that * were not known at the time the binary was compiled. * * @param values Array containing the raw enum values to add to this array. * @param count The number of raw values to add. **/ - (void)addRawValues:(const int32_t [__nullable])values count:(NSUInteger)count; /** * Inserts a raw enum value at the given index. * * @note This method bypass the validationFunc to enable the setting of values that * were not known at the time the binary was compiled. * * @param value Raw enum value to add. * @param index The index into which to insert the value. **/ - (void)insertRawValue:(int32_t)value atIndex:(NSUInteger)index; /** * Replaces the raw enum value at the given index with the given value. * * @note This method bypass the validationFunc to enable the setting of values that * were not known at the time the binary was compiled. * * @param index The index for which to replace the value. * @param value The raw enum value to replace with. **/ - (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(int32_t)value; // No validation applies to these methods. /** * Removes the value at the given index. * * @param index The index of the value to remove. **/ - (void)removeValueAtIndex:(NSUInteger)index; /** * Removes all the values from this array. **/ - (void)removeAll; /** * Exchanges the values between the given indexes. * * @param idx1 The index of the first element to exchange. * @param idx2 The index of the second element to exchange. **/ - (void)exchangeValueAtIndex:(NSUInteger)idx1 withValueAtIndex:(NSUInteger)idx2; @end //%PDDM-EXPAND-END DECLARE_ARRAYS() NS_ASSUME_NONNULL_END //%PDDM-DEFINE DECLARE_ARRAYS() //%ARRAY_INTERFACE_SIMPLE(Int32, int32_t) //%ARRAY_INTERFACE_SIMPLE(UInt32, uint32_t) //%ARRAY_INTERFACE_SIMPLE(Int64, int64_t) //%ARRAY_INTERFACE_SIMPLE(UInt64, uint64_t) //%ARRAY_INTERFACE_SIMPLE(Float, float) //%ARRAY_INTERFACE_SIMPLE(Double, double) //%ARRAY_INTERFACE_SIMPLE(Bool, BOOL) //%ARRAY_INTERFACE_ENUM(Enum, int32_t) // // The common case (everything but Enum) // //%PDDM-DEFINE ARRAY_INTERFACE_SIMPLE(NAME, TYPE) //%#pragma mark - NAME //% //%/** //% * Class used for repeated fields of ##TYPE## values. This performs better than //% * boxing into NSNumbers in NSArrays. //% * //% * @note This class is not meant to be subclassed. //% **/ //%@interface GPB##NAME##Array : NSObject <NSCopying> //% //%/** The number of elements contained in the array. */ //%@property(nonatomic, readonly) NSUInteger count; //% //%/** //% * @return A newly instanced and empty GPB##NAME##Array. //% **/ //%+ (instancetype)array; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the single element given. //% * //% * @param value The value to be placed in the array. //% * //% * @return A newly instanced GPB##NAME##Array with value in it. //% **/ //%+ (instancetype)arrayWithValue:(TYPE)value; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the contents of the given //% * array. //% * //% * @param array Array with the contents to be put into the new array. //% * //% * @return A newly instanced GPB##NAME##Array with the contents of array. //% **/ //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the given capacity. //% * //% * @param count The capacity needed for the array. //% * //% * @return A newly instanced GPB##NAME##Array with a capacity of count. //% **/ //%+ (instancetype)arrayWithCapacity:(NSUInteger)count; //% //%/** //% * @return A newly initialized and empty GPB##NAME##Array. //% **/ //%- (instancetype)init NS_DESIGNATED_INITIALIZER; //% //%/** //% * Initializes the array, copying the given values. //% * //% * @param values An array with the values to put inside this array. //% * @param count The number of elements to copy into the array. //% * //% * @return A newly initialized GPB##NAME##Array with a copy of the values. //% **/ //%- (instancetype)initWithValues:(const TYPE [__nullable])values //% count:(NSUInteger)count; //% //%/** //% * Initializes the array, copying the given values. //% * //% * @param array An array with the values to put inside this array. //% * //% * @return A newly initialized GPB##NAME##Array with a copy of the values. //% **/ //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; //% //%/** //% * Initializes the array with the given capacity. //% * //% * @param count The capacity needed for the array. //% * //% * @return A newly initialized GPB##NAME##Array with a capacity of count. //% **/ //%- (instancetype)initWithCapacity:(NSUInteger)count; //% //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, Basic) //% //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, Basic) //% //%@end //% // // Macros specific to Enums (to tweak their interface). // //%PDDM-DEFINE ARRAY_INTERFACE_ENUM(NAME, TYPE) //%#pragma mark - NAME //% //%/** //% * This class is used for repeated fields of ##TYPE## values. This performs //% * better than boxing into NSNumbers in NSArrays. //% * //% * @note This class is not meant to be subclassed. //% **/ //%@interface GPB##NAME##Array : NSObject <NSCopying> //% //%/** The number of elements contained in the array. */ //%@property(nonatomic, readonly) NSUInteger count; //%/** The validation function to check if the enums are valid. */ //%@property(nonatomic, readonly) GPBEnumValidationFunc validationFunc; //% //%/** //% * @return A newly instanced and empty GPB##NAME##Array. //% **/ //%+ (instancetype)array; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the enum validation function //% * given. //% * //% * @param func The enum validation function for the array. //% * //% * @return A newly instanced GPB##NAME##Array. //% **/ //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the enum validation function //% * given and the single raw value given. //% * //% * @param func The enum validation function for the array. //% * @param value The raw value to add to this array. //% * //% * @return A newly instanced GPB##NAME##Array. //% **/ //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func //% rawValue:(TYPE)value; //% //%/** //% * Creates and initializes a GPB##NAME##Array that adds the elements from the //% * given array. //% * //% * @param array Array containing the values to add to the new array. //% * //% * @return A newly instanced GPB##NAME##Array. //% **/ //%+ (instancetype)arrayWithValueArray:(GPB##NAME##Array *)array; //% //%/** //% * Creates and initializes a GPB##NAME##Array with the given enum validation //% * function and with the givencapacity. //% * //% * @param func The enum validation function for the array. //% * @param count The capacity needed for the array. //% * //% * @return A newly instanced GPB##NAME##Array with a capacity of count. //% **/ //%+ (instancetype)arrayWithValidationFunction:(nullable GPBEnumValidationFunc)func //% capacity:(NSUInteger)count; //% //%/** //% * Initializes the array with the given enum validation function. //% * //% * @param func The enum validation function for the array. //% * //% * @return A newly initialized GPB##NAME##Array with a copy of the values. //% **/ //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func //% NS_DESIGNATED_INITIALIZER; //% //%/** //% * Initializes the array, copying the given values. //% * //% * @param func The enum validation function for the array. //% * @param values An array with the values to put inside this array. //% * @param count The number of elements to copy into the array. //% * //% * @return A newly initialized GPB##NAME##Array with a copy of the values. //% **/ //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func //% rawValues:(const TYPE [__nullable])values //% count:(NSUInteger)count; //% //%/** //% * Initializes the array, copying the given values. //% * //% * @param array An array with the values to put inside this array. //% * //% * @return A newly initialized GPB##NAME##Array with a copy of the values. //% **/ //%- (instancetype)initWithValueArray:(GPB##NAME##Array *)array; //% //%/** //% * Initializes the array with the given capacity. //% * //% * @param func The enum validation function for the array. //% * @param count The capacity needed for the array. //% * //% * @return A newly initialized GPB##NAME##Array with a capacity of count. //% **/ //%- (instancetype)initWithValidationFunction:(nullable GPBEnumValidationFunc)func //% capacity:(NSUInteger)count; //% //%// These will return kGPBUnrecognizedEnumeratorValue if the value at index is not a //%// valid enumerator as defined by validationFunc. If the actual value is //%// desired, use "raw" version of the method. //% //%ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, NAME) //% //%// These methods bypass the validationFunc to provide access to values that were not //%// known at the time the binary was compiled. //% //%/** //% * Gets the raw enum value at the given index. //% * //% * @param index The index of the raw enum value to get. //% * //% * @return The raw enum value at the given index. //% **/ //%- (TYPE)rawValueAtIndex:(NSUInteger)index; //% //%/** //% * Enumerates the values on this array with the given block. //% * //% * @param block The block to enumerate with. //% * **value**: The current value being enumerated. //% * **idx**: The index of the current value. //% * **stop**: A pointer to a boolean that when set stops the enumeration. //% **/ //%- (void)enumerateRawValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; //% //%/** //% * Enumerates the values on this array with the given block. //% * //% * @param opts Options to control the enumeration. //% * @param block The block to enumerate with. //% * **value**: The current value being enumerated. //% * **idx**: The index of the current value. //% * **stop**: A pointer to a boolean that when set stops the enumeration. //% **/ //%- (void)enumerateRawValuesWithOptions:(NSEnumerationOptions)opts //% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; //% //%// If value is not a valid enumerator as defined by validationFunc, these //%// methods will assert in debug, and will log in release and assign the value //%// to the default value. Use the rawValue methods below to assign non enumerator //%// values. //% //%ARRAY_MUTABLE_INTERFACE(NAME, TYPE, NAME) //% //%@end //% //%PDDM-DEFINE ARRAY_IMMUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) //%/** //% * Gets the value at the given index. //% * //% * @param index The index of the value to get. //% * //% * @return The value at the given index. //% **/ //%- (TYPE)valueAtIndex:(NSUInteger)index; //% //%/** //% * Enumerates the values on this array with the given block. //% * //% * @param block The block to enumerate with. //% * **value**: The current value being enumerated. //% * **idx**: The index of the current value. //% * **stop**: A pointer to a boolean that when set stops the enumeration. //% **/ //%- (void)enumerateValuesWithBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; //% //%/** //% * Enumerates the values on this array with the given block. //% * //% * @param opts Options to control the enumeration. //% * @param block The block to enumerate with. //% * **value**: The current value being enumerated. //% * **idx**: The index of the current value. //% * **stop**: A pointer to a boolean that when set stops the enumeration. //% **/ //%- (void)enumerateValuesWithOptions:(NSEnumerationOptions)opts //% usingBlock:(void (NS_NOESCAPE ^)(TYPE value, NSUInteger idx, BOOL *stop))block; //%PDDM-DEFINE ARRAY_MUTABLE_INTERFACE(NAME, TYPE, HELPER_NAME) //%/** //% * Adds a value to this array. //% * //% * @param value The value to add to this array. //% **/ //%- (void)addValue:(TYPE)value; //% //%/** //% * Adds values to this array. //% * //% * @param values The values to add to this array. //% * @param count The number of elements to add. //% **/ //%- (void)addValues:(const TYPE [__nullable])values count:(NSUInteger)count; //% //%ARRAY_EXTRA_MUTABLE_METHODS1_##HELPER_NAME(NAME, TYPE) //%/** //% * Inserts a value into the given position. //% * //% * @param value The value to add to this array. //% * @param index The index into which to insert the value. //% **/ //%- (void)insertValue:(TYPE)value atIndex:(NSUInteger)index; //% //%/** //% * Replaces the value at the given index with the given value. //% * //% * @param index The index for which to replace the value. //% * @param value The value to replace with. //% **/ //%- (void)replaceValueAtIndex:(NSUInteger)index withValue:(TYPE)value; //%ARRAY_EXTRA_MUTABLE_METHODS2_##HELPER_NAME(NAME, TYPE) //%/** //% * Removes the value at the given index. //% * //% * @param index The index of the value to remove. //% **/ //%- (void)removeValueAtIndex:(NSUInteger)index; //% //%/** //% * Removes all the values from this array. //% **/ //%- (void)removeAll; //% //%/** //% * Exchanges the values between the given indexes. //% * //% * @param idx1 The index of the first element to exchange. //% * @param idx2 The index of the second element to exchange. //% **/ //%- (void)exchangeValueAtIndex:(NSUInteger)idx1 //% withValueAtIndex:(NSUInteger)idx2; // // These are hooks invoked by the above to do insert as needed. // //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Basic(NAME, TYPE) //%/** //% * Adds the values from the given array to this array. //% * //% * @param array The array containing the elements to add to this array. //% **/ //%- (void)addValuesFromArray:(GPB##NAME##Array *)array; //% //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Basic(NAME, TYPE) // Empty //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS1_Enum(NAME, TYPE) // Empty //%PDDM-DEFINE ARRAY_EXTRA_MUTABLE_METHODS2_Enum(NAME, TYPE) //% //%// These methods bypass the validationFunc to provide setting of values that were not //%// known at the time the binary was compiled. //% //%/** //% * Adds a raw enum value to this array. //% * //% * @note This method bypass the validationFunc to enable the setting of values that //% * were not known at the time the binary was compiled. //% * //% * @param value The raw enum value to add to the array. //% **/ //%- (void)addRawValue:(TYPE)value; //% //%/** //% * Adds raw enum values to this array. //% * //% * @note This method bypass the validationFunc to enable the setting of values that //% * were not known at the time the binary was compiled. //% * //% * @param array Array containing the raw enum values to add to this array. //% **/ //%- (void)addRawValuesFromArray:(GPB##NAME##Array *)array; //% //%/** //% * Adds raw enum values to this array. //% * //% * @note This method bypass the validationFunc to enable the setting of values that //% * were not known at the time the binary was compiled. //% * //% * @param values Array containing the raw enum values to add to this array. //% * @param count The number of raw values to add. //% **/ //%- (void)addRawValues:(const TYPE [__nullable])values count:(NSUInteger)count; //% //%/** //% * Inserts a raw enum value at the given index. //% * //% * @note This method bypass the validationFunc to enable the setting of values that //% * were not known at the time the binary was compiled. //% * //% * @param value Raw enum value to add. //% * @param index The index into which to insert the value. //% **/ //%- (void)insertRawValue:(TYPE)value atIndex:(NSUInteger)index; //% //%/** //% * Replaces the raw enum value at the given index with the given value. //% * //% * @note This method bypass the validationFunc to enable the setting of values that //% * were not known at the time the binary was compiled. //% * //% * @param index The index for which to replace the value. //% * @param value The raw enum value to replace with. //% **/ //%- (void)replaceValueAtIndex:(NSUInteger)index withRawValue:(TYPE)value; //% //%// No validation applies to these methods. //%
{ "pile_set_name": "Github" }
grant { permission java.security.AllPermission; };
{ "pile_set_name": "Github" }
#include QMK_KEYBOARD_H const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_all( KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_ENT, KC_LSFT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(1), KC_RCTL), [1] = LAYOUT_all( RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), [2] = LAYOUT_all( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), [3] = LAYOUT_all( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS) };
{ "pile_set_name": "Github" }
#include "downloadthreadabstract.h" #include "downloadsettingmanager.h" #include <QNetworkAccessManager> #include <QNetworkRequest> #include <QThread> #if defined Q_OS_UNIX || defined Q_CC_MINGW # include <unistd.h> #endif #include <QSslError> DownLoadThreadAbstract::DownLoadThreadAbstract(const QString &url, const QString &save, QObject *parent) : DownloadNetworkAbstract(parent) { m_url = url; m_savePathName = save; m_hasReceived = 0; m_currentReceived = 0; if(QFile::exists(save)) { QFile::remove(save); } m_file = new QFile(save, this); m_timer.setInterval(MT_S2MS); connect(&m_timer, SIGNAL(timeout()), SLOT(updateDownloadSpeed())); } DownLoadThreadAbstract::~DownLoadThreadAbstract() { } void DownLoadThreadAbstract::deleteAll() { DownloadNetworkAbstract::deleteAll(); if(m_file) { delete m_file; m_file = nullptr; } deleteLater(); } void DownLoadThreadAbstract::replyError(QNetworkReply::NetworkError) { TTK_LOGGER_ERROR("Abnormal network connection"); emit downLoadDataChanged("The file create failed"); deleteAll(); } #ifndef QT_NO_SSL void DownLoadThreadAbstract::sslErrors(QNetworkReply* reply, const QList<QSslError> &errors) { sslErrorsString(reply, errors); emit downLoadDataChanged("The file create failed"); deleteAll(); } #endif void DownLoadThreadAbstract::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { m_currentReceived = bytesReceived; m_totalSize = bytesTotal; } void DownLoadThreadAbstract::updateDownloadSpeed() { int delta = m_currentReceived - m_hasReceived; ////////////////////////////////////// ///limit speed if(M_SETTING_PTR->value(DownloadSettingManager::DownloadLimitChoiced).toInt() == 0) { int limitValue = M_SETTING_PTR->value(DownloadSettingManager::DownloadDLoadLimitChoiced).toInt(); if(limitValue != 0 && delta > limitValue*MH_KB) { #if defined Q_OS_WIN && defined TTK_GREATER_NEW QThread::msleep(MT_S2MS - limitValue*MH_KB*MT_S2MS/delta); #else usleep((MT_S2MS - limitValue*MH_KB*MT_S2MS/delta)*MT_S2MS); #endif delta = limitValue*MH_KB; } } ////////////////////////////////////// m_hasReceived = m_currentReceived; }
{ "pile_set_name": "Github" }
Keymaker: Lightweight SSH key management on AWS EC2 =================================================== Keymaker is **the missing link between SSH and IAM accounts on Amazon AWS**. It's a stateless synchronization engine that securely manages the process of SSH public key sharing and verification, user and group synchronization, and home directory sharing (via optional `EFS <https://aws.amazon.com/efs/>`_ integration). You, the AWS account administrator, define or import user and group identities in IAM, and instances in your account dynamically retrieve and use those identities to authenticate your users. Keymaker is the modern, minimalistic alternative to **LDAP** or **Active Directory** authentication. Installation ------------ Run ``pip install keymaker``. On instances that accept SSH logins: - Run ``keymaker install``. - Ensure processes launched by sshd have the IAM permissions ``iam:GetSSHPublicKey``, ``iam:ListSSHPublicKeys``, ``iam:GetUser``, ``iam:ListGroups``, ``iam:GetGroup``, ``iam:ListGroupsForUser``, ``iam:GetRole``, and ``sts:GetCallerIdentity``. The easiest way to do this is by running ``keymaker configure --instance-iam-role INSTANCE_ROLE`` as a privileged IAM user, which will create and attach a Keymaker IAM policy to the role ``INSTANCE_ROLE`` (which you should then assign, via an IAM Instance Profile, to any instances you launch). You can also manually configure these permissions, or attach the IAMReadOnlyAccess managed policy. Keymaker requires OpenSSH v6.2+, provided by Ubuntu 14.04+ and RHEL7+. Usage ----- Run ``keymaker`` with no arguments to get usage information. In client mode (running on a computer that you will connect from), you can run ``keymaker <subcommand>``, where subcommand is:: upload_key Upload public SSH key for a user. Run this command for each user who will be accessing EC2 hosts. list_keys Get public SSH keys for a given or current IAM/SSH user. disable_key Disable a given public SSH key for a given or current IAM/SSH user. enable_key Enable a given public SSH key for a given or current IAM/SSH user. delete_key Delete a given public SSH key for a given or current IAM/SSH user. configure Perform administrative configuration tasks on the current AWS account. Use ``keymaker <subcommand> --help`` to get a full description and list of options for each command. Principle of operation ---------------------- Amazon Web Services `IAM <https://aws.amazon.com/iam/>`_ user accounts provide the ability to add SSH public keys to their metadata (up to 5 keys can be added; individual keys can be disabled). Keymaker uses this metadata to authenticate SSH logins. Keymaker provides an integrated way for a user to upload their public SSH key to their IAM account with ``keymaker upload_key``. Run ``keymaker install`` on instances that you want your users to connect to. This installs three components: * An ``AuthorizedKeysCommand`` sshd configuration directive, which acts as a login event hook and dynamically retrieves public SSH keys from IAM for the user logging in, using the default `boto3 <https://github.com/boto/boto3>`_ credentials (which default to the instance's IAM role credentials). * A ``pam_exec`` PAM configuration directive, which causes sshd to call ``keymaker-create-account-for-iam-user`` early in the login process. This script detects if a Linux user account does not exist for the authenticating principal but an authorized IAM account exists with the same name, and creates the account on demand. The UID of the account is computed from a hash of the user's SSH key, making it stable across instances that run Keymaker. * A `cron job <https://en.wikipedia.org/wiki/Cron>`_ that runs on your instance once an hour and synchronizes IAM group membership information. Only IAM groups whose names start with a configurable prefix (by default, ``keymaker_*``) are synchronized as Linux groups. As a result, users who connect to your instances over SSH are given access based on information centralized in your AWS account. Users must have an active IAM account with active matching SSH public keys in order for authentication to succeed. Users' UIDs and group memberships are also synchronized across your instances, so any UID-based checks or group-based privileges remain current as well. Cross-account authentication ---------------------------- Some AWS security models put IAM users in one AWS account, and resources (EC2 instances, S3 buckets, etc.) in a family of other federated AWS accounts (for example, a dev account and a prod account). Users then assume roles in those federated accounts, subject to their permissions, with `sts:AssumeRole <http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html>`_. When users connect via SSH to instances running in federated accounts, Keymaker can be instructed to look up the user identity and SSH public key in the other AWS account (called the "ID resolver" account). Keymaker expects to find this configuration information by introspecting the instance's own IAM role description. The description is expected to contain a list of space-separated config tokens, for example, ``keymaker_id_resolver_account=123456789012 keymaker_id_resolver_iam_role=id_resolver``. For ``sts:AssumeRole`` to work, the role ``id_resolver`` in account 123456789012 is expected to have a trust policy allowing the instance's IAM role to perform sts:AssumeRole on ``id_resolver``. Run the following command in the ID resolver account (that contains the IAM users) to apply this configuration automatically: ``keymaker configure --instance-iam-role arn:aws:iam::987654321098:role/INSTANCE_ROLE --cross-account-profile AWS_CLI_PROFILE_NAME``. Here, 987654321098 is the account ID of the federated account where EC2 instances will run, and AWS_CLI_PROFILE_NAME is the name of the `AWS CLI role profile <http://docs.aws.amazon.com/cli/latest/userguide/cli-roles.html>`_ that you have set up to access the federated account. Requiring IAM group membership ------------------------------ Group membership is asserted if the instance's IAM role description contains the config token ``keymaker_require_iam_group=prod_ssh_users``. The user logging in is then required to be a member of the **prod_ssh_users** IAM group. Apply this configuration automatically by running ``keymaker configure --require-iam-group IAM_GROUP_NAME``. Security considerations ----------------------- Integrating IAM user identities with Unix user identities has implications for your security threat model. With Keymaker, a principal with the ability to set SSH public keys on an IAM user account can impersonate that user when logging in to an EC2 instance. As an example, this can expand the scope of a compromised AWS secret key. You can mitigate this threat with an IAM policy restricting access to the `UploadSSHPublicKey <http://docs.aws.amazon.com/IAM/latest/APIReference/API_UploadSSHPublicKey.html>`_ method. FAQ --- **Does running Keymaker require root access?** The answer depends on what you mean by "running Keymaker". - To install keymaker into the sshd config and crontab (keymaker install), you need access to those daemons' config files, which normally means you need root access. - The keymaker authorization hook (runs when sshd logs you in) does not need root access. - None of the client-side commands (listed under "Usage" above) need root access. EFS integration --------------- Email kislyuk@gmail.com for details on the EFS integration. Authors ------- * Andrey Kislyuk Links ----- * `Project home page (GitHub) <https://github.com/kislyuk/keymaker>`_ * `Documentation (Read the Docs) <https://keymaker.readthedocs.io/en/latest/>`_ * `Package distribution (PyPI) <https://pypi.python.org/pypi/keymaker>`_ Bugs ~~~~ Please report bugs, issues, feature requests, etc. on `GitHub <https://github.com/kislyuk/keymaker/issues>`_. License ------- Licensed under the terms of the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_. .. image:: https://travis-ci.org/kislyuk/keymaker.svg :target: https://travis-ci.org/kislyuk/keymaker .. image:: https://coveralls.io/repos/kislyuk/keymaker/badge.svg?branch=master :target: https://coveralls.io/r/kislyuk/keymaker?branch=master .. image:: https://img.shields.io/pypi/v/keymaker.svg :target: https://pypi.python.org/pypi/keymaker .. image:: https://img.shields.io/pypi/l/keymaker.svg :target: https://pypi.python.org/pypi/keymaker .. image:: https://readthedocs.org/projects/keymaker/badge/?version=latest :target: https://keymaker.readthedocs.io/
{ "pile_set_name": "Github" }
/****************************************************************************/ // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo // Copyright (C) 2001-2020 German Aerospace Center (DLR) and others. // This program and the accompanying materials are made available under the // terms of the Eclipse Public License 2.0 which is available at // https://www.eclipse.org/legal/epl-2.0/ // This Source Code may also be made available under the following Secondary // Licenses when the conditions for such availability set forth in the Eclipse // Public License 2.0 are satisfied: GNU General Public License, version 2 // or later which is available at // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later /****************************************************************************/ /// @file GUIContainer.h /// @author Melanie Weber /// @author Andreas Kendziorra /// @date Wed, 01.08.2014 /// // A MSVehicle extended by some values for usage within the gui /****************************************************************************/ #pragma once #include <config.h> #include <vector> #include <set> #include <string> #include <fx.h> #include <utils/gui/globjects/GUIGlObject.h> #include <utils/common/RGBColor.h> #include <microsim/transportables/MSTransportable.h> #include <utils/gui/globjects/GUIGLObjectPopupMenu.h> #include <utils/gui/settings/GUIPropertySchemeStorage.h> #include "GUIBaseVehicle.h" // =========================================================================== // class declarations // =========================================================================== class GUISUMOAbstractView; class GUIGLObjectPopupMenu; class MSDevice_Vehroutes; // =========================================================================== // class definitions // =========================================================================== /** * @class GUIContainer */ class GUIContainer : public MSTransportable, public GUIGlObject { public: /** @brief Constructor */ GUIContainer(const SUMOVehicleParameter* pars, MSVehicleType* vtype, MSTransportable::MSTransportablePlan* plan); /// @brief destructor ~GUIContainer(); /// @name inherited from GUIGlObject //@{ /** @brief Returns an own popup-menu * * @param[in] app The application needed to build the popup-menu * @param[in] parent The parent window needed to build the popup-menu * @return The built popup-menu * @see GUIGlObject::getPopUpMenu */ GUIGLObjectPopupMenu* getPopUpMenu(GUIMainWindow& app, GUISUMOAbstractView& parent); /** @brief Returns an own parameter window * * @param[in] app The application needed to build the parameter window * @param[in] parent The parent window needed to build the parameter window * @return The built parameter window * @see GUIGlObject::getParameterWindow */ GUIParameterTableWindow* getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent); /** @brief Returns an own type parameter window * * @param[in] app The application needed to build the parameter window * @param[in] parent The parent window needed to build the parameter window * @return The built parameter window */ GUIParameterTableWindow* getTypeParameterWindow(GUIMainWindow& app, GUISUMOAbstractView& parent); /** @brief Returns the boundary to which the view shall be centered in order to show the object * * @return The boundary the object is within * @see GUIGlObject::getCenteringBoundary */ Boundary getCenteringBoundary() const; /** @brief Draws the object * @param[in] s The settings for the current view (may influence drawing) * @see GUIGlObject::drawGL */ void drawGL(const GUIVisualizationSettings& s) const; /** @brief Draws additionally triggered visualisations * @param[in] parent The view * @param[in] s The settings for the current view (may influence drawing) */ virtual void drawGLAdditional(GUISUMOAbstractView* const parent, const GUIVisualizationSettings& s) const; //@} /* @brief set the position of a container while being transported by a vehicle * @note This must be called by the vehicle before the call to drawGl */ void setPositionInVehicle(const GUIBaseVehicle::Seat& pos) { myPositionInVehicle = pos; } /// @name inherited from MSContainer with added locking //@{ /// @brief return the offset from the start of the current edge double getEdgePos() const; /// @brief return the Network coordinate of the container // @note overrides the base method and returns myPositionInVehicle while in driving stage Position getPosition() const; /// @brief return the current angle of the container double getAngle() const; /// @brief the time this container spent waiting in seconds double getWaitingSeconds() const; /// @brief the current speed of the container double getSpeed() const; //@} /** * @class GUIContainerPopupMenu * * A popup-menu for vehicles. In comparison to the normal popup-menu, this one * also allows to trigger further visualisations and to track the vehicle. */ class GUIContainerPopupMenu : public GUIGLObjectPopupMenu { FXDECLARE(GUIContainerPopupMenu) public: /** @brief Constructor * @param[in] app The main window for instantiation of other windows * @param[in] parent The parent view for changing it * @param[in] o The object of interest */ GUIContainerPopupMenu(GUIMainWindow& app, GUISUMOAbstractView& parent, GUIGlObject& o); /// @brief Destructor ~GUIContainerPopupMenu(); /// @brief Called if the plan shall be shown long onCmdShowPlan(FXObject*, FXSelector, void*); /// @brief Called if the person shall be tracked long onCmdStartTrack(FXObject*, FXSelector, void*); /// @brief Called if the person shall not be tracked any longer long onCmdStopTrack(FXObject*, FXSelector, void*); protected: /// @brief default constructor needed by FOX FOX_CONSTRUCTOR(GUIContainerPopupMenu) }; /// @brief Enabled visualisations, per view std::map<GUISUMOAbstractView*, int> myAdditionalVisualizations; private: /// The mutex used to avoid concurrent updates of the vehicle buffer mutable FXMutex myLock; /// The position of a container while riding a vehicle GUIBaseVehicle::Seat myPositionInVehicle; /// @brief sets the color according to the currente settings void setColor(const GUIVisualizationSettings& s) const; /// @brief gets the color value according to the current scheme index double getColorValue(const GUIVisualizationSettings& s, int activeScheme) const; /// @brief sets the color according to the current scheme index and some vehicle function bool setFunctionalColor(int activeScheme) const; /// @name drawing helper methods /// @{ void drawAction_drawAsPoly(const GUIVisualizationSettings& s) const; void drawAction_drawAsImage(const GUIVisualizationSettings& s) const; /// @} };
{ "pile_set_name": "Github" }
#!/usr/bin/env python # -*- coding: utf-8 -*- # # @author jiehua233@gmail.com # @site https://chenjiehua.me # @date 2016-09-06 # """proxy ip example """ import csv import random import requests retrymax = 3 timeout = 30 proxycsv = "proxyip.csv" target = "http://www.baidu.com" def main(): total_weight, proxyip = load_proxyip(proxycsv) for i in range(retrymax): ip = get_proxyip(total_weight, proxyip) print "Using proxy:", ip try: r = requests.get(target, proxies={"http": "http://" + ip}, timeout=timeout) print "Http resp code:", r.status_code break except Exception as e: print e def load_proxyip(fpath): """ proxyip list with weight """ total_weight, proxyip = 0, [] with open(fpath) as f: csvreader = csv.DictReader(f, restval=0, delimiter=",", quotechar="\"", quoting=csv.QUOTE_MINIMAL) for row in csvreader: ip = row["ip"] + ":" + row["port"] weight = 1/float(row["speed"]) total_weight += weight proxyip.append((ip, weight)) return total_weight, proxyip def get_proxyip(total_weight, proxyip): r = random.uniform(0, total_weight) upto = 0 for ip, weight in proxyip: if upto + weight >= r: return ip upto += weight print "Error: total_weight=%s, random_weight=%s" % (total_weight, r) return "localhost:8888" if __name__ == "__main__": main()
{ "pile_set_name": "Github" }
management.endpoints.web.exposure.include: health,info,bindings spring.cloud.stream.function.definition: toUpperCase spring.cloud.stream.function.bindings.toUpperCase-in-0: input spring.cloud.stream.function.bindings.toUpperCase-out-0: output
{ "pile_set_name": "Github" }
:fa:`puzzle-piece` Maintainability ================================== A program is **maintainable** if it is easy to understand and modify the code even for someone that is unfamiliar with the code base. Avoid the following anti-patterns to increase maintainability and avoid creating `spaghetti code`. .. toctree:: :maxdepth: 1 from_module_import_all_used not_using_with_to_open_files returning_more_than_one_variable_type_from_function_call using_the_global_statement using_single_letter_as_variable_name dynamically_creating_names
{ "pile_set_name": "Github" }
precision mediump float; varying vec4 vertex_color; varying vec2 vTextureCoord; uniform sampler2D uSampler; // default is 0, so we don't have to set it void main(void) { vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); gl_FragColor = vec4(vTextureCoord.s, vTextureCoord.t, 0, 1); gl_FragColor = textureColor; gl_FragColor = vec4(0., 1., 0., 1.); }
{ "pile_set_name": "Github" }
<?php require_once('require/class.Connection.php'); require_once('require/class.Spotter.php'); require_once('require/class.Stats.php'); require_once('require/class.Language.php'); if (!isset($_GET['airport'])) { header('Location: '.$globalURL.'/airport'); die(); } $Spotter = new Spotter(); $airport = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING); $airport_array = $Spotter->getAllAirportInfo($airport); if (!empty($airport_array)) { //$spotter_array = $Spotter->getSpotterDataByAirport($airport,"0,1",""); $title = sprintf(_("Most Common Aircraft to/from %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']); require_once('header.php'); print '<div class="select-item">'; print '<form action="'.$globalURL.'/airport" method="post">'; print '<select name="airport" class="selectpicker" data-live-search="true">'; print '<option></option>'; $Stats = new Stats(); $airport_names = $Stats->getAllAirportNames(); if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames(); ksort($airport_names); foreach($airport_names as $airport_name) { if($airport == $airport_name['airport_icao']) { print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>'; } else { print '<option value="'.$airport_name['airport_icao'].'">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>'; } } print '</select>'; print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; print '</form>'; print '</div>'; print '<br />'; if ($airport != "NA") { print '<div class="info column">'; print '<h1>'.$airport_array[0]['city'].', '.$airport_array[0]['name'].' ('.$airport_array[0]['icao'].')</h1>'; print '<div><span class="label">'._("Name").'</span>'.$airport_array[0]['name'].'</div>'; print '<div><span class="label">'._("City").'</span>'.$airport_array[0]['city'].'</div>'; print '<div><span class="label">'._("Country").'</span>'.$airport_array[0]['country'].'</div>'; print '<div><span class="label">'._("ICAO").'</span>'.$airport_array[0]['icao'].'</div>'; print '<div><span class="label">'._("IATA").'</span>'.$airport_array[0]['iata'].'</div>'; print '<div><span class="label">'._("Altitude").'</span>'.$airport_array[0]['altitude'].'</div>'; print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>'; print '</div>'; } else { print '<div class="alert alert-warning">'._("This special airport profile shows all flights that do <u>not</u> have a departure and/or arrival airport associated with them.").'</div>'; } include('airport-sub-menu.php'); print '<div class="column">'; print '<h2>'._("Most Common Aircraft").'</h2>'; print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>'; $aircraft_array = $Spotter->countAllAircraftTypesByAirport($airport); if (!empty($aircraft_array)) { print '<div class="table-responsive">'; print '<table class="common-type table-striped">'; print '<thead>'; print '<th></th>'; print '<th>'._("Aircraft Type").'</th>'; print '<th>'._("# of times").'</th>'; print '<th></th>'; print '</thead>'; print '<tbody>'; $i = 1; foreach($aircraft_array as $aircraft_item) { print '<tr>'; print '<td><strong>'.$i.'</strong></td>'; print '<td>'; print '<a href="'.$globalURL.'/aircraft/'.$aircraft_item['aircraft_icao'].'">'.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')</a>'; print '</td>'; print '<td>'; print $aircraft_item['aircraft_icao_count']; print '</td>'; print '<td><a href="'.$globalURL.'/search?aircraft='.$aircraft_item['aircraft_icao'].'&airport='.$airport.'">'._("Search flights").'</a></td>'; print '</tr>'; $i++; } print '<tbody>'; print '</table>'; print '</div>'; } print '</div>'; } else { $title = _("Airport"); require_once('header.php'); print '<h1>'._("Error").'</h1>'; print '<p>'._("Sorry, the airport does not exist in this database. :(").'</p>'; } require_once('footer.php'); ?>
{ "pile_set_name": "Github" }
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package unix func itoa(val int) string { // do it here rather than with fmt to avoid dependency if val < 0 { return "-" + uitoa(uint(-val)) } return uitoa(uint(val)) } func uitoa(val uint) string { var buf [32]byte // big enough for int64 i := len(buf) - 1 for val >= 10 { buf[i] = byte(val%10 + '0') i-- val /= 10 } buf[i] = byte(val + '0') return string(buf[i:]) }
{ "pile_set_name": "Github" }
// this file can either be read and passed to an OpenCL compiler directly, // or included in a C++11 source file as a string literal #ifndef __OPENCL_VERSION__ // If we are including this file in C++, // the entire source file following (except the last #endif) will become // a raw string literal. The extra ")" is just for mathcing parentheses // to make the editor happy. The extra ")" and extra endif will be skipped. // DO NOT add anything between here and the next #ifdef, otherwise you need // to modify the skip count at the end of this file. R""() #endif #ifndef _HISTOGRAM_16_KERNEL_ #define _HISTOGRAM_16_KERNEL_ #pragma OPENCL EXTENSION cl_khr_local_int32_base_atomics : enable #pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable // Configurable options: // NUM_BANKS should be a power of 2 #ifndef NUM_BANKS #define NUM_BANKS 8 #endif // how many bits in thread ID represent the bank = log2(NUM_BANKS) #ifndef BANK_BITS #define BANK_BITS 3 #endif // use double precision or not #ifndef USE_DP_FLOAT #define USE_DP_FLOAT 0 #endif // ignore hessian, and use the local memory for hessian as an additional bank for gradient #ifndef CONST_HESSIAN #define CONST_HESSIAN 0 #endif #define LOCAL_SIZE_0 256 #define NUM_BINS 16 // if USE_DP_FLOAT is set to 1, we will use double precision for the accumulator #if USE_DP_FLOAT == 1 #pragma OPENCL EXTENSION cl_khr_fp64 : enable #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable typedef double acc_type; typedef ulong acc_int_type; #define as_acc_type as_double #define as_acc_int_type as_ulong #else typedef float acc_type; typedef uint acc_int_type; #define as_acc_type as_float #define as_acc_int_type as_uint #endif // number of features to process in a 4-byte feature tuple #define DWORD_FEATURES 8 // number of bits per feature #define FEATURE_BITS (sizeof(uchar4) * 8 / DWORD_FEATURES) // bit mask for number of features to process in a 4-byte feature tuple #define DWORD_FEATURES_MASK (DWORD_FEATURES - 1) // log2 of number of features to process in a 4-byte feature tuple #define LOG2_DWORD_FEATURES 3 // mask for getting the bank ID #define BANK_MASK (NUM_BANKS - 1) // 8 features, each has a gradient and a hessian #define HG_BIN_MULT (NUM_BANKS * DWORD_FEATURES * 2) // 8 features, each has a counter #define CNT_BIN_MULT (NUM_BANKS * DWORD_FEATURES) // local memory size in bytes #define LOCAL_MEM_SIZE (DWORD_FEATURES * (sizeof(uint) + 2 * sizeof(acc_type)) * NUM_BINS * NUM_BANKS) // unroll the atomic operation for a few times. Takes more code space, // but compiler can generate better code for faster atomics. #define UNROLL_ATOMIC 1 // Options passed by compiler at run time: // IGNORE_INDICES will be set when the kernel does not // #define IGNORE_INDICES // #define POWER_FEATURE_WORKGROUPS 10 // use all features and do not use feature mask #ifndef ENABLE_ALL_FEATURES #define ENABLE_ALL_FEATURES 1 #endif // detect Nvidia platforms #ifdef cl_nv_pragma_unroll #define NVIDIA 1 #endif // use binary patching for AMD GCN 1.2 or newer #ifndef AMD_USE_DS_ADD_F32 #define AMD_USE_DS_ADD_F32 0 #endif typedef uint data_size_t; typedef float score_t; #define ATOMIC_FADD_SUB1 { \ expected.f_val = current.f_val; \ next.f_val = expected.f_val + val; \ current.u_val = atom_cmpxchg((volatile __local acc_int_type *)addr, expected.u_val, next.u_val); \ if (current.u_val == expected.u_val) \ goto end; \ } #define ATOMIC_FADD_SUB2 ATOMIC_FADD_SUB1 \ ATOMIC_FADD_SUB1 #define ATOMIC_FADD_SUB4 ATOMIC_FADD_SUB2 \ ATOMIC_FADD_SUB2 #define ATOMIC_FADD_SUB8 ATOMIC_FADD_SUB4 \ ATOMIC_FADD_SUB4 #define ATOMIC_FADD_SUB16 ATOMIC_FADD_SUB8 \ ATOMIC_FADD_SUB8 #define ATOMIC_FADD_SUB32 ATOMIC_FADD_SUB16\ ATOMIC_FADD_SUB16 #define ATOMIC_FADD_SUB64 ATOMIC_FADD_SUB32\ ATOMIC_FADD_SUB32 // atomic add for float number in local memory inline void atomic_local_add_f(__local acc_type *addr, const float val) { union{ acc_int_type u_val; acc_type f_val; } next, expected, current; #if (NVIDIA == 1 && USE_DP_FLOAT == 0) float res = 0; asm volatile ("atom.shared.add.f32 %0, [%1], %2;" : "=f"(res) : "l"(addr), "f"(val)); #elif (AMD_USE_DS_ADD_F32 == 1 && USE_DP_FLAT == 0) // this instruction (DS_AND_U32) will be patched into a DS_ADD_F32 // we need to hack here because DS_ADD_F32 is not exposed via OpenCL atom_and((__local acc_int_type *)addr, as_acc_int_type(val)); #else current.f_val = *addr; #if UNROLL_ATOMIC == 1 // provide a fast path // then do the complete loop // this should work on all devices ATOMIC_FADD_SUB8 ATOMIC_FADD_SUB4 #endif do { expected.f_val = current.f_val; next.f_val = expected.f_val + val; current.u_val = atom_cmpxchg((volatile __local acc_int_type *)addr, expected.u_val, next.u_val); } while (current.u_val != expected.u_val); end: ; #endif } /* Makes MSVC happy with long string literal )"" R""() */ // this function will be called by histogram16 // we have one sub-histogram of one feature in registers, and need to read others void within_kernel_reduction16x8(uchar8 feature_mask, __global const acc_type* restrict feature4_sub_hist, const uint skip_id, acc_type stat_val, uint cnt_val, const ushort num_sub_hist, __global acc_type* restrict output_buf, __local acc_type * restrict local_hist) { const ushort ltid = get_local_id(0); // range 0 - 255 const ushort lsize = LOCAL_SIZE_0; ushort feature_id = ltid & DWORD_FEATURES_MASK; // range 0 - 7 uchar is_hessian_first = (ltid >> LOG2_DWORD_FEATURES) & 1; // hessian or gradient ushort bin_id = ltid >> (LOG2_DWORD_FEATURES + 1); // range 0 - 16 ushort i; #if POWER_FEATURE_WORKGROUPS != 0 // if there is only 1 work group, no need to do the reduction // add all sub-histograms for 4 features __global const acc_type* restrict p = feature4_sub_hist + ltid; for (i = 0; i < skip_id; ++i) { // 256 threads working on 8 features' 16 bins, gradient and hessian stat_val += *p; p += NUM_BINS * DWORD_FEATURES * 2; if (ltid < LOCAL_SIZE_0 / 2) { cnt_val += as_acc_int_type(*p); } p += NUM_BINS * DWORD_FEATURES; } // skip the counters we already have p += 3 * DWORD_FEATURES * NUM_BINS; for (i = i + 1; i < num_sub_hist; ++i) { stat_val += *p; p += NUM_BINS * DWORD_FEATURES * 2; if (ltid < LOCAL_SIZE_0 / 2) { cnt_val += as_acc_int_type(*p); } p += NUM_BINS * DWORD_FEATURES; } #endif // printf("thread %d:feature=%d, bin_id=%d, hessian=%d, stat_val=%f, cnt=%d", ltid, feature_id, bin_id, is_hessian_first, stat_val, cnt_val); // now overwrite the local_hist for final reduction and output // reverse the f7...f0 order to match the real order feature_id = DWORD_FEATURES_MASK - feature_id; local_hist[feature_id * 3 * NUM_BINS + bin_id * 3 + is_hessian_first] = stat_val; bin_id = ltid >> (LOG2_DWORD_FEATURES); // range 0 - 16, for counter if (ltid < LOCAL_SIZE_0 / 2) { local_hist[feature_id * 3 * NUM_BINS + bin_id * 3 + 2] = as_acc_type((acc_int_type)cnt_val); } barrier(CLK_LOCAL_MEM_FENCE); for (i = ltid; i < DWORD_FEATURES * 3 * NUM_BINS; i += lsize) { output_buf[i] = local_hist[i]; } } /* Makes MSVC happy with long string literal )"" R""() */ __attribute__((reqd_work_group_size(LOCAL_SIZE_0, 1, 1))) #if USE_CONSTANT_BUF == 1 __kernel void histogram16(__global const uchar4* restrict feature_data_base, __constant const uchar8* restrict feature_masks __attribute__((max_constant_size(65536))), const data_size_t feature_size, __constant const data_size_t* restrict data_indices __attribute__((max_constant_size(65536))), const data_size_t num_data, __constant const score_t* restrict ordered_gradients __attribute__((max_constant_size(65536))), #if CONST_HESSIAN == 0 __constant const score_t* restrict ordered_hessians __attribute__((max_constant_size(65536))), #else const score_t const_hessian, #endif __global char* restrict output_buf, __global volatile int * sync_counters, __global acc_type* restrict hist_buf_base) { #else __kernel void histogram16(__global const uchar4* feature_data_base, __constant const uchar8* restrict feature_masks __attribute__((max_constant_size(65536))), const data_size_t feature_size, __global const data_size_t* data_indices, const data_size_t num_data, __global const score_t* ordered_gradients, #if CONST_HESSIAN == 0 __global const score_t* ordered_hessians, #else const score_t const_hessian, #endif __global char* restrict output_buf, __global volatile int * sync_counters, __global acc_type* restrict hist_buf_base) { #endif // allocate the local memory array aligned with float2, to guarantee correct alignment on NVIDIA platforms // otherwise a "Misaligned Address" exception may occur __local float2 shared_array[LOCAL_MEM_SIZE/sizeof(float2)]; const uint gtid = get_global_id(0); const uint gsize = get_global_size(0); const ushort ltid = get_local_id(0); const ushort lsize = LOCAL_SIZE_0; // get_local_size(0); const ushort group_id = get_group_id(0); // local memory per workgroup is 12 KB // clear local memory __local uint * ptr = (__local uint *) shared_array; for (int i = ltid; i < LOCAL_MEM_SIZE/sizeof(uint); i += lsize) { ptr[i] = 0; } barrier(CLK_LOCAL_MEM_FENCE); // gradient/hessian histograms // assume this starts at 32 * 4 = 128-byte boundary // each bank: 2 * 8 * 16 * size_of(float) = 1 KB // there are 8 banks (sub-histograms) used by 256 threads total 8 KB /* memory layout of gh_hist: ----------------------------------------------------------------------------------------------- bk0_g_f0_bin0 bk0_g_f1_bin0 bk0_g_f2_bin0 bk0_g_f3_bin0 bk0_g_f4_bin0 bk0_g_f5_bin0 bk0_g_f6_bin0 bk0_g_f7_bin0 bk0_h_f0_bin0 bk0_h_f1_bin0 bk0_h_f2_bin0 bk0_h_f3_bin0 bk0_h_f4_bin0 bk0_h_f5_bin0 bk0_h_f6_bin0 bk0_h_f7_bin0 bk1_g_f0_bin0 bk1_g_f1_bin0 bk1_g_f2_bin0 bk1_g_f3_bin0 bk1_g_f4_bin0 bk1_g_f5_bin0 bk1_g_f6_bin0 bk1_g_f7_bin0 bk1_h_f0_bin0 bk1_h_f1_bin0 bk1_h_f2_bin0 bk1_h_f3_bin0 bk1_h_f4_bin0 bk1_h_f5_bin0 bk1_h_f6_bin0 bk1_h_f7_bin0 bk2_g_f0_bin0 bk2_g_f1_bin0 bk2_g_f2_bin0 bk2_g_f3_bin0 bk2_g_f4_bin0 bk2_g_f5_bin0 bk2_g_f6_bin0 bk2_g_f7_bin0 bk2_h_f0_bin0 bk2_h_f1_bin0 bk2_h_f2_bin0 bk2_h_f3_bin0 bk2_h_f4_bin0 bk2_h_f5_bin0 bk2_h_f6_bin0 bk2_h_f7_bin0 bk3_g_f0_bin0 bk3_g_f1_bin0 bk3_g_f2_bin0 bk3_g_f3_bin0 bk3_g_f4_bin0 bk3_g_f5_bin0 bk3_g_f6_bin0 bk3_g_f7_bin0 bk3_h_f0_bin0 bk3_h_f1_bin0 bk3_h_f2_bin0 bk3_h_f3_bin0 bk3_h_f4_bin0 bk3_h_f5_bin0 bk3_h_f6_bin0 bk3_h_f7_bin0 bk4_g_f0_bin0 bk4_g_f1_bin0 bk4_g_f2_bin0 bk4_g_f3_bin0 bk4_g_f4_bin0 bk4_g_f5_bin0 bk4_g_f6_bin0 bk4_g_f7_bin0 bk4_h_f0_bin0 bk4_h_f1_bin0 bk4_h_f2_bin0 bk4_h_f3_bin0 bk4_h_f4_bin0 bk4_h_f5_bin0 bk4_h_f6_bin0 bk4_h_f7_bin0 bk5_g_f0_bin0 bk5_g_f1_bin0 bk5_g_f2_bin0 bk5_g_f3_bin0 bk5_g_f4_bin0 bk5_g_f5_bin0 bk5_g_f6_bin0 bk5_g_f7_bin0 bk5_h_f0_bin0 bk5_h_f1_bin0 bk5_h_f2_bin0 bk5_h_f3_bin0 bk5_h_f4_bin0 bk5_h_f5_bin0 bk5_h_f6_bin0 bk5_h_f7_bin0 bk6_g_f0_bin0 bk6_g_f1_bin0 bk6_g_f2_bin0 bk6_g_f3_bin0 bk6_g_f4_bin0 bk6_g_f5_bin0 bk6_g_f6_bin0 bk6_g_f7_bin0 bk6_h_f0_bin0 bk6_h_f1_bin0 bk6_h_f2_bin0 bk6_h_f3_bin0 bk6_h_f4_bin0 bk6_h_f5_bin0 bk6_h_f6_bin0 bk6_h_f7_bin0 bk7_g_f0_bin0 bk7_g_f1_bin0 bk7_g_f2_bin0 bk7_g_f3_bin0 bk7_g_f4_bin0 bk7_g_f5_bin0 bk7_g_f6_bin0 bk7_g_f7_bin0 bk7_h_f0_bin0 bk7_h_f1_bin0 bk7_h_f2_bin0 bk7_h_f3_bin0 bk7_h_f4_bin0 bk7_h_f5_bin0 bk7_h_f6_bin0 bk7_h_f7_bin0 ... bk0_g_f0_bin16 bk0_g_f1_bin16 bk0_g_f2_bin16 bk0_g_f3_bin16 bk0_g_f4_bin16 bk0_g_f5_bin16 bk0_g_f6_bin16 bk0_g_f7_bin16 bk0_h_f0_bin16 bk0_h_f1_bin16 bk0_h_f2_bin16 bk0_h_f3_bin16 bk0_h_f4_bin16 bk0_h_f5_bin16 bk0_h_f6_bin16 bk0_h_f7_bin16 bk1_g_f0_bin16 bk1_g_f1_bin16 bk1_g_f2_bin16 bk1_g_f3_bin16 bk1_g_f4_bin16 bk1_g_f5_bin16 bk1_g_f6_bin16 bk1_g_f7_bin16 bk1_h_f0_bin16 bk1_h_f1_bin16 bk1_h_f2_bin16 bk1_h_f3_bin16 bk1_h_f4_bin16 bk1_h_f5_bin16 bk1_h_f6_bin16 bk1_h_f7_bin16 bk2_g_f0_bin16 bk2_g_f1_bin16 bk2_g_f2_bin16 bk2_g_f3_bin16 bk2_g_f4_bin16 bk2_g_f5_bin16 bk2_g_f6_bin16 bk2_g_f7_bin16 bk2_h_f0_bin16 bk2_h_f1_bin16 bk2_h_f2_bin16 bk2_h_f3_bin16 bk2_h_f4_bin16 bk2_h_f5_bin16 bk2_h_f6_bin16 bk2_h_f7_bin16 bk3_g_f0_bin16 bk3_g_f1_bin16 bk3_g_f2_bin16 bk3_g_f3_bin16 bk3_g_f4_bin16 bk3_g_f5_bin16 bk3_g_f6_bin16 bk3_g_f7_bin16 bk3_h_f0_bin16 bk3_h_f1_bin16 bk3_h_f2_bin16 bk3_h_f3_bin16 bk3_h_f4_bin16 bk3_h_f5_bin16 bk3_h_f6_bin16 bk3_h_f7_bin16 bk4_g_f0_bin16 bk4_g_f1_bin16 bk4_g_f2_bin16 bk4_g_f3_bin16 bk4_g_f4_bin16 bk4_g_f5_bin16 bk4_g_f6_bin16 bk4_g_f7_bin16 bk4_h_f0_bin16 bk4_h_f1_bin16 bk4_h_f2_bin16 bk4_h_f3_bin16 bk4_h_f4_bin16 bk4_h_f5_bin16 bk4_h_f6_bin16 bk4_h_f7_bin16 bk5_g_f0_bin16 bk5_g_f1_bin16 bk5_g_f2_bin16 bk5_g_f3_bin16 bk5_g_f4_bin16 bk5_g_f5_bin16 bk5_g_f6_bin16 bk5_g_f7_bin16 bk5_h_f0_bin16 bk5_h_f1_bin16 bk5_h_f2_bin16 bk5_h_f3_bin16 bk5_h_f4_bin16 bk5_h_f5_bin16 bk5_h_f6_bin16 bk5_h_f7_bin16 bk6_g_f0_bin16 bk6_g_f1_bin16 bk6_g_f2_bin16 bk6_g_f3_bin16 bk6_g_f4_bin16 bk6_g_f5_bin16 bk6_g_f6_bin16 bk6_g_f7_bin16 bk6_h_f0_bin16 bk6_h_f1_bin16 bk6_h_f2_bin16 bk6_h_f3_bin16 bk6_h_f4_bin16 bk6_h_f5_bin16 bk6_h_f6_bin16 bk6_h_f7_bin16 bk7_g_f0_bin16 bk7_g_f1_bin16 bk7_g_f2_bin16 bk7_g_f3_bin16 bk7_g_f4_bin16 bk7_g_f5_bin16 bk7_g_f6_bin16 bk7_g_f7_bin16 bk7_h_f0_bin16 bk7_h_f1_bin16 bk7_h_f2_bin16 bk7_h_f3_bin16 bk7_h_f4_bin16 bk7_h_f5_bin16 bk7_h_f6_bin16 bk7_h_f7_bin16 ----------------------------------------------------------------------------------------------- */ // with this organization, the LDS/shared memory bank is independent of the bin value // all threads within a quarter-wavefront (half-warp) will not have any bank conflict __local acc_type * gh_hist = (__local acc_type *)shared_array; // counter histogram // each bank: 8 * 16 * size_of(uint) = 0.5 KB // there are 8 banks used by 256 threads total 4 KB /* memory layout in cnt_hist: ----------------------------------------------- bk0_c_f0_bin0 bk0_c_f1_bin0 bk0_c_f2_bin0 bk0_c_f3_bin0 bk0_c_f4_bin0 bk0_c_f5_bin0 bk0_c_f6_bin0 bk0_c_f7_bin0 bk1_c_f0_bin0 bk1_c_f1_bin0 bk1_c_f2_bin0 bk1_c_f3_bin0 bk1_c_f4_bin0 bk1_c_f5_bin0 bk1_c_f6_bin0 bk1_c_f7_bin0 bk2_c_f0_bin0 bk2_c_f1_bin0 bk2_c_f2_bin0 bk2_c_f3_bin0 bk2_c_f4_bin0 bk2_c_f5_bin0 bk2_c_f6_bin0 bk2_c_f7_bin0 bk3_c_f0_bin0 bk3_c_f1_bin0 bk3_c_f2_bin0 bk3_c_f3_bin0 bk3_c_f4_bin0 bk3_c_f5_bin0 bk3_c_f6_bin0 bk3_c_f7_bin0 bk4_c_f0_bin0 bk4_c_f1_bin0 bk4_c_f2_bin0 bk4_c_f3_bin0 bk4_c_f4_bin0 bk4_c_f5_bin0 bk4_c_f6_bin0 bk4_c_f7_bin0 bk5_c_f0_bin0 bk5_c_f1_bin0 bk5_c_f2_bin0 bk5_c_f3_bin0 bk5_c_f4_bin0 bk5_c_f5_bin0 bk5_c_f6_bin0 bk5_c_f7_bin0 bk6_c_f0_bin0 bk6_c_f1_bin0 bk6_c_f2_bin0 bk6_c_f3_bin0 bk6_c_f4_bin0 bk6_c_f5_bin0 bk6_c_f6_bin0 bk6_c_f7_bin0 bk7_c_f0_bin0 bk7_c_f1_bin0 bk7_c_f2_bin0 bk7_c_f3_bin0 bk7_c_f4_bin0 bk7_c_f5_bin0 bk7_c_f6_bin0 bk7_c_f7_bin0 ... bk0_c_f0_bin16 bk0_c_f1_bin16 bk0_c_f2_bin16 bk0_c_f3_bin16 bk0_c_f4_bin16 bk0_c_f5_bin16 bk0_c_f6_bin16 bk0_c_f7_bin0 bk1_c_f0_bin16 bk1_c_f1_bin16 bk1_c_f2_bin16 bk1_c_f3_bin16 bk1_c_f4_bin16 bk1_c_f5_bin16 bk1_c_f6_bin16 bk1_c_f7_bin0 bk2_c_f0_bin16 bk2_c_f1_bin16 bk2_c_f2_bin16 bk2_c_f3_bin16 bk2_c_f4_bin16 bk2_c_f5_bin16 bk2_c_f6_bin16 bk2_c_f7_bin0 bk3_c_f0_bin16 bk3_c_f1_bin16 bk3_c_f2_bin16 bk3_c_f3_bin16 bk3_c_f4_bin16 bk3_c_f5_bin16 bk3_c_f6_bin16 bk3_c_f7_bin0 bk4_c_f0_bin16 bk4_c_f1_bin16 bk4_c_f2_bin16 bk4_c_f3_bin16 bk4_c_f4_bin16 bk4_c_f5_bin16 bk4_c_f6_bin16 bk4_c_f7_bin0 bk5_c_f0_bin16 bk5_c_f1_bin16 bk5_c_f2_bin16 bk5_c_f3_bin16 bk5_c_f4_bin16 bk5_c_f5_bin16 bk5_c_f6_bin16 bk5_c_f7_bin0 bk6_c_f0_bin16 bk6_c_f1_bin16 bk6_c_f2_bin16 bk6_c_f3_bin16 bk6_c_f4_bin16 bk6_c_f5_bin16 bk6_c_f6_bin16 bk6_c_f7_bin0 bk7_c_f0_bin16 bk7_c_f1_bin16 bk7_c_f2_bin16 bk7_c_f3_bin16 bk7_c_f4_bin16 bk7_c_f5_bin16 bk7_c_f6_bin16 bk7_c_f7_bin0 ----------------------------------------------- */ __local uint * cnt_hist = (__local uint *)(gh_hist + 2 * DWORD_FEATURES * NUM_BINS * NUM_BANKS); // thread 0, 1, 2, 3, 4, 5, 6, 7 compute histograms for gradients first // thread 8, 9, 10, 11, 12, 13, 14, 15 compute histograms for hessians first // etc. uchar is_hessian_first = (ltid >> LOG2_DWORD_FEATURES) & 1; // thread 0-15 write result to bank0, 16-31 to bank1, 32-47 to bank2, 48-63 to bank3, etc ushort bank = (ltid >> (LOG2_DWORD_FEATURES + 1)) & BANK_MASK; ushort group_feature = group_id >> POWER_FEATURE_WORKGROUPS; // each 2^POWER_FEATURE_WORKGROUPS workgroups process on one feature (compile-time constant) // feature_size is the number of examples per feature __global const uchar4* feature_data = feature_data_base + group_feature * feature_size; // size of threads that process this feature4 const uint subglobal_size = lsize * (1 << POWER_FEATURE_WORKGROUPS); // equavalent thread ID in this subgroup for this feature4 const uint subglobal_tid = gtid - group_feature * subglobal_size; // extract feature mask, when a byte is set to 0, that feature is disabled #if ENABLE_ALL_FEATURES == 1 // hopefully the compiler will propogate the constants and eliminate all branches uchar8 feature_mask = (uchar8)(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff); #else uchar8 feature_mask = feature_masks[group_feature]; #endif // exit if all features are masked if (!as_ulong(feature_mask)) { return; } // STAGE 1: read feature data, and gradient and hessian // first half of the threads read feature data from global memory // 4 features stored in a tuple MSB...(0, 1, 2, 3)...LSB // We will prefetch data into the "next" variable at the beginning of each iteration uchar4 feature4; uchar4 feature4_next; // offset used to rotate feature4 vector, & 0x7 ushort offset = (ltid & DWORD_FEATURES_MASK); #if ENABLE_ALL_FEATURES == 0 // rotate feature_mask to match the feature order of each thread feature_mask = as_uchar8(rotate(as_ulong(feature_mask), (ulong)offset*8)); #endif // store gradient and hessian float stat1, stat2; float stat1_next, stat2_next; ushort bin, addr, addr2; data_size_t ind; data_size_t ind_next; stat1 = ordered_gradients[subglobal_tid]; #if CONST_HESSIAN == 0 stat2 = ordered_hessians[subglobal_tid]; #endif #ifdef IGNORE_INDICES ind = subglobal_tid; #else ind = data_indices[subglobal_tid]; #endif feature4 = feature_data[ind]; /* Makes MSVC happy with long string literal )"" R""() */ // there are 2^POWER_FEATURE_WORKGROUPS workgroups processing each feature4 for (uint i = subglobal_tid; i < num_data; i += subglobal_size) { // prefetch the next iteration variables // we don't need bondary check because we have made the buffer larger stat1_next = ordered_gradients[i + subglobal_size]; #if CONST_HESSIAN == 0 stat2_next = ordered_hessians[i + subglobal_size]; #endif #ifdef IGNORE_INDICES // we need to check to bounds here ind_next = i + subglobal_size < num_data ? i + subglobal_size : i; // start load next feature as early as possible feature4_next = feature_data[ind_next]; #else ind_next = data_indices[i + subglobal_size]; #endif #if CONST_HESSIAN == 0 // swap gradient and hessian for threads 8, 9, 10, 11, 12, 13, 14, 15 float tmp = stat1; stat1 = is_hessian_first ? stat2 : stat1; stat2 = is_hessian_first ? tmp : stat2; // stat1 = select(stat1, stat2, is_hessian_first); // stat2 = select(stat2, tmp, is_hessian_first); #endif // STAGE 2: accumulate gradient and hessian offset = (ltid & DWORD_FEATURES_MASK); // printf("thread %x, %08x -> %08x", ltid, as_uint(feature4), rotate(as_uint(feature4), (uint)(offset * FEATURE_BITS))); feature4 = as_uchar4(rotate(as_uint(feature4), (uint)(offset * FEATURE_BITS))); if (feature_mask.s7) { bin = feature4.s3 >> 4; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 0, 1, 2, 3, 4, 5, 6 ,7's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 0, 1, 2, 3, 4, 5, 6, 7's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 0, 1, 2, 3, 4, 5, 6, 7's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 0, 1, 2, 3, 4, 5, 6, 7's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s6) { bin = feature4.s3 & 0xf; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 1, 2, 3, 4, 5, 6 ,7, 0's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 1, 2, 3, 4, 5, 6, 7, 0's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 1, 2, 3, 4, 5, 6, 7, 0's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 1, 2, 3, 4, 5, 6, 7, 0's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s5) { bin = feature4.s2 >> 4; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 2, 3, 4, 5, 6, 7, 0, 1's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 2, 3, 4, 5, 6, 7, 0, 1's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 2, 3, 4, 5, 6, 7, 0, 1's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 2, 3, 4, 5, 6, 7, 0, 1's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s4) { bin = feature4.s2 & 0xf; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 3, 4, 5, 6, 7, 0, 1, 2's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 3, 4, 5, 6, 7, 0, 1, 2's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 3, 4, 5, 6, 7, 0, 1, 2's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 3, 4, 5, 6, 7, 0, 1, 2's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } // prefetch the next iteration variables // we don't need bondary check because if it is out of boundary, ind_next = 0 #ifndef IGNORE_INDICES feature4_next = feature_data[ind_next]; #endif offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s3) { bin = feature4.s1 >> 4; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 4, 5, 6, 7, 0, 1, 2, 3's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 4, 5, 6, 7, 0, 1, 2, 3's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 4, 5, 6, 7, 0, 1, 2, 3's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 4, 5, 6, 7, 0, 1, 2, 3's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s2) { bin = feature4.s1 & 0xf; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 5, 6, 7, 0, 1, 2, 3, 4's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 5, 6, 7, 0, 1, 2, 3, 4's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 5, 6, 7, 0, 1, 2, 3, 4's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 5, 6, 7, 0, 1, 2, 3, 4's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s1) { bin = feature4.s0 >> 4; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 6, 7, 0, 1, 2, 3, 4, 5's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 6, 7, 0, 1, 2, 3, 4, 5's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 6, 7, 0, 1, 2, 3, 4, 5's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 6, 7, 0, 1, 2, 3, 4, 5's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s0) { bin = feature4.s0 & 0xf; addr = bin * HG_BIN_MULT + bank * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + offset; addr2 = addr + DWORD_FEATURES - 2 * DWORD_FEATURES * is_hessian_first; // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 7, 0, 1, 2, 3, 4, 5, 6's gradients for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 7, 0, 1, 2, 3, 4, 5, 6's hessians for example 8, 9, 10, 11, 12, 13, 14, 15 atomic_local_add_f(gh_hist + addr, stat1); // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 7, 0, 1, 2, 3, 4, 5, 6's hessians for example 0, 1, 2, 3, 4, 5, 6, 7 // thread 8, 9, 10, 11, 12, 13, 14, 15 now process feature 7, 0, 1, 2, 3, 4, 5, 6's gradients for example 8, 9, 10, 11, 12, 13, 14, 15 #if CONST_HESSIAN == 0 atomic_local_add_f(gh_hist + addr2, stat2); #endif } // STAGE 3: accumulate counter // there are 8 counters for 8 features // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 0, 1, 2, 3, 4, 5, 6, 7's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (ltid & DWORD_FEATURES_MASK); if (feature_mask.s7) { bin = feature4.s3 >> 4; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (0)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 1, 2, 3, 4, 5, 6, 7, 0's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s6) { bin = feature4.s3 & 0xf; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (1)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 2, 3, 4, 5, 6, 7, 0, 1's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s5) { bin = feature4.s2 >> 4; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (2)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 3, 4, 5, 6, 7, 0, 1, 2's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s4) { bin = feature4.s2 & 0xf; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (3)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 4, 5, 6, 7, 0, 1, 2, 3's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s3) { bin = feature4.s1 >> 4; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (4)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 5, 6, 7, 0, 1, 2, 3, 4's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s2) { bin = feature4.s1 & 0xf; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (5)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 6, 7, 0, 1, 2, 3, 4, 5's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s1) { bin = feature4.s0 >> 4; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (6)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } // thread 0, 1, 2, 3, 4, 5, 6, 7 now process feature 7, 0, 1, 2, 3, 4, 5, 6's counts for example 0, 1, 2, 3, 4, 5, 6, 7 offset = (offset + 1) & DWORD_FEATURES_MASK; if (feature_mask.s0) { bin = feature4.s0 & 0xf; addr = bin * CNT_BIN_MULT + bank * DWORD_FEATURES + offset; // printf("thread %x add counter %d feature %d (7)\n", ltid, bin, offset); atom_inc(cnt_hist + addr); } stat1 = stat1_next; stat2 = stat2_next; feature4 = feature4_next; } barrier(CLK_LOCAL_MEM_FENCE); /* Makes MSVC happy with long string literal )"" R""() */ #if ENABLE_ALL_FEATURES == 0 // restore feature_mask feature_mask = feature_masks[group_feature]; #endif // now reduce the 4 banks of subhistograms into 1 acc_type stat_val = 0.0f; uint cnt_val = 0; // 256 threads, working on 8 features and 16 bins, 2 stats // so each thread has an independent feature/bin/stat to work on. const ushort feature_id = ltid & DWORD_FEATURES_MASK; // bits 0 - 2 of ltid, range 0 - 7 ushort bin_id = ltid >> (LOG2_DWORD_FEATURES + 1); // bits 3 is is_hessian_first; bits 4 - 7 range 0 - 16 is bin ID offset = (ltid >> (LOG2_DWORD_FEATURES + 1)) & BANK_MASK; // helps avoid LDS bank conflicts for (int i = 0; i < NUM_BANKS; ++i) { ushort bank_id = (i + offset) & BANK_MASK; stat_val += gh_hist[bin_id * HG_BIN_MULT + bank_id * 2 * DWORD_FEATURES + is_hessian_first * DWORD_FEATURES + feature_id]; } if (ltid < LOCAL_SIZE_0 / 2) { // first 128 threads accumulate the 8 * 16 = 128 counter values bin_id = ltid >> LOG2_DWORD_FEATURES; // bits 3 - 6 range 0 - 16 is bin ID offset = (ltid >> LOG2_DWORD_FEATURES) & BANK_MASK; // helps avoid LDS bank conflicts for (int i = 0; i < NUM_BANKS; ++i) { ushort bank_id = (i + offset) & BANK_MASK; cnt_val += cnt_hist[bin_id * CNT_BIN_MULT + bank_id * DWORD_FEATURES + feature_id]; } } // now thread 0 - 7 holds feature 0 - 7's gradient for bin 0 and counter bin 0 // now thread 8 - 15 holds feature 0 - 7's hessian for bin 0 and counter bin 1 // now thread 16- 23 holds feature 0 - 7's gradient for bin 1 and counter bin 2 // now thread 24- 31 holds feature 0 - 7's hessian for bin 1 and counter bin 3 // etc, #if CONST_HESSIAN == 1 // Combine the two banks into one, and fill the hessians with counter value * hessian constant barrier(CLK_LOCAL_MEM_FENCE); gh_hist[ltid] = stat_val; if (ltid < LOCAL_SIZE_0 / 2) { cnt_hist[ltid] = cnt_val; } barrier(CLK_LOCAL_MEM_FENCE); if (is_hessian_first) { // this is the hessians // thread 8 - 15 read counters stored by thread 0 - 7 // thread 24- 31 read counters stored by thread 8 - 15 // thread 40- 47 read counters stored by thread 16- 23, etc stat_val = const_hessian * cnt_hist[((ltid - DWORD_FEATURES) >> (LOG2_DWORD_FEATURES + 1)) * DWORD_FEATURES + (ltid & DWORD_FEATURES_MASK)]; } else { // this is the gradients // thread 0 - 7 read gradients stored by thread 8 - 15 // thread 16- 23 read gradients stored by thread 24- 31 // thread 32- 39 read gradients stored by thread 40- 47, etc stat_val += gh_hist[ltid + DWORD_FEATURES]; } barrier(CLK_LOCAL_MEM_FENCE); #endif // write to output // write gradients and hessians histogram for all 4 features // output data in linear order for further reduction // output size = 4 (features) * 3 (counters) * 64 (bins) * sizeof(float) /* memory layout of output: g_f0_bin0 g_f1_bin0 g_f2_bin0 g_f3_bin0 g_f4_bin0 g_f5_bin0 g_f6_bin0 g_f7_bin0 h_f0_bin0 h_f1_bin0 h_f2_bin0 h_f3_bin0 h_f4_bin0 h_f5_bin0 h_f6_bin0 h_f7_bin0 g_f0_bin1 g_f1_bin1 g_f2_bin1 g_f3_bin1 g_f4_bin1 g_f5_bin1 g_f6_bin1 g_f7_bin1 h_f0_bin1 h_f1_bin1 h_f2_bin1 h_f3_bin1 h_f4_bin1 h_f5_bin1 h_f6_bin1 h_f7_bin1 ... ... g_f0_bin16 g_f1_bin16 g_f2_bin16 g_f3_bin16 g_f4_bin16 g_f5_bin16 g_f6_bin16 g_f7_bin16 h_f0_bin16 h_f1_bin16 h_f2_bin16 h_f3_bin16 h_f4_bin16 h_f5_bin16 h_f6_bin16 h_f7_bin16 c_f0_bin0 c_f1_bin0 c_f2_bin0 c_f3_bin0 c_f4_bin0 c_f5_bin0 c_f6_bin0 c_f7_bin0 c_f0_bin1 c_f1_bin1 c_f2_bin1 c_f3_bin1 c_f4_bin1 c_f5_bin1 c_f6_bin1 c_f7_bin1 ... c_f0_bin16 c_f1_bin16 c_f2_bin16 c_f3_bin16 c_f4_bin16 c_f5_bin16 c_f6_bin16 c_f7_bin16 */ // if there is only one workgroup processing this feature4, don't even need to write uint feature4_id = (group_id >> POWER_FEATURE_WORKGROUPS); #if POWER_FEATURE_WORKGROUPS != 0 __global acc_type * restrict output = (__global acc_type * restrict)output_buf + group_id * DWORD_FEATURES * 3 * NUM_BINS; // if g_val and h_val are double, they are converted to float here // write gradients and hessians for 8 features output[0 * DWORD_FEATURES * NUM_BINS + ltid] = stat_val; // write counts for 8 features if (ltid < LOCAL_SIZE_0 / 2) { output[2 * DWORD_FEATURES * NUM_BINS + ltid] = as_acc_type((acc_int_type)cnt_val); } barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE); mem_fence(CLK_GLOBAL_MEM_FENCE); // To avoid the cost of an extra reducting kernel, we have to deal with some // gray area in OpenCL. We want the last work group that process this feature to // make the final reduction, and other threads will just quit. // This requires that the results written by other workgroups available to the // last workgroup (memory consistency) #if NVIDIA == 1 // this is equavalent to CUDA __threadfence(); // ensure the writes above goes to main memory and other workgroups can see it asm volatile("{\n\tmembar.gl;\n\t}\n\t" :::"memory"); #else // FIXME: how to do the above on AMD GPUs?? // GCN ISA says that the all writes will bypass L1 cache (write through), // however when the last thread is reading sub-histogram data we have to // make sure that no part of data is modified in local L1 cache of other workgroups. // Otherwise reading can be a problem (atomic operations to get consistency). // But in our case, the sub-histogram of this workgroup cannot be in the cache // of another workgroup, so the following trick will work just fine. #endif // Now, we want one workgroup to do the final reduction. // Other workgroups processing the same feature quit. // The is done by using an global atomic counter. // On AMD GPUs ideally this should be done in GDS, // but currently there is no easy way to access it via OpenCL. __local uint * counter_val = cnt_hist; if (ltid == 0) { // all workgroups processing the same feature add this counter *counter_val = atom_inc(sync_counters + feature4_id); } // make sure everyone in this workgroup is here barrier(CLK_LOCAL_MEM_FENCE); // everyone in this wrokgroup: if we are the last workgroup, then do reduction! if (*counter_val == (1 << POWER_FEATURE_WORKGROUPS) - 1) { if (ltid == 0) { // printf("workgroup %d start reduction!\n", group_id); // printf("feature_data[0] = %d %d %d %d", feature_data[0].s0, feature_data[0].s1, feature_data[0].s2, feature_data[0].s3); // clear the sync counter for using it next time sync_counters[feature4_id] = 0; } #else // only 1 work group, no need to increase counter // the reduction will become a simple copy if (1) { barrier(CLK_LOCAL_MEM_FENCE); #endif // locate our feature4's block in output memory uint output_offset = (feature4_id << POWER_FEATURE_WORKGROUPS); __global acc_type const * restrict feature4_subhists = (__global acc_type *)output_buf + output_offset * DWORD_FEATURES * 3 * NUM_BINS; // skip reading the data already in local memory uint skip_id = group_id ^ output_offset; // locate output histogram location for this feature4 __global acc_type* restrict hist_buf = hist_buf_base + feature4_id * DWORD_FEATURES * 3 * NUM_BINS; within_kernel_reduction16x8(feature_mask, feature4_subhists, skip_id, stat_val, cnt_val, 1 << POWER_FEATURE_WORKGROUPS, hist_buf, (__local acc_type *)shared_array); } } // The following line ends the string literal, adds an extra #endif at the end // the +9 skips extra characters ")", newline, "#endif" and newline at the beginning // )"" "\n#endif" + 9 #endif
{ "pile_set_name": "Github" }
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Oct 15 2018 10:31:50). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <objc/NSObject.h> #import <SecurityFoundation/SFKeychainItemAttributes-Protocol.h> #import <SecurityFoundation/_SFKeyAttributes-Protocol.h> @class NSString, _SFKeySpecifier; __attribute__((visibility("hidden"))) @interface SFSymmetricKeyAttributes : NSObject <_SFKeyAttributes, SFKeychainItemAttributes> { id _symmetricKeyAttributesInternal; NSString *persistentIdentifier; } - (void).cxx_destruct; @property(readonly, copy, nonatomic) NSString *persistentIdentifier; // @synthesize persistentIdentifier; @property(readonly, copy, nonatomic) NSString *keyDomain; - (void)setKeySpecifier:(id)arg1; @property(readonly, copy, nonatomic) _SFKeySpecifier *keySpecifier; @property(copy, nonatomic) NSString *localizedDescription; @property(copy, nonatomic) NSString *localizedLabel; - (id)copyWithZone:(struct _NSZone *)arg1; - (id)initWithSpecifier:(id)arg1 domain:(id)arg2; - (id)initWithSpecifier:(id)arg1; // Remaining properties @property(readonly, copy) NSString *debugDescription; @property(readonly, copy) NSString *description; @property(readonly) unsigned long long hash; @property(readonly) Class superclass; @end
{ "pile_set_name": "Github" }
package com.stevenschoen.putionew.transfers import android.content.Context import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView import androidx.fragment.app.Fragment import com.stevenschoen.putionew.PutioBottomSheetDialogFragment import com.stevenschoen.putionew.R import com.stevenschoen.putionew.model.transfers.PutioTransfer class TransferOptionsFragment : PutioBottomSheetDialogFragment() { companion object { const val EXTRA_TRANSFER = "transfer" fun newInstance(context: Context, transfer: PutioTransfer): TransferOptionsFragment { val args = Bundle() args.putParcelable(EXTRA_TRANSFER, transfer) return Fragment.instantiate(context, TransferOptionsFragment::class.java.name, args) as TransferOptionsFragment } } val transfer by lazy { arguments!!.getParcelable<PutioTransfer>(EXTRA_TRANSFER)!! } var callbacks: Callbacks? = null override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { val view = inflater.inflate(R.layout.transfer_options, container, false) val nameView = view.findViewById<TextView>(R.id.transfer_options_name) nameView.text = transfer.name val retryView = view.findViewById<View>(R.id.transfer_options_retry) retryView.setOnClickListener { callbacks?.onRetrySelected() } if (transfer.status == "ERROR") { retryView.visibility = View.VISIBLE retryView.isEnabled = true } else { retryView.visibility = View.GONE retryView.isEnabled = false } val removeView = view.findViewById<View>(R.id.transfer_options_remove) removeView.setOnClickListener { callbacks?.onRemoveSelected() } return view } interface Callbacks { fun onRetrySelected() fun onRemoveSelected() } }
{ "pile_set_name": "Github" }
/** <title>GSNibLoading</title> <abstract> These are templates for use with OSX Nib files. These classes are the templates and other things which are needed for reading/writing nib files. </abstract> Copyright (C) 1997, 1999 Free Software Foundation, Inc. Author: Gregory John Casamento Date: 2003, 2005 Author: Fred Kiefer Date: 2003, 2010 This file is part of the GNUstep GUI Library. 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 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; see the file COPYING.LIB. If not, see <http://www.gnu.org/licenses/> or write to the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #define EXPOSE_NSKeyedUnarchiver_IVARS #import <Foundation/NSArchiver.h> #import <Foundation/NSArray.h> #import <Foundation/NSBundle.h> #import <Foundation/NSByteOrder.h> #import <Foundation/NSCoder.h> #import <Foundation/NSData.h> #import <Foundation/NSDecimalNumber.h> #import <Foundation/NSDictionary.h> #import <Foundation/NSDebug.h> #import <Foundation/NSEnumerator.h> #import <Foundation/NSException.h> #import <Foundation/NSKeyedArchiver.h> #import <Foundation/NSObjCRuntime.h> #import <Foundation/NSSet.h> #import <Foundation/NSString.h> // FIXME: Used for NSKeyedArchiver access. All this should be moved into base. /* * Setup for inline operation of arrays. */ #define GSI_ARRAY_RETAIN(A, X) RETAIN((X).obj) #define GSI_ARRAY_RELEASE(A, X) RELEASE((X).obj) #define GSI_ARRAY_TYPES GSUNION_OBJ #include <GNUstepBase/GSIArray.h> #import "GNUstepGUI/GSNibLoading.h" #import "AppKit/NSApplication.h" #import "AppKit/NSImage.h" #import "AppKit/NSMenuItem.h" #import "AppKit/NSMenuView.h" #import "AppKit/NSNib.h" #import "AppKit/NSScreen.h" #import "AppKit/NSSound.h" #import "AppKit/NSToolbar.h" #import "GNUstepGUI/GSInstantiator.h" #import "GSGuiPrivate.h" static BOOL _isInInterfaceBuilder = NO; @interface NSKeyedUnarchiver (NSClassSwapperPrivate) - (BOOL) replaceObject: (id)oldObj withObject: (id)newObj; - (NSDictionary *)keyMap; - (Class) replacementClassForClassName: (NSString *)className; @end @interface NSApplication (NibCompatibility) - (void) _setMainMenu: (NSMenu*)aMenu; @end @interface NSView (NibCompatibility) - (void) _fixSubviews; @end /* Correct some instances where the ":" is missing from the method name in the label */ @interface NSNibControlConnector (NibCompatibility) - (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator; @end @interface NSNibConnector (NibCompatibility) - (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator; @end @interface NSDecimalNumberPlaceholder : NSObject @end @interface _NSCornerView : NSView @end @interface NSMenu (NibCompatibility) - (void) _setMain: (BOOL)isMain; @end @interface NSMenu (GNUstepPrivate) - (void) _setGeometry; @end @implementation NSMenu (NibCompatibility) // FIXME: Why can't this be merged with setMain: ? - (void) _setMain: (BOOL)isMain { if (isMain) { NSMenuView *oldRep; NSInterfaceStyle oldStyle; NSInterfaceStyle newStyle; NSString *processName; if ([self numberOfItems] == 0) return; oldRep = [self menuRepresentation]; oldStyle = [oldRep interfaceStyle]; newStyle = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil); processName = [[NSProcessInfo processInfo] processName]; /* * If necessary, rebuild menu for (different) style */ if (oldStyle != newStyle) { NSMenuView *newRep; newRep = [[NSMenuView alloc] initWithFrame: NSZeroRect]; if (newStyle == NSMacintoshInterfaceStyle || newStyle == NSWindows95InterfaceStyle) { [newRep setHorizontal: YES]; } else { [newRep setHorizontal: NO]; } [newRep setInterfaceStyle: newStyle]; [self setMenuRepresentation: newRep]; RELEASE(newRep); } [[self window] setTitle: processName]; [[self window] setLevel: NSMainMenuWindowLevel]; // if it's a standard menu, transform it to be more NeXT'ish/GNUstep-like if (_menu.horizontal == NO) { NSMenuItem *appItem; NSMenu *sub; SEL sel = @selector(terminate:); /* The title of the main menu should be the process name. */ [self setTitle: processName]; /* If there is no 'quite' item (one which sends a -terminate: * actions) we add one. */ if ([self indexOfItemWithTarget: nil andAction: sel] < 0 && [self indexOfItemWithTarget: NSApp andAction: sel] < 0) { NSString *quitString; NSMenuItem *quitItem; quitString = [NSString stringWithFormat: @"%@ %@", NSLocalizedString (@"Quit", @"Quit"), processName]; quitItem = [[NSMenuItem alloc] initWithTitle: quitString action: @selector(terminate:) keyEquivalent: @"q"]; [self addItem: quitItem]; } /* An OSX main menu has the first item pointing to a submenu * whose contents are much the same as a GNUstep info menu. */ appItem = (NSMenuItem*)[self itemAtIndex: 0]; // Info item. sub = [appItem submenu]; if (sub != nil) { NSString *infoString; NSInteger index; infoString = NSLocalizedString (@"Info", @"Info"); [appItem setTitle: infoString]; [sub setTitle: infoString]; /* The submenu may contain a 'quit' item ... if so we need to * remove it as we already added one to the main menu. */ index = [sub indexOfItemWithTarget: nil andAction: sel]; if (index < 0) { index = [sub indexOfItemWithTarget: NSApp andAction: sel]; } if (index >= 0) { [sub removeItemAtIndex: index]; } } } [self _setGeometry]; [self sizeToFit]; if ([NSApp isActive]) { [self display]; } } else { [self close]; [[self window] setLevel: NSSubmenuWindowLevel]; } } @end @implementation NSApplication (NibCompatibility) - (void) _setMainMenu: (NSMenu*)aMenu { if (_main_menu == aMenu) { return; } if (_main_menu != nil) { [_main_menu setMain: NO]; } ASSIGN(_main_menu, aMenu); if (_main_menu != nil) { [_main_menu _setMain: YES]; } } @end @implementation NSView (NibCompatibility) - (void) _setWindow: (id) w { _window = w; } - (void) _fixSubviews { NSEnumerator *en = [[self subviews] objectEnumerator]; id v = nil; while ((v = [en nextObject]) != nil) { if ([v window] != [self window] || [v superview] != self) { [v _setWindow: [self window]]; RETAIN(v); [_sub_views removeObject: v]; [self addSubview: v]; RELEASE(v); } [v _fixSubviews]; } } @end /** * NSWindowTemplate * * Instances of this class take the place of all windows in the nib file. */ @implementation NSWindowTemplate + (void) initialize { if (self == [NSWindowTemplate class]) { [self setVersion: 0]; } } - (void) dealloc { RELEASE(_title); RELEASE(_viewClass); RELEASE(_windowClass); RELEASE(_view); RELEASE(_autosaveName); RELEASE(_realObject); [super dealloc]; } /** * Designated initializer for NSWindowTemplate. */ - (id) initWithWindow: (NSWindow *)window className: (NSString *)windowClass isDeferred: (BOOL) deferred isOneShot: (BOOL) oneShot isVisible: (BOOL) visible wantsToBeColor: (BOOL) wantsToBeColor autoPositionMask: (int) autoPositionMask { if ((self = [super init]) != nil) { if (window != nil) { // object members ASSIGN(_title, [window title]); ASSIGN(_viewClass, NSStringFromClass([[window contentView] class])); ASSIGN(_windowClass, windowClass); ASSIGN(_view, [window contentView]); ASSIGN(_autosaveName, [window frameAutosaveName]); // style & size _windowStyle = [window styleMask]; _backingStoreType = [window backingType]; _maxSize = [window maxSize]; _minSize = [window minSize]; _windowRect = [window frame]; _screenRect = [[NSScreen mainScreen] frame]; // flags _flags.isHiddenOnDeactivate = [window hidesOnDeactivate]; _flags.isNotReleasedOnClose = (![window isReleasedWhenClosed]); _flags.isDeferred = deferred; _flags.isOneShot = oneShot; _flags.isVisible = visible; _flags.wantsToBeColor = wantsToBeColor; _flags.dynamicDepthLimit = [window hasDynamicDepthLimit]; _flags.autoPositionMask = autoPositionMask; _flags.savePosition = YES; // not yet implemented. } } return self; } - (id) initWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { if ([coder containsValueForKey: @"NSViewClass"]) { ASSIGN(_viewClass, [coder decodeObjectForKey: @"NSViewClass"]); } if ([coder containsValueForKey: @"NSWindowClass"]) { ASSIGN(_windowClass, [coder decodeObjectForKey: @"NSWindowClass"]); } if ([coder containsValueForKey: @"NSWindowStyleMask"]) { _windowStyle = [coder decodeIntForKey: @"NSWindowStyleMask"]; } if ([coder containsValueForKey: @"NSWindowBacking"]) { _backingStoreType = [coder decodeIntForKey: @"NSWindowBacking"]; } if ([coder containsValueForKey: @"NSWindowView"]) { ASSIGN(_view, [coder decodeObjectForKey: @"NSWindowView"]); } if ([coder containsValueForKey: @"NSWTFlags"]) { unsigned long flags = [coder decodeIntForKey: @"NSWTFlags"]; memcpy((void *)&_flags,(void *)&flags,sizeof(struct _GSWindowTemplateFlags)); } if ([coder containsValueForKey: @"NSMinSize"]) { _minSize = [coder decodeSizeForKey: @"NSMinSize"]; } if ([coder containsValueForKey: @"NSMaxSize"]) { _maxSize = [coder decodeSizeForKey: @"NSMaxSize"]; } else { _maxSize = NSMakeSize (10e4, 10e4); } if ([coder containsValueForKey: @"NSWindowRect"]) { _windowRect = [coder decodeRectForKey: @"NSWindowRect"]; } if ([coder containsValueForKey: @"NSFrameAutosaveName"]) { ASSIGN(_autosaveName, [coder decodeObjectForKey: @"NSFrameAutosaveName"]); } if ([coder containsValueForKey: @"NSWindowTitle"]) { ASSIGN(_title, [coder decodeObjectForKey: @"NSWindowTitle"]); _windowStyle |= NSTitledWindowMask; } _baseWindowClass = [NSWindow class]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return self; } - (void) encodeWithCoder: (NSCoder *)aCoder { if ([aCoder allowsKeyedCoding]) { unsigned long flags = 0; NSRect rect = [NSWindow contentRectForFrameRect: _windowRect styleMask: _windowStyle]; memcpy((void *)&flags,(void *)&_flags,sizeof(unsigned long)); [aCoder encodeObject: _viewClass forKey: @"NSViewClass"]; [aCoder encodeObject: _windowClass forKey: @"NSWindowClass"]; [aCoder encodeInt: _windowStyle forKey: @"NSWindowStyleMask"]; [aCoder encodeInt: _backingStoreType forKey: @"NSWindowBacking"]; [aCoder encodeObject: _view forKey: @"NSWindowView"]; [aCoder encodeInt: flags forKey: @"NSWTFlags"]; [aCoder encodeSize: _minSize forKey: @"NSMinSize"]; [aCoder encodeSize: _maxSize forKey: @"NSMaxSize"]; [aCoder encodeRect: rect forKey: @"NSWindowRect"]; [aCoder encodeObject: _title forKey: @"NSWindowTitle"]; [aCoder encodeObject: _autosaveName forKey: @"NSFrameAutosaveName"]; } } /** * This method is used to get the real object when connections are established. */ - (id) nibInstantiate { if (_realObject == nil) { Class aClass; if ([NSClassSwapper isInInterfaceBuilder]) { aClass = [self baseWindowClass]; } else { aClass = NSClassFromString(_windowClass); } if (aClass == nil) { [NSException raise: NSInternalInconsistencyException format: @"Unable to find class '%@'", _windowClass]; } _realObject = [[aClass allocWithZone: NSDefaultMallocZone()] initWithContentRect: _windowRect styleMask: _windowStyle backing: _backingStoreType defer: _flags.isDeferred]; // set flags... [_realObject setHidesOnDeactivate: _flags.isHiddenOnDeactivate]; [_realObject setReleasedWhenClosed: !(_flags.isNotReleasedOnClose)]; [_realObject setOneShot: _flags.isOneShot]; // [_realObject setVisible: _flags.isVisible]; // this is determined by whether it's in the visible windows array... // [_realObject setWantsToBeColor: _flags.wantsToBeColor]; // not applicable on GNUstep. [_realObject setAutodisplay: YES]; [_realObject setDynamicDepthLimit: _flags.dynamicDepthLimit]; // [_realObject setAutoPositionMask: _flags.autoPositionMask]; // currently not implemented for nibs // [_realObject setAutoPosition: _flags.autoPosition]; [_realObject setDynamicDepthLimit: _flags.dynamicDepthLimit]; // [_realObject setFrameAutosaveName: _autosaveName]; // done after setting the min/max sizes // reset attributes... [_realObject setContentView: _view]; [_realObject setMinSize: _minSize]; [_realObject setMaxSize: _maxSize]; [_realObject setTitle: _title]; if ([_viewClass isKindOfClass: [NSToolbar class]]) { // FIXME: No idea what is going on here [_realObject setToolbar: (NSToolbar*)_viewClass]; } [_view _fixSubviews]; // FIXME What is the point of calling -setFrame:display: here? It looks // like an effective no op to me. // resize the window... [_realObject setFrame: [NSWindow frameRectForContentRect: [self windowRect] styleMask: [self windowStyle]] display: NO]; [_realObject setFrameAutosaveName: _autosaveName]; } return _realObject; } // setters and getters /** * sets the type of backing store the window uses. */ - (void) setBackingStoreType: (NSBackingStoreType)type { _backingStoreType = type; } /** * Returns the type of backing store which is used. */ - (NSBackingStoreType) backingStoreType { return _backingStoreType; } /** * Sets whether or not the window is deferred. */ - (void) setDeferred: (BOOL)flag { _flags.isDeferred = flag; } /** * Returns YES, if the window is deferred, NO otherwise. */ - (BOOL) isDeferred { return _flags.isDeferred; } /** * Sets the maximum size of the window. */ - (void) setMaxSize: (NSSize)maxSize { _maxSize = maxSize; } /** * Returns the maximum size of the window. */ - (NSSize) maxSize { return _maxSize; } /** * Sets the minimum size of the window. */ - (void) setMinSize: (NSSize)minSize { _minSize = minSize; } /** * Returns the maximum size of the window. */ - (NSSize) minSize { return _minSize; } /** * Sets the window style. */ - (void) setWindowStyle: (unsigned)style { _windowStyle = style; } /** * Returns the window style. */ - (unsigned) windowStyle { return _windowStyle; } /** * Sets the window title. */ - (void) setTitle: (NSString *) title { ASSIGN(_title, title); } /** * Returns the window style. */ - (NSString *)title; { return _title; } /** * Sets the class used for the content view. */ - (void) setViewClass: (NSString *)viewClass { ASSIGN(_viewClass,viewClass); } /** * Returns the name of the class used for the content view. */ - (NSString *)viewClass { return _viewClass; } /** * Sets the window rect. */ - (void) setWindowRect: (NSRect)rect { _windowRect = rect; } /** * Returns the window rect. */ - (NSRect)windowRect { return _windowRect; } /** * Sets the screen rect. */ - (void) setScreenRect: (NSRect)rect { _screenRect = rect; } /** * Returns the screen rect. */ - (NSRect) screenRect { return _screenRect; } /** * Sets the instantiated object/real object. */ - (void) setRealObject: (id)o { ASSIGN(_realObject,o); } /** * Returns the real object represented by this template. */ - (id) realObject { return _realObject; } /** * Sets the view instance. */ - (void) setView: (id)view { ASSIGN(_view,view); } /** * Gets the view instance. */ - (id) view { return _view; } /** * sets the class name to be used when unarchiving the window. */ - (void) setClassName: (NSString *)name { ASSIGN(_windowClass, name); } /** * Returns the class instance. */ - (NSString *)className { return _windowClass; } /** * Returns the base window class. This is usually NSWindow, but this method * is overriden in the editor so that a different class may be used to take the * place of the window. In the case of Gorm, this is GormNSWindow. */ - (Class) baseWindowClass { return _baseWindowClass; } @end /* * NSViewTemplate * * Template for any classes which derive from NSView */ @implementation NSViewTemplate + (void) initialize { if (self == [NSViewTemplate class]) { [self setVersion: 0]; } } - (void) dealloc { RELEASE(_className); RELEASE(_realObject); [super dealloc]; } /** * Designated initializer for NSViewTemplate. */ - (id) initWithObject: (id)o className: (NSString *)name { if ((self = [super init]) != nil) { [self setRealObject: o]; [self setClassName: name]; } return self; } - (id) initWithCoder: (NSCoder *)coder { self = [super initWithCoder: coder]; if (self != nil) { if ([coder allowsKeyedCoding]) { _className = [coder decodeObjectForKey: @"NSClassName"]; } if (_realObject == nil) { Class aClass = NSClassFromString(_className); if (aClass == nil) { [NSException raise: NSInternalInconsistencyException format: @"Unable to find class '%@'", _className]; } else { ASSIGN(_realObject, [[aClass allocWithZone: NSDefaultMallocZone()] initWithCoder: coder]); [[self superview] replaceSubview: self with: _realObject]; // replace the old view... } } AUTORELEASE(self); return _realObject; } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return nil; } - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { [coder encodeObject: (id)_className forKey: @"NSClassName"]; [_realObject encodeWithCoder: coder]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't encode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } } // setters and getters /** * Set the class name to be used by the NSView subclass. */ - (void) setClassName: (NSString *)name { ASSIGN(_className, name); } /** * Returns the classname. */ - (NSString *)className { return _className; } /** * Set the real object of the template. */ - (void) setRealObject: (id)o { ASSIGN(_realObject, o); } /** * Get the real object represented by the template. */ - (id) realObject { return _realObject; } @end // Template for any classes which derive from NSText @implementation NSTextTemplate + (void) initialize { if (self == [NSTextTemplate class]) { [self setVersion: 0]; } } @end /** * NSTextViewTemplate * * Template for any classes which derive from NSTextView */ @implementation NSTextViewTemplate + (void) initialize { if (self == [NSTextViewTemplate class]) { [self setVersion: 0]; } } @end // Template for any classes which derive from NSMenu. @implementation NSMenuTemplate + (void) initialize { if (self == [NSMenuTemplate class]) { [self setVersion: 0]; } } - (void) dealloc { RELEASE(_menuClass); RELEASE(_realObject); [super dealloc]; } - (id) initWithCoder: (NSCoder *)aCoder { RELEASE(self); return nil; } - (void) encodeWithCoder: (NSCoder *)aCoder { } - (void) setClassName: (NSString *)className { ASSIGN(_menuClass, className); } - (NSString *)className { return _menuClass; } - (void) setRealObject: (id)o { ASSIGN(_realObject,o); } - (id) realObject { return _realObject; } @end @implementation NSCustomObject - (void) setClassName: (NSString *)name { ASSIGNCOPY(_className, name); } - (NSString *)className { return _className; } - (void) setExtension: (NSString *)name { ASSIGNCOPY(_extension, name); } - (NSString *)extension { return _extension; } - (void) setRealObject: (id)obj { ASSIGN(_object, obj); } - (id) realObject { return _object; } - (id) initWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]); ASSIGN(_object, [coder decodeObjectForKey: @"NSObject"]); } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return self; } - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { [coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeConditionalObject: (id)_extension forKey: @"NSExtension"]; [coder encodeConditionalObject: (id)_object forKey: @"NSObject"]; } else { [NSException raise: NSInvalidArgumentException format: @"Keyed coding not implemented for %@.", NSStringFromClass([self class])]; } } - (id) nibInstantiate { if (_object == nil) { Class aClass; if ([NSClassSwapper isInInterfaceBuilder]) { aClass = [self class]; } else { aClass = NSClassFromString(_className); } if (aClass == nil) { [NSException raise: NSInternalInconsistencyException format: @"Unable to find class '%@'", _className]; } if (GSObjCIsKindOf(aClass, [NSApplication class]) || [_className isEqual: @"NSApplication"]) { _object = RETAIN([aClass sharedApplication]); } else { _object = [[aClass allocWithZone: NSDefaultMallocZone()] init]; } } return _object; } - (void) awakeFromNib { NSDebugLog(@"Called awakeFromNib on an NSCustomObject instance: %@", self); if ([_object respondsToSelector: @selector(awakeFromNib)]) { [_object awakeFromNib]; } } - (NSString *) description { return [NSString stringWithFormat: @"<%s: %lx> = <<className: %@, object: %@>>", GSClassNameFromObject(self), (unsigned long)self, _className,_object]; } - (void) dealloc { RELEASE(_className); RELEASE(_extension); RELEASE(_object); [super dealloc]; } @end @implementation NSCustomView - (void) setClassName: (NSString *)name { ASSIGNCOPY(_className, name); } - (NSString *)className { return _className; } - (void) setExtension: (NSString *)ext; { ASSIGNCOPY(_extension, ext); } - (NSString *)extension { return _extension; } - (id) nibInstantiate { if ([NSClassSwapper isInInterfaceBuilder]) { _view = self; return self; } if (_view == nil) { Class aClass; // If the class name is nil, assume NSView. if (_className == nil) { aClass = [NSView class]; } else { aClass = NSClassFromString(_className); } if (aClass == nil) { [NSException raise: NSInternalInconsistencyException format: @"Unable to find class '%@'", _className]; } else { _view = [[aClass allocWithZone: NSDefaultMallocZone()] initWithFrame: [self frame]]; } } return _view; } - (id) nibInstantiateWithCoder: (NSCoder *)coder { if ([NSClassSwapper isInInterfaceBuilder]) { return _view; } else if ([coder allowsKeyedCoding]) { NSArray *subs = nil; id nextKeyView = nil; id prevKeyView = nil; NSEnumerator *en = nil; id v = nil; prevKeyView = [coder decodeObjectForKey: @"NSPreviousKeyView"]; nextKeyView = [coder decodeObjectForKey: @"NSNextKeyView"]; if (nextKeyView != nil) { [_view setNextKeyView: nextKeyView]; } if (prevKeyView != nil) { [_view setPreviousKeyView: prevKeyView]; } if ([coder containsValueForKey: @"NSvFlags"]) { int vFlags = [coder decodeIntForKey: @"NSvFlags"]; [_view setAutoresizingMask: vFlags & 0x3F]; [_view setAutoresizesSubviews: ((vFlags & 0x100) == 0x100)]; [_view setHidden: ((vFlags & 0x80000000) == 0x80000000)]; } /* if ([coder containsValueForKey: @"NSNextResponder"]) { [_view setNextResponder: [coder decodeObjectForKey: @"NSNextResponder"]]; } */ // reset the bounds... // [_view setBounds: [_view frame]]; subs = [coder decodeObjectForKey: @"NSSubviews"]; en = [subs objectEnumerator]; while((v = [en nextObject]) != nil) { [_view addSubview: v]; } } else { [NSException raise: NSInternalInconsistencyException format: @"Called NSCustomView awakeAfterUsingCoder with non-keyed archiver."]; } return _view; } - (id) initWithCoder: (NSCoder *)coder { // if in interface builder, then initialize as normal. if ([NSClassSwapper isInInterfaceBuilder]) { self = [super initWithCoder: coder]; if (self == nil) { return nil; } } if ([coder allowsKeyedCoding]) { // get the super stuff without calling super... if ([coder containsValueForKey: @"NSFrame"]) { _frame = [coder decodeRectForKey: @"NSFrame"]; } else { _frame = NSZeroRect; if ([coder containsValueForKey: @"NSFrameSize"]) { _frame.size = [coder decodeSizeForKey: @"NSFrameSize"]; } } ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_extension, [coder decodeObjectForKey: @"NSExtension"]); if ([self nibInstantiate] != nil) { [self nibInstantiateWithCoder: coder]; } if (self != _view) { AUTORELEASE(self); } } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return _view; } - (void) encodeWithCoder: (NSCoder *)coder { [super encodeWithCoder: coder]; if ([coder allowsKeyedCoding]) { [coder encodeObject: _className forKey: @"NSClassName"]; [coder encodeObject: _extension forKey: @"NSExtension"]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't encode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } } @end /** * This class represents an image or a sound which is referenced by the nib file. */ @implementation NSCustomResource - (void) setClassName: (NSString *)className { ASSIGNCOPY(_className, className); } - (NSString *)className { return _className; } - (void) setResourceName: (NSString *)resourceName { ASSIGNCOPY(_resourceName, resourceName); } - (NSString *)resourceName { return _resourceName; } - (id) initWithCoder: (NSCoder *)coder { id realObject = nil; if ([coder allowsKeyedCoding]) { ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_resourceName, [coder decodeObjectForKey: @"NSResourceName"]); // FIXME: this is a hack, but for now it should do. if ([_className isEqual: @"NSSound"]) { realObject = RETAIN([NSSound soundNamed: _resourceName]); } else if ([_className isEqual: @"NSImage"]) { realObject = RETAIN([NSImage imageNamed: _resourceName]); } if (realObject == nil) { NSLog(@"Could not load NSCustomResource %@ for class %@", _resourceName, _className); // Use a default instead of the missing object if ([_className isEqual: @"NSSound"]) { realObject = RETAIN([NSSound soundNamed: @"Ping"]); } else if ([_className isEqual: @"NSImage"]) { realObject = RETAIN([NSImage imageNamed: @"GNUstep"]); } } // The object has been substituted, release the placeholder. RELEASE(self); } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return realObject; } - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { [coder encodeObject: (id)_className forKey: @"NSClassName"]; [coder encodeObject: (id)_resourceName forKey: @"NSResourceName"]; } } @end /** * Category to add methods to NSKeyedUnarchiver which are needed during * nib reading. */ @implementation NSKeyedUnarchiver (NSClassSwapperPrivate) /** * This method is used to replace oldObj with newObj * in the map that is maintained in NSKeyedUnarchiver. */ - (BOOL) replaceObject: (id)oldObj withObject: (id)newObj { unsigned int i = 0; unsigned int count = GSIArrayCount(_objMap); for (i = 0; i < count; i++) { id obj = GSIArrayItemAtIndex(_objMap, i).obj; if (obj == oldObj) break; } if (i < count) { GSIArraySetItemAtIndex(_objMap, (GSIArrayItem)newObj, i); return YES; } return NO; } /** * This method is private and is purely for debugging purposes. */ - (NSDictionary *)keyMap { return _keyMap; } /** * This method returns the class which replaces the class named * by className. It uses the classes map to do this. */ - (Class) replacementClassForClassName: (NSString *)className { Class aClass; if ((aClass = [self classForClassName: className]) == nil) { if ((aClass = [[self class] classForClassName: className]) == nil) { aClass = NSClassFromString(className); if (aClass == nil) { [NSException raise: NSInternalInconsistencyException format: @"NSClassSwapper unable to find class '%@'", className]; } } } return aClass; } @end /** * NSClassSwapper * * This class is used to stand-in for objects which need to be replaced by another object. * When this class is loaded in the live application, it unarchives and immediately replaces * itself with the instance of the object requested. This is necessary since IB/Gorm does * have objects this is used for in palettes, so there is no "live" or actual instance saved * in the gorm file... only this object as a stand in. */ @implementation NSClassSwapper - (id) initWithObject: (id)object withClassName: (NSString *)className originalClassName: (NSString *)origClassName { if ((self = [super init]) != nil) { [self setTemplate: object]; [self setClassName: className]; [self setOriginalClassName: origClassName]; } return self; } /** * This class method keeps track of whether or not we are operating within IB/Gorm. * When unarchiving in IB/Gorm some behavior may need to be surpressed for some objects * or it */ + (void) setIsInInterfaceBuilder: (BOOL)flag { _isInInterfaceBuilder = flag; } /** * returns YES, if we are currently in IB/Gorm. */ + (BOOL) isInInterfaceBuilder { return _isInInterfaceBuilder; } /** * Sets the template represented by temp. */ - (void) setTemplate: (id)temp { ASSIGN(_template, temp); } /** * Returns the template. */ - (id) template { return _template; } /** * Sets the class name. */ - (void) setClassName: (NSString *)className { ASSIGNCOPY(_className, className); } /** * Returns the class name. */ - (NSString *)className { return _className; } /** * Sets the original class name. */ - (void) setOriginalClassName: (NSString *)className { ASSIGNCOPY(_originalClassName, className); } /** * Returns the original class name. */ - (NSString *)originalClassName { return _originalClassName; } /** * Instantiates the real object using className. */ - (void) instantiateRealObject: (NSCoder *)coder withClassName: (NSString *)className { Class newClass = nil; id object = nil; NSKeyedUnarchiver *decoder = (NSKeyedUnarchiver *)coder; if ([NSClassSwapper isInInterfaceBuilder] == YES) { newClass = [decoder replacementClassForClassName: _originalClassName]; } else { newClass = [decoder replacementClassForClassName: className]; } // swap the class... object = [newClass allocWithZone: NSDefaultMallocZone()]; [decoder setDelegate: self]; // set the delegate... [decoder replaceObject: self withObject: object]; [self setTemplate: [object initWithCoder: decoder]]; if (object != _template) { [decoder replaceObject: object withObject: _template]; } [decoder setDelegate: nil]; // unset the delegate... } /** * This delegate method makes the proper substitution for cellClass * when the object needs to have it's own cell. An example of this * is NSSecureTextField/NSSecureTextFieldCell. */ - (id) unarchiver: (NSKeyedUnarchiver *)coder didDecodeObject: (id)obj { Class newClass = nil; id result = obj; // if we are in an interface builder, then return the original object. if ([NSClassSwapper isInInterfaceBuilder] == YES) { newClass = [coder replacementClassForClassName: _originalClassName]; } else { newClass = [coder replacementClassForClassName: _className]; } // if this is a class which uses cells, override with the new cellClass, if the // subclass responds to cellClass. if ([obj isKindOfClass: [NSCell class]] && [newClass respondsToSelector: @selector(cellClass)] && [_className isEqualToString: _originalClassName] == NO) { Class newCellClass = [newClass cellClass]; if (newCellClass != [NSCell class]) { RELEASE(obj); result = [[newCellClass alloc] initWithCoder: coder]; } } return result; } /** * Decode NSClassSwapper. */ - (id) initWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { ASSIGN(_className, [coder decodeObjectForKey: @"NSClassName"]); ASSIGN(_originalClassName, [coder decodeObjectForKey: @"NSOriginalClassName"]); // build the real object... if ([NSClassSwapper isInInterfaceBuilder] == YES) { [self instantiateRealObject: coder withClassName: _originalClassName]; } else { [self instantiateRealObject: coder withClassName: _className]; } { id object; object = RETAIN(_template); RELEASE(self); return AUTORELEASE(object); } } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return self; } /** * Encode NSClassSwapper. */ - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { [coder encodeObject: _originalClassName forKey: @"NSOriginalClassName"]; [coder encodeObject: _className forKey: @"NSClassName"]; [_template encodeWithCoder: coder]; // encode the actual object; } else { [NSException raise: NSInvalidArgumentException format: @"Can't encode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } } /** * Deallocate NSClassSwapper instance. */ - (void) dealloc { RELEASE(_className); RELEASE(_originalClassName); RELEASE(_template); [super dealloc]; } @end @implementation NSNibConnector (NibCompatibility) /** * This method causes the connection to instantiate the objects in it's source * and destination. The instantiator is the object which holds any custom * class information which might be needed to do the proprer substitution of * objects based on the contents of the maps. */ - (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator { [self setSource: [instantiator instantiateObject: _src]]; [self setDestination: [instantiator instantiateObject: _dst]]; } - (id) nibInstantiate { if ([_src respondsToSelector: @selector(nibInstantiate)]) { [self setSource: [_src nibInstantiate]]; } if ([_dst respondsToSelector: @selector(nibInstantiate)]) { [self setDestination: [_dst nibInstantiate]]; } return self; } @end @implementation NSNibControlConnector (NibCompatibility) /** * This method overrides the default implementation of instantiate with * instantiator. It also corrects a common issue in some nib files * by adding a colon to the end if none was given. It then calls the * superclass with the corrected label. */ - (void) instantiateWithInstantiator: (id<GSInstantiator>)instantiator { NSRange colonRange = [_tag rangeOfString: @":"]; NSUInteger location = colonRange.location; if (location == NSNotFound) { NSString *newTag = [NSString stringWithFormat: @"%@:",_tag]; [self setLabel: (id)newTag]; } [super instantiateWithInstantiator: instantiator]; } @end /** * NSIBObjectData * * This class is the container for all of the nib data. It contains several maps. * The maps are the following: * * name -> object (name table) * object -> name (name table reverse lookup) * classes -> object (for custom class storage) * oids -> object (for relating the oid to each object) * accessibilityOids -> object * * The maps are stored in the nib itself as a set of synchronized * arrays one array containing the keys and the other the values. This is why, in the * initWithCoder: and encodeWithCoder: methods they are saved as arrays and then * loaded into NSMapTables. */ @implementation NSIBObjectData /** * Get the values from the map in the same order as the keys. */ - (NSArray *) _valuesForKeys: (NSArray *)keys inMap: (NSMapTable *)map { NSMutableArray *result = [NSMutableArray array]; NSEnumerator *en = [keys objectEnumerator]; id key = nil; while ((key = [en nextObject]) != nil) { id value = (id)NSMapGet(map,key); [result addObject: value]; } return result; } /** * Build a map with two arrays of keys and values. */ - (void) _buildMap: (NSMapTable *)mapTable withKeys: (NSArray *)keys andValues: (NSArray *)values { NSEnumerator *ken = [keys objectEnumerator]; NSEnumerator *ven = [values objectEnumerator]; id key = nil; id value = nil; while ((key = [ken nextObject]) != nil && (value = [ven nextObject]) != nil) { NSMapInsert(mapTable, key, value); if (value == nil) { NSLog(@"==> WARNING: Value for key %@ is %@",key , value); } } } /** * Encode the NSIBObjectData container */ - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { NSArray *accessibilityOidsKeys = (NSArray *)NSAllMapTableKeys(_accessibilityOids); NSArray *accessibilityOidsValues = [self _valuesForKeys: accessibilityOidsKeys inMap: _accessibilityOids]; NSArray *classKeys = (NSArray *)NSAllMapTableKeys(_classes); NSArray *classValues = [self _valuesForKeys: classKeys inMap: _classes]; NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names); NSArray *nameValues = [self _valuesForKeys: nameKeys inMap: _names]; NSArray *objectsKeys = (NSArray *)NSAllMapTableKeys(_objects); NSArray *objectsValues = [self _valuesForKeys: objectsKeys inMap: _objects]; NSArray *oidsKeys = (NSArray *)NSAllMapTableKeys(_oids); NSArray *oidsValues = [self _valuesForKeys: oidsKeys inMap: _oids]; [(NSKeyedArchiver *)coder setClassName: @"_NSCornerView" forClass: NSClassFromString(@"GSTableCornerView")]; [coder encodeObject: (id)_accessibilityConnectors forKey: @"NSAccessibilityConnectors"]; [coder encodeObject: (id) accessibilityOidsKeys forKey: @"NSAccessibilityOidsKeys"]; [coder encodeObject: (id) accessibilityOidsValues forKey: @"NSAccessibilityOidsValues"]; [coder encodeObject: (id) classKeys forKey: @"NSClassesKeys"]; [coder encodeObject: (id) classValues forKey: @"NSClassesValues"]; [coder encodeObject: (id) nameKeys forKey: @"NSNamesKeys"]; [coder encodeObject: (id) nameValues forKey: @"NSNamesValues"]; [coder encodeObject: (id) objectsKeys forKey: @"NSObjectsKeys"]; [coder encodeObject: (id) objectsValues forKey: @"NSObjectsValues"]; [coder encodeObject: (id) oidsKeys forKey: @"NSOidsKeys"]; [coder encodeObject: (id) oidsValues forKey: @"NSOidsValues"]; [coder encodeObject: (id) _connections forKey: @"NSConnections"]; [coder encodeObject: (id) _fontManager forKey: @"NSFontManager"]; [coder encodeObject: (id) _framework forKey: @"NSFramework"]; [coder encodeObject: (id) _visibleWindows forKey: @"NSVisibleWindows"]; [coder encodeInt: _nextOid forKey: @"NSNextOid"]; [coder encodeConditionalObject: (id) _root forKey: @"NSRoot"]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't encode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } } /** * Decode the NSIBObjectData container. */ - (id) initWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { NSArray *nameKeys = nil; NSArray *nameValues = nil; NSArray *classKeys = nil; NSArray *classValues = nil; NSArray *objectsKeys = nil; NSArray *objectsValues = nil; NSArray *oidsKeys = nil; NSArray *oidsValues = nil; NSArray *accessibilityOidsKeys = nil; NSArray *accessibilityOidsValues = nil; [(NSKeyedUnarchiver *)coder setClass: NSClassFromString(@"GSTableCornerView") forClassName: @"_NSCornerView"]; // // Get root, font, framwork and oid. // Retain objects since NSKeyedUnarchiver autoreleases unarchived objects. // ASSIGN(_root, [coder decodeObjectForKey: @"NSRoot"]); ASSIGN(_fontManager, [coder decodeObjectForKey: @"NSFontManager"]); ASSIGN(_framework, [coder decodeObjectForKey: @"NSFramework"]); _nextOid = [coder decodeIntForKey: @"NSNextOid"]; // get connections. ASSIGN(_connections, (NSMutableArray *) [coder decodeObjectForKey: @"NSConnections"]); ASSIGN(_accessibilityConnectors, (NSMutableArray *) [coder decodeObjectForKey: @"NSAccessibilityConnectors"]); // get visible windows ASSIGN(_visibleWindows, (NSMutableArray *) [coder decodeObjectForKey: @"NSVisibleWindows"]); // instantiate the maps.. _classes = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _names = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _objects = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _oids = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); // // Get the maps. There is no need to retain these, // since they are going to be placed into the NSMapTable // structures anyway. // nameKeys = (NSArray *) [coder decodeObjectForKey: @"NSNamesKeys"]; nameValues = (NSArray *) [coder decodeObjectForKey: @"NSNamesValues"]; classKeys = (NSArray *) [coder decodeObjectForKey: @"NSClassesKeys"]; classValues = (NSArray *) [coder decodeObjectForKey: @"NSClassesValues"]; objectsKeys = (NSArray *) [coder decodeObjectForKey: @"NSObjectsKeys"]; objectsValues = (NSArray *) [coder decodeObjectForKey: @"NSObjectsValues"]; oidsKeys = (NSArray *) [coder decodeObjectForKey: @"NSOidsKeys"]; oidsValues = (NSArray *) [coder decodeObjectForKey: @"NSOidsValues"]; // Fill in the maps... [self _buildMap: _classes withKeys: classKeys andValues: classValues]; [self _buildMap: _names withKeys: nameKeys andValues: nameValues]; [self _buildMap: _objects withKeys: objectsKeys andValues: objectsValues]; [self _buildMap: _oids withKeys: oidsKeys andValues: oidsValues]; // // Only get these maps when in the editor. They // aren't useful outside of it and only waste memory if // unarchived in the live application. // if ([NSClassSwapper isInInterfaceBuilder]) { // Only get these when in the editor... accessibilityOidsKeys = (NSArray *) [coder decodeObjectForKey: @"NSAccessibilityOidsKeys"]; accessibilityOidsValues = (NSArray *) [coder decodeObjectForKey: @"NSAccessibilityOidsValues"]; _accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); [self _buildMap: _accessibilityOids withKeys: accessibilityOidsKeys andValues: accessibilityOidsValues]; } // instantiate... _topLevelObjects = [[NSMutableSet alloc] init]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } return self; } /** * Initialize a new NSIBObjectData. */ - (id) init { if ((self = [super init]) != nil) { // instantiate the maps.. _objects = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _names = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _oids = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _classes = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); _accessibilityOids = NSCreateMapTable(NSObjectMapKeyCallBacks, NSObjectMapValueCallBacks, 2); // initialize the objects... _accessibilityConnectors = [[NSMutableArray alloc] init]; _connections = [[NSMutableArray alloc] init]; _visibleWindows = [[NSMutableArray alloc] init]; _framework = nil; _fontManager = nil; _root = nil; _nextOid = 0; } return self; } /** * Deallocate NSIBObjectData. */ - (void) dealloc { // free the maps. NSFreeMapTable(_objects); NSFreeMapTable(_names); NSFreeMapTable(_classes); NSFreeMapTable(_oids); // these are not allocated when not in interface builder. if ([NSClassSwapper isInInterfaceBuilder]) { NSFreeMapTable(_accessibilityOids); } // free other objects. RELEASE(_accessibilityConnectors); RELEASE(_connections); RELEASE(_fontManager); RELEASE(_framework); RELEASE(_visibleWindows); RELEASE(_root); RELEASE(_topLevelObjects); [super dealloc]; } /** * Call nibInstantiate on an object, if it responds to the nibInstantiate selector. */ - (id)instantiateObject: (id)obj { id newObject = obj; if ([obj respondsToSelector: @selector(nibInstantiate)]) { newObject = [obj nibInstantiate]; } return newObject; } /** * Instantiate all of the objects in the nib file. */ - (void) nibInstantiateWithOwner: (id)owner topLevelObjects: (NSMutableArray *)topLevelObjects { NSEnumerator *en; NSArray *objs; id obj = nil; id menu = nil; // set the new root object. [_root setRealObject: owner]; // iterate over all objects, instantiate them and fill in top level array. /* Note: We instantiate all objects before establishing any connections between them, so that any shared instances defined in the nib are initialized before being used. This sequence is important when, e.g., the nib defines a shared document controller that is an instance of a subclass of NSDocumentController. */ objs = NSAllMapTableKeys(_objects); en = [objs objectEnumerator]; while ((obj = [en nextObject]) != nil) { id v = NSMapGet(_objects, obj); NSInteger oid = [(id)NSMapGet(_oids, obj) intValue]; obj = [self instantiateObject: obj]; // Object is top level if it isn't the owner but points to it. /* Don't record proxy objects in the top level array. The only reliable way to identify proxy objects seems to look at their object ID. Apparently, Apple is using fixed negative IDs for proxy objects (-1 = File's Owner, -2 = First Responder, -3 = NSApplication). */ if (oid >= 0) { if ((v == owner || v == _root) && (obj != owner) && (obj != _root)) { [topLevelObjects addObject: obj]; // All top level objects must be released by the caller to avoid // leaking, unless they are going to be released by other nib // objects on behalf of the owner. RETAIN(obj); } } } // iterate over connections, instantiate and then establish them. en = [_connections objectEnumerator]; while ((obj = [en nextObject]) != nil) { if ([obj respondsToSelector: @selector(instantiateWithInstantiator:)]) { [obj instantiateWithInstantiator: self]; [obj establishConnection]; } } // awaken all objects except proxy objects. objs = NSAllMapTableKeys(_objects); en = [objs objectEnumerator]; while ((obj = [en nextObject]) != nil) { NSInteger oid = [(id)NSMapGet(_oids, obj) intValue]; if (oid >= 0) { if ([obj respondsToSelector: @selector(realObject)]) { obj = [obj realObject]; } if ([obj respondsToSelector: @selector(awakeFromNib)]) { [obj awakeFromNib]; } } } // awaken the owner if ([owner respondsToSelector: @selector(awakeFromNib)]) { [owner awakeFromNib]; } // bring visible windows to front... en = [_visibleWindows objectEnumerator]; while ((obj = [en nextObject]) != nil) { id w = [obj realObject]; [w orderFront: self]; } // add the menu... menu = [self objectForName: @"MainMenu"]; if (menu != nil) { menu = [self instantiateObject: menu]; [NSApp _setMainMenu: menu]; } } /** * Awake after loading the nib and extract the top level and owner for nib instantiation, * then call nibInstantateWithOwner:topLevelObjects: */ - (void) awakeWithContext: (NSDictionary *)context { NSMutableArray *tlo = [context objectForKey: NSNibTopLevelObjects]; id owner = [context objectForKey: NSNibOwner]; // instantiate... [self nibInstantiateWithOwner: owner topLevelObjects: tlo]; } /** * Retrieve an object by name from the map. */ - (id) objectForName: (NSString *)name { NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names); NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names); NSUInteger i = [nameValues indexOfObject: name]; id result = nil; if (i != NSNotFound) { result = [nameKeys objectAtIndex: i]; } return result; } /** * Get the name for an object. */ - (NSString *) nameForObject: (id)obj { NSArray *nameKeys = (NSArray *)NSAllMapTableKeys(_names); NSArray *nameValues = (NSArray *)NSAllMapTableValues(_names); int i = [nameKeys indexOfObject: obj]; NSString *result = [nameValues objectAtIndex: i]; return result; } /** * Set the root object. */ - (void) setRoot: (id) root { ASSIGN(_root, root); } /** * Return the root object. */ - (id) root { return _root; } /** * Set the value of the next available oid. */ - (void) setNextOid: (int)noid { _nextOid = noid; } /** * Get the value of the next available oid. */ - (int) nextOid { return _nextOid; } /** * Connections between objects. */ - (NSMutableArray *) connections { return _connections; } /** * Set of top level objects. */ - (NSMutableSet *) topLevelObjects { return _topLevelObjects; } /** * Names to objects */ - (NSMutableDictionary *) nameTable { return nil; } /** * Set of all visible windows. */ - (NSMutableArray *) visibleWindows { return _visibleWindows; } /** * Objects to names table. */ - (NSMapTable *) objects { return _objects; } /** * Names to objects table. */ - (NSMapTable *) names { return _names; } /** * Classes to objects table. */ - (NSMapTable *) classes { return _classes; } /** * Oids to objects table. */ - (NSMapTable *) oids { return _oids; } @end /** * NSButtonImageSource * * This class is used by buttons to pull the correct image based on a given state. */ @implementation NSButtonImageSource - (id) initWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { ASSIGN(imageName, [coder decodeObjectForKey: @"NSImageName"]); } else { [NSException raise: NSInvalidArgumentException format: @"Can't decode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } AUTORELEASE(self); return RETAIN([NSImage imageNamed: imageName]); } - (void) encodeWithCoder: (NSCoder *)coder { if ([coder allowsKeyedCoding]) { [coder encodeObject: imageName forKey: @"NSImageName"]; } else { [NSException raise: NSInvalidArgumentException format: @"Can't encode %@ with %@.",NSStringFromClass([self class]), NSStringFromClass([coder class])]; } } /** * Initializes with image name. */ - (id) initWithImageNamed: (NSString *)name { if ((self = [super init]) != nil) { ASSIGN(imageName,name); } return self; } /** * Returns imageName. */ - (NSString *)imageName { return imageName; } - (void) dealloc { RELEASE(imageName); [super dealloc]; } @end @implementation NSIBHelpConnector - (id) init { if ((self = [super init]) != nil) { _file = nil; ASSIGN(_marker, @"NSToolTipHelpKey"); } return self; } - (void) dealloc { RELEASE(_file); RELEASE(_marker); [super dealloc]; } - (id) initWithCoder: (NSCoder *)coder { if ((self = [super initWithCoder: coder]) != nil) { if ([coder allowsKeyedCoding]) { if ([coder containsValueForKey: @"NSFile"]) { ASSIGN(_file, [coder decodeObjectForKey: @"NSFile"]); } if ([coder containsValueForKey: @"NSMarker"]) { ASSIGN(_marker, [coder decodeObjectForKey: @"NSMarker"]); } } else { ASSIGN(_file, [coder decodeObject]); ASSIGN(_marker, [coder decodeObject]); } } return self; } - (void) encodeWithCoder: (NSCoder *)coder { [super encodeWithCoder: coder]; if ([coder allowsKeyedCoding]) { if (_file != nil) { [coder encodeObject: _file forKey: @"NSFile"]; } if (_marker != nil) { [coder encodeObject: _file forKey: @"NSMarker"]; } } else { [coder encodeObject: _file]; [coder encodeObject: _marker]; } } - (void) establishConnection { if ([_dst respondsToSelector: @selector(setToolTip:)]) { [_dst setToolTip: _marker]; } } - (void) setFile: (id)file { ASSIGN(_file, file); } - (id) file { return _file; } - (void) setMarker: (id)marker { ASSIGN(_marker, marker); } - (id) marker { return _marker; } @end @implementation NSDecimalNumberPlaceholder - (id) initWithCoder: (NSCoder *)coder { NSDecimalNumber *dn = nil; if ([coder allowsKeyedCoding]) { NSUInteger len = 0; short exponent = (short)[coder decodeIntForKey: @"NS.exponent"]; NSByteOrder bo = [coder decodeIntForKey: @"NS.mantissa.bo"]; BOOL negative = [coder decodeBoolForKey: @"NS.negative"]; void *mantissaBytes = (void *)[coder decodeBytesForKey: @"NS.mantissa" returnedLength: &len]; unsigned long long unswapped = 0; unsigned long long mantissa = 0; // BOOL compact = [coder decodeBoolForKey: @"NS.compact"]; // int length = [coder decodeIntForKey: @"NS.length"]; memcpy((void *)&unswapped, (void *)mantissaBytes, sizeof(unsigned long long)); switch(bo) { case NS_BigEndian: mantissa = NSSwapBigLongLongToHost(unswapped); break; case NS_LittleEndian: mantissa = NSSwapLittleLongLongToHost(unswapped); break; default: break; } dn = [[NSDecimalNumber alloc] initWithMantissa: mantissa exponent: exponent isNegative: negative]; } RELEASE(self); return dn; } @end /** * NSCornerView * * Overridden in NSTableView to be GSTableCornerView, * but the class needs to be present to be overridden. * * Currently this is a place-holder class. */ @implementation _NSCornerView @end /** * NSPSMatrix. * * This class is needed for nib encoding/decoding by transforms. * Currently it's only referenced in the NSProgressIndicator, * as far as I can tell. * * Place holder class. */ @implementation NSPSMatrix - (void) encodeWithCoder: (NSCoder *)coder { // do nothing... just encoding the presence of the class. } - (id) initWithCoder: (NSCoder *)coder { // NSLog(@"NSPSMatrix = %@",[(NSKeyedUnarchiver *)coder keyMap]); return self; } @end
{ "pile_set_name": "Github" }
import * as React from 'react'; /** * Column properties. */ interface IColumnProps { /** prop1 description */ prop1?: string; /** prop2 description */ prop2: number; } /** * Column description */ export class Column extends React.Component<IColumnProps, {}> { public static defaultProps: Partial<IColumnProps> = { prop1: 'prop1' }; public render() { const { prop1 } = this.props; return <div>{prop1}</div>; } }
{ "pile_set_name": "Github" }
package com.smartdevicelink.test.rpc.enums; import com.smartdevicelink.proxy.rpc.enums.MassageCushion; import junit.framework.TestCase; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * This is a unit test class for the SmartDeviceLink library project class : * {@link com.smartdevicelink.rpc.enums.MassageCushion} */ public class MassageCushionTests extends TestCase { /** * Verifies that the enum values are not null upon valid assignment. */ public void testValidEnums() { String example = "TOP_LUMBAR"; MassageCushion enumTopLumbar = MassageCushion.valueForString(example); example = "MIDDLE_LUMBAR"; MassageCushion enumMiddleLumbar = MassageCushion.valueForString(example); example = "BOTTOM_LUMBAR"; MassageCushion enumBottomLumbar = MassageCushion.valueForString(example); example = "BACK_BOLSTERS"; MassageCushion enumBackBolsters = MassageCushion.valueForString(example); example = "SEAT_BOLSTERS"; MassageCushion enumSeatBolsters = MassageCushion.valueForString(example); assertNotNull("TOP_LUMBAR returned null", enumTopLumbar); assertNotNull("MIDDLE_LUMBAR returned null", enumMiddleLumbar); assertNotNull("BOTTOM_LUMBAR returned null", enumBottomLumbar); assertNotNull("BACK_BOLSTERS returned null", enumBackBolsters); assertNotNull("SEAT_BOLSTERS returned null", enumSeatBolsters); } /** * Verifies that an invalid assignment is null. */ public void testInvalidEnum() { String example = "tOP_LUMBAR"; try { MassageCushion temp = MassageCushion.valueForString(example); assertNull("Result of valueForString should be null.", temp); } catch (IllegalArgumentException exception) { fail("Invalid enum throws IllegalArgumentException."); } } /** * Verifies that a null assignment is invalid. */ public void testNullEnum() { String example = null; try { MassageCushion temp = MassageCushion.valueForString(example); assertNull("Result of valueForString should be null.", temp); } catch (NullPointerException exception) { fail("Null string throws NullPointerException."); } } /** * Verifies the possible enum values of MassageCushion. */ public void testListEnum() { List<MassageCushion> enumValueList = Arrays.asList(MassageCushion.values()); List<MassageCushion> enumTestList = new ArrayList<MassageCushion>(); enumTestList.add(MassageCushion.TOP_LUMBAR); enumTestList.add(MassageCushion.MIDDLE_LUMBAR); enumTestList.add(MassageCushion.BOTTOM_LUMBAR); enumTestList.add(MassageCushion.BACK_BOLSTERS); enumTestList.add(MassageCushion.SEAT_BOLSTERS); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); } }
{ "pile_set_name": "Github" }
.well { box-shadow: inset 0 0 0 rgba(0, 0, 0, 0); border: 1px solid #DCDEE4; border-radius: 0; background-color: $light-gray; margin-bottom: 0; }
{ "pile_set_name": "Github" }
/* * Copyright 2018 The Kythe Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package beamio import ( "bytes" "context" "encoding/binary" "fmt" "hash/crc32" "io" "log" "path/filepath" "reflect" "sort" "strings" "time" "github.com/apache/beam/sdks/go/pkg/beam" "github.com/apache/beam/sdks/go/pkg/beam/io/filesystem" "github.com/syndtr/goleveldb/leveldb/comparer" "github.com/syndtr/goleveldb/leveldb/journal" "github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/table" ) func init() { beam.RegisterType(reflect.TypeOf((*shardKeyValue)(nil)).Elem()) beam.RegisterType(reflect.TypeOf((*writeManifest)(nil)).Elem()) beam.RegisterType(reflect.TypeOf((*writeTable)(nil)).Elem()) } // WriteLevelDB writes a set of PCollections containing KVs to a new LevelDB at // the given path. Each KV is serialized and stored as a single LevelDB // key-value entry according to their enclosing PCollection's beam.Coder. Each // table may have different KV types. Keys must be unique across all // PCollections. func WriteLevelDB(s beam.Scope, path string, numShards int, tables ...beam.PCollection) { filesystem.ValidateScheme(path) s = s.Scope("WriteLevelDB") tableMetadata := writeShards(s, path, numShards, tables...) // Write all SSTable metadata to the LevelDB's MANIFEST journal. s = s.Scope("Manifest") beam.ParDo(s, &writeManifest{Path: path}, beam.GroupByKey(s, beam.AddFixedKey(s, tableMetadata))) } func writeShards(s beam.Scope, path string, numShards int, tables ...beam.PCollection) beam.PCollection { s = s.Scope("Shards") encoded := EncodeKeyValues(s, tables...) // Group each key-value by a shard number based on its key's byte encoding. shards := beam.GroupByKey(s, beam.ParDo(s, &shardKeyValue{Shards: numShards}, encoded)) // Write each shard to a separate SSTable. The resulting PCollection contains // each SSTable's metadata (*tableMetadata). return beam.ParDo(s, &writeTable{path}, shards) } type writeManifest struct{ Path string } type fsFile struct { io.WriteCloser fs filesystem.Interface } // Close implements part of the io.WriteCloser interface. It closes both the // file and underlying filesystem. func (f *fsFile) Close() error { fErr := f.WriteCloser.Close() fsErr := f.fs.Close() if fErr != nil { return fErr } return fsErr } func openWrite(ctx context.Context, path string) (io.WriteCloser, error) { fs, err := filesystem.New(ctx, path) if err != nil { return nil, err } f, err := fs.OpenWrite(ctx, path) if err != nil { return nil, err } return &fsFile{f, fs}, nil } // Constants used as IDs for LevelDB journal entries. const ( manifestCompararerNum = 1 manifestCurrentJournalNum = 2 manifestNextFileNum = 3 manifestLastCompactionNum = 4 manifestAddedTableNum = 7 ) // ProcessElement combines all tableMetadata into LevelDB's journal format and // writes the database's CURRENT manifest file. It returns the maximum shard // number processed. func (w *writeManifest) ProcessElement(ctx context.Context, _ beam.T, e func(*tableMetadata) bool) (int, error) { const manifestName = "MANIFEST-000000" defer func(start time.Time) { log.Printf("Manifest written in %s", time.Since(start)) }(time.Now()) // Write the CURRENT manifest to the 0'th LevelDB file. f, err := openWrite(ctx, schemePreservingPathJoin(w.Path, manifestName)) if err != nil { return 0, err } journals := journal.NewWriter(f) j, err := journals.Next() if err != nil { return 0, err } // Comparer putUvarint(j, manifestCompararerNum) putBytes(j, []byte(keyComparer{}.Name())) // Current journal putUvarint(j, manifestCurrentJournalNum) putUvarint(j, 0) // MANIFEST-000000 // Added table entry var maxShard, maxSeq int var md tableMetadata for e(&md) { putUvarint(j, manifestAddedTableNum) putUvarint(j, 0) // all SSTables are level-0 putUvarint(j, uint64(md.Shard)) putUvarint(j, uint64(md.Size)) putBytes(j, md.First) putBytes(j, md.Last) // Keep track of the last shard num and maximum sequence number. if md.Shard > maxShard { maxShard = md.Shard } if md.Seq > maxSeq { maxSeq = md.Seq } } // Next available file entry putUvarint(j, manifestNextFileNum) putUvarint(j, uint64(maxShard+1)) // Last compaction sequence putUvarint(j, manifestLastCompactionNum) putUvarint(j, uint64(maxSeq)) if err := journals.Close(); err != nil { return 0, err } else if err := f.Close(); err != nil { return 0, err } // Write the CURRENT pointer to the freshly written manifest file. currentFile, err := openWrite(ctx, schemePreservingPathJoin(w.Path, "CURRENT")) if err != nil { return 0, err } else if _, err := io.WriteString(currentFile, manifestName+"\n"); err != nil { return 0, err } else if err := currentFile.Close(); err != nil { return 0, err } return maxShard, nil } // putUvarint writes x as a varint to w. func putUvarint(w io.Writer, x uint64) error { buf := make([]byte, binary.MaxVarintLen64) n := binary.PutUvarint(buf, x) _, err := w.Write(buf[:n]) return err } // putBytes writes a varint-prefixed buffer to w. func putBytes(w io.Writer, b []byte) error { if err := putUvarint(w, uint64(len(b))); err != nil { return err } _, err := w.Write(b) return err } type writeTable struct{ Path string } // tableMetadata represents a single SSTable within a LevelDB. Each SSTable // written by the LevelDB sink is a level-0 table (meaning that its key ranges // can overlap with another SSTable's). type tableMetadata struct { // Shard is the table's identifying number. Shard int // First/Last are the first and last keys in the table. First, Last []byte // Size is the byte size of the encoded table. Size int // Seq is the last used sequence number in the table. Seq int } var ( duplicateLevelDBKeysCounter = beam.NewCounter("kythe.beamio.leveldb", "duplicate-keys") conflictingLevelDBValuesCounter = beam.NewCounter("kythe.beamio.leveldb", "conflicting-values") ) const schemaSeparator = "://" // schemePreservingPathJoin is like filepath.Join, but doesn't collapse // the double-slash in the schema prefix, if any. func schemePreservingPathJoin(p, f string) string { parts := strings.SplitN(p, schemaSeparator, 2) if len(parts) == 2 { return parts[0] + schemaSeparator + filepath.Join(parts[1], f) } return filepath.Join(p, f) } // ProcessElement writes a set of KeyValues to the an SSTable per shard. Shards // should be small enough to fit into memory so that they can be sorted. // TODO(BEAM-4405): use SortValues extension to remove in-memory requirement func (w *writeTable) ProcessElement(ctx context.Context, shard int, kvIter func(*KeyValue) bool, emit func(tableMetadata)) error { opts := &opt.Options{ BlockSize: 5 * opt.MiB, Comparer: keyComparer{}, } var totalElements int defer func(start time.Time) { log.Printf("Shard %04d: %s (size: %d)", shard, time.Since(start), totalElements) }(time.Now()) md := tableMetadata{Shard: shard + 1} var els []KeyValue var kv KeyValue for kvIter(&kv) { els = append(els, kv) } sort.Slice(els, func(i, j int) bool { return bytes.Compare(els[i].Key, els[j].Key) < 0 }) // Remove duplicate keys j := 1 for i := 1; i < len(els); i++ { if bytes.Equal(els[j-1].Key, els[i].Key) { if !bytes.Equal(els[j-1].Value, els[i].Value) { conflictingLevelDBValuesCounter.Inc(ctx, 1) } duplicateLevelDBKeysCounter.Inc(ctx, 1) } else { els[j] = els[i] j++ } } els = els[:j] // Encode keys for LevelDB for i := 0; i < len(els); i++ { md.Seq++ els[i].Key = makeLevelDBKey(uint64(md.Seq), els[i].Key) } totalElements = len(els) md.First = els[0].Key md.Last = els[len(els)-1].Key // Write each sorted key-value to an SSTable. f, err := openWrite(ctx, schemePreservingPathJoin(w.Path, fmt.Sprintf("%06d.ldb", md.Shard))) if err != nil { return err } wr := table.NewWriter(f, opts) for _, kv := range els { if err := wr.Append(kv.Key, kv.Value); err != nil { return err } } if err := wr.Close(); err != nil { return err } else if err := f.Close(); err != nil { return err } md.Size = wr.BytesLen() emit(md) return nil } type shardKeyValue struct{ Shards int } func (s *shardKeyValue) ProcessElement(kv KeyValue) (int, KeyValue) { h := crc32.NewIEEE() h.Write(kv.Key) return int(h.Sum32()) % s.Shards, kv } const keySuffixSize = 8 // makeLevelDBKey constructs an internal LevelDB key from a user key. seq is // the sequence number for the key-value entry within the LevelDB. func makeLevelDBKey(seq uint64, key []byte) []byte { const typ = 1 // value (vs. deletion) k := make([]byte, len(key)+keySuffixSize) copy(k, key) binary.LittleEndian.PutUint64(k[len(key):], (seq<<keySuffixSize)|typ) return k } // parseLevelDBKey returns the user key and the sequence number (and value type) // from an internal LevelDB key. func parseLevelDBKey(key []byte) (ukey []byte, seqNum uint64) { return key[:len(key)-keySuffixSize], binary.LittleEndian.Uint64(key[len(key)-keySuffixSize:]) } // keyComparer compares internal (ukey, seqNum) LevelDB keys. type keyComparer struct{} // Name implements part of the comparer.Comparer interface. func (keyComparer) Name() string { return "leveldb.BytewiseComparator" } // Compare implements part of the comparer.Comparer interface. func (keyComparer) Compare(a, b []byte) int { ak, an := parseLevelDBKey(a) bk, bn := parseLevelDBKey(b) c := bytes.Compare(ak, bk) if c == 0 { return int(bn - an) } return c } // Separator implements part of the comparer.Comparer interface. func (keyComparer) Separator(dst, a, b []byte) []byte { ak, _ := parseLevelDBKey(a) bk, _ := parseLevelDBKey(b) dst = comparer.DefaultComparer.Separator(dst, ak, bk) if dst != nil && len(dst) < len(ak) && bytes.Compare(ak, dst) < 0 { return append(dst, maxKeyNumSuffix...) } return nil } // Successor implements part of the comparer.Comparer interface. func (keyComparer) Successor(dst, k []byte) []byte { k, _ = parseLevelDBKey(k) dst = comparer.DefaultComparer.Successor(dst, k) if dst != nil && len(dst) < len(k) && bytes.Compare(k, dst) < 0 { return append(dst, maxKeyNumSuffix...) } return nil } // maxKeyNumSuffix is maximum possible sequence number (and value type) for an // internal LevelDB key. var maxKeyNumSuffix = bytes.Repeat([]byte{0xFF}, keySuffixSize)
{ "pile_set_name": "Github" }
#include "soundcloud.h" #include "request.h" #include <QDebug> SoundCloud::SoundCloud(QObject *parent) : QObject(parent) { getHome(); } bool SoundCloud::cidEmpty(){ return cid.trimmed().isEmpty(); } void SoundCloud::extract_cid(QString rep) { cid = rep.split("client_id:\"").last().split("\"").first(); } void SoundCloud::getHome() { jsId = 0; Request *req = new Request(this); connect(req,&Request::requestFinished,[=](QString uid,QString rep) { Q_UNUSED(uid); getJs(rep); req->deleteLater(); }); req->get(home,"0"); } void SoundCloud::getJs(const QString res){ QRegExp regExp("src=*\"([^\"]+.js)"); jsList.clear(); int pos = 0; while ((pos = regExp.indexIn(res, pos)) != -1) { jsList << regExp.cap(1); pos += regExp.matchedLength(); } //reverse list for(int k=0, s=jsList.size(), max=(s/2); k<max; k++) jsList.swap(k,s-(1+k)); getCid(); } void SoundCloud::getCid(){ if(cidjs.trimmed().isEmpty()) { Request *req = new Request(this); connect(req,&Request::requestFinished,[=](QString uid,QString rep){ if(rep.contains("client_id:\"")){ qDebug()<<"CLIENT ID FOUND IN"<<uid; cidjs = rep; extract_cid(rep); }else{ if(jsId<jsList.count()){ jsId = jsId + 1; getCid(); } } req->deleteLater(); }); qDebug()<<"REQUEST:"<<jsId<<jsList.at(jsId); req->get(jsList.at(jsId),QString::number(jsId)); } }
{ "pile_set_name": "Github" }
'********************************************************************************** '* クラス名 :RegionEntity '* クラス日本語名 :自動生成Entityクラス '* '* 作成日時 :2014/2/9 '* 作成者 :棟梁 D層自動生成ツール(墨壺), 日立 太郎 '* 更新履歴 : '* '* 日時 更新者 内容 '* ---------- ---------------- ------------------------------------------------- '* 20xx/xx/xx XX XX XXXX '********************************************************************************** ' System~ Imports System ''' <summary>自動生成Entityクラス</summary> <Serializable> _ Public Class RegionEntity #Region "メンバ変数" ''' <summary>設定フラグ:RegionID</summary> Public IsSetPK_RegionID As Boolean = False ''' <summary>メンバ変数:RegionID</summary> Private _PK_RegionID As Nullable(Of System.Int32) ''' <summary>プロパティ:RegionID</summary> Public Property PK_RegionID() As Nullable(Of System.Int32) Get Return Me._PK_RegionID End Get Set Me.IsSetPK_RegionID = True Me._PK_RegionID = value End Set End Property ''' <summary>設定フラグ:RegionDescription</summary> Public IsSet_RegionDescription As Boolean = False ''' <summary>メンバ変数:RegionDescription</summary> Private _RegionDescription As System.String ''' <summary>プロパティ:RegionDescription</summary> Public Property RegionDescription() As System.String Get Return Me._RegionDescription End Get Set Me.IsSet_RegionDescription = True Me._RegionDescription = value End Set End Property ''' <summary>設定フラグ:Set_RegionID_forUPD</summary> Public IsSet_Set_RegionID_forUPD As Boolean = False ''' <summary>メンバ変数:Set_RegionID_forUPD</summary> Private _Set_RegionID_forUPD As Nullable(Of System.Int32) ''' <summary>プロパティ:Set_RegionID_forUPD</summary> Public Property Set_RegionID_forUPD() As Nullable(Of System.Int32) Get Return Me._Set_RegionID_forUPD End Get Set Me.IsSet_Set_RegionID_forUPD = True Me._Set_RegionID_forUPD = value End Set End Property ''' <summary>設定フラグ:Set_RegionDescription_forUPD</summary> Public IsSet_Set_RegionDescription_forUPD As Boolean = False ''' <summary>メンバ変数:Set_RegionDescription_forUPD</summary> Private _Set_RegionDescription_forUPD As System.String ''' <summary>プロパティ:Set_RegionDescription_forUPD</summary> Public Property Set_RegionDescription_forUPD() As System.String Get Return Me._Set_RegionDescription_forUPD End Get Set Me.IsSet_Set_RegionDescription_forUPD = True Me._Set_RegionDescription_forUPD = value End Set End Property ''' <summary>設定フラグ:RegionID_Like</summary> Public IsSet_RegionID_Like As Boolean = False ''' <summary>メンバ変数:RegionID_Like</summary> Private _RegionID_Like As Nullable(Of System.Int32) ''' <summary>プロパティ:RegionID_Like</summary> Public Property RegionID_Like() As Nullable(Of System.Int32) Get Return Me._RegionID_Like End Get Set Me.IsSet_RegionID_Like = True Me._RegionID_Like = value End Set End Property ''' <summary>設定フラグ:RegionDescription_Like</summary> Public IsSet_RegionDescription_Like As Boolean = False ''' <summary>メンバ変数:RegionDescription_Like</summary> Private _RegionDescription_Like As System.String ''' <summary>プロパティ:RegionDescription_Like</summary> Public Property RegionDescription_Like() As System.String Get Return Me._RegionDescription_Like End Get Set Me.IsSet_RegionDescription_Like = True Me._RegionDescription_Like = value End Set End Property #End Region End Class
{ "pile_set_name": "Github" }
/** @jsx h */ import h from '../../../hyperscript'; export default ( <document> <hr /> <paragraph>Hello World</paragraph> </document> );
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <Workspace version = "1.0"> <FileRef location = "group:Examples/../Masonry.xcodeproj"> </FileRef> <FileRef location = "group:Examples/Masonry iOS Examples.xcodeproj"> </FileRef> <FileRef location = "group:Tests/Masonry Tests.xcodeproj"> </FileRef> <FileRef location = "group:Pods/Pods.xcodeproj"> </FileRef> </Workspace>
{ "pile_set_name": "Github" }
{ "name": "debug", "repo": "visionmedia/debug", "description": "small debugging utility", "version": "2.6.9", "keywords": [ "debug", "log", "debugger" ], "main": "src/browser.js", "scripts": [ "src/browser.js", "src/debug.js" ], "dependencies": { "rauchg/ms.js": "0.7.1" } }
{ "pile_set_name": "Github" }
// 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/. js> Array.isArray; function isArray() { [native code for Array.isArray, arity=1] } js> Array.isArray() false js> Array.isArray(undefined); false js> Array.isArray(null); false js> Array.isArray(true); false js> Array.isArray(1); false js> Array.isArray('hello'); false js> Array.isArray({}); false js> Array.isArray(function(){}) false js> (function() { print(Array.isArray(arguments)) })() false js> Array.isArray([]) true js> Array.isArray(new Array()) true
{ "pile_set_name": "Github" }
''' Copyright (C) 2019 Gitcoin Core This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import time from django.core.management.base import BaseCommand from django.utils import timezone from dashboard.models import Investigation, Profile class Command(BaseCommand): help = 'Investigates sybil attacks' def handle(self, *args, **options): then = timezone.now() - timezone.timedelta(minutes=120) profiles = Profile.objects.filter(last_visit__gt=then) for profile in profiles: start_time = time.time() print(f"{profile.pk} at {round(start_time,2)}") Investigation.investigate_sybil(profile) profile.save() the_time = time.time() - start_time print(f"END {profile.pk} after {round(the_time,2)} s")
{ "pile_set_name": "Github" }
; ; Old School Computer Architecture - interfacing FLOS ; Stefano Bodrato, 2011 ; ; Get the size for the given file ; ; $Id: get_file_size.asm,v 1.5 2016-06-22 22:13:09 dom Exp $ ; INCLUDE "target/osca/def/flos.def" SECTION code_clib PUBLIC get_file_size PUBLIC _get_file_size get_file_size: _get_file_size: ; __FASTCALL__, HL points to filename push ix ;save callers push iy call kjt_find_file push ix pop de push iy pop hl pop iy pop ix ;restore callers ret z ld hl,0 ld d,h ld e,l ret
{ "pile_set_name": "Github" }
// *********************** // Navbar // this file contains styling for both top navbar and sidenav for docs page // *********************** #top-navigation { background-image: url("../img/slss_bg_pattern_2.svg"); background-repeat: repeat-y; background-size: 1200px auto; border-radius: 0; margin: 0; } #top-navigation.home { background: none; } .navbar { background-image: url("../img/slss_bg_pattern_2.svg"); background-color: $sless-dark-blue; background-size: 1200px auto; border-radius: 0; margin: 0; min-height: 6.5rem; margin-bottom: 4rem; .container { padding: 0; } &.home { .navbar-brand { visibility: hidden; } .s-badge { margin-left: -150px; } .dropdown-menu { background-color: $sless-blue; border-radius: $border-radius; left: -5rem; margin-top: 1rem; margin-bottom: 1rem; } } } .arrow_box { position: relative; background: #4D8FCC; } .arrow_box:after { bottom: 100%; left: 50%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-color: rgba(77, 143, 204, 0); border-bottom-color: #4D8FCC; border-width: 1rem; margin-left: -1rem; } .icon-bar { background-color: $sless-blue; display: block; width: 2.2rem; height: .2rem; border-radius: .1rem; margin-top: .4rem; } .navbar-brand { color: #fff; min-height: 6.5rem; margin-right: 4rem; background-image: url("../img/secretless_4c_ko_horiz.svg"); width: 15rem; text-indent: -999rem; background-size: contain; background-repeat: no-repeat; background-position-y: center; } .navbar-nav { .dropdown-menu { width: 100%; .top-drop { border-bottom: .1rem solid #ffffff1a; &:last-of-type { border-bottom: none; } } } } .navbar-nav li { font-size: 1.4rem; font-weight: 100; //height: 6.5rem; display: flex; flex-direction: row; align-items: center; color: #fff; padding: .8rem 1rem; &.top-drop a { color: #fff; } &.top-sub.active > a { color: $sless-blue; } &.top-drop.active > a { color: $sless-blue; } .dropdown-menu li a { color: #fff; } } .dropdown.top-sub:focus, .dropdown.top-sub a:focus { outline: none; } @media (max-width: 991px) { .navbar-nav { .dropdown-menu { background-color: $sless-blue; border-radius: $border-radius; li { transition: all 0.4s; &:hover { background-color: darken($sless-blue, 10); a { color: #fff; } } } } li { flex-direction: column; } } .arrow_box:after { display: none; } } .navbar-nav a { color: lighten($sless-light-blue, 05); font-size: 1.5rem; font-weight: 500; transition: all 0.4s; letter-spacing: .05rem; width: 100%; &:hover { text-decoration: none; color: $sless-blue; } } .dropdown-menu { background-color: $sless-dark-blue; min-width: 16rem; border-radius: 0 0 .4rem .4rem; margin: 0; border: 0; box-shadow: 0 .6rem 1.2rem rgba(0, 0, 0, 0.175); li { height: 5rem; } } // ********************* // Side Navigation #side-navigation { border-radius: .4rem; justify-content: center; flex-direction: column; margin-bottom: 8rem; h3 { &.active { a { color: darken($sless-blue, 30); } } a{ color: $sless-blue; } } a { color: $sless-text; transition: all 0.4s; &:hover { color: $sless-blue; text-decoration: none; } } ul { list-style-type: none; padding: 0; li { font-weight: 300; &.active { a { font-weight: 800; } } &.active.section { font-weight: 800; } &.active.entry { font-weight: 800; } } } .list-link { font-family: $sless-font-secondary; width: 100%; padding: 1rem 0 0 2.5rem ; } .sidenav-group { background-color: lighten($sless-light-blue, 02); padding: 2rem 0; border-radius: $border-radius; :nth-child(1) { border-top: none; padding-top: 0; } :last-child { margin-bottom: 0; } h3 { padding: 2rem 2.5rem .5rem 2.5rem; color: $sless-blue; border-top: .1rem solid darken($sless-light-blue, 10); font-weight: 800; font-size: 1.6rem; a:hover { color: darken($sless-blue, 20); } } } .sidenav-list { font-weight: 800; margin: .5rem 0; border-top: .1rem solid darken($sless-light-blue, 10); } .group-of-sections { font-weight: 500; padding: 0px 2.5rem; } .sidenav-sublist { padding: 0rem 2.5rem; } .sidenav-subsublist { padding: .6rem 0; } .sidenav-subsublist li{ margin-left: 1rem; i { margin-right: .5rem; font-size: 1.3rem; color: $sless-blue; } } } #cybr-nav { width: 100%; margin-bottom: 0; height: 6.5rem; background: transparent; } .navbar-list li { font-size: 1.4rem; font-weight: 100; } .navbar-list a { color: lighten($sless-light-blue, 05); padding: .8rem 1rem; font-size: 1.5rem; font-weight: 500; transition: all 0.4s; letter-spacing: .1rem; &:hover { text-decoration: none; color: $sless-blue; } } .sidenav-item { list-style-type: none; margin: 0 0 .2rem 0; font-size: 1.5rem; font-weight: 800; } .fixed-nav { position: fixed; top: 0; margin-right: 10.0rem; } .fixed-nav-documentation { position: relative; left: 21.5rem; } .sidenav-item:hover a:hover { text-decoration: none; } .navbar-list > ul { display: flex; list-style: none; justify-content: flex-end; letter-spacing: .2rem; } .navbar-list > ul > li { margin: 1.0rem; } .navbar .default { margin-bottom: 0; } /* default class and toggled when user selects down caret for side navbar*/ .dropdown-menu-option { display: none; padding-left: .8rem; border-top: .1rem solid darken($sless-light-blue, 10); display: none; padding: 1rem 2.5rem; margin: 0 -2.5rem; background-color:darken($sless-light-blue, 02); } .dropdown-btn { i { float: right; color: #4d8fcc; margin-top: .6rem; } } .rotatingArrow { transform: rotate(90deg); } .arrow { transition: all 0.4s; } /* Keeps side navbar open */ .navbar-open { display: block; }
{ "pile_set_name": "Github" }
<?php class TestClass { public $prop = 2; public function foo() { echo "Called foo(), property = $this->prop\n"; var_dump($this); return "Return Val"; } private static function privateMethod() { echo "Called privateMethod()\n"; } } abstract class AbstractClass { abstract function foo(); } $foo = new ReflectionMethod('TestClass', 'foo'); $privateMethod = new ReflectionMethod("TestClass::privateMethod"); $testClassInstance = new TestClass(); $testClassInstance->prop = "Hello"; echo "invoke() on a non-object:\n"; try { var_dump($foo->invoke(true)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } echo "\ninvoke() on a non-instance:\n"; try { var_dump($foo->invoke(new stdClass())); } catch (ReflectionException $e) { var_dump($e->getMessage()); } echo "\nPrivate method:\n"; try { var_dump($privateMethod->invoke($testClassInstance)); } catch (ReflectionException $e) { var_dump($e->getMessage()); } echo "\nAbstract method:\n"; $abstractMethod = new ReflectionMethod("AbstractClass::foo"); try { $abstractMethod->invoke(true); } catch (ReflectionException $e) { var_dump($e->getMessage()); } ?>
{ "pile_set_name": "Github" }
=== 1.1.0 / 2013-02-06 * Yandex is now also pinged when the sitemap is updated * Deprecated methods from v1.0.0 now removed === 1.0.2 / 2013-02-06 * Fixes an issue with duplicate URLs === 1.0.1 / 2012-03-10 * Fixes an issue generating correct URL paths === 1.0.0 / 2011-10-24 * API Change: Sitemaps are now generated using a block syntax. Find methods are no longer the responsibility of BigSitemap. Instead, sitemaps are generated using a block, in which you call your own find methods, passing the results to BigSitemap with the 'add' method. See the README for details. * BigSitemapRails and BigSitemapMerb are now BigSitemap::Rails and BigSitemap::Merb, respectively. * Sitemap files are now placed in the document root by default * Sitemaps are now automatically cleaned before generating the new set * Search engines are now pinged automatically when the sitemap is generated * Lock files are now generated automatically * Sitemap files are no longer split amongst your models === 0.8.5 / 2011-10-20 * Gzipped files now include indents and newlines === 0.8.4 / 2011-10-20 * Fixes an issue where joins where causing ambiguous "id" column (https://github.com/alexrabarts/big_sitemap/pull/17) * Fixes an issue with empty <loc> nodes (https://github.com/alexrabarts/big_sitemap/pull/20) === 0.8.3 / 2011-03-08 * Separate URL and file paths are now supported via the :document_path and :url_path options * Fixes an issue when initializing in Rails 3 === 0.8.2 / 2011-01-25 * Fixes an issue where sitemap files were not being generated if the same model was added more than once (fixes issue #5: https://github.com/alexrabarts/big_sitemap/issues/#issue/5) === 0.8.1 / 2011-01-25 * API change: Rails/Merb are no longer automatically detected - use BigSitemapRails and BigSitemapMerb instead * API change: Rails' polymorphic_url helper is no longer used to generate URLs (use a lambda with the new :location option instead) * Static resources can now be added using the add_static method * Incremental updates are now available via the :partial_update option * "loc" URL values can now be generated with lambdas * Sitemap files can now be locked while being generated using the with_lock method * Several bug fixes === 0.5.1 / 2009-09-07 * Fixes an issue with the :last_modified key being passed into the find method options === 0.5.0 / 2009-09-07 * Add support for lambdas when specifying lastmod === 0.4.0 / 2009-08-09 * Use Bing instead of Live/MSN. Note, this breaks backwards compatibility as the old :ping_msn option is now :ping_bing. === 0.3.5 / 2009-08-05 * Fixed bugs in root_url generation and url_for_sitemap generation === 0.3.4 / 2009-07-02 * BigSitemap-specific options are no longer passed through to the ORM's find method === 0.3.2 / 2009-06-09 * Better handling of URLs when Rails' polymorphic_url isn't available in the model === 0.3.2 / 2009-06-09 * Fixes "uninitialized constant ActionController" error * Fixes "Unknown key(s): path" error === 0.3.1 / 2009-04-18 * Fixes broken gemspec === 0.3.0 / 2009-04-06 * API change: Pass model through as first argument to add method, e.g.sitemap.add(Posts, {:path => 'articles'}) * API change: Use Rails' polymorphic_url helper to generate URLs if Rails is being used * API change: Only ping search engines when ping_search_engines is explicitly called * Add support for passing options through to the model's find method, e.g. :conditions * Allow base URL to be specified as a hash as well as a string * Add support for changefreq and priority * Pluralize sitemap model filenames * GZipping may optionally be turned off === 0.2.1 / 2009-03-12 * Normalize path arguments so it no longer matters whether a leading slash is used or not === 0.2.0 / 2009-03-11 * Methods are now chainable === 0.1.4 / 2009-03-11 * Add clean method to clear out Sitemaps directory * Make methods chainable === 0.1.3 / 2009-03-10 * Initial release
{ "pile_set_name": "Github" }
package de.metas.purchasecandidate; import de.metas.util.Check; import lombok.Value; /* * #%L * marketing-base * %% * Copyright (C) 2018 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% */ @Value public class BPPurchaseScheduleId { int repoId; public static BPPurchaseScheduleId ofRepoId(final int repoId) { return new BPPurchaseScheduleId(repoId); } private BPPurchaseScheduleId(final int repoId) { this.repoId = Check.assumeGreaterThanZero(repoId, "repoId"); } }
{ "pile_set_name": "Github" }
package hcl2shim import ( "fmt" "reflect" "strconv" "strings" "github.com/zclconf/go-cty/cty" ) // RequiresReplace takes a list of flatmapped paths from a // InstanceDiff.Attributes along with the corresponding cty.Type, and returns // the list of the cty.Paths that are flagged as causing the resource // replacement (RequiresNew). // This will filter out redundant paths, paths that refer to flatmapped indexes // (e.g. "#", "%"), and will return any changes within a set as the path to the // set itself. func RequiresReplace(attrs []string, ty cty.Type) ([]cty.Path, error) { var paths []cty.Path for _, attr := range attrs { p, err := requiresReplacePath(attr, ty) if err != nil { return nil, err } paths = append(paths, p) } // now trim off any trailing paths that aren't GetAttrSteps, since only an // attribute itself can require replacement paths = trimPaths(paths) // There may be redundant paths due to set elements or index attributes // Do some ugly n^2 filtering, but these are always fairly small sets. for i := 0; i < len(paths)-1; i++ { for j := i + 1; j < len(paths); j++ { if reflect.DeepEqual(paths[i], paths[j]) { // swap the tail and slice it off paths[j], paths[len(paths)-1] = paths[len(paths)-1], paths[j] paths = paths[:len(paths)-1] j-- } } } return paths, nil } // trimPaths removes any trailing steps that aren't of type GetAttrSet, since // only an attribute itself can require replacement func trimPaths(paths []cty.Path) []cty.Path { var trimmed []cty.Path for _, path := range paths { path = trimPath(path) if len(path) > 0 { trimmed = append(trimmed, path) } } return trimmed } func trimPath(path cty.Path) cty.Path { for len(path) > 0 { _, isGetAttr := path[len(path)-1].(cty.GetAttrStep) if isGetAttr { break } path = path[:len(path)-1] } return path } // requiresReplacePath takes a key from a flatmap along with the cty.Type // describing the structure, and returns the cty.Path that would be used to // reference the nested value in the data structure. // This is used specifically to record the RequiresReplace attributes from a // ResourceInstanceDiff. func requiresReplacePath(k string, ty cty.Type) (cty.Path, error) { if k == "" { return nil, nil } if !ty.IsObjectType() { panic(fmt.Sprintf("requires replace path on non-object type: %#v", ty)) } path, err := pathFromFlatmapKeyObject(k, ty.AttributeTypes()) if err != nil { return path, fmt.Errorf("[%s] %s", k, err) } return path, nil } func pathSplit(p string) (string, string) { parts := strings.SplitN(p, ".", 2) head := parts[0] rest := "" if len(parts) > 1 { rest = parts[1] } return head, rest } func pathFromFlatmapKeyObject(key string, atys map[string]cty.Type) (cty.Path, error) { k, rest := pathSplit(key) path := cty.Path{cty.GetAttrStep{Name: k}} ty, ok := atys[k] if !ok { return path, fmt.Errorf("attribute %q not found", k) } if rest == "" { return path, nil } p, err := pathFromFlatmapKeyValue(rest, ty) if err != nil { return path, err } return append(path, p...), nil } func pathFromFlatmapKeyValue(key string, ty cty.Type) (cty.Path, error) { var path cty.Path var err error switch { case ty.IsPrimitiveType(): err = fmt.Errorf("invalid step %q with type %#v", key, ty) case ty.IsObjectType(): path, err = pathFromFlatmapKeyObject(key, ty.AttributeTypes()) case ty.IsTupleType(): path, err = pathFromFlatmapKeyTuple(key, ty.TupleElementTypes()) case ty.IsMapType(): path, err = pathFromFlatmapKeyMap(key, ty) case ty.IsListType(): path, err = pathFromFlatmapKeyList(key, ty) case ty.IsSetType(): path, err = pathFromFlatmapKeySet(key, ty) default: err = fmt.Errorf("unrecognized type: %s", ty.FriendlyName()) } if err != nil { return path, err } return path, nil } func pathFromFlatmapKeyTuple(key string, etys []cty.Type) (cty.Path, error) { var path cty.Path var err error k, rest := pathSplit(key) // we don't need to convert the index keys to paths if k == "#" { return path, nil } idx, err := strconv.Atoi(k) if err != nil { return path, err } path = cty.Path{cty.IndexStep{Key: cty.NumberIntVal(int64(idx))}} if idx >= len(etys) { return path, fmt.Errorf("index %s out of range in %#v", key, etys) } if rest == "" { return path, nil } ty := etys[idx] p, err := pathFromFlatmapKeyValue(rest, ty.ElementType()) if err != nil { return path, err } return append(path, p...), nil } func pathFromFlatmapKeyMap(key string, ty cty.Type) (cty.Path, error) { var path cty.Path var err error k, rest := key, "" if !ty.ElementType().IsPrimitiveType() { k, rest = pathSplit(key) } // we don't need to convert the index keys to paths if k == "%" { return path, nil } path = cty.Path{cty.IndexStep{Key: cty.StringVal(k)}} if rest == "" { return path, nil } p, err := pathFromFlatmapKeyValue(rest, ty.ElementType()) if err != nil { return path, err } return append(path, p...), nil } func pathFromFlatmapKeyList(key string, ty cty.Type) (cty.Path, error) { var path cty.Path var err error k, rest := pathSplit(key) // we don't need to convert the index keys to paths if key == "#" { return path, nil } idx, err := strconv.Atoi(k) if err != nil { return path, err } path = cty.Path{cty.IndexStep{Key: cty.NumberIntVal(int64(idx))}} if rest == "" { return path, nil } p, err := pathFromFlatmapKeyValue(rest, ty.ElementType()) if err != nil { return path, err } return append(path, p...), nil } func pathFromFlatmapKeySet(key string, ty cty.Type) (cty.Path, error) { // once we hit a set, we can't return consistent paths, so just mark the // set as a whole changed. return nil, nil } // FlatmapKeyFromPath returns the flatmap equivalent of the given cty.Path for // use in generating legacy style diffs. func FlatmapKeyFromPath(path cty.Path) string { var parts []string for _, step := range path { switch step := step.(type) { case cty.GetAttrStep: parts = append(parts, step.Name) case cty.IndexStep: switch ty := step.Key.Type(); { case ty == cty.String: parts = append(parts, step.Key.AsString()) case ty == cty.Number: i, _ := step.Key.AsBigFloat().Int64() parts = append(parts, strconv.Itoa(int(i))) } } } return strings.Join(parts, ".") }
{ "pile_set_name": "Github" }
// IConfiguratorListener.hh -- Listen for configuration changes. // // Copyright (C) 2001 - 2007 Rob Caelers <robc@krandor.nl> // All rights reserved. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundator; either versor 2, or (at your optor) // any later versor. // // 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. // #ifndef ICONFIGURATORLISTENER_HH #define ICONFIGURATORLISTENER_HH #include <string> namespace workrave { //! Listener to receive notifications of changed configuration. class IConfiguratorListener { public: virtual ~IConfiguratorListener() {} //! The configuration item with specified key has changed. virtual void config_changed_notify(const std::string &key) = 0; }; } #endif // ICONFIGURATORLISTENER_HH
{ "pile_set_name": "Github" }
// blake2.cpp - written and placed in the public domain by Jeffrey Walton // and Zooko Wilcox-O'Hearn. Based on Aumasson, Neves, // Wilcox-O'Hearn and Winnerlein's reference BLAKE2 // implementation at http://github.com/BLAKE2/BLAKE2. // // The BLAKE2b and BLAKE2s numbers are consistent with the BLAKE2 team's // numbers. However, we have an Altivec/POWER7 implementation of BLAKE2s, // and a POWER8 implementation of BLAKE2b (BLAKE2 is missing them). The // Altivec/POWER7 code is about 2x faster than C++ when using GCC 5.0 or // above. The POWER8 code is about 2.5x faster than C++ when using GCC 5.0 // or above. If you use GCC 4.0 (PowerMac) or GCC 4.8 (GCC Compile Farm) // then the PowerPC code will be slower than C++. Be sure to use GCC 5.0 // or above for PowerPC builds or disable Altivec for BLAKE2b and BLAKE2s // if using the old compilers. #include "pch.h" #include "config.h" #include "cryptlib.h" #include "argnames.h" #include "algparam.h" #include "blake2.h" #include "cpu.h" // Uncomment for benchmarking C++ against SSE2 or NEON. // Do so in both blake2.cpp and blake2-simd.cpp. // #undef CRYPTOPP_SSE41_AVAILABLE // #undef CRYPTOPP_ARM_NEON_AVAILABLE // #undef CRYPTOPP_ALTIVEC_AVAILABLE // #undef CRYPTOPP_POWER8_AVAILABLE // Disable NEON/ASIMD for Cortex-A53 and A57. The shifts are too slow and C/C++ is about // 3 cpb faster than NEON/ASIMD. Also see http://github.com/weidai11/cryptopp/issues/367. #if (defined(__aarch32__) || defined(__aarch64__)) && defined(CRYPTOPP_SLOW_ARMV8_SHIFT) # undef CRYPTOPP_ARM_NEON_AVAILABLE #endif // BLAKE2s bug on AIX 7.1 (POWER7) with XLC 12.01 // https://github.com/weidai11/cryptopp/issues/743 #if defined(__xlC__) && (__xlC__ < 0x0d01) # define CRYPTOPP_DISABLE_ALTIVEC 1 # undef CRYPTOPP_POWER7_AVAILABLE # undef CRYPTOPP_POWER8_AVAILABLE # undef CRYPTOPP_ALTIVEC_AVAILABLE #endif NAMESPACE_BEGIN(CryptoPP) // Export the tables to the SIMD files extern const word32 BLAKE2S_IV[8]; extern const word64 BLAKE2B_IV[8]; CRYPTOPP_ALIGN_DATA(16) const word32 BLAKE2S_IV[8] = { 0x6A09E667UL, 0xBB67AE85UL, 0x3C6EF372UL, 0xA54FF53AUL, 0x510E527FUL, 0x9B05688CUL, 0x1F83D9ABUL, 0x5BE0CD19UL }; CRYPTOPP_ALIGN_DATA(16) const word64 BLAKE2B_IV[8] = { W64LIT(0x6a09e667f3bcc908), W64LIT(0xbb67ae8584caa73b), W64LIT(0x3c6ef372fe94f82b), W64LIT(0xa54ff53a5f1d36f1), W64LIT(0x510e527fade682d1), W64LIT(0x9b05688c2b3e6c1f), W64LIT(0x1f83d9abfb41bd6b), W64LIT(0x5be0cd19137e2179) }; NAMESPACE_END ANONYMOUS_NAMESPACE_BEGIN using CryptoPP::byte; using CryptoPP::word32; using CryptoPP::word64; using CryptoPP::rotrConstant; CRYPTOPP_ALIGN_DATA(16) const byte BLAKE2S_SIGMA[10][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 }, }; CRYPTOPP_ALIGN_DATA(16) const byte BLAKE2B_SIGMA[12][16] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 }, { 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 }, { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 }, { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 }, { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 }, { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } }; template <unsigned int R, unsigned int N> inline void BLAKE2B_G(const word64 m[16], word64& a, word64& b, word64& c, word64& d) { a = a + b + m[BLAKE2B_SIGMA[R][2*N+0]]; d = rotrConstant<32>(d ^ a); c = c + d; b = rotrConstant<24>(b ^ c); a = a + b + m[BLAKE2B_SIGMA[R][2*N+1]]; d = rotrConstant<16>(d ^ a); c = c + d; b = rotrConstant<63>(b ^ c); } template <unsigned int R> inline void BLAKE2B_ROUND(const word64 m[16], word64 v[16]) { BLAKE2B_G<R,0>(m,v[ 0],v[ 4],v[ 8],v[12]); BLAKE2B_G<R,1>(m,v[ 1],v[ 5],v[ 9],v[13]); BLAKE2B_G<R,2>(m,v[ 2],v[ 6],v[10],v[14]); BLAKE2B_G<R,3>(m,v[ 3],v[ 7],v[11],v[15]); BLAKE2B_G<R,4>(m,v[ 0],v[ 5],v[10],v[15]); BLAKE2B_G<R,5>(m,v[ 1],v[ 6],v[11],v[12]); BLAKE2B_G<R,6>(m,v[ 2],v[ 7],v[ 8],v[13]); BLAKE2B_G<R,7>(m,v[ 3],v[ 4],v[ 9],v[14]); } template <unsigned int R, unsigned int N> inline void BLAKE2S_G(const word32 m[16], word32& a, word32& b, word32& c, word32& d) { a = a + b + m[BLAKE2S_SIGMA[R][2*N+0]]; d = rotrConstant<16>(d ^ a); c = c + d; b = rotrConstant<12>(b ^ c); a = a + b + m[BLAKE2S_SIGMA[R][2*N+1]]; d = rotrConstant<8>(d ^ a); c = c + d; b = rotrConstant<7>(b ^ c); } template <unsigned int R> inline void BLAKE2S_ROUND(const word32 m[16], word32 v[]) { BLAKE2S_G<R,0>(m,v[ 0],v[ 4],v[ 8],v[12]); BLAKE2S_G<R,1>(m,v[ 1],v[ 5],v[ 9],v[13]); BLAKE2S_G<R,2>(m,v[ 2],v[ 6],v[10],v[14]); BLAKE2S_G<R,3>(m,v[ 3],v[ 7],v[11],v[15]); BLAKE2S_G<R,4>(m,v[ 0],v[ 5],v[10],v[15]); BLAKE2S_G<R,5>(m,v[ 1],v[ 6],v[11],v[12]); BLAKE2S_G<R,6>(m,v[ 2],v[ 7],v[ 8],v[13]); BLAKE2S_G<R,7>(m,v[ 3],v[ 4],v[ 9],v[14]); } ANONYMOUS_NAMESPACE_END NAMESPACE_BEGIN(CryptoPP) void BLAKE2_Compress32_CXX(const byte* input, BLAKE2s_State& state); void BLAKE2_Compress64_CXX(const byte* input, BLAKE2b_State& state); #if CRYPTOPP_SSE41_AVAILABLE extern void BLAKE2_Compress32_SSE4(const byte* input, BLAKE2s_State& state); extern void BLAKE2_Compress64_SSE4(const byte* input, BLAKE2b_State& state); #endif #if CRYPTOPP_ARM_NEON_AVAILABLE extern void BLAKE2_Compress32_NEON(const byte* input, BLAKE2s_State& state); extern void BLAKE2_Compress64_NEON(const byte* input, BLAKE2b_State& state); #endif #if CRYPTOPP_POWER8_AVAILABLE extern void BLAKE2_Compress32_POWER8(const byte* input, BLAKE2s_State& state); #elif CRYPTOPP_ALTIVEC_AVAILABLE extern void BLAKE2_Compress32_ALTIVEC(const byte* input, BLAKE2s_State& state); #endif #if CRYPTOPP_POWER8_AVAILABLE extern void BLAKE2_Compress64_POWER8(const byte* input, BLAKE2b_State& state); #endif unsigned int BLAKE2b::OptimalDataAlignment() const { #if defined(CRYPTOPP_SSE41_AVAILABLE) if (HasSSE41()) return 16; else #endif #if (CRYPTOPP_ARM_NEON_AVAILABLE) if (HasNEON()) return 4; else #endif #if (CRYPTOPP_POWER8_AVAILABLE) if (HasPower8()) return 16; else #endif return GetAlignmentOf<word64>(); } std::string BLAKE2b::AlgorithmProvider() const { #if defined(CRYPTOPP_SSE41_AVAILABLE) if (HasSSE41()) return "SSE4.1"; else #endif #if (CRYPTOPP_ARM_NEON_AVAILABLE) if (HasNEON()) return "NEON"; else #endif #if (CRYPTOPP_POWER8_AVAILABLE) if (HasPower8()) return "Power8"; else #endif return "C++"; } unsigned int BLAKE2s::OptimalDataAlignment() const { #if defined(CRYPTOPP_SSE41_AVAILABLE) if (HasSSE41()) return 16; else #endif #if (CRYPTOPP_ARM_NEON_AVAILABLE) if (HasNEON()) return 4; else #endif #if (CRYPTOPP_POWER8_AVAILABLE) if (HasPower8()) return 16; else #elif (CRYPTOPP_ALTIVEC_AVAILABLE) if (HasAltivec()) return 16; else #endif return GetAlignmentOf<word32>(); } std::string BLAKE2s::AlgorithmProvider() const { #if defined(CRYPTOPP_SSE41_AVAILABLE) if (HasSSE41()) return "SSE4.1"; else #endif #if (CRYPTOPP_ARM_NEON_AVAILABLE) if (HasNEON()) return "NEON"; else #endif #if (CRYPTOPP_POWER8_AVAILABLE) if (HasPower8()) return "Power8"; else #elif (CRYPTOPP_ALTIVEC_AVAILABLE) if (HasAltivec()) return "Altivec"; else #endif return "C++"; } void BLAKE2s_State::Reset() { std::memset(m_hft, 0x00, m_hft.SizeInBytes()); m_len = 0; } void BLAKE2b_State::Reset() { std::memset(m_hft, 0x00, m_hft.SizeInBytes()); m_len = 0; } BLAKE2s_ParameterBlock::BLAKE2s_ParameterBlock(size_t digestLen, size_t keyLen, const byte* saltStr, size_t saltLen, const byte* personalizationStr, size_t personalizationLen) { Reset(digestLen, keyLen); if (saltStr && saltLen) memcpy_s(salt(), SALTSIZE, saltStr, saltLen); if (personalizationStr && personalizationLen) memcpy_s(personalization(), PERSONALIZATIONSIZE, personalizationStr, personalizationLen); } BLAKE2b_ParameterBlock::BLAKE2b_ParameterBlock(size_t digestLen, size_t keyLen, const byte* saltStr, size_t saltLen, const byte* personalizationStr, size_t personalizationLen) { Reset(digestLen, keyLen); if (saltStr && saltLen) memcpy_s(salt(), SALTSIZE, saltStr, saltLen); if (personalizationStr && personalizationLen) memcpy_s(personalization(), PERSONALIZATIONSIZE, personalizationStr, personalizationLen); } void BLAKE2s_ParameterBlock::Reset(size_t digestLen, size_t keyLen) { std::memset(m_data, 0x00, m_data.size()); m_data[DigestOff] = static_cast<byte>(digestLen); m_data[KeyOff] = static_cast<byte>(keyLen); m_data[FanoutOff] = m_data[DepthOff] = 1; } void BLAKE2b_ParameterBlock::Reset(size_t digestLen, size_t keyLen) { std::memset(m_data, 0x00, m_data.size()); m_data[DigestOff] = static_cast<byte>(digestLen); m_data[KeyOff] = static_cast<byte>(keyLen); m_data[FanoutOff] = m_data[DepthOff] = 1; } BLAKE2s::BLAKE2s(bool treeMode, unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(0), m_treeMode(treeMode) { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); UncheckedSetKey(NULLPTR, 0, MakeParameters (Name::DigestSize(), (int)digestSize) (Name::TreeMode(), treeMode)); } BLAKE2b::BLAKE2b(bool treeMode, unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(0), m_treeMode(treeMode) { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); UncheckedSetKey(NULLPTR, 0, MakeParameters (Name::DigestSize(), (int)digestSize) (Name::TreeMode(), treeMode)); } BLAKE2s::BLAKE2s(unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(0), m_treeMode(false) { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); UncheckedSetKey(NULLPTR, 0, MakeParameters (Name::DigestSize(), (int)digestSize) (Name::TreeMode(), false)); } BLAKE2b::BLAKE2b(unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(0), m_treeMode(false) { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); UncheckedSetKey(NULLPTR, 0, MakeParameters (Name::DigestSize(), (int)digestSize) (Name::TreeMode(), false)); } BLAKE2s::BLAKE2s(const byte *key, size_t keyLength, const byte* salt, size_t saltLength, const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(static_cast<unsigned int>(keyLength)), m_treeMode(treeMode) { CRYPTOPP_ASSERT(keyLength <= MAX_KEYLENGTH); CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); CRYPTOPP_ASSERT(saltLength <= SALTSIZE); CRYPTOPP_ASSERT(personalizationLength <= PERSONALIZATIONSIZE); UncheckedSetKey(key, static_cast<unsigned int>(keyLength), MakeParameters (Name::DigestSize(),(int)digestSize) (Name::TreeMode(),treeMode) (Name::Salt(), ConstByteArrayParameter(salt, saltLength)) (Name::Personalization(), ConstByteArrayParameter(personalization, personalizationLength))); } BLAKE2b::BLAKE2b(const byte *key, size_t keyLength, const byte* salt, size_t saltLength, const byte* personalization, size_t personalizationLength, bool treeMode, unsigned int digestSize) : m_digestSize(digestSize), m_keyLength(static_cast<unsigned int>(keyLength)), m_treeMode(treeMode) { CRYPTOPP_ASSERT(keyLength <= MAX_KEYLENGTH); CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); CRYPTOPP_ASSERT(saltLength <= SALTSIZE); CRYPTOPP_ASSERT(personalizationLength <= PERSONALIZATIONSIZE); UncheckedSetKey(key, static_cast<unsigned int>(keyLength), MakeParameters (Name::DigestSize(),(int)digestSize) (Name::TreeMode(),treeMode) (Name::Salt(), ConstByteArrayParameter(salt, saltLength)) (Name::Personalization(), ConstByteArrayParameter(personalization, personalizationLength))); } void BLAKE2s::UncheckedSetKey(const byte *key, unsigned int length, const CryptoPP::NameValuePairs& params) { if (key && length) { m_key.New(BLOCKSIZE); std::memcpy(m_key, key, length); std::memset(m_key + length, 0x00, BLOCKSIZE - length); m_keyLength = length; } else { m_key.resize(0); m_keyLength = 0; } m_digestSize = static_cast<unsigned int>(params.GetIntValueWithDefault( Name::DigestSize(), static_cast<int>(m_digestSize))); m_state.Reset(); m_block.Reset(m_digestSize, m_keyLength); (void)params.GetValue(Name::TreeMode(), m_treeMode); ConstByteArrayParameter t; if (params.GetValue(Name::Salt(), t) && t.begin() && t.size()) memcpy_s(m_block.salt(), SALTSIZE, t.begin(), t.size()); if (params.GetValue(Name::Personalization(), t) && t.begin() && t.size()) memcpy_s(m_block.personalization(), PERSONALIZATIONSIZE, t.begin(), t.size()); Restart(); } void BLAKE2b::UncheckedSetKey(const byte *key, unsigned int length, const CryptoPP::NameValuePairs& params) { if (key && length) { m_key.New(BLOCKSIZE); std::memcpy(m_key, key, length); std::memset(m_key + length, 0x00, BLOCKSIZE - length); m_keyLength = length; } else { m_key.resize(0); m_keyLength = 0; } m_digestSize = static_cast<unsigned int>(params.GetIntValueWithDefault( Name::DigestSize(), static_cast<int>(m_digestSize))); m_state.Reset(); m_block.Reset(m_digestSize, m_keyLength); (void)params.GetValue(Name::TreeMode(), m_treeMode); ConstByteArrayParameter t; if (params.GetValue(Name::Salt(), t) && t.begin() && t.size()) memcpy_s(m_block.salt(), SALTSIZE, t.begin(), t.size()); if (params.GetValue(Name::Personalization(), t) && t.begin() && t.size()) memcpy_s(m_block.personalization(), PERSONALIZATIONSIZE, t.begin(), t.size()); Restart(); } void BLAKE2s::Restart() { static const word32 zero[2] = {0,0}; Restart(m_block, zero); } void BLAKE2b::Restart() { static const word64 zero[2] = {0,0}; Restart(m_block, zero); } void BLAKE2s::Restart(const BLAKE2s_ParameterBlock& block, const word32 counter[2]) { // We take a counter as a parameter to allow customized state. m_state.Reset(); if (counter != NULLPTR) { word32* t = m_state.t(); t[0] = counter[0]; t[1] = counter[1]; } // We take a parameter block as a parameter to allow customized state. // Avoid the copy of the parameter block when we are passing our own block. if (block.data() == m_block.data()) m_block.Reset(m_digestSize, m_keyLength); else { std::memcpy(m_block.data(), block.data(), m_block.size()); m_block.m_data[BLAKE2s_ParameterBlock::DigestOff] = (byte)m_digestSize; m_block.m_data[BLAKE2s_ParameterBlock::KeyOff] = (byte)m_keyLength; } const word32* iv = BLAKE2S_IV; PutBlock<word32, LittleEndian, true> put(m_block.data(), m_state.h()); put(iv[0])(iv[1])(iv[2])(iv[3])(iv[4])(iv[5])(iv[6])(iv[7]); // When BLAKE2 is keyed, the input stream is simply {key || 0 || message}. // The key is padded to a full Blocksize with 0. Key it during Restart to // avoid FirstPut and friends. Key size == 0 means no key. if (m_keyLength) Update(m_key, BLOCKSIZE); } void BLAKE2b::Restart(const BLAKE2b_ParameterBlock& block, const word64 counter[2]) { // We take a counter as a parameter to allow customized state. m_state.Reset(); if (counter != NULLPTR) { word64* t = m_state.t(); t[0] = counter[0]; t[1] = counter[1]; } // We take a parameter block as a parameter to allow customized state. // Avoid the copy of the parameter block when we are passing our own block. if (block.data() == m_block.data()) m_block.Reset(m_digestSize, m_keyLength); else { std::memcpy(m_block.data(), block.data(), m_block.size()); m_block.m_data[BLAKE2b_ParameterBlock::DigestOff] = (byte)m_digestSize; m_block.m_data[BLAKE2b_ParameterBlock::KeyOff] = (byte)m_keyLength; } const word64* iv = BLAKE2B_IV; PutBlock<word64, LittleEndian, true> put(m_block.data(), m_state.h()); put(iv[0])(iv[1])(iv[2])(iv[3])(iv[4])(iv[5])(iv[6])(iv[7]); // When BLAKE2 is keyed, the input stream is simply {key || 0 || message}. // The key is padded to a full Blocksize with 0. Key it during Restart to // avoid FirstPut and friends. Key size == 0 means no key. if (m_keyLength) Update(m_key, BLOCKSIZE); } void BLAKE2s::Update(const byte *input, size_t length) { CRYPTOPP_ASSERT(input != NULLPTR || length == 0); if (length > BLOCKSIZE - m_state.m_len) { if (m_state.m_len != 0) { // Complete current block const size_t fill = BLOCKSIZE - m_state.m_len; std::memcpy(m_state.m_buf+m_state.m_len, input, fill); IncrementCounter(BLOCKSIZE); Compress(m_state.m_buf); m_state.m_len = 0; length -= fill, input += fill; } // Compress in-place to avoid copies while (length > BLOCKSIZE) { IncrementCounter(BLOCKSIZE); Compress(input); length -= BLOCKSIZE, input += BLOCKSIZE; } } // Copy tail bytes if (length) { CRYPTOPP_ASSERT(length <= BLOCKSIZE - m_state.m_len); std::memcpy(m_state.m_buf+m_state.m_len, input, length); m_state.m_len += static_cast<unsigned int>(length); } } void BLAKE2b::Update(const byte *input, size_t length) { CRYPTOPP_ASSERT(input != NULLPTR || length == 0); if (length > BLOCKSIZE - m_state.m_len) { if (m_state.m_len != 0) { // Complete current block const size_t fill = BLOCKSIZE - m_state.m_len; std::memcpy(m_state.m_buf+m_state.m_len, input, fill); IncrementCounter(BLOCKSIZE); Compress(m_state.m_buf); m_state.m_len = 0; length -= fill, input += fill; } // Compress in-place to avoid copies while (length > BLOCKSIZE) { CRYPTOPP_ASSERT(m_state.m_len == 0); IncrementCounter(BLOCKSIZE); Compress(input); length -= BLOCKSIZE, input += BLOCKSIZE; } } // Copy tail bytes if (length) { CRYPTOPP_ASSERT(length <= BLOCKSIZE - m_state.m_len); std::memcpy(m_state.m_buf + m_state.m_len, input, length); m_state.m_len += static_cast<unsigned int>(length); } } void BLAKE2s::TruncatedFinal(byte *hash, size_t size) { CRYPTOPP_ASSERT(hash != NULLPTR); this->ThrowIfInvalidTruncatedSize(size); word32* f = m_state.f(); // Set last block unconditionally f[0] = ~static_cast<word32>(0); // Set last node if tree mode if (m_treeMode) f[1] = ~static_cast<word32>(0); // Increment counter for tail bytes only IncrementCounter(m_state.m_len); std::memset(m_state.m_buf + m_state.m_len, 0x00, BLOCKSIZE - m_state.m_len); Compress(m_state.m_buf); // Copy to caller buffer std::memcpy(hash, m_state.h(), size); Restart(); } void BLAKE2b::TruncatedFinal(byte *hash, size_t size) { CRYPTOPP_ASSERT(hash != NULLPTR); this->ThrowIfInvalidTruncatedSize(size); word64* f = m_state.f(); // Set last block unconditionally f[0] = ~static_cast<word64>(0); // Set last node if tree mode if (m_treeMode) f[1] = ~static_cast<word64>(0); // Increment counter for tail bytes only IncrementCounter(m_state.m_len); std::memset(m_state.m_buf + m_state.m_len, 0x00, BLOCKSIZE - m_state.m_len); Compress(m_state.m_buf); // Copy to caller buffer std::memcpy(hash, m_state.h(), size); Restart(); } void BLAKE2s::IncrementCounter(size_t count) { word32* t = m_state.t(); t[0] += static_cast<word32>(count); t[1] += !!(t[0] < count); } void BLAKE2b::IncrementCounter(size_t count) { word64* t = m_state.t(); t[0] += static_cast<word64>(count); t[1] += !!(t[0] < count); } void BLAKE2s::Compress(const byte *input) { #if CRYPTOPP_SSE41_AVAILABLE if(HasSSE41()) { return BLAKE2_Compress32_SSE4(input, m_state); } #endif #if CRYPTOPP_ARM_NEON_AVAILABLE if(HasNEON()) { return BLAKE2_Compress32_NEON(input, m_state); } #endif #if CRYPTOPP_POWER8_AVAILABLE if(HasPower8()) { return BLAKE2_Compress32_POWER8(input, m_state); } #elif CRYPTOPP_ALTIVEC_AVAILABLE if(HasAltivec()) { return BLAKE2_Compress32_ALTIVEC(input, m_state); } #endif return BLAKE2_Compress32_CXX(input, m_state); } void BLAKE2b::Compress(const byte *input) { #if CRYPTOPP_SSE41_AVAILABLE if(HasSSE41()) { return BLAKE2_Compress64_SSE4(input, m_state); } #endif #if CRYPTOPP_ARM_NEON_AVAILABLE if(HasNEON()) { return BLAKE2_Compress64_NEON(input, m_state); } #endif #if CRYPTOPP_POWER8_AVAILABLE if(HasPower8()) { return BLAKE2_Compress64_POWER8(input, m_state); } #endif return BLAKE2_Compress64_CXX(input, m_state); } void BLAKE2_Compress64_CXX(const byte* input, BLAKE2b_State& state) { word64 m[16], v[16]; GetBlock<word64, LittleEndian, true> get1(input); get1(m[0])(m[1])(m[2])(m[3])(m[4])(m[5])(m[6])(m[7])(m[8])(m[9])(m[10])(m[11])(m[12])(m[13])(m[14])(m[15]); GetBlock<word64, LittleEndian, true> get2(state.h()); get2(v[0])(v[1])(v[2])(v[3])(v[4])(v[5])(v[6])(v[7]); const word64* iv = BLAKE2B_IV; const word64* tf = state.t(); v[ 8] = iv[0]; v[ 9] = iv[1]; v[10] = iv[2]; v[11] = iv[3]; v[12] = tf[0] ^ iv[4]; v[13] = tf[1] ^ iv[5]; v[14] = tf[2] ^ iv[6]; v[15] = tf[3] ^ iv[7]; BLAKE2B_ROUND<0>(m, v); BLAKE2B_ROUND<1>(m, v); BLAKE2B_ROUND<2>(m, v); BLAKE2B_ROUND<3>(m, v); BLAKE2B_ROUND<4>(m, v); BLAKE2B_ROUND<5>(m, v); BLAKE2B_ROUND<6>(m, v); BLAKE2B_ROUND<7>(m, v); BLAKE2B_ROUND<8>(m, v); BLAKE2B_ROUND<9>(m, v); BLAKE2B_ROUND<10>(m, v); BLAKE2B_ROUND<11>(m, v); word64* h = state.h(); for (unsigned int i = 0; i < 8; ++i) h[i] = h[i] ^ ConditionalByteReverse(LITTLE_ENDIAN_ORDER, v[i] ^ v[i + 8]); } void BLAKE2_Compress32_CXX(const byte* input, BLAKE2s_State& state) { word32 m[16], v[16]; GetBlock<word32, LittleEndian, true> get1(input); get1(m[0])(m[1])(m[2])(m[3])(m[4])(m[5])(m[6])(m[7])(m[8])(m[9])(m[10])(m[11])(m[12])(m[13])(m[14])(m[15]); GetBlock<word32, LittleEndian, true> get2(state.h()); get2(v[0])(v[1])(v[2])(v[3])(v[4])(v[5])(v[6])(v[7]); const word32* iv = BLAKE2S_IV; const word32* tf = state.t(); v[ 8] = iv[0]; v[ 9] = iv[1]; v[10] = iv[2]; v[11] = iv[3]; v[12] = tf[0] ^ iv[4]; v[13] = tf[1] ^ iv[5]; v[14] = tf[2] ^ iv[6]; v[15] = tf[3] ^ iv[7]; BLAKE2S_ROUND<0>(m, v); BLAKE2S_ROUND<1>(m, v); BLAKE2S_ROUND<2>(m, v); BLAKE2S_ROUND<3>(m, v); BLAKE2S_ROUND<4>(m, v); BLAKE2S_ROUND<5>(m, v); BLAKE2S_ROUND<6>(m, v); BLAKE2S_ROUND<7>(m, v); BLAKE2S_ROUND<8>(m, v); BLAKE2S_ROUND<9>(m, v); word32* h = state.h(); for (unsigned int i = 0; i < 8; ++i) h[i] = h[i] ^ ConditionalByteReverse(LITTLE_ENDIAN_ORDER, v[i] ^ v[i + 8]); } NAMESPACE_END
{ "pile_set_name": "Github" }
/** * Copyright (c) 2016-present Invertase Limited & Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this library 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. * */ // TODO not supported until SDK 6.0.0 // //#import <Foundation/Foundation.h> //#import <React/RCTBridgeModule.h> // //@interface RNFBMLNaturalLanguageTranslateModule : NSObject <RCTBridgeModule> //@end
{ "pile_set_name": "Github" }
/* *************************************************************************************** * Copyright (C) 2006 EsperTech, Inc. All rights reserved. * * http://www.espertech.com/esper * * http://www.espertech.com * * ---------------------------------------------------------------------------------- * * The software in this package is published under the terms of the GPL license * * a copy of which has been included with this distribution in the license.txt file. * *************************************************************************************** */ package com.espertech.esper.common.internal.collection; import com.espertech.esper.common.client.type.EPTypeClass; import java.util.HashMap; import java.util.Iterator; import java.util.Map; /** * reference-counting set based on a HashMap implementation that stores keys and a reference counter for * each unique key value. Each time the same key is added, the reference counter increases. * Each time a key is removed, the reference counter decreases. */ public class RefCountedSet<K> { public final static EPTypeClass EPTYPE = new EPTypeClass(RefCountedSet.class); private Map<K, Integer> refSet; private int numValues; /** * Constructor. */ public RefCountedSet() { refSet = new HashMap<K, Integer>(); } public RefCountedSet(Map<K, Integer> refSet, int numValues) { this.refSet = refSet; this.numValues = numValues; } /** * Clear out the collection. */ public void clear() { refSet.clear(); numValues = 0; } /** * Add a key to the set. Add with a reference count of one if the key didn't exist in the set. * Increase the reference count by one if the key already exists. * Return true if this is the first time the key was encountered, or false if key is already in set. * * @param key to add * @return true if the key is not in the set already, false if the key is already in the set */ public boolean add(K key) { Integer value = refSet.get(key); if (value == null) { refSet.put(key, 1); numValues++; return true; } value++; numValues++; refSet.put(key, value); return false; } /** * Add a key to the set with the given number of references. * * @param key to add * @param numReferences initial number of references */ public void add(K key, int numReferences) { Integer value = refSet.get(key); if (value == null) { refSet.put(key, numReferences); numValues += numReferences; return; } throw new IllegalArgumentException("Key '" + key + "' already in collection"); } /** * Removed a key to the set. Removes the key if the reference count is one. * Decreases the reference count by one if the reference count is more then one. * Return true if the reference count was one and the key thus removed, or false if key is stays in set. * * @param key to add * @return true if the key is removed, false if it stays in the set * @throws IllegalStateException is a key is removed that wasn't added to the map */ public boolean remove(K key) { Integer value = refSet.get(key); if (value == null) { return true; // ignore duplcate removals } if (value == 1) { refSet.remove(key); numValues--; return true; } value--; refSet.put(key, value); numValues--; return false; } /** * Remove a key from the set regardless of the number of references. * * @param key to add * @return true if the key is removed, false if the key was not found * @throws IllegalStateException if a key is removed that wasn't added to the map */ public boolean removeAll(K key) { Integer value = refSet.remove(key); return value != null; } /** * Returns an iterator over the entry set. * * @return entry set iterator */ public Iterator<Map.Entry<K, Integer>> entryIterator() { return refSet.entrySet().iterator(); } /** * Returns a key iterator. * * @return key iterator */ public Iterator<K> keyIterator() { return refSet.keySet().iterator(); } /** * Returns the number of values in the collection. * * @return size */ public int size() { return numValues; } public Map<K, Integer> getRefSet() { return refSet; } public int getNumValues() { return numValues; } public void setNumValues(int numValues) { this.numValues = numValues; } }
{ "pile_set_name": "Github" }
module.exports = { presets: ['@vue/app'], }
{ "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 license@zend.com so we can send you a copy immediately. * * @category Zend * @package Zend_Gdata * @subpackage Photos * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id: Width.php 23775 2011-03-01 17:25:24Z ralph $ */ /** * @see Zend_Gdata_Extension */ require_once 'Zend/Gdata/Extension.php'; /** * @see Zend_Gdata_Photos */ require_once 'Zend/Gdata/Photos.php'; /** * Represents the gphoto:width element used by the API. * This indicates the width of a photo in pixels. * * @category Zend * @package Zend_Gdata * @subpackage Photos * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ class Zend_Gdata_Photos_Extension_Width extends Zend_Gdata_Extension { protected $_rootNamespace = 'gphoto'; protected $_rootElement = 'width'; /** * Constructs a new Zend_Gdata_Photos_Extension_Width object. * * @param string $text (optional) The value to represent. */ public function __construct($text = null) { $this->registerAllNamespaces(Zend_Gdata_Photos::$namespaces); parent::__construct(); $this->setText($text); } }
{ "pile_set_name": "Github" }
#populator populator.plugin-title = Data Populator populator.plugin-description = Populate a Countly app with random data (typically for testing or demonstration) populator.title = Populate Data populator.amount-users = Amount of user populator.date-range = Date range populator.date-from = Date from populator.date-to = Date to populator.start = Generate demo data populator.stop = Stop Generating populator.bulk = Bulk requests queued populator.users = Users generated populator.events = Events generated populator.sessions = Sessions generated populator.extends = Sessions extended populator.duration = Total session duration populator.requests = Requests generated populator.push-users = Messaging enabled users populator.purchases = Purchases made populator.crashes = Crashes occured populator.maxtime = Maximum time to run (seconds) populator.warning1 = This plugin populates data for {0} populator.warning2 = Make sure your app doesn't involve real data,otherwise it will conflict with generated data. populator.help = <p>Select the start and end dates of user activities and press "Start Generating"</p><p>Countly populator will generate user data and emulate their behaviour with sessions, events, etc</p><p>The longer you let populator run, the more frequent sessions and events users will have in the selected time period</p><p>To stop process, simply click "Stop Generating" button</p> populator.yes-populate-data = Yes, populate data populator.no-populate-data = No, don't do that populator.demo-data = Demo data populator.tooltip = Populate app with random data for demo after creation populator.success = Click on Continue to refresh the page and go to dashboard. populator.generating = Generating ... populator.sub-title = Generate data for your app in <br/>an easy way populator.description = This plugin will start generating completely randomized, non-real sample data for your current application. It will help you understand how your Countly user interface will look like, once you start collecting real data.<br/><br/>Do not forget to create another application, or completely remove pregenerated data, before sending production level data. populator.finished-confirm-title = Finished populating data populator.locked-title = Application is locked populator.locked-description = In order to use data populator you have to unlock this application from <a href="#/manage/apps">Application Management</a>. systemlogs.action.populator_run = Populator Started populator.populator-tab-title = Populate populator.templates-tab-title = Templates populator.templates-view-title = App Templates populator.template = Template populator.template-type = Type populator.number-of-user-props = Number of User Properties populator.number-of-events = Number of Events populator.edited-by = Edited by populator.create-new-template = Create new template populator.save-template = Save template populator.discard-changes = Discard changes populator.create-template = Create template populator.edit-template = Edit template: {0} populator.template-name = Template name populator.custom-user-props = Custom User Properties populator.events = Events populator.add-custom-user-prop = + Add a custom user property populator.add-segmentation = + Add a segmentation populator.add-event = + Add event populator.event-key = Event key populator.user-prop-key = Key populator.user-prop-values = Values (Comma separated) populator.segmentation-key = Segmentation populator.segmentation-values = Values (Comma separated) populator.remove-event = Remove event populator.template-type-default = Default populator.template-type-custom = Custom populator.duration-help-title = Add duration property populator.duration-help-subtitle = Duration property is for measuring the time it takes for a user to complete certain actions inside the application. populator.sum-help-title = Add sum property populator.sum-help-subtitle = Sum property is a floating point number to track an additional numeric value for your event, such as the purchase amount. populator.app-template = App template populator.select-template = Select template populator.edit-template = Edit template populator.duplicate-template = Duplicate template populator.delete-template = Delete template populator.failed-to-fetch-templates = Failed to fetch templates populator.failed-to-fetch-template = Failed to fetch template with id "{0}" populator.failed-to-edit-template = Failed to edit template with id "{0}" populator.failed-to-remove-template = Failed to remove template with id "{0}" populator.failed-to-create-template = Failed to create template populator.template-name-placeholder = Enter template name populator.select-a-template-first = Please select a template to generate data with
{ "pile_set_name": "Github" }
This is an important floating point math routine, documented in many places. Example code utilizing this routine: - https://www.lemon64.com/forum/viewtopic.php?t=42934
{ "pile_set_name": "Github" }
/* * Copyright 2016 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> * * 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.ocpsoft.rewrite.servlet.config; import static org.assertj.core.api.Assertions.assertThat; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import org.ocpsoft.rewrite.config.ConfigurationProvider; import org.ocpsoft.rewrite.test.RewriteTest; import org.openqa.selenium.WebDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; /** * @see https://github.com/ocpsoft/rewrite/issues/243 */ @RunWith(Arquillian.class) public class PathAndQueryTest extends RewriteTest { @Deployment(testable = false) public static WebArchive getDeployment() { return RewriteTest.getDeployment() .addClass(PathAndQueryProvider.class) .addAsServiceProvider(ConfigurationProvider.class, PathAndQueryProvider.class); } @ArquillianResource private java.net.URL baseUrl; @Test public void testWithQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithQuery?p1=foo&p2=bar"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithQuery%3Fp1=foo&p2=bar"); } @Test public void testWithoutQuery() throws Exception { WebDriver driver = new HtmlUnitDriver(); driver.get(baseUrl.toString() + "pathAndQuery/pathWithoutQuery"); assertThat(driver.getCurrentUrl()).endsWith("/resultingPath/pathWithoutQuery"); } }
{ "pile_set_name": "Github" }
<%@ jet package="org.eclipse.emf.codegen.ecore.templates.editor" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="HomeHTML" version="$Id: home.htmljet,v 1.2 2010/08/25 13:36:45 emerks Exp $" %> <% /** * <copyright> * * Copyright (c) 2010 Ed Merks and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Ed Merks - Initial API and implementation * * </copyright> */ %> <%GenModel genModel = (GenModel)argument; /* Trick to import java.util.* without warnings */Iterator.class.getName();%> <?xml version="1.0" encoding="UTF-8"?> <!doctype html> <html style="height : 100%"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!-- --> <!-- Any title is fine --> <!-- --> <title><%=genModel.getModelName()%> Application</title> <style TYPE="text/css"> <!-- .ToolBar { background-color: #d0e4f6; } .ToolBarButton { float: left; margin-top: 5px; } .ToolBarButtonLeftMargin { float: left; margin-left: 10px; margin-top: 5px; } .Header { background-color: #628cd5; color: #FFFFFF; float: left; font-weight: bold; font-size: xx-large; } .HeaderLabel { float: left; margin-left: 10px; } .PropertiesTitle { background-color: #628cd5; color: #FFFFFF; font-weight: bold; font-size: large; } .PropertiesTitleLabel { float: left; margin-left: 5px; } --> </style> <!-- --> <!-- This script loads your compiled module. --> <!-- If you add any GWT meta tags, they must --> <!-- be added before this line. --> <script type="text/javascript" language="javascript" src="<%=genModel.getQualifiedEditorModuleName()%>/<%=genModel.getQualifiedEditorModuleName()%>.nocache.js"></script> </head> <body style="height : 100%"> <div id="main" style="height : 100%"> </div> </body> </html>
{ "pile_set_name": "Github" }
package(default_visibility = ["//visibility:public"]) licenses(["notice"]) filegroup( name = "package-srcs", srcs = glob(["**"]), tags = ["automanaged"], visibility = ["//visibility:private"], ) filegroup( name = "all-srcs", srcs = [":package-srcs"], tags = ["automanaged"], )
{ "pile_set_name": "Github" }
#!/usr/bin/env ruby require 'optparse' require 'rbconfig' command = :run lib = File.dirname(File.dirname(File.expand_path(__FILE__))) opts = OptionParser.new do |opts| opts.banner = "home_run: Fast Date/DateTime classes for ruby" opts.define_head "Usage: home_run (--option | command)" opts.separator "" opts.separator "Options:" opts.on_tail("--install", "install to site_ruby") do command = :install end opts.on_tail("--uninstall", "uninstall from site_ruby") do command = :uninstall end opts.on_tail("--bench", "run comparative benchmarks") do command = :bench end opts.on_tail("--spec", "run the specs (requires mspec)") do command = :spec end end if ARGV.empty? $stderr.puts opts.help exit(1) end opts.order! case command when :bench Dir.chdir(lib) ENV['RUBY'] = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) require 'rubygems' require 'rake' load './Rakefile' Rake::Task[:bench_all].invoke when :spec Dir.chdir(lib) ENV['PATH'] = [RbConfig::CONFIG['bindir'], ENV['PATH']].join(File::PATH_SEPARATOR) ENV['RUBY'] = File.join(RbConfig::CONFIG['ruby_install_name']) require 'rubygems' require 'rake' load './Rakefile' Rake::Task[:default].invoke when :install Dir.chdir(lib) require 'fileutils' FUV = FileUtils::Verbose FUV.cp("lib/date.rb", RbConfig::CONFIG['sitelibdir']) FUV.mkdir_p(File.join(RbConfig::CONFIG['sitelibdir'], 'date')) FUV.cp("lib/date/format.rb", File.join(RbConfig::CONFIG['sitelibdir'], 'date')) if File.exists?("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}") FUV.cp("lib/date_ext.#{RbConfig::CONFIG['DLEXT']}", RbConfig::CONFIG['sitearchdir']) else # Windows binary gem files if File.exists?('lib/1.8/date_ext.so') FUV.mkdir_p(File.join(RbConfig::CONFIG['sitearchdir'], '1.8')) FUV.cp("lib/1.8/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.8')) end if File.exists?('lib/1.9/date_ext.so') FUV.mkdir_p(File.join(RbConfig::CONFIG['sitearchdir'], '1.9')) FUV.cp("lib/1.9/date_ext.so", File.join(RbConfig::CONFIG['sitearchdir'], '1.9')) end end when :uninstall require 'fileutils' FUV = FileUtils::Verbose FUV.rm_f(File.join(RbConfig::CONFIG['sitelibdir'], 'date.rb')) FUV.rm_f(File.join(RbConfig::CONFIG['sitelibdir'], 'date/format.rb')) FUV.rmdir(File.join(RbConfig::CONFIG['sitelibdir'], 'date')) rescue nil FUV.rm_f(File.join(RbConfig::CONFIG['sitearchdir'], "date_ext.#{RbConfig::CONFIG['DLEXT']}")) FUV.rm_f(File.join(RbConfig::CONFIG['sitearchdir'], '1.8/date_ext.so')) FUV.rmdir(File.join(RbConfig::CONFIG['sitearchdir'], '1.8')) rescue nil FUV.rm_f(File.join(RbConfig::CONFIG['sitearchdir'], '1.9/date_ext.so')) FUV.rmdir(File.join(RbConfig::CONFIG['sitearchdir'], '1.9')) rescue nil else ENV['RUBYOPT'] = "-rdate #{ENV['RUBYOPT']}" ENV['RUBYLIB'] = [File.join(lib, 'lib'), File.join(lib, 'ext', 'date_ext'), ENV['RUBYLIB']].join(File::PATH_SEPARATOR) exec(*ARGV) end
{ "pile_set_name": "Github" }
<?php /** * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ namespace SquareConnect\Model; /** * CatalogDiscountModifyTaxBasisTest Class Doc Comment * * @category Class * @package SquareConnect * @author Square Inc. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2 * @link https://squareup.com/developers */ class CatalogDiscountModifyTaxBasisTest extends \PHPUnit_Framework_TestCase { /** * Setup before running each test case */ public static function setUpBeforeClass() { } /** * Clean up after running each test case */ public static function tearDownAfterClass() { } /** * Test CatalogDiscountModifyTaxBasis */ public function testCatalogDiscountModifyTaxBasis() { } }
{ "pile_set_name": "Github" }
package pump; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; public class Formatters { public static DecimalFormat priceFmt = new DecimalFormat("#0.0000000", new DecimalFormatSymbols(Locale.US)); public static String formatPrice(double price) { int lcdSize = 4; String text = priceFmt.format(price); int i = 0; int digits = 0; while (true) { while (i < text.length() && text.charAt(i) == '.') i++; if (digits == lcdSize) return text.substring(0, i); if (i >= text.length()) break; digits++; i++; } return text; } public static DecimalFormat costFmt = new DecimalFormat("#0.00", new DecimalFormatSymbols(Locale.US)); public static String formatSaleCost(double cost) { return costFmt.format(cost); } public static DecimalFormat quantityFmt = new DecimalFormat("#0.00", new DecimalFormatSymbols(Locale.US)); public static String formatSaleQuantity(double quantity) { return quantityFmt.format(quantity); } }
{ "pile_set_name": "Github" }
/* Copyright 2016 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // package options is the public flags and options used by a generic api // server. It takes a minimal set of dependencies and does not reference // implementations, in order to ensure it may be reused by multiple components // (such as CLI commands that wish to generate or validate config). package options // import "k8s.io/apiserver/pkg/server/options"
{ "pile_set_name": "Github" }
package io.ebean; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * Represents an Order By for a Query. * <p> * Is a ordered list of OrderBy.Property objects each specifying a property and * whether it is ascending or descending order. * </p> * <p> * Typically you will not construct an OrderBy yourself but use one that exists * on the Query object. * </p> */ public final class OrderBy<T> implements Serializable { private static final long serialVersionUID = 9157089257745730539L; private transient Query<T> query; private final List<Property> list; /** * Create an empty OrderBy with no associated query. */ public OrderBy() { this.list = new ArrayList<>(3); } private OrderBy(List<Property> list) { this.list = list; } /** * Create an orderBy parsing the order by clause. * <p> * The order by clause follows SQL order by clause with comma's between each * property and optionally "asc" or "desc" to represent ascending or * descending order respectively. * </p> */ public OrderBy(String orderByClause) { this(null, orderByClause); } /** * Construct with a given query and order by clause. */ public OrderBy(Query<T> query, String orderByClause) { this.query = query; this.list = new ArrayList<>(3); parse(orderByClause); } /** * Reverse the ascending/descending order on all the properties. */ public void reverse() { for (Property aList : list) { aList.reverse(); } } /** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName) { list.add(new Property(propertyName, true)); return query; } /** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName, String collation) { list.add(new Property(propertyName, true, collation)); return query; } /** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName) { list.add(new Property(propertyName, false)); return query; } /** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName, String collation) { list.add(new Property(propertyName, false, collation)); return query; } /** * Return true if the property is known to be contained in the order by clause. */ public boolean containsProperty(String propertyName) { for (Property aList : list) { if (propertyName.equals(aList.getProperty())) { return true; } } return false; } /** * Return a copy of this OrderBy with the path trimmed. */ public OrderBy<T> copyWithTrim(String path) { List<Property> newList = new ArrayList<>(list.size()); for (Property aList : list) { newList.add(aList.copyWithTrim(path)); } return new OrderBy<>(newList); } /** * Return the properties for this OrderBy. */ public List<Property> getProperties() { // not returning an Immutable list at this point return list; } /** * Return true if this OrderBy does not have any properties. */ public boolean isEmpty() { return list.isEmpty(); } /** * Return the associated query if there is one. */ public Query<T> getQuery() { return query; } /** * Associate this OrderBy with a query. */ public void setQuery(Query<T> query) { this.query = query; } /** * Return a copy of the OrderBy. */ public OrderBy<T> copy() { OrderBy<T> copy = new OrderBy<>(); for (Property property : list) { copy.add(property.copy()); } return copy; } /** * Add to the order by by parsing a raw expression. */ public void add(String rawExpression) { parse(rawExpression); } /** * Add a property to the order by. */ public void add(Property p) { list.add(p); } @Override public String toString() { return list.toString(); } /** * Returns the OrderBy in string format. */ public String toStringFormat() { if (list.isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.size(); i++) { Property property = list.get(i); if (i > 0) { sb.append(", "); } sb.append(property.toStringFormat()); } return sb.toString(); } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof OrderBy<?>)) { return false; } OrderBy<?> e = (OrderBy<?>) obj; return e.list.equals(list); } /** * Return a hash value for this OrderBy. This can be to determine logical * equality for OrderBy clauses. */ @Override public int hashCode() { return list.hashCode(); } /** * Clear the orderBy removing any current order by properties. * <p> * This is intended to be used when some code creates a query with a * 'default' order by clause and some other code may clear the 'default' * order by clause and replace. * </p> */ public OrderBy<T> clear() { list.clear(); return this; } /** * Return true if this order by can be used in select clause. */ public boolean supportsSelect() { for (Property property : list) { if (!property.supportsSelect()) { return false; } } return true; } /** * A property and its ascending descending order. */ public static final class Property implements Serializable { private static final long serialVersionUID = 1546009780322478077L; private String property; private boolean ascending; private String collation; private String nulls; private String highLow; public Property(String property, boolean ascending) { this.property = property; this.ascending = ascending; } public Property(String property, boolean ascending, String nulls, String highLow) { this.property = property; this.ascending = ascending; this.nulls = nulls; this.highLow = highLow; } public Property(String property, boolean ascending, String collation) { this.property = property; this.ascending = ascending; this.collation = collation; } public Property(String property, boolean ascending, String collation, String nulls, String highLow) { this.property = property; this.ascending = ascending; this.collation = collation; this.nulls = nulls; this.highLow = highLow; } /** * Return a copy of this Property with the path trimmed. */ public Property copyWithTrim(String path) { return new Property(property.substring(path.length() + 1), ascending, collation, nulls, highLow); } @Override public int hashCode() { int hc = property.hashCode(); hc = hc * 92821 + (ascending ? 0 : 1); hc = hc * 92821 + (collation == null ? 0 : collation.hashCode()); hc = hc * 92821 + (nulls == null ? 0 : nulls.hashCode()); hc = hc * 92821 + (highLow == null ? 0 : highLow.hashCode()); return hc; } @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Property)) { return false; } Property e = (Property) obj; if (ascending != e.ascending) return false; if (!property.equals(e.property)) return false; if (!Objects.equals(collation, e.collation)) return false; if (!Objects.equals(nulls, e.nulls)) return false; return Objects.equals(highLow, e.highLow); } @Override public String toString() { return toStringFormat(); } public String toStringFormat() { if (nulls == null && collation == null) { if (ascending) { return property; } else { return property + " desc"; } } else { StringBuilder sb = new StringBuilder(); if (collation != null) { if (collation.contains("${}")) { // this is a complex collation, e.g. DB2 - we must replace the property sb.append(collation.replace("${}", property)); } else { sb.append(property); sb.append(" collate ").append(collation); } } else { sb.append(property); } if (!ascending) { sb.append(" ").append("desc"); } if (nulls != null) { sb.append(" ").append(nulls).append(" ").append(highLow); } return sb.toString(); } } /** * Reverse the ascending/descending order for this property. */ public void reverse() { this.ascending = !ascending; } /** * Trim off the pathPrefix. */ public void trim(String pathPrefix) { property = property.substring(pathPrefix.length() + 1); } /** * Return a copy of this property. */ public Property copy() { return new Property(property, ascending, collation, nulls, highLow); } /** * Return the property name. */ public String getProperty() { return property; } /** * Set the property name. */ public void setProperty(String property) { this.property = property; } /** * Return true if the order is ascending. */ public boolean isAscending() { return ascending; } /** * Set to true if the order is ascending. */ public void setAscending(boolean ascending) { this.ascending = ascending; } /** * Support use in select clause if no collation or nulls ordering. */ boolean supportsSelect() { return nulls == null; } } private void parse(String orderByClause) { if (orderByClause == null) { return; } String[] chunks = orderByClause.split(","); for (String chunk : chunks) { Property p = parseProperty(chunk); if (p != null) { list.add(p); } } } private Property parseProperty(String chunk) { String[] pairs = chunk.split(" "); if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<>(pairs.length); for (String pair : pairs) { if (!isEmptyString(pair)) { wordList.add(pair); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } if (wordList.size() == 4) { // nulls high or nulls low as 3rd and 4th boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc, wordList.get(2), wordList.get(3)); } return new Property(chunk.trim(), true); } private boolean isAscending(String s) { s = s.toLowerCase(); if (s.startsWith("asc")) { return true; } if (s.startsWith("desc")) { return false; } String m = "Expecting [" + s + "] to be asc or desc?"; throw new RuntimeException(m); } private boolean isEmptyString(String s) { return s == null || s.isEmpty(); } }
{ "pile_set_name": "Github" }
package com.oraclechain.pocketeos.bean; /** * Created by pocketEos on 2018/1/11. */ public class AnswerBean { private String answer_option; private String answer_details; public String getAnswer_option() { return answer_option == null ? "" : answer_option; } public void setAnswer_option(String answer_option) { this.answer_option = answer_option; } public String getAnswer_details() { return answer_details == null ? "" : answer_details; } public void setAnswer_details(String answer_details) { this.answer_details = answer_details; } }
{ "pile_set_name": "Github" }
# LANGUAGE translation of CakePHP Application # Copyright YEAR NAME <EMAIL@ADDRESS> # No version information was available in the source files. # #, fuzzy msgid "" msgstr "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2009-05-27 09:47+0200\n" "PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n" "Last-Translator: NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" #: controllers/components/toolbar.php:91 msgid "Component initialization and startup" msgstr "" #: controllers/components/toolbar.php:140 msgid "Controller Action" msgstr "" #: controllers/components/toolbar.php:167 msgid "Render Controller Action" msgstr "" #: controllers/components/toolbar.php:231 msgid "Could not load DebugToolbar panel %s" msgstr "" #: views/elements/debug_toolbar.ctp:25 msgid "There are no active panels. You must enable a panel to see its output." msgstr "" #: views/elements/history_panel.ctp:21 msgid "Request History" msgstr "" #: views/elements/history_panel.ctp:23 msgid "No previous requests logged." msgstr "" #: views/elements/history_panel.ctp:25 msgid "previous requests available" msgstr "" #: views/elements/history_panel.ctp:27 msgid "Restore to current request" msgstr "" #: views/elements/log_panel.ctp:21 msgid "Logs" msgstr "" #: views/elements/log_panel.ctp:28 msgid "Time" msgstr "" #: views/elements/log_panel.ctp:28 views/elements/timer_panel.ctp:54 msgid "Message" msgstr "" #: views/elements/log_panel.ctp:37 msgid "There were no log entries made this request" msgstr "" #: views/elements/request_panel.ctp:21 msgid "Request" msgstr "" #: views/elements/request_panel.ctp:35 msgid "Current Route" msgstr "" #: views/elements/session_panel.ctp:21 msgid "Session" msgstr "" #: views/elements/sql_log_panel.ctp:21 msgid "Sql Logs" msgstr "" #: views/elements/sql_log_panel.ctp:31 msgid "toggle (%s) query explains for %s" msgstr "" #: views/elements/sql_log_panel.ctp:39 msgid "No slow queries!, or your database does not support EXPLAIN" msgstr "" #: views/elements/sql_log_panel.ctp:44 msgid "No active database connections" msgstr "" #: views/elements/timer_panel.ctp:33 msgid "Memory" msgstr "" #: views/elements/timer_panel.ctp:35 msgid "Current Memory Use" msgstr "" #: views/elements/timer_panel.ctp:39 msgid "Peak Memory Use" msgstr "" #: views/elements/timer_panel.ctp:43 msgid "Timers" msgstr "" #: views/elements/timer_panel.ctp:45 msgid "%s (ms)" msgstr "" #: views/elements/timer_panel.ctp:46 msgid "Total Request Time:" msgstr "" #: views/elements/timer_panel.ctp:54 msgid "Time in ms" msgstr "" #: views/elements/timer_panel.ctp:54 msgid "Graph" msgstr "" #: views/elements/variables_panel.ctp:21 msgid "View Variables" msgstr "" #: views/helpers/simple_graph.php:79 msgid "Starting %sms into the request, taking %sms" msgstr ""
{ "pile_set_name": "Github" }
/* Copyright 2013-2016 Jason Leyba Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.github.jsdossier.annotations; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import javax.inject.Qualifier; /** Qualifier for the path of the closest common ancestor for all input modules. */ @Qualifier @Retention(RetentionPolicy.RUNTIME) public @interface ModulePrefix {}
{ "pile_set_name": "Github" }
schedule: program->configApplyDirection("s1", "DensePull")->configApplyParallelization("s1","dynamic-vertex-parallel")->setApply("s1", "pull_edge_based_load_balance", 1); program->fuseFields("out_degree", "old_rank");
{ "pile_set_name": "Github" }
{ "name": "terraform-test-app", "config_vars": { "FOO": "bar" } }
{ "pile_set_name": "Github" }
/*===------------- math.h - Alternative math.h header ----------------------=== * * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. * See https://llvm.org/LICENSE.txt for license information. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception * *===-----------------------------------------------------------------------=== */ #include <__clang_openmp_math.h> #ifndef __CLANG_NO_HOST_MATH__ #include_next <math.h> #else #undef __CLANG_NO_HOST_MATH__ #endif
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (c) 2018 Red Hat, Inc. and others. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which accompanies this distribution, and is available at https://www.eclipse.org/legal/epl-2.0/ SPDX-License-Identifier: EPL-2.0 Contributors: Mat Booth (Red Hat) - initial implementation --> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.eclipse.cdt</groupId> <artifactId>cdt-parent</artifactId> <version>10.0.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> <version>6.0.0-SNAPSHOT</version> <artifactId>org.eclipse.cdt.core.native</artifactId> <packaging>eclipse-plugin</packaging> <profiles> <profile> <id>build-native.all</id> <activation> <property> <name>native</name> <value>all</value> </property> </activation> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>natives</id> <phase>process-resources</phase> <configuration> <target> <exec executable="make" newenvironment="false" failOnError="true" dir="./native_src"> <arg value="rebuild" /> </exec> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>build-native.docker</id> <activation> <property> <name>native</name> <value>docker</value> </property> </activation> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>natives</id> <phase>process-resources</phase> <configuration> <target> <exec executable="docker" newenvironment="false" failOnError="true"> <!-- docker run -\-rm -t -v $(git rev-parse -\-show-toplevel):/work -w /work/$(git rev-parse -\-show-prefix) quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest make -C native_src rebuild --> <arg value="run" /> <arg value="--rm" /> <arg value="-t" /> <arg value="-v" /> <arg value="${project.basedir}/../..:/work" /> <arg value="-w" /> <arg value="/work/core/org.eclipse.cdt.core.native" /> <arg value="quay.io/eclipse-cdt/cdt-infra-eclipse-full:latest" /> <arg value="make" /> <arg value="-C" /> <arg value="native_src" /> <arg value="rebuild" /> </exec> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>jniheaders</id> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <executions> <execution> <id>headers</id> <phase>process-resources</phase> <configuration> <compilerArgs> <arg>-h</arg> <arg>${project.basedir}/native_src/include</arg> </compilerArgs> <source>11</source> <target>11</target> <encoding>UTF-8</encoding> </configuration> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> </project>
{ "pile_set_name": "Github" }
v1 2015-06-29 ------------- 1. No more default keybindings. It is quite difficult to pick unused default shortcuts that fits for all platforms, so I was advized to simply remove the defaults keybindings and let users choose theirs. If you haven't already overwritten the PHP Companion shortcuts, you must go to "Preferences > Key Bindings - User" and copy theses lines. Linux/Windows users [ ... { "keys": ["f6"], "command": "expand_fqcn" }, { "keys": ["shift+f6"], "command": "expand_fqcn", "args": {"leading_separator": true} }, { "keys": ["f5"], "command": "find_use" }, { "keys": ["f4"], "command": "import_namespace" }, { "keys": ["shift+f12"], "command": "goto_definition_scope" } ... ] OSX users [ ... { "keys": ["f9"], "command": "expand_fqcn" }, { "keys": ["shift+f9"], "command": "expand_fqcn", "args": {"leading_separator": true} }, { "keys": ["f10"], "command": "find_use" }, { "keys": ["f8"], "command": "import_namespace" }, { "keys": ["shift+f12"], "command": "goto_definition_scope" } ... ] 2. readme updated.
{ "pile_set_name": "Github" }
function toMoney (value) { return Number(value).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' }) } export default toMoney
{ "pile_set_name": "Github" }
// COPYRIGHT © 2020 Esri // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // This material is licensed for use under the Esri Master License // Agreement (MLA), and is bound by the terms of that agreement. // You may redistribute and use this code without modification, // provided you adhere to the terms of the MLA and include this // copyright notice. // // See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english // // For additional information, contact: // Environmental Systems Research Institute, Inc. // Attn: Contracts and Legal Services Department // 380 New York Street // Redlands, California, USA 92373 // USA // // email: contracts@esri.com // // See http://js.arcgis.com/3.33/esri/copyright.txt for details. define({root:{display:{elevationProfileTitle:"Elevation Profile",showMe:"show me",selectLine:"<b>Select</b> a feature in the map.",popupRequirement:"NOTE: the feature must be in a layer with Popups enabled.",digitizeDistanceMeasureTool:"Use the <b>Measure</b> tools.",selectFeatureHelpUrl:"http://help.arcgis.com/en/arcgisonline/help/010q/010q0000004s000000.htm#ESRI_SECTION1_DAA22E89DF67448E8F3682309F39BE5D",measureToolHelpUrl:"http://help.arcgis.com/en/arcgisonline/help/index.html#//010q00000096000000",hoverOver:"Hover over or touch the Elevation Profile chart to display elevations and show location on map.",directionLabel:"Profile Direction"},buttons:{measureLabel:"Measure",helpLabel:"Help",profileForward:"Forward",profileReverse:"Reverse",flipProfileTitle:"Click to flip Profile Direction",aggregationShowLabel:"Show Aggregation Information",aggregationHideLabel:"Hide Aggregation Information",aggregateElevationGainForward:"Aggregate Elevation Gain Forward",aggregateElevationLossForward:"Aggregate Elevation Loss Forward",aggregateElevationGainReverse:"Aggregate Elevation Gain Reverse",aggregateElevationLossReverse:"Aggregate Elevation Loss Reverse"},chart:{title:"Elevation Profile",demResolution:"DEM Resolution",elevationTitleTemplate:"Elevation in {0}",distanceTitleTemplate:"Distance in {0}",gainLossTemplate:"Min:{min} Max:{max} Start:{start} End:{end} Change:{gainloss}"},errors:{MissingConstructorParameters:"Missing constructor parameter.",InvalidConfiguration:"Invalid configuration.",UnableToProcessResults:"Unable to process analysis results.",UnableToNormalizeGeometry:"Unable to normalize input polyline geometry",NullGeometry:"Input polyline geometry is null. Unable to update profile",InvalidProfileResults:"ProfileChart.update(...) missing 'profileResults' parameter."}},ar:1,bs:1,ca:1,cs:1,da:1,de:1,el:1,es:1,et:1,fi:1,fr:1,he:1,hr:1,hu:1,id:1,it:1,ja:1,ko:1,lt:1,lv:1,nl:1,nb:1,pl:1,"pt-br":1,"pt-pt":1,ro:1,ru:1,sr:1,sv:1,th:1,tr:1,uk:1,vi:1,"zh-cn":1,"zh-hk":1,"zh-tw":1});
{ "pile_set_name": "Github" }
# coding: utf-8 module GoogleAnalytics class EventCollectionRenderer def initialize(event_collection, tracker_id) @event_collection = event_collection @tracker_id = tracker_id end def to_s @event_collection.map { |event| EventRenderer.new(event, @tracker_id).to_s }.join("\n") end end end
{ "pile_set_name": "Github" }
package(default_visibility = ["//visibility:public"]) load( "@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test", ) filegroup( name = "package-srcs", srcs = glob(["**"]), tags = ["automanaged"], visibility = ["//visibility:private"], ) filegroup( name = "all-srcs", srcs = [ ":package-srcs", "//hack/boilerplate:all-srcs", "//hack/e2e-internal:all-srcs", "//hack/lib:all-srcs", "//hack/make-rules:all-srcs", ], tags = ["automanaged"], ) sh_test( name = "verify-boilerplate", srcs = ["verify-boilerplate.sh"], data = ["//:all-srcs"], tags = ["manual"], ) # Disable gofmt test until we can figure out how to access the gofmt binary. # https://github.com/bazelbuild/rules_go/issues/511 #sh_test( # name = "verify-gofmt", # srcs = ["verify-gofmt.sh"], # data = [ # "//:all-srcs", # "@io_bazel_rules_go_toolchain//:toolchain", # ], # tags = ["manual"], #) test_suite( name = "verify-all", tags = ["manual"], tests = [ "verify-boilerplate", # "verify-gofmt", ], ) go_binary( name = "hack", embed = [":go_default_library"], ) go_test( name = "go_default_test", srcs = ["e2e_test.go"], data = glob(["testdata/**"]), embed = [":go_default_library"], ) go_library( name = "go_default_library", srcs = ["e2e.go"], importpath = "k8s.io/kubernetes/hack", ) sh_binary( name = "update-mirror", srcs = ["update-workspace-mirror.sh"], args = ["$(location @workspace_urls//:urls.txt)"], data = ["@workspace_urls//:urls.txt"], )
{ "pile_set_name": "Github" }
100 71 47 64 30 49 54 58 38 42 44 35 75 61 57 41 71 75 72 57 66 71 34 32 33 72 62 51 46 48 75 77 56 51 68 49 42 47 79 65 74 33 41 52 63 53 44 71 41 33 48 77 74 42 37 67 39 53 71 59 58 46 65 70 72 68 36 70 72 44 78 76 35 70 59 50 30 36 31 73 78 59 53 64 34 36 70 46 56 61 38 74 69 56 53 67 68 48 62 59 71 63 45 69 38 34 60 57 36 53 66 51 75 54 52 50 59 57 53 77 42 66 70 41 66 35 47 35 54 61 32 30 30 71 54 46 60 37 71 37 67 37 67 33 63 75 39 39 38 51 68 52 76 36 60 43 48 30 71 42 35 40 39 54 67 78 63 75 71 32 30 71 66 54 50 76 51 78 79 48 64 61 64 33 79 48 68 30 68 57 47 58 73 78 63 37 51 40 47 43 44 39 46 65 31 30 79 49 36 78 33 54 38 74 39 69 32 75 65 73 73 53 67 44 33 78 30 38 48 60 76 78 61 69 78 39 37 52 52 68 72 68 59 70 37 38 71 45 68 36 41 32 64 52 35 58 76 42 66 55 63 49 72 74 46 61 78 52 31 51 79 37 56 72 69 55 42 30 40 33 49 41 68 31 69 35 53 32 65 62 65 68 56 47 37 62 62 49 34 51 69 56 59 48 72 55 35 64 79 71 42 75 40 48 33 69 53 59 76 67 59 79 67 46 79 73 75 77 46 66 35 68 62 35 64 44 31 46 51 66 43 43 35 65 33 42 38 62 75 43 36 51 38 76 62 61 74 76 52 59 41 65 30 53 46 74 39 72 69 33 54 34 40 75 79 66 43 54 52 48 48 67 35 38 71 32 55 57 44 44 54 64 54 52 39 63 50 67 77 48 57 53 50 43 48 72 65 32 60 43 57 32 79 57 55 73 54 53 52 41 61 33 62 35 73 55 61 72 72 52 66 44 30 67 40 43 54 50 50 65 63 41 40 76 47 65 30 70 74 75 54 49 55 56 74 38 32 51 46 58 73 31 64 48 44 49 32 30 67 40 56 40 37 50 45 56 57 73 38 44 39 62 66 45 67 57 54 55 57 59 58 53 50 32 42 53 76 67 41 75 55 44 40 32 46 60 56 41 51 41 77 33 50 70 54 68 43 70 31 42 59 30 43 38 58 45 37 57 30 38 69 33 40 37 54 57 38 43 67 31 30 40 58 73 64 35 70 41 34 65 36 52 30 53 65 36 46 56 37 56 37 67 51 49 41 76 52 47 42 47 76 65 71 53 59 59 45 39 62 76 35 33 42 64 64 34 52 37 49 62 43 37 63 41 65 47 78 55 68 53 72 34 41 71 55 39 55 51 50 56 64 35 63 30 78 59 31 73 64 67 64 36 73 56 35 42 78 61 30 43 71 35 35 72 42 41 57 54 58 32 73 76 53 70 43 55 52 48 40 47 62 42 75 49 61 70 68 65 70 77 69 70 75 33 44 31 70 74 38 65 39 72 35 44 61 33 59 55 38 72 77 79 36 41 57 47 71 59 70 43 54 31 57 45 63 43 72 54 31 72 39 50 58 57 64 55 66 78 50 67 77 34 33 51 43 36 43 40 51 69 70 44 72 49 43 71 34 48 62 30 35 55 69 33 52 78 77 64 78 51 44 43 55 75 42 76 58 49 42 49 65 69 74 45 70 75 38 48 50 31 53 62 52 32 67 50 43 31 33 53 57 30 49 45 45 58 73 77 68 73 67 39 43 79 61 68 72 38 40 51 38 34 68 76 70 79 73 60 50 78 47 66 63 65 56 65 68 33 59 54 78 53 39 37 46 74 35 48 56 41 55 35 31 79 76 64 45 44 72 55 43 72 76 78 52 56 36 53 59 34 35 56 42 55 73 45 66 66 71 44 74 36 32 66 68 62 35 45 61 60 71 55 41 67 66 70 30 42 64 73 33 46 32 38 42 63 34 33 64 33 36 78 54 47 43 39 58 30 60 48 38 30 35 41 44 33 56 73 39 32 41 69 78 62 33 54 50 32 53 61 49 58 39 38 49 51 33 75 61 34 72 65 43 78 69 52 68 67 40 41 64 38 41 39 73 45 49 67 49 38 30 51 44 47 45 35 45 60 69 42 68 62 34 65 40 64 54 60 45 31 71 45 59 40 78 53 68 57 62 36 69 43 38 71 70 53 43 58 64 58 30 51 65 54 51 63 47 33 75 48 55 56 59 30 78 39 73 66 60 46 79 47 58 59 44 51 35 56 46 46 56 46 67 61 44 70 66 51 42 51 44 39 45 32 53 54 71 75 42 53 61 36 48 48 32 37 37 61 42 66 60 44 39 64 36 70 73 76 32 34 75 38 78 71 42 61 44 69 38 52 34 75 32 49 59 68 53 48 46 39 78 66 76 42 63 38 52 76 72 67 55 77 38 32 37 78 60 72 30 58 79 32 78 62 70 45 55 42 47 66 77 48 77 58 31 46 60 79 55 38 59 50 70 40 77 42 35 55 72 41 34 78 76 44 76 68 49 68 43 55 45 51 55 45 58 64 50 35 44 37 42 41 54 79 49 60 53 30 63 55 40 67 66 67 58 73 66 44 44 71 79 65 35 67 34 67 53 44 50 38 48 61 65 32 53 32 74 56 56 76 52 79 70 54 49 73 41 71 69 49 45 35 65 46 30 45 39 44 46 73 54 39 30 75 53 69 41 52 48 38 61 48 56 40 52 54 59 40 32 62 71 75 44 54 44 32 35 40 54 52 51 52 77 57 69 35 75 74 30 73 34 61 42 52 69 58 42 42 47 38 45 38 53 39 64 34 66 49 38 75 36 46 30 47 72 67 62 36 54 77 51 63 52 61 56 63 78 53 62 48 56 50 41 62 36 70 55 54 66 57 49 73 64 57 48 48 71 76 63 58 57 56 51 77 42 33 57 38 75 38 65 68 67 73 43 31 30 58 41 30 79 72 34 49 61 45 47 43 73 64 52 52 60 31 72 57 57 50 32 44 61 70 53 67 53 59 75 49 57 72 40 62 38 56 67 50 58 31 38 43 40 63 66 72 40 52 58 64 71 48 33 47 45 68 61 37 30 44 78 38 41 43 36 37 58 69 65 45 55 66 66 63 40 60 78 58 72 63 70 46 65 40 79 67 72 62 58 32 49 74 74 38 32 77 62 65 38 44 77 73 79 45 71 69 30 42 78 53 31 54 63 71 30 34 70 77 49 60 58 61 74 70 67 79 55 63 68 72 73 32 41 40 64 70 77 65 59 70 35 71 72 40 79 58 59 51 57 53 73 50 77 56 56 70 62 58 39 48 69 39 79 54 52 60 38 47 38 57 33 50 37 76 54 52 41 49 41 36 70 43 63 46 62 32 71 34 43 42 76 40 45 34 79 66 60 78 62 67 64 70 47 36 50 71 62 79 53 38 35 51 75 76 46 58 58 59 38 57 30 37 59 61 75 58 56 33 79 64 45 73 38 52 73 59 44 48 35 71 53 52 78 31 66 74 76 57 47 59 46 54 71 49 42 76 73 71 45 79 37 70 32 66 31 67 56 42 35 63 74 60 77 45 45 43 41 58 58 58 70 41 77 75 50 55 69 30 79 63 45 44 62 37 62 76 47 52 62 40 71 61 67 35 59 51 68 31 77 38 76 56 39 69 52 46 66 35 58 44 40 33 57 78 33 41 61 62 35 77 36 32 51 76 61 51 35 77 54 48 65 56 54 39 78 54 33 52 65 73 68 33 62 77 60 56 58 30 31 41 79 35 43 46 53 41 75 53 54 30 33 61 67 79 40 73 45 52 59 61 42 56 61 77 70 51 35 52 62 69 50 45 61 38 73 36 58 78 36 51 46 76 77 50 74 59 68 39 64 49 58 47 45 56 64 48 36 58 77 48 70 79 65 66 79 50 40 51 43 45 65 48 60 61 47 67 74 66 37 40 57 54 61 32 51 48 73 65 67 41 34 57 36 48 52 43 30 72 67 68 68 35 69 77 61 73 64 67 41 73 47 31 62 77 45 33 34 64 75 55 51 44 61 52 36 36 73 73 60 60 48 41 43 48 31 46 59 48 70 61 63 59 43 39 33 66 75 45 54 50 65 60 56 35 55 51 38 39 36 32 62 35 70 55 42 65 42 60 66 77 32 38 60 70 56 38 73 70 76 54 53 77 60 65 52 30 37 35 46 71 68 61 48 45 76 55 39 42 66 35 42 73 72 51 52 42 78 48 48 47 44 30 70 65 39 49 75 33 70 59 79 35 71 41 61 32 33 63 59 67 72 33 63 50 44 48 74 43 59 32 44 49 50 35 77 74 67 56 56 53 70 59 70 68 40 51 75 51 50 63 69 35 58 59 36 42 65 67 76 63 68 65 59 73 70 42 45 31 35 37 47 49 64 51 37 78 75 77 48 68 74 52 43 58 44 31 53 70 34 31 57 77 72 51 43 31 43 51 45 51 75 40 75 71 52 42 31 45 35 73 68 59 62 38 34 52 37 75 68 74 70 69 34 34 53 55 58 54 61 60 63 53 74 60 76 67 75 35 46 30 69 68 43 65 77 39 60 54 38 67 54 50 52 73 35 64 41 36 36 64 55 62 49 71 62 64 59 59 63 47 66 55 48 67 58 49 57 67 71 36 75 40 31 73 62 66 60 55 37 64 54 49 70 56 71 31 59 70 54 52 71 69 67 70 69 73 33 43 61 33 35 56 59 75 69 48 78 63 69 45 51 73 56 52 68 58 61 79 58 71 53 73 64 73 79 32 37 32 71 67 76 71 67 43 30 46 70 42 65 56 40 57 62 40 69 35 54 43 52 75 46 40 68 68 41 75 47 55 47 69 72 43 77 32 47 79 53 56 33 78 31 50 66 38 47 36 35 61 42 49 55 36 61 75 74 71 33 68 45 30 49 52 71 63 63 55 72 49 30 34 58 65 37 63 73 70 33 30 63 52 51 41 70 68 71 38 77 32 38 59 32 63 70 32 48 52 75 65 38 41 72 74 79 68 58 72 37 71 77 49 75 60 43 44 40 41 65 53 34 42 33 32 49 34 59 32 54 79 60 74 74 79 48 45 43 32 53 50 61 77 41 49 78 78 33 32 59 33 73 52 68 43 64 30 52 70 41 72 31 60 57 46 56 58 50 45 78 78 59 65 37 63 42 32 42 50 50 52 53 71 66 68 47 47 72 78 47 79 45 69 62 49 61 33 60 58 61 69 32 60 52 44 37 75 58 61 70 40 57 51 66 39 73 70 63 67 73 60 54 73 62 33 41 70 42 37 77 31 53 70 47 70 33 46 63 41 39 75 66 31 45 31 70 39 77 63 30 38 51 55 61 67 51 67 79 34 59 68 30 60 41 48 35 70 58 39 52 78 40 78 65 61 44 47 73 76 41 76 68 50 68 56 35 47 51 40 32 38 63 35 45 56 31 64 39 73 78 53 72 73 63 67 33 70 41 74 48 57 78 69 78 59 77 79 61 49 55 78 79 66 79 53 73 61 34 41 64 65 47 46 73 34 46 33 38 53 64 72 47 78 49 60 41 44 70 57 73 34 79 54 75 36 38 69 38 39 69 77 70 48 44 55 56 69 33 46 42 70 50 56 75 71 66 31 39 67 63 65 70 30 66 35 61 58 32 57 42 54 45 52 62 65 58 76 69 58 63 55 45 40 75 58 51 35 50 57 53 64 31 55 66 64 31 67 40 54 70 36 51 60 65 75 62 55 48 53 42 67 78 35 42 47 72 69 77 76 33 61 45 69 38 59 75 74 79 75 52 55 42 52 53 60 68 77 72 38 33 57 55 64 31 58 62 49 66 58 69 68 51 56 43 57 55 54 61 30 41 42 32 78 75 64 46 67 37 73 64 74 39 51 38 73 48 57 49 37 71 71 44 53 45 52 59 71 45 45 66 37 39 30 32 73 71 59 78 57 78 54 54 54 63 65 68 50 42 59 64 39 58 53 65 30 54 73 35 42 45 47 37 57 64 34 70 64 71 51 65 64 70 72 78 66 48 51 54 77 56 34 49 38 57 73 48 46 32 68 30 49 48 70 64 69 36 38 62 58 44 67 69 54 50 57 34 68 71 78 72 32 51 34 76 36 39 63 38 41 63 66 34 65 72 72 40 41 50 73 58 67 43 43 71 64 45 36 41 42 41 39 31 68 50 54 37 37 64 31 31 69 38 71 70 43 42 35 40 73 52 32 56 73 53 46 31 55 58 62 41 49 33 59 37 72 31 33 72 50 49 52 37 74 35 70 63 42 39 37 68 40 51 51 34 77 44 53 59 69 46 67 36 62 50 69 46 52 63 40 33 35 71 39 66 67 59 72 47 75 36 68 32 34 46 63 40 49 61 68 47 56 78 44 50 33 37 49 46 52 72 37 43 40 77 73 60 47 73 56 44 56 47 64 50 51 72 44 34 46 73 44 55 30 42 30 31 56 59 73 57 69 41 65 52 64 74 41 43 34 76 68 38 37 60 53 44 54 76 67 61 48 41 72 71 62 53 41 71 41 60 78 49 71 30 59 47 47 44 75 71 66 47 58 33 39 53 61 33 49 46 63 47 65 32 60 37 61 47 40 46 67 51 57 75 44 68 51 77 45 72 41 37 35 33 51 60 70 60 55 50 70 57 78 66 34 69 61 74 68 40 48 49 39 57 39 49 59 46 30 76 33 38 60 73 36 79 34 52 40 74 34 63 76 59 51 58 39 71 51 68 46 63 65 50 59 41 40 38 62 42 36 58 59 77 67 68 49 63 70 75 46 63 39 37 47 64 33 65 38 73 73 73 46 31 70 74 67 54 42 77 31 75 47 72 72 67 60 43 76 40 69 58 39 66 74 70 62 49 50 73 72 42 44 57 37 74 35 43 41 43 73 44 33 75 42 61 76 39 78 48 54 41 34 65 57 63 70 42 57 57 47 70 72 30 30 38 56 34 65 60 61 75 67 53 52 57 59 41 41 34 60 33 73 51 65 58 73 30 35 51 50 32 55 61 70 64 70 66 64 78 69 45 76 42 42 32 61 67 44 37 78 36 50 30 62 31 73 79 62 74 61 55 34 30 56 46 68 31 53 73 71 60 75 48 39 43 58 59 68 34 43 59 49 46 59 57 67 32 45 72 53 52 78 53 33 78 75 77 38 38 41 73 45 61 32 40 58 36 35 45 53 49 45 33 35 64 58 75 70 63 65 30 48 74 63 65 78 61 62 36 40 52 62 31 36 65 40 51 57 67 73 48 63 75 51 33 72 41 59 64 42 73 60 41 64 38 56 36 71 73 68 57 49 64 54 73 65 54 74 62 47 57 35 76 66 69 70 67 30 39 58 36 57 33 72 30 41 55 73 75 46 45 34 36 48 71 65 78 55 43 53 42 48 37 76 69 66 74 76 73 52 41 60 35 38 77 50 70 53 57 43 34 76 52 30 71 71 76 55 43 54 59 75 33 74 73 47 67 70 59 71 55 64 40 30 37 51 72 73 47 47 33 73 73 69 41 55 58 58 78 30 72 74 34 53 33 66 77 76 56 41 34 68 51 66 35 79 36 58 47 31 49 71 46 47 76 73 67 51 42 47 79 74 77 31 58 72 34 48 48 71 76 42 50 74 48 55 49 64 54 64 39 79 44 75 33 62 31 67 44 43 31 49 70 47 63 48 64 32 66 49 78 67 77 54 48 57 78 73 62 51 49 73 57 44 34 64 73 75 41 73 72 78 70 79 70 73 54 79 54 44 53 49 48 45 63 68 41 32 43 38 79 68 75 61 50 36 51 48 51 38 37 77 62 68 52 53 36 36 69 36 75 31 53 48 30 77 66 71 36 40 43 31 60 74 73 71 75 58 79 35 44 65 57 54 34 36 47 57 35 32 66 48 78 59 41 69 38 70 55 40 62 69 76 30 42 52 59 52 66 57 33 56 50 65 32 31 77 31 31 65 73 52 46 46 58 41 55 68 76 69 74 36 56 32 38 68 51 66 38 57 58 59 77 79 60 75 58 42 56 49 57 71 77 65 61 36 64 34 49 39 36 51 75 45 46 40 77 65 70 57 79 35 66 68 55 73 57 60 67 35 62 33 30 34 69 68 45 38 40 70 79 77 37 34 34 67 65 79 72 43 42 62 63 31 59 67 63 30 44 63 37 48 40 48 38 71 62 67 64 79 31 49 63 36 72 70 67 42 40 50 65 43 45 77 57 54 64 33 63 58 66 54 64 55 79 42 64 54 72 34 52 35 43 42 53 64 40 52 33 77 52 30 67 47 36 61 77 35 66 37 79 70 78 65 77 64 72 55 76 35 58 68 72 58 75 72 67 36 47 33 73 35 76 39 54 34 45 69 36 39 72 79 55 66 41 77 48 43 57 42 76 39 71 60 70 64 45 66 53 46 74 66 67 46 73 79 51 74 57 65 30 70 65 55 48 48 36 59 38 71 55 66 60 46 50 64 77 58 66 34 30 53 44 41 70 30 34 63 46 71 50 75 36 68 36 37 46 37 58 79 54 35 71 70 62 38 76 47 70 47 37 64 76 42 32 69 56 75 36 44 30 66 59 56 52 59 31 42 56 44 37 50 68 42 74 41 60 30 73 36 41 77 69 38 70 32 59 48 49 37 64 77 57 55 43 39 51 72 69 66 51 31 64 59 38 66 49 77 34 78 32 35 68 62 45 46 61 59 53 57 51 43 62 70 46 68 49 69 43 39 31 51 63 44 68 42 64 39 31 54 63 39 44 79 75 52 71 46 57 32 45 71 68 40 47 35 67 54 52 69 71 78 34 64 48 71 52 48 54 56 67 63 71 75 48 45 54 32 76 36 54 46 61 74 70 64 76 56 57 35 48 71 71 45 71 51 39 30 47 46 73 54 44 35 37 32 46 55 76 62 69 76 75 33 32 31 56 33 64 79 30 35 76 55 50 66 75 73 53 62 36 76 40 56 72 30 70 75 32 30 45 66 41 40 64 59 64 30 62 36 66 64 70 47 62 46 46 68 55 31 40 30 62 51 73 68 34 73 75 60 68 47 50 75 63 45 76 63 70 62 69 69 63 47 59 33 59 43 30 32 75 41 31 48 43 43 37 34 56 47 41 59 44 46 61 72 78 52 35 67 37 38 44 42 40 76 45 60 45 76 70 77 72 44 74 64 50 45 30 36 36 32 76 63 41 47 45 75 55 34 78 49 59 68 51 72 77 77 39 32 51 38 52 39 77 79 79 50 50 66 64 42 45 33 65 71 79 47 38 74 49 61 59 38 37 39 36 79 55 56 54 37 54 64 58 76 75 61 44 79 48 68 37 73 34 35 77 47 35 71 73 63 77 59 66 35 63 34 60 32 34 59 68 50 34 52 56 31 45 66 61 60 55 40 44 68 37 70 68 61 77 72 48 50 61 41 49 61 70 63 52 43 32 32 58 51 78 77 75 36 52 66 74 57 74 63 77 70 65 44 53 67 33 48 60 35 46 38 42 36 48 31 72 56 36 32 64 53 50 42 30 55 41 30 75 68 50 31 63 78 72 78 64 75 67 42 73 38 39 51 46 52 62 71 63 68 45 56 46 78 69 63 35 77 76 49 55 47 67 50 60 72 65 69 53 60 53 57 66 61 65 52 75 59 65 43 65 65 63 66 76 78 65 32 51 40 62 66 68 49 66 72 45 58 78 76 66 41 56 77 51 32 75 32 44 69 52 37 50 50 34 39 60 78 71 40 40 71 47 63 55 66 79 55 70 56 36 52 33 66 47 45 72 75 46 36 66 67 78 56 44 65 45 38 70 40 44 34 42 32 68 36 55 60 79 59 59 43 68 47 51 75 71 49 69 38 45 42 53 61 50 77 33 38 38 45 59 46 69 43 51 71 39 61 52 44 46 68 50 48 79 35 30 74 66 58 36 57 43 53 51 57 53 41 53 64 32 67 47 43 33 56 75 75 43 36 50 39 35 76 63 53 32 59 49 56 73 65 45 51 74 37 51 67 79 49 76 45 32 72 33 37 70 39 37 66 39 45 66 49 39 43 65 58 31 48 49 36 61 58 54 75 73 54 46 54 41 65 52 51 37 75 54 68 63 38 75 52 63 61 33 62 30 70 60 38 35 32 38 48 37 41 50 58 36 43 62 72 62 47 50 38 54 67 74 63 44 44 44 76 70 55 35 43 47 72 61 49 60 48 58 78 50 59 71 46 67 38 56 55 39 48 50 65 44 36 77 36 64 40 31 38 58 74 69 54 56 74 70 69 52 49 31 32 74 53 69 39 57 67 66 46 57 49 53 79 44 45 74 66 49 58 56 38 32 76 67 45 68 46 68 62 54 63 45 36 36 42 46 54 59 72 64 52 79 76 56 62 32 55 46 45 32 39 35 47 74 34 73 54 79 52 51 63 43 47 73 53 40 55 54 65 31 52 38 75 56 50 71 68 59 52 57 73 38 34 52 56 67 46 33 70 42 69 33 59 79 52 32 32 49 34 59 64 68 54 56 43 64 52 78 33 33 37 48 63 67 75 59 41 74 39 41 37 56 52 75 72 52 58 76 41 65 65 59 46 62 36 38 79 50 76 54 50 56 36 63 75 54 71 68 68 44 34 57 33 72 34 53 32 55 41 72 54 79 65 70 76 58 35 34 71 39 61 59 32 63 72 62 42 79 41 77 35 70 49 39 58 69 58 60 51 58 70 36 78 74 75 55 40 78 46 60 45 44 56 52 59 73 62 35 66 63 35 67 62 68 45 44 48 79 62 38 76 68 58 68 75 39 49 74 42 49 79 48 47 38 73 41 33 70 66 56 33 34 30 48 53 77 76 46 60 45 32 30 47 53 66 48 77 59 54 58 40 38 55 47 42 64 32 49 42 50 41 65 70 41 44 30 40 75 47 34 67 47 45 72 68 53 45 59 67 68 49 66 60 39 70 51 49 61 56 50 41 34 73 64 37 79 66 59 30 37 35 45 64 79 74 72 50 49 47 43 33 47 57 40 35 33 71 42 56 34 52 64 46 30 73 75 32 77 51 41 74 39 46 65 69 48 37 48 34 30 62 79 50 65 78 72 46 62 59 46 39 38 63 79 65 37 50 51 72 60 57 36 75 66 33 32 48 65 65 58 58 40 31 79 44 65 56 37 67 71 68 73 76 63 73 48 53 65 39 76 61 41 69 64 53 79 61 79 72 36 30 67 70 49 53 68 47 63 30 38 36 68 43 50 46 38 65 53 59 78 36 50 55 76 63 68 49 76 70 55 49 49 71 77 75 34 38 38 74 71 71 67 30 62 55 66 68 38 60 65 43 64 33 57 65 56 50 66 61 50 79 78 57 79 65 53 67 31 61 47 63 51 56 59 61 74 72 47 30 58 46 64
{ "pile_set_name": "Github" }
/** * Copyright 2020 The Pennsylvania State University * @license Apache-2.0, see License.md for full text. */ import { html, css } from "lit-element/lit-element.js"; import { HAXWiring } from "@lrnwebcomponents/hax-body-behaviors/lib/HAXWiring.js"; import { A11yDetails } from "@lrnwebcomponents/a11y-details/a11y-details.js"; /** * `a11y-figure` * accessible progressive disclosure with detail and summary ### Styling #### Figure Caption Custom property | Description | Default ----------------|-------------|---------- --a11y-details-figcaption-fontSize | font-size | unset --a11y-details-figcaption-color | text color | #000 --a11y-details-figcaption-backgroundColor | background-color | #fff --a11y-details-figcaption-margin | padding | 0 --a11y-details-figcaption-padding | padding | 0 #### Summary Button Custom property | Description | Default ----------------|-------------|---------- --a11y-details-summary-fontSize | font-size | 0.8em --a11y-details-summary-color | text color | #000 --a11y-details-summary-backgroundColor | background-color | #fff --a11y-details-summary-borderColor | border-color | #000 --a11y-details-summary-borderWidth | border-width | 1px --a11y-details-summary-borderStyle | border-style | solid --a11y-details-summary-borderRadius | border-radius | 3px --a11y-details-summary-padding | padding | 0.5em #### Summary Button (:focus state) Custom property | Description | Default ----------------|-------------|---------- --a11y-details-summary-focus-color | text color | #000 --a11y-details-summary-focus-backgroundColor | background-color | #fff --a11y-details-summary-focus-borderColor | border-color | #000 --a11y-details-summary-focus-borderWidth | border-width | 1px --a11y-details-summary-focus-borderStyle | border-style | dotted --a11y-details-summary-focus-borderRadius | border-radius | 3px #### Details Custom property | Description | Default ----------------|-------------|---------- --a11y-details-fontSize | font-size | 0.8em --a11y-details-color | text color | #000 --a11y-details-backgroundColor | background-color | rgba(255,255,255,0.8) --a11y-details-borderColor | border-color | #000 --a11y-details-borderWidth | border-width | 1px --a11y-details-borderStyle | border-style | solid --a11y-details-borderRadius | border-radius | 3px --a11y-details-padding | padding | 0.5em --a11y-details-maxHeight | max-height | 400px * @lit-html * @lit-element * @demo demo/index.html */ class A11yFigure extends A11yDetails { //styles function static get styles() { return [ css` :host { display: block; } :host([hidden]) { display: none; } figure { position: relative; } figcaption { display: flex; width: 100%; align-items: center; justify-content: space-between; margin: var(--a11y-figure-figcaption-margin, 0); padding: var(--a11y-figure-figcaption-padding, 0); font-size: var(--a11y-figure-figcaption-fontSize, unset); background-color: var(--a11y-figure-figcaption-backgroundColor, #fff); color: var(--a11y-figure-figcaption-color, #000); } ::slotted([slot="figcaption"]) { margin: 0; } img, ::slotted([slot="image"]) { width: 100%; } `, ]; } // render function render() { return html` <figure> ${this.imgSrc ? html` <img src="${this.imgSrc}" alt="${this.imgAlt}" /> ` : ``} <slot name="image" ?hidden="${this.imgSrc}"></slot> <figcaption> <slot name="figcaption"></slot> <a11y-details open-text="${this.openText}" close-text="${this.closeText}" > <div slot="summary"><slot name="summary"></slot></div> <div slot="details"><slot name="details"></slot></div> <slot name="figdetails"></slot> </a11y-details> </figcaption> </figure> <slot hidden></slot> `; } // haxProperty definition static get haxProperties() { return { canScale: true, canPosition: true, canEditSource: false, gizmo: { title: "Accessible Figure", description: "Accessible figure with long description", icon: "av:call-to-action", color: "grey", groups: ["11"], handles: [ { type: "image", source: "imgSrc", alt: "imgAlt", caption: "figcaption", ariaDescribedby: "describedBy", }, ], meta: { author: "nikkimk", owner: "The Pennsylvania State University", }, }, settings: { quick: [], configure: [ { property: "imgSrc", title: "Image", inputMethod: "haxupload", }, { property: "imgAlt", title: "Alt Text", inputMethod: "alt", required: true, }, { slot: "figcaption", title: "Figure Caption", description: "Figure caption text that is always visible.", inputMethod: "code-editor", }, { slot: "details", title: "Decription", description: "Detailed image description that can be hidden or shown", inputMethod: "code-editor", }, { slot: "summary", title: "Decription Button", description: 'Default for button that shows/hides description text, eg. "info", "medatadata", etc. ', inputMethod: "code-editor", }, ], advanced: [ { property: "openText", title: "Optional summary text when details are open", inputMethod: "textfield", required: false, }, { property: "closeText", title: "Optional summary text when details are closed", inputMethod: "textfield", required: false, }, ], }, demoSchema: [ { tag: "a11y-figure", properties: { imgSrc: "//placekitten.com/400/300", imgAlt: "random kitten", openText: "Show Description", closeText: "Hide Description", style: "max-width:400px", }, content: '<h4 slot="figcaption">Random Kitten</h4>\n<div slot="summary">Image Description</div>\n<div slot="details">Aenean eget nisl volutpat, molestie purus eget, bibendum metus. Pellentesque magna velit, tincidunt quis pharetra id, gravida placerat erat. Maecenas id dui pretium risus pulvinar feugiat vel nec leo. Praesent non congue tellus. Suspendisse ac tincidunt purus. Donec eu dui a metus vehicula bibendum sed nec tortor. Nunc convallis justo sed nibh consectetur, at pharetra nulla accumsan.</div>', }, ], }; } // properties available to the custom element for data binding static get properties() { return { ...super.properties, imgSrc: { type: String, attribute: "img-src", }, imgAlt: { type: String, attribute: "img-alt", }, }; } /** * Store the tag name to make it easier to obtain directly. * @notice function name must be here for tooling to operate correctly */ tag() { return "a11y-figure"; } // life cycle constructor() { super(); this.tag = A11yFigure.tag; } /** * mutation observer for a11y-details * @readonly * @returns {object} */ get observer() { let callback = (mutationsList) => this._watchChildren(mutationsList); return new MutationObserver(callback); } /** * mutation observer for <details/> in unnamed slot * @readonly * @returns {object} */ get figureObserver() { let callback = () => this._updateElement(); return new MutationObserver(callback); } /** * updates an element based on changes in slot * * @memberof A11yDetails */ _updateElement() { let figure = this.querySelector("* > figure"), image = figure ? figure.querySelector("* > img") : undefined, figcaption = figure ? figure.querySelector("* > figcaption") : undefined; if (image) { (this.querySelectorAll("[slot=image]") || []).forEach((image) => image.remove() ); image.cloneNode(); image.slot = "image"; this.appendChild(image); } if (figcaption) { this._copyAndFilter(figcaption.cloneNode(true), [ "figcaption", "details", "summary", ]); } } _copyAndFilter(clone, nodenames = [], i = 0) { let childname = nodenames[i + 1], child = clone && childname ? clone.querySelector(`* > ${childname}`) : undefined; if (child) { this._copyAndFilter(child, nodenames, i + 1); Object.keys(child || {}).forEach((index) => child[index].remove()); } this._copyToSlot(nodenames[i], clone); } /** * watches the element's slots for a <details/> element * * @param {object} mutationsList * @memberof A11yDetails */ _watchChildren(mutationsList) { if (this._hasMutations(mutationsList)) { this._updateElement(); this.figureObserver.observe(this.querySelector("* > figure"), { childList: true, subtree: true, characterData: true, }); } else if ( this._hasMutations(mutationsList, "removedNodes") && !this.querySelector("* > figureObserver") && this.detailsObserver.disconnect ) { this.detailsObserver.disconnect(); } } /** * life cycle, element is afixed to the DOM */ connectedCallback() { super.connectedCallback(); this.HAXWiring = new HAXWiring(); this.HAXWiring.setup(A11yFigure.haxProperties, A11yFigure.tag, this); } } customElements.define("a11y-figure", A11yFigure); export { A11yFigure };
{ "pile_set_name": "Github" }
#pragma once extern int l_dostring(lua_State *L, const char *s, const char *name); extern int l_report(lua_State *L, int status); extern int l_docall(lua_State *L, int narg, int nres); extern int l_handle_line(lua_State *L, char *line);
{ "pile_set_name": "Github" }
{ "@context": { "property": "http://example.com/property", "nested": "http://example.com/nested", "@language": "en" }, "property": "this is English", "nested": { "@context": { "@language": null }, "property": "and this is a plain string" } }
{ "pile_set_name": "Github" }
/*- * This code is derived from OpenBSD's libc/regex, original license follows: * * Copyright (c) 1992, 1993, 1994 Henry Spencer. * Copyright (c) 1992, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Henry Spencer. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University 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 REGENTS 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 REGENTS 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. * * @(#)regerror.c 8.4 (Berkeley) 3/20/94 */ #include <sys/types.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <limits.h> #include <stdlib.h> #include "regex_impl.h" #include "regutils.h" #ifdef _MSC_VER #define snprintf _snprintf #endif static const char *regatoi(const llvm_regex_t *, char *, int); static struct rerr { int code; const char *name; const char *explain; } rerrs[] = { { REG_NOMATCH, "REG_NOMATCH", "llvm_regexec() failed to match" }, { REG_BADPAT, "REG_BADPAT", "invalid regular expression" }, { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" }, { REG_ECTYPE, "REG_ECTYPE", "invalid character class" }, { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" }, { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" }, { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" }, { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" }, { REG_EBRACE, "REG_EBRACE", "braces not balanced" }, { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" }, { REG_ERANGE, "REG_ERANGE", "invalid character range" }, { REG_ESPACE, "REG_ESPACE", "out of memory" }, { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" }, { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" }, { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" }, { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" }, { 0, "", "*** unknown regexp error code ***" } }; /* - llvm_regerror - the interface to error numbers = extern size_t llvm_regerror(int, const llvm_regex_t *, char *, size_t); */ /* ARGSUSED */ size_t llvm_regerror(int errcode, const llvm_regex_t *preg, char *errbuf, size_t errbuf_size) { struct rerr *r; size_t len; int target = errcode &~ REG_ITOA; const char *s; char convbuf[50]; if (errcode == REG_ATOI) s = regatoi(preg, convbuf, sizeof convbuf); else { for (r = rerrs; r->code != 0; r++) if (r->code == target) break; if (errcode&REG_ITOA) { if (r->code != 0) { assert(strlen(r->name) < sizeof(convbuf)); (void) llvm_strlcpy(convbuf, r->name, sizeof convbuf); } else (void)snprintf(convbuf, sizeof convbuf, "REG_0x%x", target); s = convbuf; } else s = r->explain; } len = strlen(s) + 1; if (errbuf_size > 0) { llvm_strlcpy(errbuf, s, errbuf_size); } return(len); } /* - regatoi - internal routine to implement REG_ATOI */ static const char * regatoi(const llvm_regex_t *preg, char *localbuf, int localbufsize) { struct rerr *r; for (r = rerrs; r->code != 0; r++) if (strcmp(r->name, preg->re_endp) == 0) break; if (r->code == 0) return("0"); (void)snprintf(localbuf, localbufsize, "%d", r->code); return(localbuf); }
{ "pile_set_name": "Github" }
/** * $Id: Menu.js 1190 2009-08-12 17:59:29Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. */ (function(tinymce) { var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk; /** * This class is base class for all menu types like DropMenus etc. This class should not * be instantiated directly other menu controls should inherit from this one. * * @class tinymce.ui.Menu * @extends tinymce.ui.MenuItem */ tinymce.create('tinymce.ui.Menu:tinymce.ui.MenuItem', { /** * Constructs a new button control instance. * * @constructor * @method Menu * @param {String} id Button control id for the button. * @param {Object} s Optional name/value settings object. */ Menu : function(id, s) { var t = this; t.parent(id, s); t.items = {}; t.collapsed = false; t.menuCount = 0; t.onAddItem = new tinymce.util.Dispatcher(this); }, /** * Expands the menu, this will show them menu and all menu items. * * @method expand * @param {Boolean} d Optional deep state. If this is set to true all children will be expanded as well. */ expand : function(d) { var t = this; if (d) { walk(t, function(o) { if (o.expand) o.expand(); }, 'items', t); } t.collapsed = false; }, /** * Collapses the menu, this will hide the menu and all menu items. * * @method collapse * @param {Boolean} d Optional deep state. If this is set to true all children will be collapsed as well. */ collapse : function(d) { var t = this; if (d) { walk(t, function(o) { if (o.collapse) o.collapse(); }, 'items', t); } t.collapsed = true; }, /** * Returns true/false if the menu has been collapsed or not. * * @method isCollapsed * @return {Boolean} True/false state if the menu has been collapsed or not. */ isCollapsed : function() { return this.collapsed; }, /** * Adds a new menu, menu item or sub classes of them to the drop menu. * * @method add * @param {tinymce.ui.Control} o Menu or menu item to add to the drop menu. * @return {tinymce.ui.Control} Same as the input control, the menu or menu item. */ add : function(o) { if (!o.settings) o = new tinymce.ui.MenuItem(o.id || DOM.uniqueId(), o); this.onAddItem.dispatch(this, o); return this.items[o.id] = o; }, /** * Adds a menu separator between the menu items. * * @method addSeparator * @return {tinymce.ui.MenuItem} Menu item instance for the separator. */ addSeparator : function() { return this.add({separator : true}); }, /** * Adds a sub menu to the menu. * * @method addMenu * @param {Object} o Menu control or a object with settings to be created into an control. * @return {tinymce.ui.Menu} Menu control instance passed in or created. */ addMenu : function(o) { if (!o.collapse) o = this.createMenu(o); this.menuCount++; return this.add(o); }, /** * Returns true/false if the menu has sub menus or not. * * @method hasMenus * @return {Boolean} True/false state if the menu has sub menues or not. */ hasMenus : function() { return this.menuCount !== 0; }, /** * Removes a specific sub menu or menu item from the menu. * * @method remove * @param {tinymce.ui.Control} o Menu item or menu to remove from menu. * @return {tinymce.ui.Control} Control instance or null if it wasn't found. */ remove : function(o) { delete this.items[o.id]; }, /** * Removes all menu items and sub menu items from the menu. * * @method removeAll */ removeAll : function() { var t = this; walk(t, function(o) { if (o.removeAll) o.removeAll(); else o.remove(); o.destroy(); }, 'items', t); t.items = {}; }, /** * Created a new sub menu for the menu control. * * @method createMenu * @param {Object} s Optional name/value settings object. * @return {tinymce.ui.Menu} New drop menu instance. */ createMenu : function(o) { var m = new tinymce.ui.Menu(o.id || DOM.uniqueId(), o); m.onAddItem.add(this.onAddItem.dispatch, this.onAddItem); return m; } }); })(tinymce);
{ "pile_set_name": "Github" }
/* * 图表配置文件 * */ //不同类型的配置 var typeConfig = [ { chart: { type: 'line' }, plotOptions: { line: { dataLabels: { enabled: false }, enableMouseTracking: true } } }, { chart: { type: 'line' }, plotOptions: { line: { dataLabels: { enabled: true }, enableMouseTracking: false } } }, { chart: { type: 'area' } }, { chart: { type: 'bar' } }, { chart: { type: 'column' } }, { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: '#000000', connectorColor: '#000000', formatter: function() { return '<b>'+ this.point.name +'</b>: '+ ( Math.round( this.point.percentage*100 ) / 100 ) +' %'; } } } } } ];
{ "pile_set_name": "Github" }
/* ***** BEGIN LICENSE BLOCK ***** * Distributed under the BSD license: * * Copyright (c) 2012, Ajax.org B.V. * 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 Ajax.org B.V. 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 AJAX.ORG B.V. BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * ***** END LICENSE BLOCK ***** */ /* THIS FILE WAS AUTOGENERATED BY mode.tmpl.js */ define(function(require, exports, module) { "use strict"; var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var Tokenizer = require("../tokenizer").Tokenizer; var ValaHighlightRules = require("./vala_highlight_rules").ValaHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Mode = function() { this.HighlightRules = ValaHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); (function() { this.lineCommentStart = "//"; this.blockComment = {start: "/*", end: "*/"}; this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; var endState = tokenizedLine.state; if (tokens.length && tokens[tokens.length-1].type == "comment") { return indent; } if (state == "start" || state == "no_regex") { var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/); if (match) { indent += tab; } } else if (state == "doc-start") { if (endState == "start" || endState == "no_regex") { return ""; } var match = line.match(/^\s*(\/?)\*/); if (match) { if (match[1]) { indent += " "; } indent += "* "; } } return indent; }; this.checkOutdent = function(state, line, input) { return this.$outdent.checkOutdent(line, input); }; this.autoOutdent = function(state, doc, row) { this.$outdent.autoOutdent(doc, row); }; // Extra logic goes here. this.$id = "ace/mode/vala" }).call(Mode.prototype); exports.Mode = Mode; });
{ "pile_set_name": "Github" }
// Copyright 2013 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 encoding_test import ( "fmt" "io" "os" "strings" "golang.org/x/text/encoding" "golang.org/x/text/encoding/charmap" "golang.org/x/text/encoding/unicode" "golang.org/x/text/transform" ) func ExampleDecodeWindows1252() { sr := strings.NewReader("Gar\xe7on !") tr := charmap.Windows1252.NewDecoder().Reader(sr) io.Copy(os.Stdout, tr) // Output: Garçon ! } func ExampleUTF8Validator() { for i := 0; i < 2; i++ { var transformer transform.Transformer transformer = unicode.UTF16(unicode.BigEndian, unicode.IgnoreBOM).NewEncoder() if i == 1 { transformer = transform.Chain(encoding.UTF8Validator, transformer) } dst := make([]byte, 256) src := []byte("abc\xffxyz") // src is invalid UTF-8. nDst, nSrc, err := transformer.Transform(dst, src, true) fmt.Printf("i=%d: produced %q, consumed %q, error %v\n", i, dst[:nDst], src[:nSrc], err) } // Output: // i=0: produced "\x00a\x00b\x00c\xff\xfd\x00x\x00y\x00z", consumed "abc\xffxyz", error <nil> // i=1: produced "\x00a\x00b\x00c", consumed "abc", error encoding: invalid UTF-8 }
{ "pile_set_name": "Github" }
description "Docker daemon" start on (local-filesystems and net-device-up IFACE!=lo) stop on runlevel [!2345] limit nofile 524288 1048576 limit nproc 524288 1048576 respawn kill timeout 20 pre-start script # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount if grep -v '^#' /etc/fstab | grep -q cgroup \ || [ ! -e /proc/cgroups ] \ || [ ! -d /sys/fs/cgroup ]; then exit 0 fi if ! mountpoint -q /sys/fs/cgroup; then mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup fi ( cd /sys/fs/cgroup for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do mkdir -p $sys if ! mountpoint -q $sys; then if ! mount -n -t cgroup -o $sys cgroup $sys; then rmdir $sys || true fi fi done ) end script script # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker) DOCKER=/usr/bin/$UPSTART_JOB DOCKER_OPTS= if [ -f /etc/default/$UPSTART_JOB ]; then . /etc/default/$UPSTART_JOB fi exec "$DOCKER" -d $DOCKER_OPTS end script # Don't emit "started" event until docker.sock is ready. # See https://github.com/docker/docker/issues/6647 post-start script DOCKER_OPTS= if [ -f /etc/default/$UPSTART_JOB ]; then . /etc/default/$UPSTART_JOB fi if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then while ! [ -e /var/run/docker.sock ]; do initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1 echo "Waiting for /var/run/docker.sock" sleep 0.1 done echo "/var/run/docker.sock is up" fi end script
{ "pile_set_name": "Github" }
const map = new CartoMap({ container: 'map', background: 'black' }); const source = new carto.source.GeoJSON(sources['line-string']); const style = new carto.Viz('color: hex("#F00")'); const layer = new carto.Layer('layer', source, style); layer.addTo(map); layer.on('loaded', () => { window.loaded = true; });
{ "pile_set_name": "Github" }
/* * Copyright 2014-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ package com.tencent.tinker.build.aapt; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class StringUtil { public static final String BLANK = ""; public static final String SPACE = " "; public static final String NULL = "null"; public static final String CRLF_STRING = "\r\n"; public static final byte CR = '\r'; public static final byte LF = '\n'; public static final byte[] CRLF = {CR, LF}; private static final String METCH_PATTERN_REGEX = "[\\*]+"; private static final String METCH_PATTERN = Constant.Symbol.WILDCARD; private static final String METCH_PATTERN_REPLACEMENT = "[\\\\S|\\\\s]*"; private static final String ZERO = "0"; private StringUtil() { } /** * when string is null return blank,where the string is not null it return string.trim * * @param string * @return String */ public static String trim(final String string) { String result = null; if (string == null) { result = BLANK; } else { result = string.trim(); } return result; } /** * when string is null return blank string * * @param string * @return String */ public static String nullToBlank(final String string) { return string == null ? BLANK : string; } /** * when string[] is null return blank array * * @param stringArray * @return String[]{} length==0 */ public static String[] nullToBlank(final String[] stringArray) { String[] result = stringArray; if (stringArray == null) { result = new String[]{}; } return result; } /** * <p>Checks if a String is whitespace, empty ("") or null.</p> * <p/> * <pre> * StringUtils.isBlank(null) = true * StringUtils.isBlank("") = true * StringUtils.isBlank(" ") = true * StringUtils.isBlank("bob") = false * StringUtils.isBlank(" bob ") = false * </pre> * * @param string the String to check, may be null * @return <code>true</code> if the String is null, empty or whitespace */ public static boolean isBlank(final String string) { boolean result = false; int strLen; if (string == null || (strLen = string.length()) == 0) { result = true; } else { for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(string.charAt(i))) { result = false; break; } } } return result; } /** * <p> * Checks if a String is not empty (""), not null and not whitespace only. * </p> * <p/> * <pre> * StringUtils.isNotBlank(null) = false * StringUtils.isNotBlank(&quot;&quot;) = false * StringUtils.isNotBlank(&quot; &quot;) = false * StringUtils.isNotBlank(&quot;bob&quot;) = true * StringUtils.isNotBlank(&quot; bob &quot;) = true * </pre> * * @param string the String to check, may be null * @return <code>true</code> if the String is not empty and not null and * not whitespace */ public static boolean isNotBlank(final String string) { return !isBlank(string); } /** * compare stringArray1 and stringArray2 return the different in str1 * * @param stringArray1 * @param stringArray2 * @return String[] */ public static String[] compareString(final String[] stringArray1, final String[] stringArray2) { String[] differentString = null; if (stringArray1 != null && stringArray2 != null) { List<String> list = new ArrayList<String>(); for (int i = 0; i < stringArray1.length; i++) { boolean sign = false; for (int j = 0; j < stringArray2.length; j++) { if (stringArray1[i].equals(stringArray2[j])) { sign = true; break; } } if (!sign) { list.add(stringArray1[i]); } } differentString = new String[list.size()]; differentString = list.toArray(differentString); } return differentString; } /** * <p>Method:only for '*' match pattern,return true of false</p> * * @param string * @param patternString * @return boolean */ public static boolean isMatchPattern(final String string, final String patternString) { boolean result = false; if (string != null && patternString != null) { if (patternString.indexOf(METCH_PATTERN) >= 0) { String matchPattern = Constant.Symbol.XOR + patternString.replaceAll(METCH_PATTERN_REGEX, METCH_PATTERN_REPLACEMENT) + Constant.Symbol.DOLLAR; result = isMatchRegex(string, matchPattern); } else { if (string.equals(patternString)) { result = true; } } } return result; } /** * <p>Method:only for regex</p> * * @param string * @param regex * @return boolean */ public static boolean isMatchRegex(final String string, final String regex) { boolean result = false; if (string != null && regex != null) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(string); result = matcher.find(); } return result; } /** * <p>Method:only for regex,parse regex group when regex include group</p> * * @param string * @param regex * @return List<String> */ public static List<String> parseRegexGroup(final String string, final String regex) { List<String> groupList = null; if (string != null && regex != null) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(string); int groupCount = matcher.groupCount(); int count = 1; groupList = new ArrayList<String>(); if (matcher.find()) { while (count <= groupCount) { groupList.add(matcher.group(count)); count++; } } } return groupList; } /** * <p> * Method: check the string match the regex or not and return the match * field value * like {xxxx} can find xxxx * </p> * * @param string * @param regex * @param firstRegex * @param firstRegexReplace * @param lastRegexStringLength like {xxxx},last regex string is "}" so last regex string length equals 1 * @return List<String> */ public static List<String> parseStringGroup(final String string, final String regex, final String firstRegex, final String firstRegexReplace, final int lastRegexStringLength) { List<String> list = null; if (string != null) { list = new ArrayList<String>(); int lastRegexLength = lastRegexStringLength < 0 ? 0 : lastRegexStringLength; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(string); String group = null; int start = 0; while (matcher.find(start)) { start = matcher.end(); group = matcher.group(); group = group.replaceFirst(firstRegex, firstRegexReplace); group = group.substring(0, group.length() - lastRegexLength); list.add(group); } } return list; } /** * byte to hex string * * @param byteArray * @return String */ public static String byteToHexString(byte[] byteArray) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < byteArray.length; i++) { int byteCode = byteArray[i] & 0xFF; if (byteCode < 0x10) { builder.append(0); } builder.append(Integer.toHexString(byteCode)); } return builder.toString(); } /** * hex string to byte * * @param source * @return byte */ public static byte[] hexStringToByte(final String source) { byte[] bytes = null; if (source != null) { bytes = new byte[source.length() / 2]; int i = 0; while (i < bytes.length) { bytes[i] = (byte) (Integer.parseInt(source.substring(i * 2, (i + 1) * 2), 16)); i++; } } return bytes; } /** * fill zero * * @param length * @return String */ public static String fillZero(int length) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < length; i++) { stringBuilder.append(ZERO); } return stringBuilder.toString(); } /** * <p>Method: string mod operator,return 0~(mod-1)</p> * * @param string * @param mod * @return int */ public static int stringMod(String string, int mod) { int hashCode = 0; if (string != null) { hashCode = string.hashCode(); if (hashCode < 0) { hashCode = Math.abs(hashCode); hashCode = hashCode < 0 ? 0 : hashCode; } } return hashCode % (mod > 0 ? mod : 1); } }
{ "pile_set_name": "Github" }
using System.Linq; using Autodesk.DesignScript.Geometry; using Autodesk.DesignScript.Runtime; using MIConvexHull; using StarMathLib; namespace Tessellation.Adapters { /// <summary> /// A cell for a 2d tesselation /// </summary> [SupressImportIntoVM] public class Cell2 : TriangulationCell<Vertex2, Cell2> { Point GetCircumcenter() { // From MathWorld: http://mathworld.wolfram.com/Circumcircle.html var points = Vertices; var m = new double[3, 3]; // x, y, 1 for (int i = 0; i < 3; i++) { m[i, 0] = points[i].Position[0]; m[i, 1] = points[i].Position[1]; m[i, 2] = 1; } var a = StarMath.determinant(m); // size, y, 1 for (int i = 0; i < 3; i++) { m[i, 0] = StarMath.norm2(points[i].Position, true); } var dx = -StarMath.determinant(m); // size, x, 1 for (int i = 0; i < 3; i++) { m[i, 1] = points[i].Position[0]; } var dy = StarMath.determinant(m); // size, x, y for (int i = 0; i < 3; i++) { m[i, 2] = points[i].Position[1]; } var s = -1.0 / (2.0 * a); return Point.ByCoordinates(s * dx, s * dy); } Point GetCentroid() { return Point.ByCoordinates(Vertices.Select(v => v.Position[0]).Average(), Vertices.Select(v => v.Position[1]).Average()); } Point circumCenter; public Point Circumcenter { get { return circumCenter = circumCenter ?? GetCircumcenter(); } } Point centroid; public Point Centroid { get { return centroid = centroid ?? GetCentroid(); } } } }
{ "pile_set_name": "Github" }
use openssl::error::ErrorStack; use openssl::ssl::{SslConnector, SslFiletype, SslMethod}; use postgres::{error::SqlState, Client, Error, Transaction}; use postgres_openssl::MakeTlsConnector; /// Runs op inside a transaction and retries it as needed. /// On non-retryable failures, the transaction is aborted and /// rolled back; on success, the transaction is committed. fn execute_txn<T, F>(client: &mut Client, op: F) -> Result<T, Error> where F: Fn(&mut Transaction) -> Result<T, Error>, { let mut txn = client.transaction()?; loop { let mut sp = txn.savepoint("cockroach_restart")?; match op(&mut sp).and_then(|t| sp.commit().map(|_| t)) { Err(ref err) if err .code() .map(|e| *e == SqlState::T_R_SERIALIZATION_FAILURE) .unwrap_or(false) => {} r => break r, } } .and_then(|t| txn.commit().map(|_| t)) } fn transfer_funds(txn: &mut Transaction, from: i64, to: i64, amount: i64) -> Result<(), Error> { // Read the balance. let from_balance: i64 = txn .query_one("SELECT balance FROM accounts WHERE id = $1", &[&from])? .get(0); assert!(from_balance >= amount); // Perform the transfer. txn.execute( "UPDATE accounts SET balance = balance - $1 WHERE id = $2", &[&amount, &from], )?; txn.execute( "UPDATE accounts SET balance = balance + $1 WHERE id = $2", &[&amount, &to], )?; Ok(()) } fn ssl_config() -> Result<MakeTlsConnector, ErrorStack> { let mut builder = SslConnector::builder(SslMethod::tls())?; builder.set_ca_file("certs/ca.crt")?; builder.set_certificate_chain_file("certs/client.maxroach.crt")?; builder.set_private_key_file("certs/client.maxroach.key", SslFiletype::PEM)?; Ok(MakeTlsConnector::new(builder.build())) } fn main() { let connector = ssl_config().unwrap(); let mut client = Client::connect("postgresql://maxroach@localhost:26257/bank", connector).unwrap(); // Run a transfer in a transaction. execute_txn(&mut client, |txn| transfer_funds(txn, 1, 2, 100)).unwrap(); // Check account balances after the transaction. for row in &client .query("SELECT id, balance FROM accounts", &[]) .unwrap() { let id: i64 = row.get(0); let balance: i64 = row.get(1); println!("{} {}", id, balance); } }
{ "pile_set_name": "Github" }
import { InnerSubscriber } from '../InnerSubscriber'; import { subscribeTo } from './subscribeTo'; import { Observable } from '../Observable'; export function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex)) { if (innerSubscriber.closed) { return undefined; } if (result instanceof Observable) { return result.subscribe(innerSubscriber); } return subscribeTo(result)(innerSubscriber); } //# sourceMappingURL=subscribeToResult.js.map
{ "pile_set_name": "Github" }
/** * Copyright (C) 2011 Daniel-Constantin Mierla (asipto.com) * * This file is part of Kamailio, a free SIP server. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * */ #ifndef _COREX_LIB_H_ #define _COREX_LIB_H_ #include "../../core/mod_fix.h" int w_corex_append_branch(sip_msg_t *msg, gparam_t *pu, gparam_t *pq); int corex_append_branch(sip_msg_t *msg, str *uri, str *qv); int corex_send(sip_msg_t *msg, gparam_t *pu, enum sip_protos proto); int corex_send_data(str *puri, str *psock, str *pdata); int corex_add_alias_subdomains(char* aliasval); int corex_register_check_self(void); #endif
{ "pile_set_name": "Github" }
/************************************************************* * * MathJax/localization/bcc/bcc.js * * Copyright (c) 2009-2018 The MathJax Consortium * * 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. * */ MathJax.Localization.addTranslation("bcc",null,{ menuTitle: "\u0628\u0644\u0648\u0686\u06CC", fontDirection: "rtl", version: "2.7.5", isLoaded: true, domains: { "_": { version: "2.7.5", isLoaded: true, strings: { MathProcessingError: "\u062E\u0637\u0627\u06CC \u067E\u0631\u062F\u0627\u0632\u0634 \u0631\u06CC\u0627\u0636\u06CC", MathError: "\u062D\u0637\u0627\u06CC \u0631\u06CC\u0627\u0636\u06CC", LoadFile: "\u0628\u0627\u0631\u06AF\u06CC\u0631\u06CC %1", Loading: "\u0644\u0648\u062F\u0628\u06CC\u062A...", LoadFailed: "\u062E\u0637\u0627 \u062F\u0631 \u0628\u0627\u0631\u06AF\u06CC\u0631\u06CC \u067E\u0631\u0648\u0646\u062F\u0647: %1", ProcessMath: "\u067E\u0631\u062F\u0627\u0632\u0634 \u0631\u06CC\u0627\u0636\u06CC: %1\u066A", Processing: "\u067E\u0631\u062F\u0627\u0632\u0634", TypesetMath: "\u062D\u0631\u0648\u0641\u200C\u0686\u06CC\u0646\u06CC \u0631\u06CC\u0627\u0636\u06CC: %1\u066A", Typesetting: "\u062D\u0631\u0648\u0641\u200C\u0686\u06CC\u0646\u06CC", MathJaxNotSupported: "\u0645\u0631\u0648\u0631\u06AF\u0631 \u0634\u0645\u0627 \u0627\u0632 MathJax \u067E\u0634\u062A\u06CC\u0628\u0627\u0646\u06CC \u0646\u0645\u06CC\u200C\u06A9\u0646\u062F" } }, "FontWarnings": {}, "HTML-CSS": {}, "HelpDialog": {}, "MathML": {}, "MathMenu": {}, "TeX": {} }, plural: function (n) { return 1; // other }, number: function (n) { return n; } }); MathJax.Ajax.loadComplete("[MathJax]/localization/bcc/bcc.js");
{ "pile_set_name": "Github" }
:root { @include theme-light; } @media (prefers-color-scheme: dark) { :root { @include theme-dark; } }
{ "pile_set_name": "Github" }
class Metricbeat < Formula desc "Collect metrics from your systems and services" homepage "https://www.elastic.co/beats/metricbeat" url "https://github.com/elastic/beats.git", tag: "v7.9.2", revision: "2ab907f5ccecf9fd82fe37105082e89fd871f684" license "Apache-2.0" head "https://github.com/elastic/beats.git" bottle do cellar :any_skip_relocation sha256 "d1f997c22a5c8f1a97407a94b0665a04ab9a6d04ebacab6dafe8c46ae9f1bfc4" => :catalina sha256 "fd4a52bfc1076d22ee02d2223f5150ca4b9695761c04490c33d9e0d2b9ef94b5" => :mojave sha256 "c0cd836780d70968e4ebe708bbe7a2ff0d4977b6f19535e0253b5e38912c5413" => :high_sierra end depends_on "go" => :build depends_on "python@3.8" => :build def install # remove non open source files rm_rf "x-pack" ENV["GOPATH"] = buildpath (buildpath/"src/github.com/elastic/beats").install buildpath.children ENV.prepend_path "PATH", buildpath/"bin" # for mage (build tool) cd "src/github.com/elastic/beats/metricbeat" do # don't build docs because it would fail creating the combined OSS/x-pack # docs and we aren't installing them anyway inreplace "magefile.go", "mg.Deps(CollectDocs, FieldsDocs)", "" system "make", "mage" system "mage", "-v", "build" ENV.deparallelize system "mage", "-v", "update" (etc/"metricbeat").install Dir["metricbeat.*", "fields.yml", "modules.d"] (libexec/"bin").install "metricbeat" prefix.install "build/kibana" end prefix.install_metafiles buildpath/"src/github.com/elastic/beats" (bin/"metricbeat").write <<~EOS #!/bin/sh exec #{libexec}/bin/metricbeat \ --path.config #{etc}/metricbeat \ --path.data #{var}/lib/metricbeat \ --path.home #{prefix} \ --path.logs #{var}/log/metricbeat \ "$@" EOS end plist_options manual: "metricbeat" def plist <<~EOS <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>#{plist_name}</string> <key>Program</key> <string>#{opt_bin}/metricbeat</string> <key>RunAtLoad</key> <true/> </dict> </plist> EOS end test do (testpath/"config/metricbeat.yml").write <<~EOS metricbeat.modules: - module: system metricsets: ["load"] period: 1s output.file: enabled: true path: #{testpath}/data filename: metricbeat EOS (testpath/"logs").mkpath (testpath/"data").mkpath fork do exec bin/"metricbeat", "-path.config", testpath/"config", "-path.data", testpath/"data" end sleep 30 assert_predicate testpath/"data/metricbeat", :exist? end end
{ "pile_set_name": "Github" }
// // Macro.h // MCLeftSilder // // Created by iOS on 16/7/19. // Copyright © 2016年 iOS. All rights reserved. // #ifndef Macro_h #define Macro_h #define kUserDefaults [NSUserDefaults standardUserDefaults] // 屏幕宽度 #define kScreenRect [[UIScreen mainScreen] bounds] #define kScreenSize [[UIScreen mainScreen] bounds].size #define kScreenWidth [[UIScreen mainScreen] bounds].size.width #define kScreenHeight [[UIScreen mainScreen] bounds].size.height #define kMainPageDistance 100 //打开左侧窗时,中视图(右视图)露出的宽度 #define kMainPageScale 1.0 //打开左侧窗时,中视图(右视图)缩放比例 #define kMainPageCenter CGPointMake(kScreenWidth + kScreenWidth * kMainPageScale / 2.0 - kMainPageDistance, kScreenHeight / 2) //打开左侧窗时,中视图中心点 #define vCouldChangeDeckStateDistance (kScreenWidth - kMainPageDistance) / 2.0 - 40 //滑动距离大于此数时,状态改变(关--》开,或者开--》关) #define vSpeedFloat 0.7 //滑动速度 #define kLeftAlpha 0.9 //左侧蒙版的最大值 #define kLeftCenterX -50 //左侧初始偏移量 #define kLeftScale 1.0 //左侧初始缩放比例 //#define kLeftSwitchViewCenterX 0 #define vDeckCanNotPanViewTag 987654 // 不响应此侧滑的View的tag // 颜色的定义 #define RGB(r, g, b) [UIColor colorWithRed:(r)/255.f green:(g)/255.f blue:(b)/255.f alpha:1.f] #define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a] #define kColorWithRGB(rgbValue) \ [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16)) / 255.0 \ green:((float)((rgbValue & 0xFF00) >> 8)) / 255.0 \ blue:((float)(rgbValue & 0xFF)) / 255.0 alpha:1.0] //项目整体背景色 #define MCBaseColor kColorWithRGB(0xf6f6f6) #define Rect(x, y, w, h) CGRectMake(x, y, w, h) #define FONT(fontSize) [UIFont systemFontOfSize:fontSize] #endif /* Macro_h */
{ "pile_set_name": "Github" }
/* * Copyright ©2018 vbill.cn. * <p> * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * </p> */ package cn.vbill.middleware.porter.manager.cluster.zookeeper; import java.util.regex.Pattern; import com.alibaba.fastjson.JSONObject; import cn.vbill.middleware.porter.common.cluster.ClusterListenerFilter; import cn.vbill.middleware.porter.common.cluster.event.ClusterTreeNodeEvent; import cn.vbill.middleware.porter.common.cluster.impl.zookeeper.ZookeeperClusterListener; import cn.vbill.middleware.porter.common.warning.WarningProviderFactory; import cn.vbill.middleware.porter.common.warning.entity.WarningMessage; /** * 邮件告警监听,控制台发送 * * @author: guohongjian[wszghj@aliyun.com] * @date: 2019年07月25日 10:09 * @version: V1.0 * @review: guohongjian[wszghj@aliyun.com]/2019年07月25日 10:09 */ public class ZKClusterWarningListener extends ZookeeperClusterListener { private static final String ZK_PATH = BASE_CATALOG + "/warning"; private static final Pattern LOG_PATTERN = Pattern.compile(ZK_PATH + "/.*"); @Override public void onEvent(ClusterTreeNodeEvent zkEvent) { String zkPath = zkEvent.getId(); logger.debug("5-ZKClusterWarningListener:{},{},{}", zkPath, zkEvent.getData(), zkEvent.getEventType()); if (zkEvent.isOnline() && LOG_PATTERN.matcher(zkPath).matches()) { try { logger.info("5-ZKClusterWarningListener...[{}]", zkEvent.getData()); WarningMessage message = JSONObject.parseObject(zkEvent.getData(), WarningMessage.class); if (message != null && 1 == message.getStreamTime()) { WarningProviderFactory.INSTANCE.notice(message); } else { logger.warn("5-ZKClusterWarningListener-Error...告警数据逻辑错误,WarningMessage数据:[{}]", zkEvent.getData()); } } catch (Exception e) { logger.error("5-ZKClusterWarningListener-Error....邮件发送出错,WarningMessage数据:[{}],请追寻...", zkEvent.getData(), e); } finally { client.delete(zkPath); } } } @Override public ClusterListenerFilter filter() { return new ClusterListenerFilter() { @Override public String getPath() { return listenPath(); } @Override public boolean doFilter(ClusterTreeNodeEvent event) { return true; } }; } @Override public String listenPath() { return ZK_PATH; } @Override public void start() { client.create(ZK_PATH, null, false, true); } }
{ "pile_set_name": "Github" }
function [ bs ] = LandmarkDetector( im ) %LANDMARKDETECTOR Summary of this function goes here % Detailed explanation goes here load('ZhuRamananModel.mat'); %posemap = 90:-15:-90; %clf; imagesc(im); axis image; axis off; drawnow; bs = detect(im, model, model.thresh); bs = clipboxes(im, bs); bs = nms_face(bs,0.3); % figure,showboxes(im, bs(1),posemap),title('Highest scoring detection'); % text((bs.xy(:,1)+bs.xy(:,3))/2,(bs.xy(:,2)+bs.xy(:,4))/2,cellstr(num2str([1:68]'))) end
{ "pile_set_name": "Github" }
/* * This file is part of Cleanflight and Betaflight. * * Cleanflight and Betaflight are free software. You can redistribute * this software and/or modify this software 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. * * Cleanflight and Betaflight are distributed in the hope that they * 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 software. * * If not, see <http://www.gnu.org/licenses/>. */ #include <stdint.h> #include "platform.h" #include "drivers/io.h" #include "drivers/dma.h" #include "drivers/timer.h" #include "drivers/timer_def.h" const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { DEF_TIM(TIM11, CH1, PB9, TIM_USE_PPM, 0, 0 ), // PPM IN DEF_TIM(TIM2, CH2, PB3, TIM_USE_MOTOR, 0, 0 ), // S1_OUT - UP1-1 DEF_TIM(TIM3, CH1, PB4, TIM_USE_MOTOR, 0, 0 ), // S2_OUT - UP1-2 DEF_TIM(TIM4, CH1, PB6, TIM_USE_MOTOR, 0, 0 ), // S3_OUT - UP1-2 DEF_TIM(TIM4, CH2, PB7, TIM_USE_MOTOR, 0, 0 ), // S4_OUT - UP1-2 DEF_TIM(TIM2, CH1, PA15, TIM_USE_ANY, 0, 0 ), // S5_OUT - UP1-1 DEF_TIM(TIM10, CH1, PB8, TIM_USE_ANY, 0, 0 ), // S6_OUT - DMA NONE DEF_TIM(TIM1, CH1, PA8, TIM_USE_LED, 0, 0 ), // LED_STRIP - DMA2_ST3_CH6 };
{ "pile_set_name": "Github" }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>$(PRODUCT_NAME)</string> <key>CFBundlePackageType</key> <string>BNDL</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1</string> </dict> </plist>
{ "pile_set_name": "Github" }