text
stringlengths 2
100k
| meta
dict |
---|---|
#------------------------------------------------------------------------------
# File: ID3.pm
#
# Description: Read ID3 meta information
#
# Revisions: 09/12/2005 - P. Harvey Created
#
# References: 1) http://www.id3.org/
# 2) http://www.mp3-tech.org/
# 3) http://www.fortunecity.com/underworld/sonic/3/id3tag.html
#------------------------------------------------------------------------------
package Image::ExifTool::ID3;
use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
$VERSION = '1.50';
sub ProcessID3v2($$$);
sub ProcessPrivate($$$);
sub ProcessSynText($$$);
sub ConvertID3v1Text($$);
sub ConvertTimeStamp($);
# audio formats that we process after an ID3v2 header (in order)
my @audioFormats = qw(APE MPC FLAC OGG MP3);
# audio formats where the processing proc is in a differently-named module
my %audioModule = (
MP3 => 'ID3',
OGG => 'Ogg',
);
# picture types for 'PIC' and 'APIC' tags
# (Note: Duplicated in ID3, ASF and FLAC modules!)
my %pictureType = (
0 => 'Other',
1 => '32x32 PNG Icon',
2 => 'Other Icon',
3 => 'Front Cover',
4 => 'Back Cover',
5 => 'Leaflet',
6 => 'Media',
7 => 'Lead Artist',
8 => 'Artist',
9 => 'Conductor',
10 => 'Band',
11 => 'Composer',
12 => 'Lyricist',
13 => 'Recording Studio or Location',
14 => 'Recording Session',
15 => 'Performance',
16 => 'Capture from Movie or Video',
17 => 'Bright(ly) Colored Fish',
18 => 'Illustration',
19 => 'Band Logo',
20 => 'Publisher Logo',
);
my %dateTimeConv = (
ValueConv => 'require Image::ExifTool::XMP; Image::ExifTool::XMP::ConvertXMPDate($val)',
PrintConv => '$self->ConvertDateTime($val)',
);
# This table is just for documentation purposes
%Image::ExifTool::ID3::Main = (
VARS => { NO_ID => 1 },
NOTES => q{
ExifTool extracts ID3 information from MP3, MPEG, AIFF, OGG, FLAC, APE, MPC
and RealAudio files. ID3v2 tags which support multiple languages (eg.
Comment and Lyrics) are extracted by specifying the tag name, followed by a
dash ('-'), then a 3-character ISO 639-2 language code (eg. "Comment-spa").
See L<http://www.id3.org/> for the official ID3 specification and
L<http://www.loc.gov/standards/iso639-2/php/code_list.php> for a list of ISO
639-2 language codes.
},
ID3v1 => {
Name => 'ID3v1',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1' },
},
ID3v1Enh => {
Name => 'ID3v1_Enh',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v1_Enh' },
},
ID3v22 => {
Name => 'ID3v2_2',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_2' },
},
ID3v23 => {
Name => 'ID3v2_3',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_3' },
},
ID3v24 => {
Name => 'ID3v2_4',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::v2_4' },
},
);
# Mapping for ID3v1 Genre numbers
my %genre = (
0 => 'Blues',
1 => 'Classic Rock',
2 => 'Country',
3 => 'Dance',
4 => 'Disco',
5 => 'Funk',
6 => 'Grunge',
7 => 'Hip-Hop',
8 => 'Jazz',
9 => 'Metal',
10 => 'New Age',
11 => 'Oldies',
12 => 'Other',
13 => 'Pop',
14 => 'R&B',
15 => 'Rap',
16 => 'Reggae',
17 => 'Rock',
18 => 'Techno',
19 => 'Industrial',
20 => 'Alternative',
21 => 'Ska',
22 => 'Death Metal',
23 => 'Pranks',
24 => 'Soundtrack',
25 => 'Euro-Techno',
26 => 'Ambient',
27 => 'Trip-Hop',
28 => 'Vocal',
29 => 'Jazz+Funk',
30 => 'Fusion',
31 => 'Trance',
32 => 'Classical',
33 => 'Instrumental',
34 => 'Acid',
35 => 'House',
36 => 'Game',
37 => 'Sound Clip',
38 => 'Gospel',
39 => 'Noise',
40 => 'Alt. Rock', # (was AlternRock)
41 => 'Bass',
42 => 'Soul',
43 => 'Punk',
44 => 'Space',
45 => 'Meditative',
46 => 'Instrumental Pop',
47 => 'Instrumental Rock',
48 => 'Ethnic',
49 => 'Gothic',
50 => 'Darkwave',
51 => 'Techno-Industrial',
52 => 'Electronic',
53 => 'Pop-Folk',
54 => 'Eurodance',
55 => 'Dream',
56 => 'Southern Rock',
57 => 'Comedy',
58 => 'Cult',
59 => 'Gangsta Rap', # (was Gansta)
60 => 'Top 40',
61 => 'Christian Rap',
62 => 'Pop/Funk',
63 => 'Jungle',
64 => 'Native American',
65 => 'Cabaret',
66 => 'New Wave',
67 => 'Psychedelic', # (was misspelt)
68 => 'Rave',
69 => 'Showtunes',
70 => 'Trailer',
71 => 'Lo-Fi',
72 => 'Tribal',
73 => 'Acid Punk',
74 => 'Acid Jazz',
75 => 'Polka',
76 => 'Retro',
77 => 'Musical',
78 => 'Rock & Roll',
79 => 'Hard Rock',
# The following genres are Winamp extensions
80 => 'Folk',
81 => 'Folk-Rock',
82 => 'National Folk',
83 => 'Swing',
84 => 'Fast-Fusion', # (was Fast Fusion)
85 => 'Bebop', # (was misspelt)
86 => 'Latin',
87 => 'Revival',
88 => 'Celtic',
89 => 'Bluegrass',
90 => 'Avantgarde',
91 => 'Gothic Rock',
92 => 'Progressive Rock',
93 => 'Psychedelic Rock',
94 => 'Symphonic Rock',
95 => 'Slow Rock',
96 => 'Big Band',
97 => 'Chorus',
98 => 'Easy Listening',
99 => 'Acoustic',
100 => 'Humour',
101 => 'Speech',
102 => 'Chanson',
103 => 'Opera',
104 => 'Chamber Music',
105 => 'Sonata',
106 => 'Symphony',
107 => 'Booty Bass',
108 => 'Primus',
109 => 'Porn Groove',
110 => 'Satire',
111 => 'Slow Jam',
112 => 'Club',
113 => 'Tango',
114 => 'Samba',
115 => 'Folklore',
116 => 'Ballad',
117 => 'Power Ballad',
118 => 'Rhythmic Soul',
119 => 'Freestyle',
120 => 'Duet',
121 => 'Punk Rock',
122 => 'Drum Solo',
123 => 'A Cappella', # (was Acapella)
124 => 'Euro-House',
125 => 'Dance Hall',
# ref http://yar.hole.ru/MP3Tech/lamedoc/id3.html
126 => 'Goa',
127 => 'Drum & Bass',
128 => 'Club-House',
129 => 'Hardcore',
130 => 'Terror',
131 => 'Indie',
132 => 'BritPop',
133 => 'Afro-Punk', # (was Negerpunk)
134 => 'Polsk Punk',
135 => 'Beat',
136 => 'Christian Gangsta Rap', # (was Christian Gangsta)
137 => 'Heavy Metal',
138 => 'Black Metal',
139 => 'Crossover',
140 => 'Contemporary Christian', # (was Contemporary C)
141 => 'Christian Rock',
142 => 'Merengue',
143 => 'Salsa',
144 => 'Thrash Metal',
145 => 'Anime',
146 => 'JPop',
147 => 'Synthpop', # (was SynthPop)
# ref http://alicja.homelinux.com/~mats/text/Music/MP3/ID3/Genres.txt
# (also used to update some Genres above)
148 => 'Abstract',
149 => 'Art Rock',
150 => 'Baroque',
151 => 'Bhangra',
152 => 'Big Beat',
153 => 'Breakbeat',
154 => 'Chillout',
155 => 'Downtempo',
156 => 'Dub',
157 => 'EBM',
158 => 'Eclectic',
159 => 'Electro',
160 => 'Electroclash',
161 => 'Emo',
162 => 'Experimental',
163 => 'Garage',
164 => 'Global',
165 => 'IDM',
166 => 'Illbient',
167 => 'Industro-Goth',
168 => 'Jam Band',
169 => 'Krautrock',
170 => 'Leftfield',
171 => 'Lounge',
172 => 'Math Rock',
173 => 'New Romantic',
174 => 'Nu-Breakz',
175 => 'Post-Punk',
176 => 'Post-Rock',
177 => 'Psytrance',
178 => 'Shoegaze',
179 => 'Space Rock',
180 => 'Trop Rock',
181 => 'World Music',
182 => 'Neoclassical',
183 => 'Audiobook',
184 => 'Audio Theatre',
185 => 'Neue Deutsche Welle',
186 => 'Podcast',
187 => 'Indie Rock',
188 => 'G-Funk',
189 => 'Dubstep',
190 => 'Garage Rock',
191 => 'Psybient',
255 => 'None',
# ID3v2 adds some text short forms...
CR => 'Cover',
RX => 'Remix',
);
# Tags for ID3v1
%Image::ExifTool::ID3::v1 = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
GROUPS => { 1 => 'ID3v1', 2 => 'Audio' },
PRIORITY => 0, # let ID3v2 tags replace these if they come later
3 => {
Name => 'Title',
Format => 'string[30]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
33 => {
Name => 'Artist',
Groups => { 2 => 'Author' },
Format => 'string[30]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
63 => {
Name => 'Album',
Format => 'string[30]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
93 => {
Name => 'Year',
Groups => { 2 => 'Time' },
Format => 'string[4]',
},
97 => {
Name => 'Comment',
Format => 'string[30]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
125 => { # ID3v1.1 (ref http://en.wikipedia.org/wiki/ID3#Layout)
Name => 'Track',
Format => 'int8u[2]',
Notes => 'v1.1 addition -- last 2 bytes of v1.0 Comment field',
RawConv => '($val =~ s/^0 // and $val) ? $val : undef',
},
127 => {
Name => 'Genre',
Notes => 'CR and RX are ID3v2 only',
Format => 'int8u',
PrintConv => \%genre,
PrintConvColumns => 3,
},
);
# ID3v1 "Enhanced TAG" information (ref 3)
%Image::ExifTool::ID3::v1_Enh = (
PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
GROUPS => { 1 => 'ID3v1_Enh', 2 => 'Audio' },
NOTES => 'ID3 version 1 "Enhanced TAG" information (not part of the official spec).',
PRIORITY => 0, # let ID3v2 tags replace these if they come later
4 => {
Name => 'Title2',
Format => 'string[60]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
64 => {
Name => 'Artist2',
Groups => { 2 => 'Author' },
Format => 'string[60]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
124 => {
Name => 'Album2',
Format => 'string[60]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
184 => {
Name => 'Speed',
Format => 'int8u',
PrintConv => {
1 => 'Slow',
2 => 'Medium',
3 => 'Fast',
4 => 'Hardcore',
},
},
185 => {
Name => 'Genre',
Format => 'string[30]',
ValueConv => 'Image::ExifTool::ID3::ConvertID3v1Text($self,$val)',
},
215 => {
Name => 'StartTime',
Format => 'string[6]',
},
221 => {
Name => 'EndTime',
Format => 'string[6]',
},
);
# Tags for ID2v2.2
%Image::ExifTool::ID3::v2_2 = (
PROCESS_PROC => \&Image::ExifTool::ID3::ProcessID3v2,
GROUPS => { 1 => 'ID3v2_2', 2 => 'Audio' },
NOTES => q{
ExifTool extracts mainly text-based tags from ID3v2 information. The tags
in the tables below are those extracted by ExifTool, and don't represent a
complete list of available ID3v2 tags.
ID3 version 2.2 tags. (These are the tags written by iTunes 5.0.)
},
CNT => 'PlayCounter',
COM => 'Comment',
IPL => 'InvolvedPeople',
PIC => {
Name => 'Picture',
Groups => { 2 => 'Preview' },
Binary => 1,
Notes => 'the 3 tags below are also extracted from this PIC frame',
},
'PIC-1' => { Name => 'PictureFormat', Groups => { 2 => 'Image' } },
'PIC-2' => {
Name => 'PictureType',
Groups => { 2 => 'Image' },
PrintConv => \%pictureType,
SeparateTable => 1,
},
'PIC-3' => { Name => 'PictureDescription', Groups => { 2 => 'Image' } },
POP => {
Name => 'Popularimeter',
PrintConv => '$val=~s/^(.*?) (\d+) (\d+)$/$1 Rating=$2 Count=$3/s; $val',
},
SLT => {
Name => 'SynLyrics',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::SynLyrics' },
},
TAL => 'Album',
TBP => 'BeatsPerMinute',
TCM => 'Composer',
TCO =>{
Name => 'Genre',
Notes => 'uses same lookup table as ID3v1 Genre',
PrintConv => 'Image::ExifTool::ID3::PrintGenre($val)',
},
TCP => { Name => 'Compilation', PrintConv => { 0 => 'No', 1 => 'Yes' } }, # iTunes
TCR => { Name => 'Copyright', Groups => { 2 => 'Author' } },
TDA => { Name => 'Date', Groups => { 2 => 'Time' } },
TDY => 'PlaylistDelay',
TEN => 'EncodedBy',
TFT => 'FileType',
TIM => { Name => 'Time', Groups => { 2 => 'Time' } },
TKE => 'InitialKey',
TLA => 'Language',
TLE => 'Length',
TMT => 'Media',
TOA => { Name => 'OriginalArtist', Groups => { 2 => 'Author' } },
TOF => 'OriginalFileName',
TOL => 'OriginalLyricist',
TOR => 'OriginalReleaseYear',
TOT => 'OriginalAlbum',
TP1 => { Name => 'Artist', Groups => { 2 => 'Author' } },
TP2 => 'Band',
TP3 => 'Conductor',
TP4 => 'InterpretedBy',
TPA => 'PartOfSet',
TPB => 'Publisher',
TRC => 'ISRC', # (international standard recording code)
TRD => 'RecordingDates',
TRK => 'Track',
TSI => 'Size',
TSS => 'EncoderSettings',
TT1 => 'Grouping',
TT2 => 'Title',
TT3 => 'Subtitle',
TXT => 'Lyricist',
TXX => 'UserDefinedText',
TYE => { Name => 'Year', Groups => { 2 => 'Time' } },
ULT => 'Lyrics',
WAF => 'FileURL',
WAR => { Name => 'ArtistURL', Groups => { 2 => 'Author' } },
WAS => 'SourceURL',
WCM => 'CommercialURL',
WCP => { Name => 'CopyrightURL', Groups => { 2 => 'Author' } },
WPB => 'PublisherURL',
WXX => 'UserDefinedURL',
# the following written by iTunes 10.5 (ref PH)
RVA => 'RelativeVolumeAdjustment',
TST => 'TitleSortOrder',
TSA => 'AlbumSortOrder',
TSP => 'PerformerSortOrder',
TS2 => 'AlbumArtistSortOrder',
TSC => 'ComposerSortOrder',
ITU => { Name => 'iTunesU', Description => 'iTunes U', Binary => 1, Unknown => 1 },
PCS => { Name => 'Podcast', Binary => 1, Unknown => 1 },
);
# tags common to ID3v2.3 and ID3v2.4
my %id3v2_common = (
# AENC => 'AudioEncryption', # Owner, preview start, preview length, encr data
APIC => {
Name => 'Picture',
Groups => { 2 => 'Preview' },
Binary => 1,
Notes => 'the 3 tags below are also extracted from this APIC frame',
},
'APIC-1' => { Name => 'PictureMIMEType', Groups => { 2 => 'Image' } },
'APIC-2' => {
Name => 'PictureType',
Groups => { 2 => 'Image' },
PrintConv => \%pictureType,
SeparateTable => 1,
},
'APIC-3' => { Name => 'PictureDescription', Groups => { 2 => 'Image' } },
COMM => 'Comment',
# COMR => 'Commercial',
# ENCR => 'EncryptionMethod',
# ETCO => 'EventTimingCodes',
# GEOB => 'GeneralEncapsulatedObject',
# GRID => 'GroupIdentification',
# LINK => 'LinkedInformation',
MCDI => { Name => 'MusicCDIdentifier', Binary => 1 },
# MLLT => 'MPEGLocationLookupTable',
OWNE => 'Ownership',
PCNT => 'PlayCounter',
POPM => {
Name => 'Popularimeter',
PrintConv => '$val=~s/^(.*?) (\d+) (\d+)$/$1 Rating=$2 Count=$3/s; $val',
},
# POSS => 'PostSynchronization',
PRIV => {
Name => 'Private',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::Private' },
},
# RBUF => 'RecommendedBufferSize',
# RVRB => 'Reverb',
SYLT => {
Name => 'SynLyrics',
SubDirectory => { TagTable => 'Image::ExifTool::ID3::SynLyrics' },
},
# SYTC => 'SynchronizedTempoCodes',
TALB => 'Album',
TBPM => 'BeatsPerMinute',
TCMP => { Name => 'Compilation', PrintConv => { 0 => 'No', 1 => 'Yes' } }, #PH (iTunes)
TCOM => 'Composer',
TCON =>{
Name => 'Genre',
Notes => 'uses same lookup table as ID3v1 Genre',
PrintConv => 'Image::ExifTool::ID3::PrintGenre($val)',
},
TCOP => { Name => 'Copyright', Groups => { 2 => 'Author' } },
TDLY => 'PlaylistDelay',
TENC => 'EncodedBy',
TEXT => 'Lyricist',
TFLT => 'FileType',
TIT1 => 'Grouping',
TIT2 => 'Title',
TIT3 => 'Subtitle',
TKEY => 'InitialKey',
TLAN => 'Language',
TLEN => {
Name => 'Length',
ValueConv => '$val / 1000',
PrintConv => '"$val s"',
},
TMED => 'Media',
TOAL => 'OriginalAlbum',
TOFN => 'OriginalFileName',
TOLY => 'OriginalLyricist',
TOPE => { Name => 'OriginalArtist', Groups => { 2 => 'Author' } },
TOWN => 'FileOwner',
TPE1 => { Name => 'Artist', Groups => { 2 => 'Author' } },
TPE2 => 'Band',
TPE3 => 'Conductor',
TPE4 => 'InterpretedBy',
TPOS => 'PartOfSet',
TPUB => 'Publisher',
TRCK => 'Track',
TRSN => 'InternetRadioStationName',
TRSO => 'InternetRadioStationOwner',
TSRC => 'ISRC', # (international standard recording code)
TSSE => 'EncoderSettings',
TXXX => 'UserDefinedText',
# UFID => 'UniqueFileID', (not extracted because it is long and nasty and not very useful)
USER => 'TermsOfUse',
USLT => 'Lyrics',
WCOM => 'CommercialURL',
WCOP => 'CopyrightURL',
WOAF => 'FileURL',
WOAR => { Name => 'ArtistURL', Groups => { 2 => 'Author' } },
WOAS => 'SourceURL',
WORS => 'InternetRadioStationURL',
WPAY => 'PaymentURL',
WPUB => 'PublisherURL',
WXXX => 'UserDefinedURL',
#
# non-standard frames
#
# the following are written by iTunes 10.5 (ref PH)
TSO2 => 'AlbumArtistSortOrder',
TSOC => 'ComposerSortOrder',
ITNU => { Name => 'iTunesU', Description => 'iTunes U', Binary => 1, Unknown => 1 },
PCST => { Name => 'Podcast', Binary => 1, Unknown => 1 },
# other proprietary Apple tags (ref http://help.mp3tag.de/main_tags.html)
TDES => 'PodcastDescription',
TGID => 'PodcastID',
WFED => 'PodcastURL',
TKWD => 'PodcastKeywords',
TCAT => 'PodcastCategory',
# more non-standard tags (ref http://eyed3.nicfit.net/compliance.html)
# NCON - unknown MusicMatch binary data
XDOR => { Name => 'OriginalReleaseTime',Groups => { 2 => 'Time' }, %dateTimeConv },
XSOA => 'AlbumSortOrder',
XSOP => 'PerformerSortOrder',
XSOT => 'TitleSortOrder',
XOLY => {
Name => 'OlympusDSS',
SubDirectory => { TagTable => 'Image::ExifTool::Olympus::DSS' },
},
);
# Tags for ID3v2.3 (http://www.id3.org/id3v2.3.0)
%Image::ExifTool::ID3::v2_3 = (
PROCESS_PROC => \&Image::ExifTool::ID3::ProcessID3v2,
GROUPS => { 1 => 'ID3v2_3', 2 => 'Audio' },
NOTES => q{
ID3 version 2.3 tags. Includes some non-standard tags written by other
software.
},
%id3v2_common, # include common tags
# EQUA => 'Equalization',
IPLS => 'InvolvedPeople',
# RVAD => 'RelativeVolumeAdjustment',
TDAT => { Name => 'Date', Groups => { 2 => 'Time' } },
TIME => { Name => 'Time', Groups => { 2 => 'Time' } },
TORY => 'OriginalReleaseYear',
TRDA => 'RecordingDates',
TSIZ => 'Size',
TYER => { Name => 'Year', Groups => { 2 => 'Time' } },
);
# Tags for ID3v2.4 (http://www.id3.org/id3v2.4.0-frames)
%Image::ExifTool::ID3::v2_4 = (
PROCESS_PROC => \&Image::ExifTool::ID3::ProcessID3v2,
GROUPS => { 1 => 'ID3v2_4', 2 => 'Audio' },
NOTES => q{
ID3 version 2.4 tags. Includes some non-standard tags written by other
software.
},
%id3v2_common, # include common tags
# EQU2 => 'Equalization',
RVA2 => 'RelativeVolumeAdjustment',
# SEEK => 'Seek',
# SIGN => 'Signature',
TDEN => { Name => 'EncodingTime', Groups => { 2 => 'Time' }, %dateTimeConv },
TDOR => { Name => 'OriginalReleaseTime',Groups => { 2 => 'Time' }, %dateTimeConv },
TDRC => { Name => 'RecordingTime', Groups => { 2 => 'Time' }, %dateTimeConv },
TDRL => { Name => 'ReleaseTime', Groups => { 2 => 'Time' }, %dateTimeConv },
TDTG => { Name => 'TaggingTime', Groups => { 2 => 'Time' }, %dateTimeConv },
TIPL => 'InvolvedPeople',
TMCL => 'MusicianCredits',
TMOO => 'Mood',
TPRO => 'ProducedNotice',
TSOA => 'AlbumSortOrder',
TSOP => 'PerformerSortOrder',
TSOT => 'TitleSortOrder',
TSST => 'SetSubtitle',
);
# Synchronized lyrics/text
%Image::ExifTool::ID3::SynLyrics = (
GROUPS => { 1 => 'ID3', 2 => 'Audio' },
VARS => { NO_ID => 1 },
PROCESS_PROC => \&ProcessSynText,
NOTES => 'The following tags are extracted from synchronized lyrics/text frames.',
desc => { Name => 'SynchronizedLyricsDescription' },
type => {
Name => 'SynchronizedLyricsType',
PrintConv => {
0 => 'Other',
1 => 'Lyrics',
2 => 'Text Transcription',
3 => 'Movement/part Name',
4 => 'Events',
5 => 'Chord',
6 => 'Trivia/"pop-up" Information',
7 => 'Web Page URL',
8 => 'Image URL',
},
},
text => {
Name => 'SynchronizedLyricsText',
List => 1,
Notes => q{
each list item has a leading time stamp in square brackets. Time stamps may
be in seconds with format [MM:SS.ss], or MPEG frames with format [FFFF],
depending on how this information was stored
},
PrintConv => \&ConvertTimeStamp,
},
);
# ID3 PRIV tags (ref PH)
%Image::ExifTool::ID3::Private = (
PROCESS_PROC => \&Image::ExifTool::ID3::ProcessPrivate,
GROUPS => { 1 => 'ID3', 2 => 'Audio' },
VARS => { NO_ID => 1 },
NOTES => q{
ID3 private (PRIV) tags. ExifTool will decode any private tags found, even
if they do not appear in this table.
},
XMP => {
SubDirectory => {
DirName => 'XMP',
TagTable => 'Image::ExifTool::XMP::Main',
},
},
PeakValue => {
ValueConv => 'length($val)==4 ? unpack("V",$val) : \$val',
},
AverageLevel => {
ValueConv => 'length($val)==4 ? unpack("V",$val) : \$val',
},
# Windows Media attributes ("/" in tag ID is converted to "_" by ProcessPrivate)
WM_WMContentID => {
Name => 'WM_ContentID',
ValueConv => 'require Image::ExifTool::ASF; Image::ExifTool::ASF::GetGUID($val)',
},
WM_WMCollectionID => {
Name => 'WM_CollectionID',
ValueConv => 'require Image::ExifTool::ASF; Image::ExifTool::ASF::GetGUID($val)',
},
WM_WMCollectionGroupID => {
Name => 'WM_CollectionGroupID',
ValueConv => 'require Image::ExifTool::ASF; Image::ExifTool::ASF::GetGUID($val)',
},
WM_MediaClassPrimaryID => {
ValueConv => 'require Image::ExifTool::ASF; Image::ExifTool::ASF::GetGUID($val)',
},
WM_MediaClassSecondaryID => {
ValueConv => 'require Image::ExifTool::ASF; Image::ExifTool::ASF::GetGUID($val)',
},
WM_Provider => {
ValueConv => '$self->Decode($val,"UCS2","II")', #PH (NC)
},
# there are lots more WM tags that could be decoded if I had samples or documentation - PH
# WM/AlbumArtist
# WM/AlbumTitle
# WM/Category
# WM/Composer
# WM/Conductor
# WM/ContentDistributor
# WM/ContentGroupDescription
# WM/EncodingTime
# WM/Genre
# WM/GenreID
# WM/InitialKey
# WM/Language
# WM/Lyrics
# WM/MCDI
# WM/MediaClassPrimaryID
# WM/MediaClassSecondaryID
# WM/Mood
# WM/ParentalRating
# WM/Period
# WM/ProtectionType
# WM/Provider
# WM/ProviderRating
# WM/ProviderStyle
# WM/Publisher
# WM/SubscriptionContentID
# WM/SubTitle
# WM/TrackNumber
# WM/UniqueFileIdentifier
# WM/WMCollectionGroupID
# WM/WMCollectionID
# WM/WMContentID
# WM/Writer
# WM/Year
);
# lookup to check for existence of tags in other ID3 versions
my %otherTable = (
\%Image::ExifTool::ID3::v2_4 => \%Image::ExifTool::ID3::v2_3,
\%Image::ExifTool::ID3::v2_3 => \%Image::ExifTool::ID3::v2_4,
);
# ID3 Composite tags
%Image::ExifTool::ID3::Composite = (
GROUPS => { 2 => 'Image' },
DateTimeOriginal => {
Description => 'Date/Time Original',
Groups => { 2 => 'Time' },
Priority => 0,
Desire => {
0 => 'ID3:RecordingTime',
1 => 'ID3:Year',
2 => 'ID3:Date',
3 => 'ID3:Time',
},
ValueConv => q{
return $val[0] if $val[0];
return undef unless $val[1];
return $val[1] unless $val[2] and $val[2] =~ /^(\d{2})(\d{2})$/;
$val[1] .= ":$1:$2";
return $val[1] unless $val[3] and $val[3] =~ /^(\d{2})(\d{2})$/;
return "$val[1] $1:$2";
},
PrintConv => '$self->ConvertDateTime($val)',
},
);
# add our composite tags
Image::ExifTool::AddCompositeTags('Image::ExifTool::ID3');
# can't share tagInfo hashes between two tables, so we must make
# copies of the necessary hashes
{
my $tag;
foreach $tag (keys %id3v2_common) {
next unless ref $id3v2_common{$tag} eq 'HASH';
my %tagInfo = %{$id3v2_common{$tag}};
# must also copy Groups hash if it exists
my $groups = $tagInfo{Groups};
$tagInfo{Groups} = { %$groups } if $groups;
$Image::ExifTool::ID3::v2_4{$tag} = \%tagInfo;
}
}
#------------------------------------------------------------------------------
# Convert ID3v1 text to exiftool character set
# Inputs: 0) ExifTool object ref, 1) text string
# Returns: converted text
sub ConvertID3v1Text($$)
{
my ($et, $val) = @_;
return $et->Decode($val, $et->Options('CharsetID3'));
}
#------------------------------------------------------------------------------
# Re-format time stamp in synchronized lyrics
# Inputs: 0) synchronized lyrics entry (eg. "[84.030]Da do do do")
# Returns: entry with formatted timestamp (eg. "[01:24.03]Da do do do")
sub ConvertTimeStamp($)
{
my $val = shift;
# do nothing if this isn't a time stamp (frame count doesn't contain a decimal)
return $val unless $val =~ /^\[(\d+\.\d+)\]/g;
my $time = $1;
# print hours only if more than 60 minutes
my $h = int($time / 3600);
if ($h) {
$time -= $h * 3600;
$h = "$h:";
} else {
$h = '';
}
my $m = int($time / 60);
my $s = $time - $m * 60;
return sprintf('[%s%.2d:%05.2f]', $h, $m, $s) . substr($val, pos($val));
}
#------------------------------------------------------------------------------
# Process ID3 synchronized lyrics/text
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
sub ProcessSynText($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
$et->VerboseDir('SynLyrics', 0, length $$dataPt);
return unless length $$dataPt > 6;
my ($enc,$lang,$timeCode,$type) = unpack('Ca3CC', $$dataPt);
$lang = lc $lang;
undef $lang if $lang !~ /^[a-z]{3}$/ or $lang eq 'eng';
pos($$dataPt) = 6;
my ($termLen, $pat);
if ($enc == 1 or $enc == 2) {
$$dataPt =~ /\G(..)*?\0\0/sg or return;
$termLen = 2;
$pat = '\G(?:..)*?\0\0(....)';
} else {
$$dataPt =~ /\0/g or return;
$termLen = 1;
$pat = '\0(....)';
}
my $desc = substr($$dataPt, 6, pos($$dataPt) - 6 - $termLen);
$desc = DecodeString($et, $desc, $enc);
my $tagInfo = $et->GetTagInfo($tagTablePtr, 'desc');
$tagInfo = Image::ExifTool::GetLangInfo($tagInfo, $lang) if $lang;
$et->HandleTag($tagTablePtr, 'type', $type);
$et->HandleTag($tagTablePtr, 'desc', $desc, TagInfo => $tagInfo);
$tagInfo = $et->GetTagInfo($tagTablePtr, 'text');
$tagInfo = Image::ExifTool::GetLangInfo($tagInfo, $lang) if $lang;
for (;;) {
my $pos = pos $$dataPt;
last unless $$dataPt =~ /$pat/sg;
my $time = unpack('N', $1);
my $text = substr($$dataPt, $pos, pos($$dataPt) - $pos - 4 - $termLen);
$text = DecodeString($et, $text, $enc);
my $timeStr;
if ($timeCode == 2) { # time in ms
$timeStr = sprintf('%.3f', $time / 1000);
} else { # time in MPEG frames
$timeStr = sprintf('%.4d', $time);
$timeStr .= '?' if $timeCode != 1;
}
$et->HandleTag($tagTablePtr, 'text', "[$timeStr]$text", TagInfo => $tagInfo);
}
}
#------------------------------------------------------------------------------
# Process ID3 PRIV data
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
sub ProcessPrivate($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
my ($tag, $start);
$et->VerboseDir('PRIV', 0, length $$dataPt);
if ($$dataPt =~ /^(.*?)\0/s) {
$tag = $1;
$start = length($tag) + 1;
} else {
$tag = '';
$start = 0;
}
unless ($$tagTablePtr{$tag}) {
$tag =~ tr{/ }{_}d; # translate '/' to '_' and remove spaces
$tag = 'private' unless $tag =~ /^[-\w]{1,24}$/;
unless ($$tagTablePtr{$tag}) {
AddTagToTable($tagTablePtr, $tag,
{ Name => ucfirst($tag), Binary => 1 });
}
}
my $key = $et->HandleTag($tagTablePtr, $tag, undef,
Size => length($$dataPt) - $start,
Start => $start,
DataPt => $dataPt,
);
# set group1 name
$et->SetGroup($key, $$et{ID3_Ver}) if $key;
}
#------------------------------------------------------------------------------
# Print ID3v2 Genre
# Inputs: TCON or TCO frame data
# Returns: Content type with decoded genre numbers
sub PrintGenre($)
{
my $val = shift;
# make sure that %genre has an entry for all numbers we are interested in
# (genre numbers are in brackets for ID3v2.2 and v2.3)
while ($val =~ /\((\d+)\)/g) {
$genre{$1} or $genre{$1} = "Unknown ($1)";
}
# (genre numbers are separated by nulls in ID3v2.4,
# but nulls are converted to '/' by DecodeString())
while ($val =~ /(?:^|\/)(\d+)(\/|$)/g) {
$genre{$1} or $genre{$1} = "Unknown ($1)";
}
$val =~ s/\((\d+)\)/\($genre{$1}\)/g;
$val =~ s/(^|\/)(\d+)(?=\/|$)/$1$genre{$2}$3/g;
$val =~ s/^\(([^)]+)\)\1?$/$1/; # clean up by removing brackets and duplicates
return $val;
}
#------------------------------------------------------------------------------
# Decode ID3 string
# Inputs: 0) ExifTool object reference
# 1) string beginning with encoding byte unless specified as argument
# 2) optional encoding (0=ISO-8859-1, 1=UTF-16 BOM, 2=UTF-16BE, 3=UTF-8)
# Returns: Decoded string in scalar context, or list of strings in list context
sub DecodeString($$;$)
{
my ($et, $val, $enc) = @_;
return '' unless length $val;
unless (defined $enc) {
$enc = unpack('C', $val);
$val = substr($val, 1); # remove encoding byte
}
my @vals;
if ($enc == 0 or $enc == 3) { # ISO 8859-1 or UTF-8
$val =~ s/\0+$//; # remove any null padding
# (must split before converting because conversion routines truncate at null)
@vals = split "\0", $val;
foreach $val (@vals) {
$val = $et->Decode($val, $enc ? 'UTF8' : 'Latin');
}
} elsif ($enc == 1 or $enc == 2) { # UTF-16 with BOM, or UTF-16BE
my $bom = "\xfe\xff";
my %order = ( "\xfe\xff" => 'MM', "\xff\xfe", => 'II' );
for (;;) {
my $v;
# split string at null terminators on word boundaries
if ($val =~ s/((..)*?)\0\0//s) {
$v = $1;
} else {
last unless length $val > 1;
$v = $val;
$val = '';
}
$bom = $1 if $v =~ s/^(\xfe\xff|\xff\xfe)//;
push @vals, $et->Decode($v, 'UCS2', $order{$bom});
}
} else {
$val =~ s/\0+$//;
return "<Unknown encoding $enc> $val";
}
return @vals if wantarray;
return join('/',@vals);
}
#------------------------------------------------------------------------------
# Convert sync-safe integer to a number we can use
# Inputs: 0) int32u sync-safe value
# Returns: actual number or undef on invalid value
sub UnSyncSafe($)
{
my $val = shift;
return undef if $val & 0x80808080;
return ($val & 0x0000007f) |
(($val & 0x00007f00) >> 1) |
(($val & 0x007f0000) >> 2) |
(($val & 0x7f000000) >> 3);
}
#------------------------------------------------------------------------------
# Process ID3v2 information
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
sub ProcessID3v2($$$)
{
my ($et, $dirInfo, $tagTablePtr) = @_;
my $dataPt = $$dirInfo{DataPt};
my $offset = $$dirInfo{DirStart};
my $size = $$dirInfo{DirLen};
my $vers = $$dirInfo{Version};
my $verbose = $et->Options('Verbose');
my $len; # frame data length
$et->VerboseDir($tagTablePtr->{GROUPS}->{1}, 0, $size);
$et->VerboseDump($dataPt, Len => $size, Start => $offset);
for (;;$offset+=$len) {
my ($id, $flags, $hi);
if ($vers < 0x0300) {
# version 2.2 frame header is 6 bytes
last if $offset + 6 > $size;
($id, $hi, $len) = unpack("x${offset}a3Cn",$$dataPt);
last if $id eq "\0\0\0";
$len += $hi << 16;
$offset += 6;
} else {
# version 2.3/2.4 frame header is 10 bytes
last if $offset + 10 > $size;
($id, $len, $flags) = unpack("x${offset}a4Nn",$$dataPt);
last if $id eq "\0\0\0\0";
$offset += 10;
# length is a "sync-safe" integer by the ID3v2.4 specification, but
# reportedly some versions of iTunes write this as a normal integer
# (ref http://www.id3.org/iTunes)
while ($vers >= 0x0400 and $len > 0x7f and not $len & 0x80808080) {
my $oldLen = $len;
$len = UnSyncSafe($len);
if (not defined $len or $offset + $len + 10 > $size) {
$et->Warn('Invalid ID3 frame size');
last;
}
# check next ID to see if it makes sense
my $nextID = substr($$dataPt, $offset + $len, 4);
last if $$tagTablePtr{$nextID};
# try again with the incorrect length word (patch for iTunes bug)
last if $offset + $oldLen + 10 > $size;
$nextID = substr($$dataPt, $offset + $len, 4);
$len = $oldLen if $$tagTablePtr{$nextID};
last; # yes, "while" was really a "goto" in disguise
}
}
last if $offset + $len > $size;
my $tagInfo = $et->GetTagInfo($tagTablePtr, $id);
unless ($tagInfo) {
my $otherTable = $otherTable{$tagTablePtr};
$tagInfo = $et->GetTagInfo($otherTable, $id) if $otherTable;
if ($tagInfo) {
$et->WarnOnce("Frame '${id}' is not valid for this ID3 version", 1);
} else {
next unless $verbose or $et->Options('Unknown');
$id =~ tr/-A-Za-z0-9_//dc;
$id = 'unknown' unless length $id;
unless ($$tagTablePtr{$id}) {
$tagInfo = { Name => "ID3_$id", Binary => 1 };
AddTagToTable($tagTablePtr, $id, $tagInfo);
}
}
}
# decode v2.3 and v2.4 flags
my (%flags, %extra);
if ($flags) {
if ($vers < 0x0400) {
# version 2.3 flags
$flags & 0x80 and $flags{Compress} = 1;
$flags & 0x40 and $flags{Encrypt} = 1;
$flags & 0x20 and $flags{GroupID} = 1;
} else {
# version 2.4 flags
$flags & 0x40 and $flags{GroupID} = 1;
$flags & 0x08 and $flags{Compress} = 1;
$flags & 0x04 and $flags{Encrypt} = 1;
$flags & 0x02 and $flags{Unsync} = 1;
$flags & 0x01 and $flags{DataLen} = 1;
}
}
if ($flags{Encrypt}) {
$et->WarnOnce('Encrypted frames currently not supported');
next;
}
# extract the value
my $val = substr($$dataPt, $offset, $len);
# reverse the unsynchronization
$val =~ s/\xff\x00/\xff/g if $flags{Unsync};
# read grouping identity
if ($flags{GroupID}) {
length($val) >= 1 or $et->Warn("Short $id frame"), next;
$val = substr($val, 1); # (ignore it)
}
# read data length
my $dataLen;
if ($flags{DataLen} or $flags{Compress}) {
length($val) >= 4 or $et->Warn("Short $id frame"), next;
$dataLen = unpack('N', $val); # save the data length word
$val = substr($val, 4);
}
# uncompress data
if ($flags{Compress}) {
if (eval { require Compress::Zlib }) {
my $inflate = Compress::Zlib::inflateInit();
my ($buff, $stat);
$inflate and ($buff, $stat) = $inflate->inflate($val);
if ($inflate and $stat == Compress::Zlib::Z_STREAM_END()) {
$val = $buff;
} else {
$et->Warn("Error inflating $id frame");
next;
}
} else {
$et->WarnOnce('Install Compress::Zlib to decode compressed frames');
next;
}
}
# validate data length
if (defined $dataLen) {
$dataLen = UnSyncSafe($dataLen);
defined $dataLen or $et->Warn("Invalid length for $id frame"), next;
$dataLen == length($val) or $et->Warn("Wrong length for $id frame"), next;
}
unless ($tagInfo) {
next unless $verbose;
%flags and $extra{Extra} = ', Flags=' . join(',', sort keys %flags);
$et->VerboseInfo($id, $tagInfo,
Table => $tagTablePtr,
Value => $val,
DataPt => $dataPt,
DataPos => $$dirInfo{DataPos},
Size => $len,
Start => $offset,
%extra
);
next;
}
#
# decode data in this frame (it is bad form to hard-code these, but the ID3 frame formats
# are so variable that it would be more work to define format types for each of them)
#
my $lang;
my $valLen = length($val); # actual value length (after decompression, etc)
if ($id =~ /^(TXX|TXXX)$/) {
# two encoded strings separated by a null
my @vals = DecodeString($et, $val);
foreach (0..1) { $vals[$_] = '' unless defined $vals[$_]; }
($val = "($vals[0]) $vals[1]") =~ s/^\(\) //;
} elsif ($id =~ /^T/ or $id =~ /^(IPL|IPLS)$/) {
$val = DecodeString($et, $val);
} elsif ($id =~ /^(WXX|WXXX)$/) {
# one encoded string and one Latin string separated by a null
my $enc = unpack('C', $val);
my $url;
if ($enc == 1 or $enc == 2) {
($val, $url) = ($val =~ /^(.(?:..)*?)\0\0(.*)/s);
} else {
($val, $url) = ($val =~ /^(..*?)\0(.*)/s);
}
unless (defined $val and defined $url) {
$et->Warn("Invalid $id frame value");
next;
}
$val = DecodeString($et, $val);
$url =~ s/\0.*//s;
$val = length($val) ? "($val) $url" : $url;
} elsif ($id =~ /^W/) {
$val =~ s/\0.*//s; # truncate at null
} elsif ($id =~ /^(COM|COMM|ULT|USLT)$/) {
$valLen > 4 or $et->Warn("Short $id frame"), next;
$lang = substr($val,1,3);
my @vals = DecodeString($et, substr($val,4), Get8u(\$val,0));
foreach (0..1) { $vals[$_] = '' unless defined $vals[$_]; }
$val = length($vals[0]) ? "($vals[0]) $vals[1]" : $vals[1];
} elsif ($id eq 'USER') {
$valLen > 4 or $et->Warn("Short $id frame"), next;
$lang = substr($val,1,3);
$val = DecodeString($et, substr($val,4), Get8u(\$val,0));
} elsif ($id =~ /^(CNT|PCNT)$/) {
$valLen >= 4 or $et->Warn("Short $id frame"), next;
my ($cnt, @xtra) = unpack('NC*', $val);
$cnt = ($cnt << 8) + $_ foreach @xtra;
$val = $cnt;
} elsif ($id =~ /^(PIC|APIC)$/) {
$valLen >= 4 or $et->Warn("Short $id frame"), next;
my ($hdr, $attr);
my $enc = unpack('C', $val);
if ($enc == 1 or $enc == 2) {
$hdr = ($id eq 'PIC') ? ".(...)(.)((?:..)*?)\0\0" : ".(.*?)\0(.)((?:..)*?)\0\0";
} else {
$hdr = ($id eq 'PIC') ? ".(...)(.)(.*?)\0" : ".(.*?)\0(.)(.*?)\0";
}
# remove header (encoding, image format or MIME type, picture type, description)
$val =~ s/^$hdr//s or $et->Warn("Invalid $id frame"), next;
my @attrs = ($1, ord($2), DecodeString($et, $3, $enc));
my $i = 1;
foreach $attr (@attrs) {
# must store descriptions even if they are empty to maintain
# sync between copy numbers when multiple images
$et->HandleTag($tagTablePtr, "$id-$i", $attr);
++$i;
}
} elsif ($id eq 'POP' or $id eq 'POPM') {
# _email, 00, rating(1), counter(4-N)
my ($email, $dat) = ($val =~ /^([^\0]*)\0(.*)$/s);
unless (defined $dat and length($dat)) {
$et->Warn("Invalid $id frame");
next;
}
my ($rating, @xtra) = unpack('C*', $dat);
my $cnt = 0;
$cnt = ($cnt << 8) + $_ foreach @xtra;
$val = "$email $rating $cnt";
} elsif ($id eq 'OWNE') {
# enc(1), _price, 00, _date(8), Seller
my @strs = DecodeString($et, $val);
$strs[1] =~ s/^(\d{4})(\d{2})(\d{2})/$1:$2:$3 /s if $strs[1]; # format date
$val = "@strs";
} elsif ($id eq 'RVA' or $id eq 'RVAD') {
my @dat = unpack('C*', $val);
my $flag = shift @dat;
my $bits = shift @dat or $et->Warn("Short $id frame"), next;
my $bytes = int(($bits + 7) / 8);
my @parse = (['Right',0,2,0x01],['Left',1,3,0x02],['Back-right',4,6,0x04],
['Back-left',5,7,0x08],['Center',8,9,0x10],['Bass',10,11,0x20]);
$val = '';
while (@parse) {
my $elem = shift @parse;
my $j = $$elem[2] * $bytes;
last if scalar(@dat) < $j + $bytes;
my $i = $$elem[1] * $bytes;
$val .= ', ' if $val;
my ($rel, $pk, $b);
for ($rel=0, $pk=0, $b=0; $b<$bytes; ++$b) {
$rel = $rel * 256 + $dat[$i + $b];
$pk = $pk * 256 + $dat[$j + $b]; # (peak - not used in printout)
}
$rel =-$rel unless $flag & $$elem[3];
$val .= sprintf("%+.1f%% %s", 100 * $rel / ((1<<$bits)-1), $$elem[0]);
}
} elsif ($id eq 'RVA2') {
my ($pos, $id) = $val=~/^([^\0]*)\0/s ? (length($1)+1, $1) : (1, '');
my @vals;
while ($pos + 4 <= $valLen) {
my $type = Get8u(\$val, $pos);
my $str = ({
0 => 'Other',
1 => 'Master',
2 => 'Front-right',
3 => 'Front-left',
4 => 'Back-right',
5 => 'Back-left',
6 => 'Front-centre',
7 => 'Back-centre',
8 => 'Subwoofer',
}->{$type} || "Unknown($type)");
my $db = Get16s(\$val,$pos+1) / 512;
# convert dB to percent as displayed by iTunes 10.5
# (not sure why I need to divide by 20 instead of 10 as expected - PH)
push @vals, sprintf('%+.1f%% %s', 10**($db/20+2)-100, $str);
# step to next channel (ignoring peak volume)
$pos += 4 + int((Get8u(\$val,$pos+3) + 7) / 8);
}
$val = join ', ', @vals;
$val .= " ($id)" if $id;
} elsif ($id eq 'PRIV') {
# save version number to set group1 name for tag later
$$et{ID3_Ver} = $$tagTablePtr{GROUPS}{1};
$et->HandleTag($tagTablePtr, $id, $val);
next;
} elsif ($$tagInfo{Format} or $$tagInfo{SubDirectory}) {
$et->HandleTag($tagTablePtr, $id, undef, DataPt => \$val);
next;
} elsif (not $$tagInfo{Binary}) {
$et->Warn("Don't know how to handle $id frame");
next;
}
if ($lang and $lang =~ /^[a-z]{3}$/i and $lang ne 'eng') {
$tagInfo = Image::ExifTool::GetLangInfo($tagInfo, lc $lang);
}
%flags and $extra{Extra} = ', Flags=' . join(',', sort keys %flags);
$et->HandleTag($tagTablePtr, $id, $val,
TagInfo => $tagInfo,
DataPt => $dataPt,
DataPos => $$dirInfo{DataPos},
Size => $len,
Start => $offset,
%extra
);
}
}
#------------------------------------------------------------------------------
# Extract ID3 information from an audio file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 on success, 0 if this file didn't contain ID3 information
# - also processes audio data if any ID3 information was found
# - sets ExifTool DoneID3 to 1 when called, or to 2 if an ID3v1 trailer exists
sub ProcessID3($$)
{
my ($et, $dirInfo) = @_;
return 0 if $$et{DoneID3}; # avoid infinite recursion
$$et{DoneID3} = 1;
# allow this to be called with either RAF or DataPt
my $raf = $$dirInfo{RAF} || new File::RandomAccess($$dirInfo{DataPt});
my ($buff, %id3Header, %id3Trailer, $hBuff, $tBuff, $eBuff, $tagTablePtr);
my $rtnVal = 0;
my $hdrEnd = 0;
my $id3Len = 0;
# read first 3 bytes of file
$raf->Seek(0, 0);
return 0 unless $raf->Read($buff, 3) == 3;
#
# identify ID3v2 header
#
while ($buff =~ /^ID3/) {
$rtnVal = 1;
$raf->Read($hBuff, 7) == 7 or $et->Warn('Short ID3 header'), last;
my ($vers, $flags, $size) = unpack('nCN', $hBuff);
$size = UnSyncSafe($size);
defined $size or $et->Warn('Invalid ID3 header'), last;
my $verStr = sprintf("2.%d.%d", $vers >> 8, $vers & 0xff);
if ($vers >= 0x0500) {
$et->Warn("Unsupported ID3 version: $verStr");
last;
}
unless ($raf->Read($hBuff, $size) == $size) {
$et->Warn('Truncated ID3 data');
last;
}
# this flag only indicates use of unsynchronized frames in ID3v2.4
if ($flags & 0x80 and $vers < 0x0400) {
# reverse the unsynchronization
$hBuff =~ s/\xff\x00/\xff/g;
}
my $pos = 10;
if ($flags & 0x40) {
# skip the extended header
$size >= 4 or $et->Warn('Bad ID3 extended header'), last;
my $len = unpack('N', $hBuff);
if ($len > length($hBuff) - 4) {
$et->Warn('Truncated ID3 extended header');
last;
}
$hBuff = substr($hBuff, $len + 4);
$pos += $len + 4;
}
if ($flags & 0x10) {
# ignore v2.4 footer (10 bytes long)
$raf->Seek(10, 1);
}
%id3Header = (
DataPt => \$hBuff,
DataPos => $pos,
DirStart => 0,
DirLen => length($hBuff),
Version => $vers,
DirName => "ID3v$verStr",
);
$id3Len += length($hBuff) + 10;
if ($vers >= 0x0400) {
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_4');
} elsif ($vers >= 0x0300) {
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_3');
} else {
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v2_2');
}
$hdrEnd = $raf->Tell();
last;
}
#
# read ID3v1 trailer if it exists
#
if ($raf->Seek(-128, 2) and $raf->Read($tBuff, 128) == 128 and $tBuff =~ /^TAG/) {
$$et{DoneID3} = 2; # set to 2 as flag that trailer exists
%id3Trailer = (
DataPt => \$tBuff,
DataPos => $raf->Tell() - 128,
DirStart => 0,
DirLen => length($tBuff),
);
$id3Len += length($tBuff);
$rtnVal = 1;
# load 'Enhanced TAG' information if available
if ($raf->Seek(-355, 2) and $raf->Read($eBuff, 227) == 227 and $eBuff =~ /^TAG+/) {
$id3Trailer{EnhancedTAG} = \$eBuff;
}
}
#
# process the the information
#
if ($rtnVal) {
# first process audio data if it exists
if ($$dirInfo{RAF}) {
my $oldType = $$et{FILE_TYPE}; # save file type
# check current file type first
my @types = grep /^$oldType$/, @audioFormats;
push @types, grep(!/^$oldType$/, @audioFormats);
my $type;
foreach $type (@types) {
# seek to end of ID3 header
$raf->Seek($hdrEnd, 0);
# set type for this file if we are successful
$$et{FILE_TYPE} = $type;
my $module = $audioModule{$type} || $type;
require "Image/ExifTool/$module.pm" or next;
my $func = "Image::ExifTool::${module}::Process$type";
# process the file
no strict 'refs';
&$func($et, $dirInfo) and last;
use strict 'refs';
}
$$et{FILE_TYPE} = $oldType; # restore original file type
}
# set file type to MP3 if we didn't find audio data
$et->SetFileType('MP3');
# record the size of the ID3 metadata
$et->FoundTag('ID3Size', $id3Len);
# process ID3v2 header if it exists
if (%id3Header) {
$et->VPrint(0, "$id3Header{DirName}:\n");
$et->ProcessDirectory(\%id3Header, $tagTablePtr);
}
# process ID3v1 trailer if it exists
if (%id3Trailer) {
$et->VPrint(0, "ID3v1:\n");
SetByteOrder('MM');
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v1');
$et->ProcessDirectory(\%id3Trailer, $tagTablePtr);
# process "Enhanced TAG" information if available
if ($id3Trailer{EnhancedTAG}) {
$et->VPrint(0, "ID3v1 Enhanced TAG:\n");
$tagTablePtr = GetTagTable('Image::ExifTool::ID3::v1_Enh');
$id3Trailer{DataPt} = $id3Trailer{EnhancedTAG};
$id3Trailer{DataPos} -= 227; # (227 = length of Enhanced TAG block)
$id3Trailer{DirLen} = 227;
$et->ProcessDirectory(\%id3Trailer, $tagTablePtr);
}
}
}
# return file pointer to start of file to read audio data if necessary
$raf->Seek(0, 0);
return $rtnVal;
}
#------------------------------------------------------------------------------
# Extract ID3 information from an MP3 audio file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# Returns: 1 on success, 0 if this wasn't a valid MP3 file
sub ProcessMP3($$)
{
my ($et, $dirInfo) = @_;
my $rtnVal = 0;
# must first check for leading/trailing ID3 information
# (and process the rest of the file if found)
unless ($$et{DoneID3}) {
$rtnVal = ProcessID3($et, $dirInfo);
}
# check for MPEG A/V data if not already processed above
unless ($rtnVal) {
my $raf = $$dirInfo{RAF};
my $buff;
#
# extract information from first audio/video frame headers
# (if found in the first $scanLen bytes)
#
# scan further into a file that should be an MP3
my $scanLen = ($$et{FILE_EXT} and $$et{FILE_EXT} eq 'MP3') ? 8192 : 256;
if ($raf->Read($buff, $scanLen)) {
require Image::ExifTool::MPEG;
if ($buff =~ /\0\0\x01(\xb3|\xc0)/) {
# look for A/V headers in first 64kB
my $buf2;
$raf->Read($buf2, 0x10000 - $scanLen) and $buff .= $buf2;
$rtnVal = 1 if Image::ExifTool::MPEG::ParseMPEGAudioVideo($et, \$buff);
} else {
# look for audio frame sync in first $scanLen bytes
# (set MP3 flag to 1 so this will fail unless layer 3 audio)
my $ext = $$et{FILE_EXT} || '';
my $mp3 = ($ext eq 'MUS') ? 0 : 1; # MUS files are MP2
$rtnVal = 1 if Image::ExifTool::MPEG::ParseMPEGAudio($et, \$buff, $mp3);
}
}
}
# check for an APE trailer if this was a valid A/V file and we haven't already done it
if ($rtnVal and not $$et{DoneAPE}) {
require Image::ExifTool::APE;
Image::ExifTool::APE::ProcessAPE($et, $dirInfo);
}
return $rtnVal;
}
1; # end
__END__
=head1 NAME
Image::ExifTool::ID3 - Read ID3 meta information
=head1 SYNOPSIS
This module is used by Image::ExifTool
=head1 DESCRIPTION
This module contains definitions required by Image::ExifTool to extract ID3
information from audio files. ID3 information is found in MP3 and various
other types of audio files.
=head1 AUTHOR
Copyright 2003-2018, Phil Harvey (phil at owl.phy.queensu.ca)
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 REFERENCES
=over 4
=item L<http://www.id3.org/>
=item L<http://www.mp3-tech.org/>
=item L<http://www.fortunecity.com/underworld/sonic/3/id3tag.html>
=back
=head1 SEE ALSO
L<Image::ExifTool::TagNames/ID3 Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>
=cut
| {
"pile_set_name": "Github"
} |
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2014 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#include "OgreStableHeaders.h"
#include "Animation/OgreSkeletonDef.h"
#include "Animation/OgreSkeletonAnimationDef.h"
#include "Animation/OgreBone.h"
#include "Math/Array/OgreBoneMemoryManager.h"
#include "Math/Array/OgreKfTransformArrayMemoryManager.h"
#include "OgreId.h"
#include "OgreOldBone.h"
#include "OgreSkeleton.h"
namespace Ogre
{
SkeletonDef::SkeletonDef( const v1::Skeleton *originalSkeleton, Real frameRate ) :
mNumUnusedSlots( 0 ),
mName( originalSkeleton->getName() )
{
mBones.reserve( originalSkeleton->getNumBones() );
//Clone the bone data
size_t numDepthLevels = 1;
v1::Skeleton::ConstBoneIterator itor = originalSkeleton->getBoneIteratorConst();
while( itor.hasMoreElements() )
{
v1::OldBone *bone = itor.getNext();
size_t parentIndex = -1;
if( bone->getParent() )
{
assert( !bone->getParent() || dynamic_cast<v1::OldBone*>( bone->getParent() ) );
v1::OldBone *parent = static_cast<v1::OldBone*>( bone->getParent() );
parentIndex = parent->getHandle();
size_t tmpDepthLevels = 2;
v1::OldNode *tmpParent = parent;
while( (tmpParent = tmpParent->getParent()) )
++tmpDepthLevels;
numDepthLevels = std::max( numDepthLevels, tmpDepthLevels );
}
BoneData boneData( bone->getHandle(), parentIndex, bone->getPosition(),
bone->getOrientation(), bone->getScale(),
bone->getName(), bone->getInheritOrientation(),
bone->getInheritScale() );
mBoneIndexByName[bone->getName()] = mBones.size();
mBones.push_back( boneData );
}
mBonesPerDepth.resize( numDepthLevels );
mDepthLevelInfoVec.resize( numDepthLevels );
for( size_t i=0; i<mBones.size(); ++i )
{
size_t currentDepthLevel = 0;
BoneData const *tmpBone = &mBones[i];
while( tmpBone->parent != std::numeric_limits<size_t>::max() )
{
tmpBone = &mBones[tmpBone->parent];
++currentDepthLevel;
}
DepthLevelInfo &info = mDepthLevelInfoVec[currentDepthLevel];
info.firstBoneIndex = std::min( i, info.firstBoneIndex );
++info.numBonesInLevel;
mBonesPerDepth[currentDepthLevel].push_back( i );
}
// Populate both mBoneToSlot and mSlotToBone
mBoneToSlot.reserve( originalSkeleton->getNumBones() );
for( size_t i=0; i<originalSkeleton->getNumBones(); ++i )
{
const v1::OldBone *bone = originalSkeleton->getBone( i );
size_t depthLevel = 0;
v1::OldNode const *parentBone = bone;
while( (parentBone = parentBone->getParent()) )
++depthLevel;
size_t offset = 0;
BoneToSlotVec::const_iterator itBoneToSlot = mBoneToSlot.begin();
BoneToSlotVec::const_iterator enBoneToSlot = mBoneToSlot.end();
while( itBoneToSlot != enBoneToSlot )
{
if( (*itBoneToSlot >> 24) == depthLevel )
++offset;
++itBoneToSlot;
}
//Build the map that lets us know the final slot bone index that will be
//assigned to this bone (to get the block we still need to divide by ARRAY_PACKED_REALS)
mBoneToSlot.push_back( static_cast<uint>((depthLevel << 24) | (offset & 0x00FFFFFF)) );
mSlotToBone[mBoneToSlot.back()] = static_cast<uint>(i);
}
//Clone the animations
mAnimationDefs.resize( originalSkeleton->getNumAnimations() );
for( size_t i=0; i<originalSkeleton->getNumAnimations(); ++i )
{
mAnimationDefs[i]._setSkeletonDef( this );
mAnimationDefs[i].setName( originalSkeleton->getAnimation( i )->getName() );
mAnimationDefs[i].build( originalSkeleton, originalSkeleton->getAnimation( i ), frameRate );
}
//Create the bones (just like we would for SkeletonInstance)so we can
//get derived position/rotation/scale and then calculate its inverse
BoneMemoryManager boneMemoryManager;
vector<Bone>::type boneNodes( mBones.size(), Bone() );
vector<list<size_t>::type>::type::const_iterator itDepth = mBonesPerDepth.begin();
vector<list<size_t>::type>::type::const_iterator enDepth = mBonesPerDepth.end();
while( itDepth != enDepth )
{
list<size_t>::type::const_iterator bonesItor = itDepth->begin();
list<size_t>::type::const_iterator bonesItorEnd = itDepth->end();
while( bonesItor != bonesItorEnd )
{
Bone *parent = 0;
size_t parentIdx = mBones[*bonesItor].parent;
const BoneData &boneData = mBones[*bonesItor];
if( parentIdx != std::numeric_limits<size_t>::max() )
parent = &boneNodes[parentIdx];
Bone &newBone = boneNodes[*bonesItor];
newBone._initialize( Id::generateNewId<Bone>(), &boneMemoryManager, parent, 0 );
newBone.setPosition( boneData.vPos );
newBone.setOrientation( boneData.qRot );
newBone.setScale( boneData.vScale );
newBone.setInheritOrientation( boneData.bInheritOrientation );
newBone.setInheritScale( boneData.bInheritScale );
newBone.setName( boneData.name );
newBone.mGlobalIndex = *bonesItor;
++bonesItor;
}
++itDepth;
}
//Calculate in bulk. Calling getDerivedPositionUpdated & Co like
//we need would need, has O(N!) complexity.
for( size_t i=0; i<boneMemoryManager.getNumDepths(); ++i )
{
BoneTransform t;
const size_t numNodes = boneMemoryManager.getFirstNode( t, i );
Bone::updateAllTransforms( numNodes, t, &ArrayMatrixAf4x3::IDENTITY, 1 );
}
{
size_t numBoneBlocks = getNumberOfBoneBlocks( mDepthLevelInfoVec.size() );
//Create initial bind pose.
mBindPose = RawSimdUniquePtr<KfTransform, MEMCATEGORY_ANIMATION>( numBoneBlocks );
RawSimdUniquePtr<SimpleMatrixAf4x3, MEMCATEGORY_ANIMATION> derivedPosesPtr =
RawSimdUniquePtr<SimpleMatrixAf4x3, MEMCATEGORY_ANIMATION>(
numBoneBlocks * ARRAY_PACKED_REALS );
size_t bindPoseIndex = 0;
KfTransform *bindPose = mBindPose.get();
SimpleMatrixAf4x3 *derivedPose = derivedPosesPtr.get();
size_t currentDepthLevel = 0;
DepthLevelInfoVec::const_iterator bonesItor = mDepthLevelInfoVec.begin();
DepthLevelInfoVec::const_iterator bonesItorEnd = mDepthLevelInfoVec.end();
while( bonesItor != bonesItorEnd )
{
list<size_t>::type::const_iterator itBoneIdx = mBonesPerDepth[currentDepthLevel].begin();
list<size_t>::type::const_iterator enBoneIdx = mBonesPerDepth[currentDepthLevel].end();
while( itBoneIdx != enBoneIdx )
{
const BoneData &boneData = mBones[*itBoneIdx];
bindPose->mPosition.setFromVector3( boneData.vPos, bindPoseIndex );
bindPose->mOrientation.setFromQuaternion( boneData.qRot, bindPoseIndex );
bindPose->mScale.setFromVector3( boneData.vScale, bindPoseIndex );
const Bone &derivedBone = boneNodes[*itBoneIdx];
derivedPose[bindPoseIndex] = derivedBone._getLocalSpaceTransform();
++bindPoseIndex;
if( bindPoseIndex >= ARRAY_PACKED_REALS )
{
bindPoseIndex = 0;
++bindPose;
derivedPose += ARRAY_PACKED_REALS;
}
++itBoneIdx;
}
if( bonesItor->numBonesInLevel <= (ARRAY_PACKED_REALS >> 1) )
{
//Repeat the slots in patterns to save memory when instances get created
//Do the same in SkeletonTrack::_bakeUnusedSlots
size_t k=0;
for( size_t j=bonesItor->numBonesInLevel; j<ARRAY_PACKED_REALS; ++j )
{
Vector3 vTmp;
Quaternion qTmp;
bindPose->mPosition.getAsVector3( vTmp, k );
bindPose->mPosition.setFromVector3( vTmp, j );
bindPose->mOrientation.getAsQuaternion( qTmp, k );
bindPose->mOrientation.setFromQuaternion( qTmp, j );
bindPose->mScale.getAsVector3( vTmp, k );
bindPose->mScale.setFromVector3( vTmp, j );
derivedPose[j] = derivedPose[k];
k = (k+1) % bonesItor->numBonesInLevel;
}
bindPoseIndex = 0;
++bindPose;
derivedPose += ARRAY_PACKED_REALS;
}
else if( bindPoseIndex != 0 )
{
//We can't repeat to save memory per instance. But we still need
//to create a hole so the next depth level starts in the first slot
//of the next block
for( ; bindPoseIndex<ARRAY_PACKED_REALS; ++bindPoseIndex )
{
bindPose->mPosition.setFromVector3( Vector3::ZERO, bindPoseIndex );
bindPose->mOrientation.setFromQuaternion( Quaternion::IDENTITY, bindPoseIndex );
bindPose->mScale.setFromVector3( Vector3::UNIT_SCALE, bindPoseIndex );
derivedPose[bindPoseIndex] = SimpleMatrixAf4x3::IDENTITY;
}
bindPoseIndex = 0;
++bindPose;
derivedPose += ARRAY_PACKED_REALS;
}
++currentDepthLevel;
++bonesItor;
}
//Now set the reverse of the binding pose (so we can pass the
//construct the derived transform matrices in the correct space)
mReverseBindPose = RawSimdUniquePtr<ArrayMatrixAf4x3, MEMCATEGORY_ANIMATION>(numBoneBlocks);
ArrayMatrixAf4x3 *reverseBindPose = mReverseBindPose.get();
derivedPose = derivedPosesPtr.get();
for( size_t i=0; i<numBoneBlocks; ++i )
{
reverseBindPose[i].loadFromAoS( derivedPose );
reverseBindPose[i].setToInverseDegeneratesAsIdentity();
derivedPose += ARRAY_PACKED_REALS;
}
}
{
//Cache the amount of unused slots for the SkeletonInstance
mNumUnusedSlots = 0;
SkeletonDef::DepthLevelInfoVec::const_iterator depthLevelItor = mDepthLevelInfoVec.begin();
while( depthLevelItor != mDepthLevelInfoVec.end() )
{
if( depthLevelItor->numBonesInLevel > (ARRAY_PACKED_REALS >> 1) )
{
size_t unusedSlots = ARRAY_PACKED_REALS -
(depthLevelItor->numBonesInLevel % ARRAY_PACKED_REALS);
if( unusedSlots != ARRAY_PACKED_REALS )
mNumUnusedSlots += unusedSlots;
}
++depthLevelItor;
}
}
{
vector<Bone>::type::iterator boneNodeItor = boneNodes.begin();
vector<Bone>::type::iterator end = boneNodes.end();
while( boneNodeItor != end )
{
//Don't check LIFO Order since the BoneMemoryManager dies with us.
const bool debugCheckLifoOrder = false;
boneNodeItor->_deinitialize( debugCheckLifoOrder );
++boneNodeItor;
}
}
}
//-----------------------------------------------------------------------------------
void SkeletonDef::getBonesPerDepth( vector<size_t>::type &out ) const
{
out.clear();
out.reserve( mDepthLevelInfoVec.size() );
DepthLevelInfoVec::const_iterator itor = mDepthLevelInfoVec.begin();
DepthLevelInfoVec::const_iterator end = mDepthLevelInfoVec.end();
while( itor != end )
{
out.push_back( itor->numBonesInLevel );
++itor;
}
}
//-----------------------------------------------------------------------------------
size_t SkeletonDef::getNumberOfBoneBlocks( size_t numLevels ) const
{
size_t numBlocks = 0;
DepthLevelInfoVec::const_iterator itor = mDepthLevelInfoVec.begin();
DepthLevelInfoVec::const_iterator end = mDepthLevelInfoVec.begin() + numLevels;
while( itor != end )
{
numBlocks += (itor->numBonesInLevel - 1 + ARRAY_PACKED_REALS) / ARRAY_PACKED_REALS;
++itor;
}
return numBlocks;
}
}
| {
"pile_set_name": "Github"
} |
/*
* Device Tree Include file for Marvell Armada XP family SoC
*
* Copyright (C) 2012 Marvell
*
* Lior Amsalem <[email protected]>
* Gregory CLEMENT <[email protected]>
* Thomas Petazzoni <[email protected]>
* Ben Dooks <[email protected]>
*
* This file is dual-licensed: you can use it either under the terms
* of the GPL or the X11 license, at your option. Note that this dual
* licensing only applies to this file, and not this project as a
* whole.
*
* a) This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This file 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.
*
* Or, alternatively
*
* b) Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use
* copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Contains definitions specific to the Armada XP SoC that are not
* common to all Armada SoCs.
*/
#include "armada-370-xp.dtsi"
/ {
model = "Marvell Armada XP family SoC";
compatible = "marvell,armadaxp", "marvell,armada-370-xp";
aliases {
serial2 = &uart2;
serial3 = &uart3;
};
soc {
compatible = "marvell,armadaxp-mbus", "simple-bus";
u-boot,dm-pre-reloc;
bootrom {
compatible = "marvell,bootrom";
reg = <MBUS_ID(0x01, 0x1d) 0 0x100000>;
};
internal-regs {
sdramc@1400 {
compatible = "marvell,armada-xp-sdram-controller";
reg = <0x1400 0x500>;
};
L2: l2-cache {
compatible = "marvell,aurora-system-cache";
reg = <0x08000 0x1000>;
cache-id-part = <0x100>;
cache-level = <2>;
cache-unified;
wt-override;
};
spi0: spi@10600 {
compatible = "marvell,armada-xp-spi",
"marvell,orion-spi";
pinctrl-0 = <&spi0_pins>;
pinctrl-names = "default";
};
spi1: spi@10680 {
compatible = "marvell,armada-xp-spi",
"marvell,orion-spi";
};
i2c0: i2c@11000 {
compatible = "marvell,mv78230-i2c", "marvell,mv64xxx-i2c";
reg = <0x11000 0x100>;
};
i2c1: i2c@11100 {
compatible = "marvell,mv78230-i2c", "marvell,mv64xxx-i2c";
reg = <0x11100 0x100>;
};
uart2: serial@12200 {
compatible = "snps,dw-apb-uart";
pinctrl-0 = <&uart2_pins>;
pinctrl-names = "default";
reg = <0x12200 0x100>;
reg-shift = <2>;
interrupts = <43>;
reg-io-width = <1>;
clocks = <&coreclk 0>;
status = "disabled";
};
uart3: serial@12300 {
compatible = "snps,dw-apb-uart";
pinctrl-0 = <&uart3_pins>;
pinctrl-names = "default";
reg = <0x12300 0x100>;
reg-shift = <2>;
interrupts = <44>;
reg-io-width = <1>;
clocks = <&coreclk 0>;
status = "disabled";
};
system-controller@18200 {
compatible = "marvell,armada-370-xp-system-controller";
reg = <0x18200 0x500>;
};
gateclk: clock-gating-control@18220 {
compatible = "marvell,armada-xp-gating-clock";
reg = <0x18220 0x4>;
clocks = <&coreclk 0>;
#clock-cells = <1>;
};
coreclk: mvebu-sar@18230 {
compatible = "marvell,armada-xp-core-clock";
reg = <0x18230 0x08>;
#clock-cells = <1>;
};
thermal@182b0 {
compatible = "marvell,armadaxp-thermal";
reg = <0x182b0 0x4
0x184d0 0x4>;
status = "okay";
};
cpuclk: clock-complex@18700 {
#clock-cells = <1>;
compatible = "marvell,armada-xp-cpu-clock";
reg = <0x18700 0x24>, <0x1c054 0x10>;
clocks = <&coreclk 1>;
};
interrupt-controller@20a00 {
reg = <0x20a00 0x2d0>, <0x21070 0x58>;
};
timer@20300 {
compatible = "marvell,armada-xp-timer";
clocks = <&coreclk 2>, <&refclk>;
clock-names = "nbclk", "fixed";
};
watchdog@20300 {
compatible = "marvell,armada-xp-wdt";
clocks = <&coreclk 2>, <&refclk>;
clock-names = "nbclk", "fixed";
};
cpurst@20800 {
compatible = "marvell,armada-370-cpu-reset";
reg = <0x20800 0x20>;
};
eth2: ethernet@30000 {
compatible = "marvell,armada-xp-neta";
reg = <0x30000 0x4000>;
interrupts = <12>;
clocks = <&gateclk 2>;
status = "disabled";
};
usb@50000 {
clocks = <&gateclk 18>;
};
usb@51000 {
clocks = <&gateclk 19>;
};
usb@52000 {
compatible = "marvell,orion-ehci";
reg = <0x52000 0x500>;
interrupts = <47>;
clocks = <&gateclk 20>;
status = "disabled";
};
xor@60900 {
compatible = "marvell,orion-xor";
reg = <0x60900 0x100
0x60b00 0x100>;
clocks = <&gateclk 22>;
status = "okay";
xor10 {
interrupts = <51>;
dmacap,memcpy;
dmacap,xor;
};
xor11 {
interrupts = <52>;
dmacap,memcpy;
dmacap,xor;
dmacap,memset;
};
};
ethernet@70000 {
compatible = "marvell,armada-xp-neta";
};
ethernet@74000 {
compatible = "marvell,armada-xp-neta";
};
xor@f0900 {
compatible = "marvell,orion-xor";
reg = <0xF0900 0x100
0xF0B00 0x100>;
clocks = <&gateclk 28>;
status = "okay";
xor00 {
interrupts = <94>;
dmacap,memcpy;
dmacap,xor;
};
xor01 {
interrupts = <95>;
dmacap,memcpy;
dmacap,xor;
dmacap,memset;
};
};
};
};
clocks {
/* 25 MHz reference crystal */
refclk: oscillator {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <25000000>;
};
};
};
&pinctrl {
ge0_gmii_pins: ge0-gmii-pins {
marvell,pins =
"mpp0", "mpp1", "mpp2", "mpp3",
"mpp4", "mpp5", "mpp6", "mpp7",
"mpp8", "mpp9", "mpp10", "mpp11",
"mpp12", "mpp13", "mpp14", "mpp15",
"mpp16", "mpp17", "mpp18", "mpp19",
"mpp20", "mpp21", "mpp22", "mpp23";
marvell,function = "ge0";
};
ge0_rgmii_pins: ge0-rgmii-pins {
marvell,pins =
"mpp0", "mpp1", "mpp2", "mpp3",
"mpp4", "mpp5", "mpp6", "mpp7",
"mpp8", "mpp9", "mpp10", "mpp11";
marvell,function = "ge0";
};
ge1_rgmii_pins: ge1-rgmii-pins {
marvell,pins =
"mpp12", "mpp13", "mpp14", "mpp15",
"mpp16", "mpp17", "mpp18", "mpp19",
"mpp20", "mpp21", "mpp22", "mpp23";
marvell,function = "ge1";
};
sdio_pins: sdio-pins {
marvell,pins = "mpp30", "mpp31", "mpp32",
"mpp33", "mpp34", "mpp35";
marvell,function = "sd0";
};
spi0_pins: spi0-pins {
marvell,pins = "mpp36", "mpp37",
"mpp38", "mpp39";
marvell,function = "spi0";
};
uart2_pins: uart2-pins {
marvell,pins = "mpp42", "mpp43";
marvell,function = "uart2";
};
uart3_pins: uart3-pins {
marvell,pins = "mpp44", "mpp45";
marvell,function = "uart3";
};
};
| {
"pile_set_name": "Github"
} |
import sys
import pandas as pd
import numpy as np
import pytz
from feast.wait import wait_retry_backoff
from feast import Client, Feature, FeatureSet, Entity, ValueType
from datetime import datetime
feast_core_url = sys.argv[1]
feast_online_serving_url = sys.argv[2]
number_of_entities = 100
df = pd.DataFrame(
{
"datetime": [
datetime.utcnow().replace(tzinfo=pytz.utc)
for _ in range(number_of_entities)
],
"user_id": [1000 + entity_id for entity_id in range(number_of_entities)],
"int32_feature": [np.int32(1) for _ in range(number_of_entities)],
"int64_feature": [np.int64(1) for _ in range(number_of_entities)],
"float_feature": [np.float(0.1) for _ in range(number_of_entities)],
"double_feature": [np.float64(0.1) for _ in range(number_of_entities)],
"string_feature": ["one" for _ in range(number_of_entities)],
"bytes_feature": [b"one" for _ in range(number_of_entities)],
"bool_feature": [True for _ in range(number_of_entities)],
"int32_list_feature": [
np.array([1, 2, 3, 4], dtype=np.int32) for _ in range(number_of_entities)
],
"int64_list_feature": [
np.array([1, 2, 3, 4], dtype=np.int64) for _ in range(number_of_entities)
],
"float_list_feature": [
np.array([1.1, 1.2, 1.3, 1.4], dtype=np.float32)
for _ in range(number_of_entities)
],
"double_list_feature": [
np.array([1.1, 1.2, 1.3, 1.4], dtype=np.float64)
for _ in range(number_of_entities)
],
"string_list_feature": [
np.array(["one", "two", "three"]) for _ in range(number_of_entities)
],
"bytes_list_feature": [
np.array([b"one", b"two", b"three"]) for _ in range(number_of_entities)
],
"bool_list_feature": [
[True, False, True] for _ in range(number_of_entities)
],
}
)
all_types_fs_expected = FeatureSet(
name="all_types",
entities=[Entity(name="user_id", dtype=ValueType.INT64)],
features=[
Feature(name="float_feature", dtype=ValueType.FLOAT),
Feature(name="int64_feature", dtype=ValueType.INT64),
Feature(name="int32_feature", dtype=ValueType.INT32),
Feature(name="string_feature", dtype=ValueType.STRING),
Feature(name="bytes_feature", dtype=ValueType.BYTES),
Feature(name="bool_feature", dtype=ValueType.BOOL),
Feature(name="double_feature", dtype=ValueType.DOUBLE),
Feature(name="double_list_feature", dtype=ValueType.DOUBLE_LIST),
Feature(name="float_list_feature", dtype=ValueType.FLOAT_LIST),
Feature(name="int64_list_feature", dtype=ValueType.INT64_LIST),
Feature(name="int32_list_feature", dtype=ValueType.INT32_LIST),
Feature(name="string_list_feature", dtype=ValueType.STRING_LIST),
Feature(name="bytes_list_feature", dtype=ValueType.BYTES_LIST),
Feature(name="bool_list_feature", dtype=ValueType.BOOL_LIST),
],
)
client = Client(core_url=feast_core_url, serving_url=feast_online_serving_url)
# Register feature set
client.apply(all_types_fs_expected)
df.info()
df.describe()
df.head()
# Ingest tdata
client.ingest(all_types_fs_expected, df)
# Wait for data to be available
def try_get_features():
online_request_entity = [{"user_id": 1001}]
online_request_features = ["float_feature"]
response = client.get_online_features(
entity_rows=online_request_entity, feature_refs=online_request_features
)
response_dict = response.to_dict()
if response_dict['float_feature'] == df.iloc[0]['float_feature']:
return response_dict, True
return response_dict, False
online_features_actual = wait_retry_backoff(
retry_fn=try_get_features,
timeout_secs=90,
timeout_msg="Timed out trying to get online feature values",
)
| {
"pile_set_name": "Github"
} |
"shadow_demon_shadow_poison_damage"
{
"challengetype" "340"
"desc" "#DOTA_ChallengeDesc_ShadowDemon_ShadowPoisonDamage"
"status_text" "#DOTA_ChallengeStatus_ShadowDemon_ShadowPoisonDamage"
"image" "images/spellicons/shadow_demon_shadow_poison.png"
"requiredhero" "79"
"events"
{
"matching_type" "linear_series"
"query"
{
"find_damage"
{
"event" "damage"
"attack" "shadow_demon_shadow_poison"
"attacker" "!hero"
"target_must_be_hero" "1"
"storage"
{
"1"
{
"key" "value"
"aggregator" "sum"
}
}
}
}
"clear_storage_per_query" "0"
"progress_stored_in" "1"
"post_tests"
{
"test_value"
{
"storage" "1"
"compare" ">="
"amount" "<shadow_poison_damage>"
}
}
}
"variables"
{
"<shadow_poison_damage>"
{
"format" "int"
"index" "0"
}
}
}
| {
"pile_set_name": "Github"
} |
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2014.
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
#ifndef BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP
#define BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/iterator.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/geometry/views/detail/range_type.hpp>
#include <boost/geometry/views/reversible_view.hpp>
#include <boost/geometry/views/closeable_view.hpp>
namespace boost { namespace geometry {
#ifndef DOXYGEN_NO_DETAIL
namespace detail {
template <typename Geometry>
struct normalized_view
{
static const bool is_const = boost::is_const<Geometry>::value;
//typedef typename ring_type<Geometry>::type ring_type;
typedef typename detail::range_type<Geometry>::type range_type;
typedef typename
boost::mpl::if_c
<
is_const,
range_type const,
range_type
>::type range;
typedef typename
reversible_view
<
range,
order_as_direction
<
geometry::point_order<Geometry>::value
>::value
>::type reversible_type;
typedef typename
boost::mpl::if_c
<
is_const,
reversible_type const,
reversible_type
>::type reversible;
typedef typename
closeable_view
<
reversible,
geometry::closure<Geometry>::value
>::type closeable_type;
typedef typename
boost::mpl::if_c
<
is_const,
closeable_type const,
closeable_type
>::type closeable;
explicit inline normalized_view(range & r)
: m_reversible(r)
, m_closeable(m_reversible)
{}
typedef typename boost::range_iterator<closeable>::type iterator;
typedef typename boost::range_const_iterator<closeable>::type const_iterator;
inline const_iterator begin() const { return boost::begin(m_closeable); }
inline const_iterator end() const { return boost::end(m_closeable); }
inline iterator begin() { return boost::begin(m_closeable); }
inline iterator end() { return boost::end(m_closeable); }
private:
reversible_type m_reversible;
closeable_type m_closeable;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_VIEWS_DETAIL_NORMALIZED_VIEW_HPP
| {
"pile_set_name": "Github"
} |
/* istanbul ignore file */
import {commitMutation, graphql} from 'react-relay';
import {ConnectionHandler} from 'relay-runtime';
import moment from 'moment';
import {renderMarkdown} from '../helpers';
const mutation = graphql`
mutation addPrReviewCommentMutation($input: AddPullRequestReviewCommentInput!) {
addPullRequestReviewComment(input: $input) {
commentEdge {
node {
id
author {
avatarUrl
login
}
body
bodyHTML
isMinimized
viewerCanReact
viewerCanUpdate
path
position
createdAt
lastEditedAt
url
authorAssociation
...emojiReactionsController_reactable
}
}
}
}
`;
let placeholderID = 0;
export default (environment, {body, inReplyTo, reviewID, threadID, viewerID, path, position}) => {
const variables = {
input: {
body,
inReplyTo,
pullRequestReviewId: reviewID,
},
};
const configs = [{
type: 'RANGE_ADD',
parentID: threadID,
connectionInfo: [{key: 'ReviewCommentsAccumulator_comments', rangeBehavior: 'append'}],
edgeName: 'commentEdge',
}];
function optimisticUpdater(store) {
const reviewThread = store.get(threadID);
if (!reviewThread) {
return;
}
const id = `add-pr-review-comment:comment:${placeholderID++}`;
const comment = store.create(id, 'PullRequestReviewComment');
comment.setValue(id, 'id');
comment.setValue(body, 'body');
comment.setValue(renderMarkdown(body), 'bodyHTML');
comment.setValue(false, 'isMinimized');
comment.setValue(false, 'viewerCanMinimize');
comment.setValue(false, 'viewerCanReact');
comment.setValue(false, 'viewerCanUpdate');
comment.setValue(moment().toISOString(), 'createdAt');
comment.setValue(null, 'lastEditedAt');
comment.setValue('NONE', 'authorAssociation');
comment.setValue('https://github.com', 'url');
comment.setValue(path, 'path');
comment.setValue(position, 'position');
comment.setLinkedRecords([], 'reactionGroups');
let author;
if (viewerID) {
author = store.get(viewerID);
} else {
author = store.create(`add-pr-review-comment:author:${placeholderID++}`, 'User');
author.setValue('...', 'login');
author.setValue('atom://github/img/avatar.svg', 'avatarUrl');
}
comment.setLinkedRecord(author, 'author');
const comments = ConnectionHandler.getConnection(reviewThread, 'ReviewCommentsAccumulator_comments');
const edge = ConnectionHandler.createEdge(store, comments, comment, 'PullRequestReviewCommentEdge');
ConnectionHandler.insertEdgeAfter(comments, edge);
}
return new Promise((resolve, reject) => {
commitMutation(
environment,
{
mutation,
variables,
configs,
optimisticUpdater,
onCompleted: resolve,
onError: reject,
},
);
});
};
| {
"pile_set_name": "Github"
} |
Title: Fixed broken duplicate user id validation when creating new users
Level: 1
Component: wato
Class: fix
Compatible: compat
State: unknown
Version: 1.4.0i1
Date: 1455706956
| {
"pile_set_name": "Github"
} |
/*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* Please refer to the NVIDIA end user license agreement (EULA) associated
* with this source code for terms and conditions that govern your use of
* this software. Any use, reproduction, disclosure, or distribution of
* this software and related documentation outside the terms of the EULA
* is strictly prohibited.
*
*/
/*
Tables for Marching Cubes
http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
*/
// edge table maps 8-bit flag representing which cube vertices are inside
// the isosurface to 12-bit number indicating which edges are intersected
uint edgeTable[256] = {
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
};
// triangle table maps same cube vertex index to a list of up to 5 triangles
// which are built from the interpolated edge vertices
#define X 255
uint triTable[256][16] = {
{X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 8, 3, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 1, 9, X, X, X, X, X, X, X, X, X, X, X, X, X},
{1, 8, 3, 9, 8, 1, X, X, X, X, X, X, X, X, X, X},
{1, 2, 10, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 8, 3, 1, 2, 10, X, X, X, X, X, X, X, X, X, X},
{9, 2, 10, 0, 2, 9, X, X, X, X, X, X, X, X, X, X},
{2, 8, 3, 2, 10, 8, 10, 9, 8, X, X, X, X, X, X, X},
{3, 11, 2, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 11, 2, 8, 11, 0, X, X, X, X, X, X, X, X, X, X},
{1, 9, 0, 2, 3, 11, X, X, X, X, X, X, X, X, X, X},
{1, 11, 2, 1, 9, 11, 9, 8, 11, X, X, X, X, X, X, X},
{3, 10, 1, 11, 10, 3, X, X, X, X, X, X, X, X, X, X},
{0, 10, 1, 0, 8, 10, 8, 11, 10, X, X, X, X, X, X, X},
{3, 9, 0, 3, 11, 9, 11, 10, 9, X, X, X, X, X, X, X},
{9, 8, 10, 10, 8, 11, X, X, X, X, X, X, X, X, X, X},
{4, 7, 8, X, X, X, X, X, X, X, X, X, X, X, X, X},
{4, 3, 0, 7, 3, 4, X, X, X, X, X, X, X, X, X, X},
{0, 1, 9, 8, 4, 7, X, X, X, X, X, X, X, X, X, X},
{4, 1, 9, 4, 7, 1, 7, 3, 1, X, X, X, X, X, X, X},
{1, 2, 10, 8, 4, 7, X, X, X, X, X, X, X, X, X, X},
{3, 4, 7, 3, 0, 4, 1, 2, 10, X, X, X, X, X, X, X},
{9, 2, 10, 9, 0, 2, 8, 4, 7, X, X, X, X, X, X, X},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, X, X, X, X},
{8, 4, 7, 3, 11, 2, X, X, X, X, X, X, X, X, X, X},
{11, 4, 7, 11, 2, 4, 2, 0, 4, X, X, X, X, X, X, X},
{9, 0, 1, 8, 4, 7, 2, 3, 11, X, X, X, X, X, X, X},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, X, X, X, X},
{3, 10, 1, 3, 11, 10, 7, 8, 4, X, X, X, X, X, X, X},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, X, X, X, X},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, X, X, X, X},
{4, 7, 11, 4, 11, 9, 9, 11, 10, X, X, X, X, X, X, X},
{9, 5, 4, X, X, X, X, X, X, X, X, X, X, X, X, X},
{9, 5, 4, 0, 8, 3, X, X, X, X, X, X, X, X, X, X},
{0, 5, 4, 1, 5, 0, X, X, X, X, X, X, X, X, X, X},
{8, 5, 4, 8, 3, 5, 3, 1, 5, X, X, X, X, X, X, X},
{1, 2, 10, 9, 5, 4, X, X, X, X, X, X, X, X, X, X},
{3, 0, 8, 1, 2, 10, 4, 9, 5, X, X, X, X, X, X, X},
{5, 2, 10, 5, 4, 2, 4, 0, 2, X, X, X, X, X, X, X},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, X, X, X, X},
{9, 5, 4, 2, 3, 11, X, X, X, X, X, X, X, X, X, X},
{0, 11, 2, 0, 8, 11, 4, 9, 5, X, X, X, X, X, X, X},
{0, 5, 4, 0, 1, 5, 2, 3, 11, X, X, X, X, X, X, X},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, X, X, X, X},
{10, 3, 11, 10, 1, 3, 9, 5, 4, X, X, X, X, X, X, X},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, X, X, X, X},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, X, X, X, X},
{5, 4, 8, 5, 8, 10, 10, 8, 11, X, X, X, X, X, X, X},
{9, 7, 8, 5, 7, 9, X, X, X, X, X, X, X, X, X, X},
{9, 3, 0, 9, 5, 3, 5, 7, 3, X, X, X, X, X, X, X},
{0, 7, 8, 0, 1, 7, 1, 5, 7, X, X, X, X, X, X, X},
{1, 5, 3, 3, 5, 7, X, X, X, X, X, X, X, X, X, X},
{9, 7, 8, 9, 5, 7, 10, 1, 2, X, X, X, X, X, X, X},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, X, X, X, X},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, X, X, X, X},
{2, 10, 5, 2, 5, 3, 3, 5, 7, X, X, X, X, X, X, X},
{7, 9, 5, 7, 8, 9, 3, 11, 2, X, X, X, X, X, X, X},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, X, X, X, X},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, X, X, X, X},
{11, 2, 1, 11, 1, 7, 7, 1, 5, X, X, X, X, X, X, X},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, X, X, X, X},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, X},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, X},
{11, 10, 5, 7, 11, 5, X, X, X, X, X, X, X, X, X, X},
{10, 6, 5, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 8, 3, 5, 10, 6, X, X, X, X, X, X, X, X, X, X},
{9, 0, 1, 5, 10, 6, X, X, X, X, X, X, X, X, X, X},
{1, 8, 3, 1, 9, 8, 5, 10, 6, X, X, X, X, X, X, X},
{1, 6, 5, 2, 6, 1, X, X, X, X, X, X, X, X, X, X},
{1, 6, 5, 1, 2, 6, 3, 0, 8, X, X, X, X, X, X, X},
{9, 6, 5, 9, 0, 6, 0, 2, 6, X, X, X, X, X, X, X},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, X, X, X, X},
{2, 3, 11, 10, 6, 5, X, X, X, X, X, X, X, X, X, X},
{11, 0, 8, 11, 2, 0, 10, 6, 5, X, X, X, X, X, X, X},
{0, 1, 9, 2, 3, 11, 5, 10, 6, X, X, X, X, X, X, X},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, X, X, X, X},
{6, 3, 11, 6, 5, 3, 5, 1, 3, X, X, X, X, X, X, X},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, X, X, X, X},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, X, X, X, X},
{6, 5, 9, 6, 9, 11, 11, 9, 8, X, X, X, X, X, X, X},
{5, 10, 6, 4, 7, 8, X, X, X, X, X, X, X, X, X, X},
{4, 3, 0, 4, 7, 3, 6, 5, 10, X, X, X, X, X, X, X},
{1, 9, 0, 5, 10, 6, 8, 4, 7, X, X, X, X, X, X, X},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, X, X, X, X},
{6, 1, 2, 6, 5, 1, 4, 7, 8, X, X, X, X, X, X, X},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, X, X, X, X},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, X, X, X, X},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, X},
{3, 11, 2, 7, 8, 4, 10, 6, 5, X, X, X, X, X, X, X},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, X, X, X, X},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, X, X, X, X},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, X},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, X, X, X, X},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, X},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, X},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, X, X, X, X},
{10, 4, 9, 6, 4, 10, X, X, X, X, X, X, X, X, X, X},
{4, 10, 6, 4, 9, 10, 0, 8, 3, X, X, X, X, X, X, X},
{10, 0, 1, 10, 6, 0, 6, 4, 0, X, X, X, X, X, X, X},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, X, X, X, X},
{1, 4, 9, 1, 2, 4, 2, 6, 4, X, X, X, X, X, X, X},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, X, X, X, X},
{0, 2, 4, 4, 2, 6, X, X, X, X, X, X, X, X, X, X},
{8, 3, 2, 8, 2, 4, 4, 2, 6, X, X, X, X, X, X, X},
{10, 4, 9, 10, 6, 4, 11, 2, 3, X, X, X, X, X, X, X},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, X, X, X, X},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, X, X, X, X},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, X},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, X, X, X, X},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, X},
{3, 11, 6, 3, 6, 0, 0, 6, 4, X, X, X, X, X, X, X},
{6, 4, 8, 11, 6, 8, X, X, X, X, X, X, X, X, X, X},
{7, 10, 6, 7, 8, 10, 8, 9, 10, X, X, X, X, X, X, X},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, X, X, X, X},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, X, X, X, X},
{10, 6, 7, 10, 7, 1, 1, 7, 3, X, X, X, X, X, X, X},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, X, X, X, X},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, X},
{7, 8, 0, 7, 0, 6, 6, 0, 2, X, X, X, X, X, X, X},
{7, 3, 2, 6, 7, 2, X, X, X, X, X, X, X, X, X, X},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, X, X, X, X},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, X},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, X},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, X, X, X, X},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, X},
{0, 9, 1, 11, 6, 7, X, X, X, X, X, X, X, X, X, X},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, X, X, X, X},
{7, 11, 6, X, X, X, X, X, X, X, X, X, X, X, X, X},
{7, 6, 11, X, X, X, X, X, X, X, X, X, X, X, X, X},
{3, 0, 8, 11, 7, 6, X, X, X, X, X, X, X, X, X, X},
{0, 1, 9, 11, 7, 6, X, X, X, X, X, X, X, X, X, X},
{8, 1, 9, 8, 3, 1, 11, 7, 6, X, X, X, X, X, X, X},
{10, 1, 2, 6, 11, 7, X, X, X, X, X, X, X, X, X, X},
{1, 2, 10, 3, 0, 8, 6, 11, 7, X, X, X, X, X, X, X},
{2, 9, 0, 2, 10, 9, 6, 11, 7, X, X, X, X, X, X, X},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, X, X, X, X},
{7, 2, 3, 6, 2, 7, X, X, X, X, X, X, X, X, X, X},
{7, 0, 8, 7, 6, 0, 6, 2, 0, X, X, X, X, X, X, X},
{2, 7, 6, 2, 3, 7, 0, 1, 9, X, X, X, X, X, X, X},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, X, X, X, X},
{10, 7, 6, 10, 1, 7, 1, 3, 7, X, X, X, X, X, X, X},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, X, X, X, X},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, X, X, X, X},
{7, 6, 10, 7, 10, 8, 8, 10, 9, X, X, X, X, X, X, X},
{6, 8, 4, 11, 8, 6, X, X, X, X, X, X, X, X, X, X},
{3, 6, 11, 3, 0, 6, 0, 4, 6, X, X, X, X, X, X, X},
{8, 6, 11, 8, 4, 6, 9, 0, 1, X, X, X, X, X, X, X},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, X, X, X, X},
{6, 8, 4, 6, 11, 8, 2, 10, 1, X, X, X, X, X, X, X},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, X, X, X, X},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, X, X, X, X},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, X},
{8, 2, 3, 8, 4, 2, 4, 6, 2, X, X, X, X, X, X, X},
{0, 4, 2, 4, 6, 2, X, X, X, X, X, X, X, X, X, X},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, X, X, X, X},
{1, 9, 4, 1, 4, 2, 2, 4, 6, X, X, X, X, X, X, X},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, X, X, X, X},
{10, 1, 0, 10, 0, 6, 6, 0, 4, X, X, X, X, X, X, X},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, X},
{10, 9, 4, 6, 10, 4, X, X, X, X, X, X, X, X, X, X},
{4, 9, 5, 7, 6, 11, X, X, X, X, X, X, X, X, X, X},
{0, 8, 3, 4, 9, 5, 11, 7, 6, X, X, X, X, X, X, X},
{5, 0, 1, 5, 4, 0, 7, 6, 11, X, X, X, X, X, X, X},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, X, X, X, X},
{9, 5, 4, 10, 1, 2, 7, 6, 11, X, X, X, X, X, X, X},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, X, X, X, X},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, X, X, X, X},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, X},
{7, 2, 3, 7, 6, 2, 5, 4, 9, X, X, X, X, X, X, X},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, X, X, X, X},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, X, X, X, X},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, X},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, X, X, X, X},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, X},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, X},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, X, X, X, X},
{6, 9, 5, 6, 11, 9, 11, 8, 9, X, X, X, X, X, X, X},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, X, X, X, X},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, X, X, X, X},
{6, 11, 3, 6, 3, 5, 5, 3, 1, X, X, X, X, X, X, X},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, X, X, X, X},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, X},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, X},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, X, X, X, X},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, X, X, X, X},
{9, 5, 6, 9, 6, 0, 0, 6, 2, X, X, X, X, X, X, X},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, X},
{1, 5, 6, 2, 1, 6, X, X, X, X, X, X, X, X, X, X},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, X},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, X, X, X, X},
{0, 3, 8, 5, 6, 10, X, X, X, X, X, X, X, X, X, X},
{10, 5, 6, X, X, X, X, X, X, X, X, X, X, X, X, X},
{11, 5, 10, 7, 5, 11, X, X, X, X, X, X, X, X, X, X},
{11, 5, 10, 11, 7, 5, 8, 3, 0, X, X, X, X, X, X, X},
{5, 11, 7, 5, 10, 11, 1, 9, 0, X, X, X, X, X, X, X},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, X, X, X, X},
{11, 1, 2, 11, 7, 1, 7, 5, 1, X, X, X, X, X, X, X},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, X, X, X, X},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, X, X, X, X},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, X},
{2, 5, 10, 2, 3, 5, 3, 7, 5, X, X, X, X, X, X, X},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, X, X, X, X},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, X, X, X, X},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, X},
{1, 3, 5, 3, 7, 5, X, X, X, X, X, X, X, X, X, X},
{0, 8, 7, 0, 7, 1, 1, 7, 5, X, X, X, X, X, X, X},
{9, 0, 3, 9, 3, 5, 5, 3, 7, X, X, X, X, X, X, X},
{9, 8, 7, 5, 9, 7, X, X, X, X, X, X, X, X, X, X},
{5, 8, 4, 5, 10, 8, 10, 11, 8, X, X, X, X, X, X, X},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, X, X, X, X},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, X, X, X, X},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, X},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, X, X, X, X},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, X},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, X},
{9, 4, 5, 2, 11, 3, X, X, X, X, X, X, X, X, X, X},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, X, X, X, X},
{5, 10, 2, 5, 2, 4, 4, 2, 0, X, X, X, X, X, X, X},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, X},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, X, X, X, X},
{8, 4, 5, 8, 5, 3, 3, 5, 1, X, X, X, X, X, X, X},
{0, 4, 5, 1, 0, 5, X, X, X, X, X, X, X, X, X, X},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, X, X, X, X},
{9, 4, 5, X, X, X, X, X, X, X, X, X, X, X, X, X},
{4, 11, 7, 4, 9, 11, 9, 10, 11, X, X, X, X, X, X, X},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, X, X, X, X},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, X, X, X, X},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, X},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, X, X, X, X},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, X},
{11, 7, 4, 11, 4, 2, 2, 4, 0, X, X, X, X, X, X, X},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, X, X, X, X},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, X, X, X, X},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, X},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, X},
{1, 10, 2, 8, 7, 4, X, X, X, X, X, X, X, X, X, X},
{4, 9, 1, 4, 1, 7, 7, 1, 3, X, X, X, X, X, X, X},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, X, X, X, X},
{4, 0, 3, 7, 4, 3, X, X, X, X, X, X, X, X, X, X},
{4, 8, 7, X, X, X, X, X, X, X, X, X, X, X, X, X},
{9, 10, 8, 10, 11, 8, X, X, X, X, X, X, X, X, X, X},
{3, 0, 9, 3, 9, 11, 11, 9, 10, X, X, X, X, X, X, X},
{0, 1, 10, 0, 10, 8, 8, 10, 11, X, X, X, X, X, X, X},
{3, 1, 10, 11, 3, 10, X, X, X, X, X, X, X, X, X, X},
{1, 2, 11, 1, 11, 9, 9, 11, 8, X, X, X, X, X, X, X},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, X, X, X, X},
{0, 2, 11, 8, 0, 11, X, X, X, X, X, X, X, X, X, X},
{3, 2, 11, X, X, X, X, X, X, X, X, X, X, X, X, X},
{2, 3, 8, 2, 8, 10, 10, 8, 9, X, X, X, X, X, X, X},
{9, 10, 2, 0, 9, 2, X, X, X, X, X, X, X, X, X, X},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, X, X, X, X},
{1, 10, 2, X, X, X, X, X, X, X, X, X, X, X, X, X},
{1, 3, 8, 9, 1, 8, X, X, X, X, X, X, X, X, X, X},
{0, 9, 1, X, X, X, X, X, X, X, X, X, X, X, X, X},
{0, 3, 8, X, X, X, X, X, X, X, X, X, X, X, X, X},
{X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X}
};
#undef X
// number of vertices for each case above
uint numVertsTable[256] = {
0,
3,
3,
6,
3,
6,
6,
9,
3,
6,
6,
9,
6,
9,
9,
6,
3,
6,
6,
9,
6,
9,
9,
12,
6,
9,
9,
12,
9,
12,
12,
9,
3,
6,
6,
9,
6,
9,
9,
12,
6,
9,
9,
12,
9,
12,
12,
9,
6,
9,
9,
6,
9,
12,
12,
9,
9,
12,
12,
9,
12,
15,
15,
6,
3,
6,
6,
9,
6,
9,
9,
12,
6,
9,
9,
12,
9,
12,
12,
9,
6,
9,
9,
12,
9,
12,
12,
15,
9,
12,
12,
15,
12,
15,
15,
12,
6,
9,
9,
12,
9,
12,
6,
9,
9,
12,
12,
15,
12,
15,
9,
6,
9,
12,
12,
9,
12,
15,
9,
6,
12,
15,
15,
12,
15,
6,
12,
3,
3,
6,
6,
9,
6,
9,
9,
12,
6,
9,
9,
12,
9,
12,
12,
9,
6,
9,
9,
12,
9,
12,
12,
15,
9,
6,
12,
9,
12,
9,
15,
6,
6,
9,
9,
12,
9,
12,
12,
15,
9,
12,
12,
15,
12,
15,
15,
12,
9,
12,
12,
9,
12,
15,
15,
12,
12,
9,
15,
6,
15,
12,
6,
3,
6,
9,
9,
12,
9,
12,
12,
15,
9,
12,
12,
15,
6,
9,
9,
6,
9,
12,
12,
15,
12,
15,
15,
6,
12,
9,
15,
12,
9,
6,
12,
3,
9,
12,
12,
15,
12,
15,
9,
12,
12,
15,
15,
6,
9,
12,
6,
3,
6,
9,
9,
6,
9,
12,
6,
3,
9,
6,
12,
3,
6,
3,
3,
0,
};
| {
"pile_set_name": "Github"
} |
#include "TaskScheduler.h"
#if defined(__linux) || defined(__linux__)
#include <signal.h>
#endif
using namespace xop;
TaskScheduler::TaskScheduler(int id)
: id_(id)
, is_shutdown_(false)
, wakeup_pipe_(new Pipe())
, trigger_events_(new xop::RingBuffer<TriggerEvent>(kMaxTriggetEvents))
{
static std::once_flag flag;
std::call_once(flag, [] {
#if defined(WIN32) || defined(_WIN32)
WSADATA wsa_data;
if (WSAStartup(MAKEWORD(2, 2), &wsa_data)) {
WSACleanup();
}
#endif
});
if (wakeup_pipe_->Create()) {
wakeup_channel_.reset(new Channel(wakeup_pipe_->Read()));
wakeup_channel_->EnableReading();
wakeup_channel_->SetReadCallback([this]() { this->Wake(); });
}
}
TaskScheduler::~TaskScheduler()
{
}
void TaskScheduler::Start()
{
#if defined(__linux) || defined(__linux__)
signal(SIGPIPE, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGUSR1, SIG_IGN);
signal(SIGTERM, SIG_IGN);
signal(SIGKILL, SIG_IGN);
#endif
is_shutdown_ = false;
while (!is_shutdown_) {
this->HandleTriggerEvent();
this->timer_queue_.HandleTimerEvent();
int64_t timeout = this->timer_queue_.GetTimeRemaining();
this->HandleEvent((int)timeout);
}
}
void TaskScheduler::Stop()
{
is_shutdown_ = true;
char event = kTriggetEvent;
wakeup_pipe_->Write(&event, 1);
}
TimerId TaskScheduler::AddTimer(TimerEvent timerEvent, uint32_t msec)
{
TimerId id = timer_queue_.AddTimer(timerEvent, msec);
return id;
}
void TaskScheduler::RemoveTimer(TimerId timerId)
{
timer_queue_.RemoveTimer(timerId);
}
bool TaskScheduler::AddTriggerEvent(TriggerEvent callback)
{
if (trigger_events_->size() < kMaxTriggetEvents) {
std::lock_guard<std::mutex> lock(mutex_);
char event = kTriggetEvent;
trigger_events_->push(std::move(callback));
wakeup_pipe_->Write(&event, 1);
return true;
}
return false;
}
void TaskScheduler::Wake()
{
char event[10] = { 0 };
while (wakeup_pipe_->Read(event, 10) > 0);
}
void TaskScheduler::HandleTriggerEvent()
{
do
{
TriggerEvent callback;
if (trigger_events_->pop(callback)) {
callback();
}
} while (trigger_events_->size() > 0);
} | {
"pile_set_name": "Github"
} |
module VirtualCss exposing (StyleSheet, clear, delete, insert)
import Native.VirtualCss
type StyleSheet
= StyleSheet
insert : String -> Int -> Int
insert =
Native.VirtualCss.insert
delete : Int -> Int
delete =
Native.VirtualCss.delete
clear : () -> ()
clear =
Native.VirtualCss.clear
| {
"pile_set_name": "Github"
} |
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. 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.
*
* @(#)open.c 8.1 (Berkeley) 6/11/93
*
*
* Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Author: Alessandro Forin
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or [email protected]
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include <stand/stand.h>
#include <stand/ufs.h>
/*
* File primitives proper
*/
struct fs_ops file_system[] = {
{ ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat }
};
#define NFSYS (sizeof(file_system) / sizeof(struct fs_ops))
struct open_file files[SOPEN_MAX];
open(fname, mode)
char *fname;
int mode;
{
register struct open_file *f;
register int fd, i, error;
char *file;
/* find a free file descriptor */
for (fd = 0, f = files; fd < SOPEN_MAX; fd++, f++)
if (f->f_flags == 0)
goto fnd;
return (-1);
fnd:
/*
* Try to open the device.
* Convert open mode (0,1,2) to F_READ, F_WRITE.
*/
f->f_flags = mode + 1;
f->f_dev = (struct devsw *)0;
file = (char *)0;
error = devopen(f, fname, &file);
if (error || f->f_dev == (struct devsw *)0)
goto err;
/* see if we opened a raw device; otherwise, 'file' is the file name. */
if (file == (char *)0) {
f->f_flags |= F_RAW;
return (0);
}
/* pass file name to the different filesystem open routines */
for (i = 0; i < NFSYS; i++) {
/* convert mode (0,1,2) to FREAD, FWRITE. */
error = (file_system[i].open)(file, f);
if (error == 0) {
f->f_ops = &file_system[i];
return (fd);
}
}
if (!error)
error = ENOENT;
err:
errno = error;
return (-1);
}
| {
"pile_set_name": "Github"
} |
/**
* Copyright 2019 The AMP HTML 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.
*/
import React from 'react';
import {AmpForm} from '@ampproject/toolbox-next-amp';
export const config = {amp: true};
export default () => (
<AmpForm method='post' action-xhr='/submit' target='_top' className='my-form'>
<input type='text' name='email' />
<input type='submit' value='Subscribe' />
</AmpForm>
);
| {
"pile_set_name": "Github"
} |
// Instantiation of vpgl_proj_camera<double>
#include "vpgl/vpgl_proj_camera.hxx"
vpgl_PROJ_CAMERA_INSTANTIATE(double);
| {
"pile_set_name": "Github"
} |
// Copyright 2016 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 gensupport
import (
"math/rand"
"time"
)
// BackoffStrategy defines the set of functions that a backoff-er must
// implement.
type BackoffStrategy interface {
// Pause returns the duration of the next pause and true if the operation should be
// retried, or false if no further retries should be attempted.
Pause() (time.Duration, bool)
// Reset restores the strategy to its initial state.
Reset()
}
// ExponentialBackoff performs exponential backoff as per https://en.wikipedia.org/wiki/Exponential_backoff.
// The initial pause time is given by Base.
// Once the total pause time exceeds Max, Pause will indicate no further retries.
type ExponentialBackoff struct {
Base time.Duration
Max time.Duration
total time.Duration
n uint
}
// Pause returns the amount of time the caller should wait.
func (eb *ExponentialBackoff) Pause() (time.Duration, bool) {
if eb.total > eb.Max {
return 0, false
}
// The next pause is selected from randomly from [0, 2^n * Base).
d := time.Duration(rand.Int63n((1 << eb.n) * int64(eb.Base)))
eb.total += d
eb.n++
return d, true
}
// Reset resets the backoff strategy such that the next Pause call will begin
// counting from the start. It is not safe to call concurrently with Pause.
func (eb *ExponentialBackoff) Reset() {
eb.n = 0
eb.total = 0
}
| {
"pile_set_name": "Github"
} |
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// 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/>.
package probe
import (
"context"
"fmt"
"strings"
"github.com/goodrain/rainbond/node/nodem/client"
"github.com/goodrain/rainbond/node/nodem/service"
)
//Probe probe
type Probe interface {
Check()
Stop()
}
//CreateProbe create probe
func CreateProbe(ctx context.Context, hostNode *client.HostNode, statusChan chan *service.HealthStatus, v *service.Service) (Probe, error) {
ctx, cancel := context.WithCancel(ctx)
model := strings.ToLower(strings.TrimSpace(v.ServiceHealth.Model))
switch model {
case "http":
return &HttpProbe{
Name: v.ServiceHealth.Name,
Address: v.ServiceHealth.Address,
Ctx: ctx,
Cancel: cancel,
ResultsChan: statusChan,
TimeInterval: v.ServiceHealth.TimeInterval,
HostNode: hostNode,
MaxErrorsNum: v.ServiceHealth.MaxErrorsNum,
}, nil
case "tcp":
return &TcpProbe{
Name: v.ServiceHealth.Name,
Address: v.ServiceHealth.Address,
Ctx: ctx,
Cancel: cancel,
ResultsChan: statusChan,
TimeInterval: v.ServiceHealth.TimeInterval,
HostNode: hostNode,
MaxErrorsNum: v.ServiceHealth.MaxErrorsNum,
}, nil
case "cmd":
return &ShellProbe{
Name: v.ServiceHealth.Name,
Address: v.ServiceHealth.Address,
Ctx: ctx,
Cancel: cancel,
ResultsChan: statusChan,
TimeInterval: v.ServiceHealth.TimeInterval,
HostNode: hostNode,
MaxErrorsNum: v.ServiceHealth.MaxErrorsNum,
}, nil
default:
cancel()
return nil, fmt.Errorf("service %s probe mode %s not support ", v.Name, model)
}
}
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable: no">
<title>about:security-levels</title>
<style>
body {
margin: 1em;
font-family: sans-serif;
font-size: 13pt;
color: #4a4a4a;
}
h1 {
text-align: center;
font-size: 35pt;
font-weight: bold;
color: #4a4a4a;
}
h2 {
font-size: 18pt;
font-weight: bold;
color: #4a4a4a;
}
h3 {
text-transform: uppercase;
font-size: 12pt;
font-weight: bold;
color: #720e95;
}
a {
font-weight: bold;
color: #720e95;
}
.dt {
font-weight: bold;
font-style: normal;
}
.outcome {
font-size: 14pt;
font-weight: bold;
color: #4a4a4a;
}
.warning {
font-weight: bold;
}
@media (prefers-color-scheme: dark) {
body {
background-color: black;
}
body, h1, h2, .outcome {
color: white;
}
a, h3 {
color: #c2a0ca;
}
}
</style>
</head>
<body>
<h1>Cấp độ bảo mật</h1>
<p>Thông thường, cấp độ bảo mật bạn chọn cho từng trang web có ảnh hưởng trực tiếp đến hiệu suất trang web.
Mỗi cấp độ sẽ được chú thích bên dưới
Một số lớp bảo vệ có thể được bỏ qua hoặc sửa đổi bằng cách sửa cài đặt bảo mật của bạn.</p>
<svg width="38" height="48" viewbox="0 0 38 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><lineargradient x1="0.5" y1="0" x2="0.5" y2="1" id="linearGradient-1"><stop stop-color="#FFD300" offset="0%"></stop><stop stop-color="#D5A900" offset="100%"></stop></lineargradient><lineargradient xlink:href="#linearGradient-1" id="linearGradient23" x1="10.677078" y1="-9.3151298e-10" x2="10.677078" y2="21.354156" gradienttransform="scale(0.88975652,1.123903)" gradientunits="userSpaceOnUse"></lineargradient><lineargradient xlink:href="#linearGradient-1" id="linearGradient25" x1="10.677078" y1="-9.3151298e-10" x2="10.677078" y2="21.354156" gradienttransform="scale(0.88975652,1.123903)" gradientunits="userSpaceOnUse"></lineargradient><lineargradient xlink:href="#linearGradient-1" id="linearGradient27" x1="78.111259" y1="215.32108" x2="78.111259" y2="236.67523" gradienttransform="scale(0.88975652,1.123903)" gradientunits="userSpaceOnUse"></lineargradient></defs><g style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1" transform="scale(2)"><g transform="translate(-60,-242)" style="fill:url(#linearGradient27);fill-rule:nonzero"><g transform="translate(60,242)" style="fill:url(#linearGradient25)"><path d="m 9.4165188,0.00409302 c 0.097455,-0.01142058 0.1962613,0.00114822 0.2875828,0.03658222 v 0 L 18.610352,3.2599103 C 18.844046,3.3442585 18.999594,3.5633131 19,3.8086436 v 0 9.6577194 c 0,2.288086 -1.308833,4.185357 -3.070816,5.843995 -1.761953,1.658638 -4.009682,3.126462 -6.0859371,4.581937 -0.2056467,0.143607 -0.4808471,0.143607 -0.6864938,0 C 7.0804984,22.43682 4.8327687,20.968996 3.0708156,19.310358 1.3088328,17.65172 0,15.754449 0,13.466363 v 0 -9.6577194 C 4.0600141e-4,3.5633131 0.15595383,3.3442585 0.38964844,3.2599103 v 0 L 9.2958984,0.04067524 C 9.3346729,0.02429203 9.375108,0.01202872 9.4165188,0.00409302 Z M 10.823,7 H 9.003 L 6,9.535 7.105,10.809 8.951,9.184 v 7.02 h 1.872 z" style="fill:url(#linearGradient23)"></path></g></g></g></svg><p class="outcome">Các trang web có thể sẽ hỏng. Nhưng bạn đạt được độ bảo mật cao.</p>
<p>Nhiều tính năng của trang web sẽ bị vô hiệu hoá và mọi thứ được dẫn qua mạng Tor.
Nhiều trang web sẽ không hoạt động hoặc hiển thị kém, nhưng danh tính của bạn
sẽ được bảo vệ khỏi những kẻ thù hung hăng nhất.</p>
<p><em class="dt">Khi nào nên sử dụng:</em>
Khi bạn lo ngại kẻ xấu phát hiện danh tính của bạn và
theo dõi hay cản trở hoạt động của bạn.</p>
<p><em class="dt">Quy tắc nạp nội dung:</em>
Nghiêm ngặt</p>
<ul>
<li>Không cho phép JavaScript</li>
<li>Vô hiệu hóa WebSockets, định vị và XHR</li>
<li>Không cho phép video hay âm thanh</li>
</ul>
<p><em class="dt">Chặn Universal Link:</em>
Bật (trang web không thể yêu cầu mở trong ứng dụng khác)</p>
<p><em class="dt">Chặn WebRTC:</em>
Bật</p>
<p><em class="dt">Chặn nội dung hỗn hợp:</em>
Tắt (không cho phép hỗn hợp HTTP/HTTPS)</p>
<p><em class="dt">Chặn quảng cáo và cửa sổ bật lên:</em>
Bật</p>
<svg width="38" height="48" viewbox="0 0 38 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><lineargradient x1="0.5" y1="0" x2="0.5" y2="1" id="linearGradient-2"><stop stop-color="#CFCFCF" offset="0%"></stop><stop stop-color="#6F6F6F" offset="100%"></stop></lineargradient><lineargradient xlink:href="#linearGradient-2" id="linearGradient26" x1="78.033737" y1="291.39529" x2="78.033737" y2="312.74945" gradienttransform="scale(0.88975659,1.1239029)" gradientunits="userSpaceOnUse"></lineargradient><lineargradient xlink:href="#linearGradient-2" id="linearGradient28" x1="78.033737" y1="291.39529" x2="78.033737" y2="312.74945" gradienttransform="scale(0.88975659,1.1239029)" gradientunits="userSpaceOnUse"></lineargradient></defs><g style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1" transform="matrix(2,0,0,2,-1.8844248,-0.97033648)"><g transform="translate(-59,-327)" style="fill:url(#linearGradient28);fill-rule:nonzero"><path d="m 69.226933,327.54068 -8.90625,3.21923 c -0.233695,0.0844 -0.389243,0.3034 -0.389648,0.54873 v 9.65772 c 0,2.28809 1.308832,4.18536 3.070815,5.844 1.761953,1.65864 4.009683,3.12646 6.085938,4.58193 0.205646,0.14361 0.480847,0.14361 0.686493,0 2.076255,-1.45547 4.323985,-2.92329 6.085938,-4.58193 1.761983,-1.65864 3.070815,-3.55591 3.070815,-5.844 v -9.65772 c -4.06e-4,-0.24533 -0.155953,-0.46438 -0.389648,-0.54873 l -8.90625,-3.21923 c -0.09132,-0.0354 -0.190128,-0.048 -0.287583,-0.0366 -0.04141,0.008 -0.08185,0.0202 -0.12062,0.0366 z m -3.295899,14.25232 3.575,-3.211 c 0.182001,-0.16467 0.364,-0.351 0.546001,-0.559 0.182,-0.208 0.272999,-0.45067 0.272999,-0.728 0,-0.312 -0.112665,-0.55683 -0.338,-0.7345 -0.225334,-0.17767 -0.489665,-0.2665 -0.793,-0.2665 -0.364001,0 -0.647832,0.11267 -0.8515,0.338 -0.203667,0.22533 -0.318499,0.50266 -0.344499,0.832 l -1.950001,-0.143 c 0.026,-0.47667 0.125666,-0.8905 0.299001,-1.2415 0.173334,-0.351 0.402998,-0.6435 0.688999,-0.8775 0.286002,-0.234 0.621832,-0.4095 1.007501,-0.5265 0.385668,-0.117 0.803831,-0.1755 1.254499,-0.1755 0.416003,0 0.805999,0.0585 1.170001,0.1755 0.364001,0.117 0.680331,0.29033 0.948999,0.52 0.268669,0.22967 0.478833,0.51783 0.6305,0.8645 0.151668,0.34667 0.227501,0.74966 0.227501,1.209 0,0.29467 -0.03033,0.56117 -0.091,0.7995 -0.06067,0.23833 -0.145166,0.455 -0.2535,0.65 -0.108333,0.195 -0.236165,0.37483 -0.3835,0.5395 -0.147334,0.16467 -0.307665,0.325 -0.481,0.481 l -2.795,2.405 h 4.082001 v 1.716 h -6.422001 z" style="fill:url(#linearGradient26)"></path></g></g></svg><p class="outcome">Hoạt động khá tốt. Danh tính của bạn được gần như được bảo vệ hoàn toàn.</p>
<p>Một số tính năng của trang web sẽ bị vô hiệu hoá và mọi thứ được dẫn qua mạng Tor.
Một số trang web sẽ hoạt động kém.</p>
<p><em class="dt">Khi nào nên sử dụng:</em>
Khi bạn cần vượt qua kiểm duyệt và tránh kẻ xấu theo dõi
hoạt động của bạn, nhưng không quá lo ngại về rò rỉ danh tính tới kẻ xấu.</p>
<p><em class="dt">Quy tắc nạp nội dung:</em>
Trung bình</p>
<ul>
<li>Cho phép một vài JavaScript</li>
<li>Vô hiệu hóa WebSockets, định vị và XHR</li>
<li>Không cho phép video hay âm thanh</li>
</ul>
<p><em class="dt">Chặn Universal Link:</em>
Bật </p>
<p><em class="dt">Chặn WebRTC:</em>
Bật</p>
<p><em class="dt">Chặn nội dung hỗn hợp:</em>
Bật</p>
<p><em class="dt">Chặn quảng cáo và cửa sổ bật lên:</em>
Bật</p>
<svg width="38" height="48" viewbox="0 0 38 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><lineargradient x1="0.5" y1="0" x2="0.5" y2="1" id="linearGradient-3"><stop stop-color="#E37C00" offset="0%"></stop><stop stop-color="#A05E0C" offset="100%"></stop></lineargradient><lineargradient xlink:href="#linearGradient-3" id="linearGradient22" x1="78.033783" y1="367.02438" x2="78.033783" y2="388.37854" gradienttransform="scale(0.88975611,1.1239035)" gradientunits="userSpaceOnUse"></lineargradient><lineargradient xlink:href="#linearGradient-3" id="linearGradient24" x1="78.033783" y1="367.02438" x2="78.033783" y2="388.37854" gradienttransform="scale(0.88975611,1.1239035)" gradientunits="userSpaceOnUse"></lineargradient></defs><g style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1" transform="matrix(2,0,0,2,-1.8844248,-0.97034648)"><g transform="translate(-59,-412)" style="fill:url(#linearGradient24);fill-rule:nonzero"><path d="m 69.347553,412.50409 c 0.09745,-0.0114 0.196262,10e-4 0.287583,0.0366 v 0 l 8.90625,3.21923 c 0.233695,0.0844 0.389242,0.3034 0.389648,0.54873 v 0 9.65772 c 0,2.28809 -1.308832,4.18536 -3.070815,5.844 -1.761953,1.65864 -4.009683,3.12646 -6.085938,4.58193 -0.205646,0.14361 -0.480847,0.14361 -0.686493,0 -2.076255,-1.45547 -4.323985,-2.92329 -6.085938,-4.58193 -1.761983,-1.65864 -3.070815,-3.55591 -3.070815,-5.844 v 0 -9.65772 c 4.05e-4,-0.24533 0.155953,-0.46438 0.389648,-0.54873 v 0 l 8.90625,-3.21923 c 0.03877,-0.0164 0.07921,-0.0287 0.12062,-0.0366 z m -0.206613,7.44419 c -0.396523,0 -0.773215,0.0419 -1.130087,0.12579 -0.356871,0.0839 -0.680694,0.21407 -0.971478,0.39062 -0.290784,0.17655 -0.541912,0.40827 -0.753391,0.69517 -0.21148,0.2869 -0.370087,0.63338 -0.475826,1.03945 v 0 l 2.180869,0.45021 c 0.06168,-0.24718 0.193854,-0.45462 0.396522,-0.62235 0.202668,-0.16772 0.458201,-0.25158 0.766609,-0.25158 0.32603,0 0.60139,0.0927 0.826087,0.27806 0.224696,0.18538 0.337043,0.41931 0.337043,0.7018 0,0.22069 -0.04406,0.39945 -0.132174,0.53627 -0.08812,0.13683 -0.204869,0.24276 -0.350261,0.3178 -0.145392,0.075 -0.306202,0.12579 -0.482435,0.15227 -0.176232,0.0265 -0.356868,0.0397 -0.541912,0.0397 v 0 h -0.647653 v 1.72138 h 0.462609 c 0.220291,0 0.440579,0.007 0.66087,0.0199 0.220291,0.0132 0.418549,0.0552 0.594782,0.12579 0.176233,0.0706 0.31942,0.17876 0.429565,0.32442 0.110146,0.14565 0.165218,0.35089 0.165218,0.61572 0,0.3531 -0.103535,0.64221 -0.310609,0.86731 -0.207073,0.2251 -0.526491,0.33765 -0.958261,0.33765 -0.422958,0 -0.742375,-0.0971 -0.958261,-0.29131 -0.215885,-0.1942 -0.359072,-0.45903 -0.429565,-0.79448 v 0 l -2.088348,0.48993 c 0.193856,0.83863 0.592577,1.45214 1.196174,1.84055 0.603598,0.38842 1.323938,0.58263 2.161044,0.58263 0.458205,0 0.892172,-0.0574 1.301913,-0.17214 0.409741,-0.11476 0.766607,-0.2891 1.070609,-0.52304 0.304001,-0.23393 0.546317,-0.52744 0.726956,-0.88055 0.180639,-0.3531 0.270956,-0.76358 0.270956,-1.23145 0,-0.27365 -0.03965,-0.53406 -0.118956,-0.78124 -0.07931,-0.24717 -0.193854,-0.46786 -0.343652,-0.66207 -0.149798,-0.1942 -0.332637,-0.35751 -0.548522,-0.48993 -0.215885,-0.13241 -0.46481,-0.21627 -0.746783,-0.25158 v 0 -0.0397 c 0.519887,-0.10593 0.916405,-0.34427 1.189566,-0.71503 0.273161,-0.37076 0.409739,-0.81655 0.409739,-1.33738 0,-0.45021 -0.08591,-0.83862 -0.257739,-1.16524 -0.171827,-0.32663 -0.403129,-0.59807 -0.693913,-0.81435 -0.290784,-0.21628 -0.627824,-0.37517 -1.011131,-0.47669 -0.383306,-0.10152 -0.782027,-0.15227 -1.196174,-0.15227 z" style="fill:url(#linearGradient22)"></path></g></g></svg><p class="outcome">Dễ dãi nhưng có thể nguy hiểm.</p>
<p>Hầu hết tính năng của trang web được cho phép và một số thứ không được dẫn qua mạng Tor.
WebRTC, gọi thoại và gọi video kết nối qua đường truyền của bạn (nên có thể bị kiểm duyệt)
<span class="warning">Cảnh báo:</span>Danh tính và địa chỉ IP của bạn có thể bị lộ trong một số trường hợp.</p>
<p><em class="dt">Khi nào nên sử dụng:</em>
Khi bạn lo ngại về hoạt động của bạn bị theo dõi, nhưng chấp nhận rằng không thể tránh hoàn toàn.</p>
<p><em class="dt">Quy tắc nạp nội dung:</em>
Không hạn chế</p>
<ul>
<li>Cho phép JavaScript (và tất cả tính năng của nó) </li>
<li>Cho phép video và âm thanh</li>
</ul>
<p><em class="dt">Chặn Universal Link:</em>
Bật </p>
<p><em class="dt">Chặn WebRTC:</em>
Tắt</p>
<p><em class="dt">Chặn nội dung hỗn hợp:</em>
Tắt</p>
<p><em class="dt">Chặn quảng cáo và cửa sổ bật lên:</em>
Bật</p>
</body>
</html>
| {
"pile_set_name": "Github"
} |
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4=
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
| {
"pile_set_name": "Github"
} |
/* qhasm: enter ge_madd */
/* qhasm: fe X1 */
/* qhasm: fe Y1 */
/* qhasm: fe Z1 */
/* qhasm: fe T1 */
/* qhasm: fe ypx2 */
/* qhasm: fe ymx2 */
/* qhasm: fe xy2d2 */
/* qhasm: fe X3 */
/* qhasm: fe Y3 */
/* qhasm: fe Z3 */
/* qhasm: fe T3 */
/* qhasm: fe YpX1 */
/* qhasm: fe YmX1 */
/* qhasm: fe A */
/* qhasm: fe B */
/* qhasm: fe C */
/* qhasm: fe D */
/* qhasm: YpX1 = Y1+X1 */
/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
fe_add(r->X,p->Y,p->X);
/* qhasm: YmX1 = Y1-X1 */
/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
fe_sub(r->Y,p->Y,p->X);
/* qhasm: A = YpX1*ypx2 */
/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<ypx2=fe#15); */
/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<ypx2=q->yplusx); */
fe_mul(r->Z,r->X,q->yplusx);
/* qhasm: B = YmX1*ymx2 */
/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<ymx2=fe#16); */
/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<ymx2=q->yminusx); */
fe_mul(r->Y,r->Y,q->yminusx);
/* qhasm: C = xy2d2*T1 */
/* asm 1: fe_mul(>C=fe#4,<xy2d2=fe#17,<T1=fe#14); */
/* asm 2: fe_mul(>C=r->T,<xy2d2=q->xy2d,<T1=p->T); */
fe_mul(r->T,q->xy2d,p->T);
/* qhasm: D = 2*Z1 */
/* asm 1: fe_add(>D=fe#5,<Z1=fe#13,<Z1=fe#13); */
/* asm 2: fe_add(>D=t0,<Z1=p->Z,<Z1=p->Z); */
fe_add(t0,p->Z,p->Z);
/* qhasm: X3 = A-B */
/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
fe_sub(r->X,r->Z,r->Y);
/* qhasm: Y3 = A+B */
/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
fe_add(r->Y,r->Z,r->Y);
/* qhasm: Z3 = D+C */
/* asm 1: fe_add(>Z3=fe#3,<D=fe#5,<C=fe#4); */
/* asm 2: fe_add(>Z3=r->Z,<D=t0,<C=r->T); */
fe_add(r->Z,t0,r->T);
/* qhasm: T3 = D-C */
/* asm 1: fe_sub(>T3=fe#4,<D=fe#5,<C=fe#4); */
/* asm 2: fe_sub(>T3=r->T,<D=t0,<C=r->T); */
fe_sub(r->T,t0,r->T);
/* qhasm: return */
| {
"pile_set_name": "Github"
} |
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef PP_PCIELANES_H
#define PP_PCIELANES_H
extern uint8_t encode_pcie_lane_width(uint32_t num_lanes);
extern uint8_t decode_pcie_lane_width(uint32_t num_lanes);
#endif
| {
"pile_set_name": "Github"
} |
Please post support requests and questions in the DataTables forums at https://datatables.net/forums. Support requests posted here will be closed. This allows all questions to be located in a single, searchable, location.
When you post your question in the DataTables forums, please ensure that you include a link to the page showing the issue so it can be debugged.
| {
"pile_set_name": "Github"
} |
//
// ControlProperty.swift
// RxCocoa
//
// Created by Krunoslav Zaher on 8/28/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import RxSwift
/// Protocol that enables extension of `ControlProperty`.
public protocol ControlPropertyType : ObservableType, ObserverType {
/// - returns: `ControlProperty` interface
func asControlProperty() -> ControlProperty<E>
}
/**
Trait for `Observable`/`ObservableType` that represents property of UI element.
Sequence of values only represents initial control value and user initiated value changes.
Programmatic value changes won't be reported.
It's properties are:
- it never fails
- `shareReplay(1)` behavior
- it's stateful, upon subscription (calling subscribe) last element is immediately replayed if it was produced
- it will `Complete` sequence on control being deallocated
- it never errors out
- it delivers events on `MainScheduler.instance`
**The implementation of `ControlProperty` will ensure that sequence of values is being subscribed on main scheduler
(`subscribeOn(ConcurrentMainScheduler.instance)` behavior).**
**It is implementor's responsibility to make sure that that all other properties enumerated above are satisfied.**
**If they aren't, then using this trait communicates wrong properties and could potentially break someone's code.**
**In case `values` observable sequence that is being passed into initializer doesn't satisfy all enumerated
properties, please don't use this trait.**
*/
public struct ControlProperty<PropertyType> : ControlPropertyType {
public typealias E = PropertyType
let _values: Observable<PropertyType>
let _valueSink: AnyObserver<PropertyType>
/// Initializes control property with a observable sequence that represents property values and observer that enables
/// binding values to property.
///
/// - parameter values: Observable sequence that represents property values.
/// - parameter valueSink: Observer that enables binding values to control property.
/// - returns: Control property created with a observable sequence of values and an observer that enables binding values
/// to property.
public init<V: ObservableType, S: ObserverType>(values: V, valueSink: S) where E == V.E, E == S.E {
_values = values.subscribeOn(ConcurrentMainScheduler.instance)
_valueSink = valueSink.asObserver()
}
/// Subscribes an observer to control property values.
///
/// - parameter observer: Observer to subscribe to property values.
/// - returns: Disposable object that can be used to unsubscribe the observer from receiving control property values.
public func subscribe<O : ObserverType>(_ observer: O) -> Disposable where O.E == E {
return _values.subscribe(observer)
}
/// `ControlEvent` of user initiated value changes. Every time user updates control value change event
/// will be emitted from `changed` event.
///
/// Programmatic changes to control value won't be reported.
///
/// It contains all control property values except for first one.
///
/// The name only implies that sequence element will be generated once user changes a value and not that
/// adjacent sequence values need to be different (e.g. because of interaction between programmatic and user updates,
/// or for any other reason).
public var changed: ControlEvent<PropertyType> {
get {
return ControlEvent(events: _values.skip(1))
}
}
/// - returns: `Observable` interface.
public func asObservable() -> Observable<E> {
return _values
}
/// - returns: `ControlProperty` interface.
public func asControlProperty() -> ControlProperty<E> {
return self
}
/// Binds event to user interface.
///
/// - In case next element is received, it is being set to control value.
/// - In case error is received, DEBUG buids raise fatal error, RELEASE builds log event to standard output.
/// - In case sequence completes, nothing happens.
public func on(_ event: Event<E>) {
switch event {
case .error(let error):
bindingError(error)
case .next:
_valueSink.on(event)
case .completed:
_valueSink.on(event)
}
}
}
extension ControlPropertyType where E == String? {
/// Transforms control property of type `String?` into control property of type `String`.
public var orEmpty: ControlProperty<String> {
let original: ControlProperty<String?> = self.asControlProperty()
let values: Observable<String> = original._values.map { $0 ?? "" }
let valueSink: AnyObserver<String> = original._valueSink.mapObserver { $0 }
return ControlProperty<String>(values: values, valueSink: valueSink)
}
}
| {
"pile_set_name": "Github"
} |
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class NSAttributedString, NSMutableArray, NSMutableString, NSString;
@interface CIMMecabraZhuyinEngine : NSObject
{
id <CIMMecabraZhuyinEngineDelegate> _delegate;
unsigned short _syllableConsonantBuffer;
unsigned short _syllableMedialBuffer;
unsigned short _syllableVowelBuffer;
unsigned short _syllableToneBuffer;
NSMutableArray *_userWordReadings;
NSMutableString *_userWordReadingBuffer;
unsigned long long _inputCursorLocation;
NSMutableString *_inputBuffer;
NSMutableArray *_inputBufferSplittingLengths;
NSMutableArray *_composedBufferSplittingLengths;
NSMutableArray *_confirmedCandidates;
NSMutableString *_composedBuffer;
BOOL _leftSingleQuotationMarkInserted;
BOOL _leftDoubleQuotationMarkInserted;
}
@property BOOL leftDoubleQuotationMarkInserted; // @synthesize leftDoubleQuotationMarkInserted=_leftDoubleQuotationMarkInserted;
@property BOOL leftSingleQuotationMarkInserted; // @synthesize leftSingleQuotationMarkInserted=_leftSingleQuotationMarkInserted;
@property(retain) NSMutableString *composedBuffer; // @synthesize composedBuffer=_composedBuffer;
@property(retain) NSMutableArray *confirmedCandidates; // @synthesize confirmedCandidates=_confirmedCandidates;
@property(retain) NSMutableArray *composedBufferSplittingLengths; // @synthesize composedBufferSplittingLengths=_composedBufferSplittingLengths;
@property(retain) NSMutableArray *inputBufferSplittingLengths; // @synthesize inputBufferSplittingLengths=_inputBufferSplittingLengths;
@property(retain) NSMutableString *inputBuffer; // @synthesize inputBuffer=_inputBuffer;
@property unsigned long long inputCursorLocation; // @synthesize inputCursorLocation=_inputCursorLocation;
@property(retain) NSMutableString *userWordReadingBuffer; // @synthesize userWordReadingBuffer=_userWordReadingBuffer;
@property(retain) NSMutableArray *userWordReadings; // @synthesize userWordReadings=_userWordReadings;
@property unsigned short syllableToneBuffer; // @synthesize syllableToneBuffer=_syllableToneBuffer;
@property unsigned short syllableVowelBuffer; // @synthesize syllableVowelBuffer=_syllableVowelBuffer;
@property unsigned short syllableMedialBuffer; // @synthesize syllableMedialBuffer=_syllableMedialBuffer;
@property unsigned short syllableConsonantBuffer; // @synthesize syllableConsonantBuffer=_syllableConsonantBuffer;
@property id <CIMMecabraZhuyinEngineDelegate> delegate; // @synthesize delegate=_delegate;
@property(readonly) NSString *syllableBuffersAggregateString;
@property(readonly) unsigned long long syllableBuffersAggregateLength;
@property(readonly) BOOL syllableBuffersOccupied;
@property(readonly) BOOL syllableBuffersValid;
@property(readonly) unsigned long long composedBufferCursorLocation;
@property(readonly) unsigned long long bufferSplittingLengthsIndex;
@property(readonly) NSAttributedString *composedText;
@property(readonly) unsigned long long currentAnalysisOptions;
@property(readonly) struct __Mecabra *zhuyinEngine;
@property(readonly, nonatomic, getter=isInlineEmpty) BOOL inlineEmpty;
- (void)reset;
- (void)resetSyllableBuffers;
- (void)updateComposedTextToClient;
- (void)updateConfirmedCandidate:(id)arg1;
- (void)enumerateConfirmedCandidatesWithDeletionIndex:(unsigned long long)arg1 usingHandler:(CDUnknownBlockType)arg2;
- (void)enumerateConfirmedCandidatesAfterInsertedCandidate:(id)arg1 usingHandler:(CDUnknownBlockType)arg2;
- (id)convertToFullWidth:(id)arg1;
- (id)readingsLengths:(id)arg1;
- (id)candidatesForReading:(id)arg1 readingRange:(struct _NSRange)arg2 currentReading:(id)arg3 shouldIncludeCompletionCandidates:(BOOL)arg4;
- (id)aggregateCandidatesForReadingAtRange:(struct _NSRange)arg1;
- (id)aggregateCandidatesForPunctuationAtRange:(struct _NSRange)arg1;
- (void)analyzeInputWithCompletionHandler:(CDUnknownBlockType)arg1;
- (void)updateUserDictionary:(id)arg1;
- (void)updateExpertDictionary:(id)arg1;
- (void)updateContacts:(id)arg1;
- (void)commitComposedTextWithCompletionHandler:(CDUnknownBlockType)arg1;
- (void)refreshComposedText;
- (void)unregisterCandidate:(id)arg1;
- (void)confirmCandidate:(id)arg1;
- (void)previewCandidate:(id)arg1;
- (BOOL)loadCandidatesWithCompletionHandler:(CDUnknownBlockType)arg1;
- (void)loadCompositionCandidatesWithCompletionHandler:(CDUnknownBlockType)arg1;
- (BOOL)moveCursorToTail;
- (BOOL)moveCursorToHead;
- (BOOL)moveCursorRight;
- (BOOL)moveCursorLeft;
- (BOOL)revertCurrentCharacterToTonelessZhuyin;
- (BOOL)forwardDeleteFromInputWithUpdatingComposedTextToClient:(BOOL)arg1;
- (BOOL)forwardDeleteFromInput;
- (BOOL)deleteFromInputWithUpdatingComposedTextToClient:(BOOL)arg1;
- (BOOL)deleteFromInput;
- (BOOL)addNonZhuyinInput:(id)arg1;
- (BOOL)addZhuyinInput:(id)arg1 withUpdatingComposedTextToClient:(BOOL)arg2;
- (BOOL)addZhuyinInput:(id)arg1;
- (void)dealloc;
- (id)initWithDelegate:(id)arg1;
@end
| {
"pile_set_name": "Github"
} |
################################################################################
#
# libtomcrypt
#
################################################################################
LIBTOMCRYPT_VERSION = 1.18.2
LIBTOMCRYPT_SITE = https://github.com/libtom/libtomcrypt/releases/download/v$(LIBTOMCRYPT_VERSION)
LIBTOMCRYPT_SOURCE = crypt-$(LIBTOMCRYPT_VERSION).tar.xz
LIBTOMCRYPT_LICENSE = WTFPL
LIBTOMCRYPT_LICENSE_FILES = LICENSE
LIBTOMCRYPT_INSTALL_STAGING = YES
LIBTOMCRYPT_INSTALL_TARGET = NO # only static library
LIBTOMCRYPT_DEPENDENCIES = libtommath
# 0001-fix-CVE-2019-17362.patch
LIBTOMCRYPT_IGNORE_CVES += CVE-2019-17362
LIBTOMCRYPT_CFLAGS = -I./src/headers $(TARGET_CFLAGS) -DLTC_SOURCE -DLTM_DESC
define LIBTOMCRYPT_BUILD_CMDS
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) CFLAGS="$(LIBTOMCRYPT_CFLAGS)"
endef
define LIBTOMCRYPT_INSTALL_STAGING_CMDS
$(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR="$(STAGING_DIR)" \
PREFIX=/usr NODOCS=1 INSTALL_USER=$(shell id -u) \
INSTALL_GROUP=$(shell id -g) install
endef
$(eval $(generic-package))
| {
"pile_set_name": "Github"
} |
import * as React from 'react';
import styles from './TilesList.module.scss';
import { SelectionZone, ISelection, Selection, SelectionMode } from 'office-ui-fabric-react/lib/Selection';
import { IFile } from '../../../../../services/FileBrowserService.types';
import { List, IPageProps } from 'office-ui-fabric-react/lib/List';
import { FocusZone } from 'office-ui-fabric-react/lib/FocusZone';
import { IRenderFunction, IRectangle, css } from 'office-ui-fabric-react/lib/Utilities';
import { FolderTile } from '../FolderTile';
import { DocumentTile } from '../DocumentTile';
import { ITilesListProps } from './ITilesListProps';
/**
* Rows per page
*/
const ROWS_PER_PAGE: number = 3;
/**
* Maximum row height
*/
const MAX_ROW_HEIGHT: number = 250;
/**
* Maximum number of cells per page
*/
const CELLS_PER_PAGE: number = 48;
/**
* Standard tile margin
*/
const STANDARD_TILE_MARGIN: number = 4;
/**
* Standard left and right padding
*/
const TILE_HORZ_PADDING: number = 32;
/**
* Standard bottom margin
*/
const BOTTOM_MARGIN: number = 36;
const LAYOUT_STORAGE_KEY: string = 'comparerOneDriveLayout';
export class TilesList extends React.Component<ITilesListProps> {
private _columnCount: number;
private _columnWidth: number;
private _rowHeight: number;
private _listElem: List = undefined;
private _pageWidth: number;
constructor(props: ITilesListProps) {
super(props);
}
public componentDidUpdate(prevProps: ITilesListProps) {
if (this.props.filePickerResult !== prevProps.filePickerResult) {
this._listElem.forceUpdate();
}
}
public render(): React.ReactElement<ITilesListProps> {
return (
<SelectionZone selection={this.props.selection} onItemInvoked={(item: IFile) => {this._handleItemInvoked(item);}}>
<FocusZone>
<List
ref={(e:any) => { this._listElem = e; }}
className={styles.folderList}
items={this.props.items}
getItemCountForPage={this._getItemCountForPage}
getPageHeight={this._getPageHeight}
onRenderPage={(pageProps: IPageProps, defaultRender?: IRenderFunction<IPageProps>) => this._onRenderPage(pageProps, defaultRender)}
/>
</FocusZone>
</SelectionZone>
);
}
/**
* Gets called what a file is selected.
*/
private _handleItemInvoked = (item: IFile) => {
// If a file is selected, open the library
if (item.isFolder) {
this.props.onFolderOpen(item);
} else {
// Otherwise, remember it was selected
this.props.onFileSelected(item);
}
}
/**
* Calculates how many items there should be in the page
*/
private _getItemCountForPage = (itemIndex: number, surfaceRect: IRectangle): number => {
if (itemIndex === 0) {
this._columnCount = Math.ceil(surfaceRect.width / MAX_ROW_HEIGHT);
this._columnWidth = Math.floor(surfaceRect.width / this._columnCount);
this._rowHeight = this._columnWidth;
this._pageWidth = surfaceRect.width;
}
// Get the list of items
const { items } = this.props;
const isFolder: boolean = items && items.length > itemIndex && items[itemIndex] ? items[itemIndex].isFolder : undefined;
// Group items by folders and files
let pageLength: number = 0;
for (let index = itemIndex; index < items.length; index++) {
const element = items[index];
if (element && element.isFolder === isFolder) {
pageLength++;
} else {
break;
}
}
// Return the page lenght, up to the maximum number of cells per page
return Math.min(pageLength, CELLS_PER_PAGE);
}
/**
* Renders a custom list page
*/
private _onRenderPage = (pageProps: IPageProps, _defaultRender?: IRenderFunction<IPageProps>): JSX.Element => {
const {
page,
className: pageClassName,
...divProps
} = pageProps;
const { items } = page;
// If there are not items to be rendered or the last one is a null mark -> request for next page data
if (!items) {
return null;
}
return (<div {...divProps} className={css(pageClassName, styles.listPage)} key={page.key}>
<div className={styles.grid}
style={{
width: this._pageWidth,
marginTop: -STANDARD_TILE_MARGIN,
marginBottom: BOTTOM_MARGIN,
marginLeft: -STANDARD_TILE_MARGIN,
marginRight: -STANDARD_TILE_MARGIN
}}
>
{items.map((item: IFile, index: number) => {
return this._onRenderCell(item, index);
})}
</div>
</div>);
}
/** Calculates the list "page" height (a.k.a. row) */
private _getPageHeight = (): number => {
return this._rowHeight * ROWS_PER_PAGE;
}
/**
* Renders a file folder cover
*/
private _onRenderCell = (item: IFile, index: number | undefined): JSX.Element => {
if (!item) {
this.props.onNextPageDataRequest();
return null;
}
let isSelected: boolean = this.props.filePickerResult && item.absoluteUrl === this.props.filePickerResult.fileAbsoluteUrl;
// I know this is a lot of divs and spans inside of each other, but my
// goal was to mimic the HTML and style of the out-of-the-box file picker
// to the best of my ability.
return (
<div
className={styles.listCell}
data-item-index={index}
style={{
flexBasis: this._columnWidth,
maxWidth: this._columnWidth,
margin: STANDARD_TILE_MARGIN,
borderStyle: "none",
borderWidth: 0
}}
>
<div
role="presentation"
className={styles.cell}
// I don't agree with this magic number. Where does this come from?
style={{ paddingTop: "97.16%" }}
>
<div role="presentation" className={styles.cellContent}>
{
item.isFolder ?
<FolderTile
item={item}
index={index}
isSelected={isSelected}
pageWidth={this._pageWidth}
tileDimensions={{
width: this._columnWidth - TILE_HORZ_PADDING,
height: this._rowHeight - TILE_HORZ_PADDING
}}
onItemInvoked={(itemInvoked: IFile) => this._handleItemInvoked(itemInvoked)}
/>
:
<DocumentTile
fileBroserService={this.props.fileBrowserService}
item={item}
index={index}
isSelected={isSelected}
pageWidth={this._pageWidth}
tileDimensions={{
width: this._columnWidth - TILE_HORZ_PADDING,
height: this._rowHeight - TILE_HORZ_PADDING
}}
onItemInvoked={(itemInvoked: IFile) => this._handleItemInvoked(itemInvoked)}
/>
}
</div>
</div>
</div>
);
}
}
| {
"pile_set_name": "Github"
} |
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
# ebuild generated by hackport 0.6.1
CABAL_FEATURES="lib profile haddock hoogle hscolour"
inherit haskell-cabal
DESCRIPTION="Support for manipulating Haskell source code"
HOMEPAGE="https://hackage.haskell.org/package/haskell-src"
SRC_URI="https://hackage.haskell.org/package/${P}/${P}.tar.gz"
LICENSE="BSD"
SLOT="0/${PV}"
#ghc-8.8.1, cabal-3 without KEYWORDS
KEYWORDS=""
IUSE=""
RDEPEND=">=dev-haskell/syb-0.7:=[profile?] <dev-haskell/syb-0.8:=[profile?]
>=dev-lang/ghc-8.8.1:=
"
DEPEND="${RDEPEND}
>=dev-haskell/cabal-3.0.0.0
>=dev-haskell/happy-1.19 <dev-haskell/happy-1.20
"
| {
"pile_set_name": "Github"
} |
.build_release/cuda/src/caffe/layers/conv_lstm_unit_layer.o : src/caffe/layers/conv_lstm_unit_layer.cu \
/usr/include/stdc-predef.h \
/usr/local/cuda-8.0/include/cuda_runtime.h \
/usr/local/cuda-8.0/include/host_config.h \
/usr/include/features.h \
/usr/include/x86_64-linux-gnu/sys/cdefs.h \
/usr/include/x86_64-linux-gnu/bits/wordsize.h \
/usr/include/x86_64-linux-gnu/gnu/stubs.h \
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h \
/usr/local/cuda-8.0/include/builtin_types.h \
/usr/local/cuda-8.0/include/device_types.h \
/usr/local/cuda-8.0/include/host_defines.h \
/usr/local/cuda-8.0/include/driver_types.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/limits.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed/syslimits.h \
/usr/include/limits.h \
/usr/include/x86_64-linux-gnu/bits/posix1_lim.h \
/usr/include/x86_64-linux-gnu/bits/local_lim.h \
/usr/include/linux/limits.h \
/usr/include/x86_64-linux-gnu/bits/posix2_lim.h \
/usr/include/x86_64-linux-gnu/bits/xopen_lim.h \
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \
/usr/local/cuda-8.0/include/surface_types.h \
/usr/local/cuda-8.0/include/texture_types.h \
/usr/local/cuda-8.0/include/vector_types.h \
/usr/local/cuda-8.0/include/library_types.h \
/usr/local/cuda-8.0/include/channel_descriptor.h \
/usr/local/cuda-8.0/include/cuda_runtime_api.h \
/usr/local/cuda-8.0/include/cuda_device_runtime_api.h \
/usr/local/cuda-8.0/include/driver_functions.h \
/usr/local/cuda-8.0/include/vector_functions.h \
/usr/local/cuda-8.0/include/vector_functions.hpp \
/usr/local/cuda-8.0/include/common_functions.h \
/usr/include/string.h \
/usr/include/xlocale.h \
/usr/include/x86_64-linux-gnu/bits/string3.h \
/usr/include/time.h \
/usr/include/x86_64-linux-gnu/bits/time.h \
/usr/include/x86_64-linux-gnu/bits/types.h \
/usr/include/x86_64-linux-gnu/bits/typesizes.h \
/usr/include/x86_64-linux-gnu/bits/timex.h \
/usr/include/c++/5/new \
/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/os_defines.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/cpu_defines.h \
/usr/include/c++/5/exception \
/usr/include/c++/5/bits/atomic_lockfree_defines.h \
/usr/include/c++/5/bits/exception_ptr.h \
/usr/include/c++/5/bits/exception_defines.h \
/usr/include/c++/5/bits/nested_exception.h \
/usr/include/stdio.h \
/usr/include/libio.h \
/usr/include/_G_config.h \
/usr/include/wchar.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h \
/usr/include/x86_64-linux-gnu/bits/stdio.h \
/usr/include/x86_64-linux-gnu/bits/stdio2.h \
/usr/include/stdlib.h \
/usr/include/x86_64-linux-gnu/bits/waitflags.h \
/usr/include/x86_64-linux-gnu/bits/waitstatus.h \
/usr/include/endian.h \
/usr/include/x86_64-linux-gnu/bits/endian.h \
/usr/include/x86_64-linux-gnu/bits/byteswap.h \
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h \
/usr/include/x86_64-linux-gnu/sys/types.h \
/usr/include/x86_64-linux-gnu/sys/select.h \
/usr/include/x86_64-linux-gnu/bits/select.h \
/usr/include/x86_64-linux-gnu/bits/sigset.h \
/usr/include/x86_64-linux-gnu/bits/select2.h \
/usr/include/x86_64-linux-gnu/sys/sysmacros.h \
/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h \
/usr/include/alloca.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h \
/usr/include/x86_64-linux-gnu/bits/stdlib.h \
/usr/include/assert.h \
/usr/local/cuda-8.0/include/math_functions.h \
/usr/include/math.h \
/usr/include/x86_64-linux-gnu/bits/math-vector.h \
/usr/include/x86_64-linux-gnu/bits/libm-simd-decl-stubs.h \
/usr/include/x86_64-linux-gnu/bits/huge_val.h \
/usr/include/x86_64-linux-gnu/bits/huge_valf.h \
/usr/include/x86_64-linux-gnu/bits/huge_vall.h \
/usr/include/x86_64-linux-gnu/bits/inf.h \
/usr/include/x86_64-linux-gnu/bits/nan.h \
/usr/include/x86_64-linux-gnu/bits/mathdef.h \
/usr/include/x86_64-linux-gnu/bits/mathcalls.h \
/usr/include/x86_64-linux-gnu/bits/mathinline.h \
/usr/include/c++/5/cmath \
/usr/include/c++/5/bits/cpp_type_traits.h \
/usr/include/c++/5/ext/type_traits.h \
/usr/include/c++/5/cstdlib \
/usr/local/cuda-8.0/include/math_functions.hpp \
/usr/local/cuda-8.0/include/math_functions_dbl_ptx3.h \
/usr/local/cuda-8.0/include/math_functions_dbl_ptx3.hpp \
/usr/local/cuda-8.0/include/cuda_surface_types.h \
/usr/local/cuda-8.0/include/cuda_texture_types.h \
/usr/local/cuda-8.0/include/device_functions.h \
/usr/local/cuda-8.0/include/device_functions.hpp \
/usr/local/cuda-8.0/include/device_atomic_functions.h \
/usr/local/cuda-8.0/include/device_atomic_functions.hpp \
/usr/local/cuda-8.0/include/device_double_functions.h \
/usr/local/cuda-8.0/include/device_double_functions.hpp \
/usr/local/cuda-8.0/include/sm_20_atomic_functions.h \
/usr/local/cuda-8.0/include/sm_20_atomic_functions.hpp \
/usr/local/cuda-8.0/include/sm_32_atomic_functions.h \
/usr/local/cuda-8.0/include/sm_32_atomic_functions.hpp \
/usr/local/cuda-8.0/include/sm_35_atomic_functions.h \
/usr/local/cuda-8.0/include/sm_60_atomic_functions.h \
/usr/local/cuda-8.0/include/sm_60_atomic_functions.hpp \
/usr/local/cuda-8.0/include/sm_20_intrinsics.h \
/usr/local/cuda-8.0/include/sm_20_intrinsics.hpp \
/usr/local/cuda-8.0/include/sm_30_intrinsics.h \
/usr/local/cuda-8.0/include/sm_30_intrinsics.hpp \
/usr/local/cuda-8.0/include/sm_32_intrinsics.h \
/usr/local/cuda-8.0/include/sm_32_intrinsics.hpp \
/usr/local/cuda-8.0/include/sm_35_intrinsics.h \
/usr/local/cuda-8.0/include/sm_61_intrinsics.h \
/usr/local/cuda-8.0/include/sm_61_intrinsics.hpp \
/usr/local/cuda-8.0/include/surface_functions.h \
/usr/local/cuda-8.0/include/texture_fetch_functions.h \
/usr/local/cuda-8.0/include/texture_indirect_functions.h \
/usr/local/cuda-8.0/include/surface_indirect_functions.h \
/usr/local/cuda-8.0/include/device_launch_parameters.h \
/usr/include/c++/5/algorithm \
/usr/include/c++/5/utility \
/usr/include/c++/5/bits/stl_relops.h \
/usr/include/c++/5/bits/stl_pair.h \
/usr/include/c++/5/bits/move.h \
/usr/include/c++/5/bits/concept_check.h \
/usr/include/c++/5/type_traits \
/usr/include/c++/5/initializer_list \
/usr/include/c++/5/bits/stl_algobase.h \
/usr/include/c++/5/bits/functexcept.h \
/usr/include/c++/5/ext/numeric_traits.h \
/usr/include/c++/5/bits/stl_iterator_base_types.h \
/usr/include/c++/5/bits/stl_iterator_base_funcs.h \
/usr/include/c++/5/debug/debug.h \
/usr/include/c++/5/bits/stl_iterator.h \
/usr/include/c++/5/bits/ptr_traits.h \
/usr/include/c++/5/bits/predefined_ops.h \
/usr/include/c++/5/bits/stl_algo.h \
/usr/include/c++/5/bits/algorithmfwd.h \
/usr/include/c++/5/bits/stl_heap.h \
/usr/include/c++/5/bits/stl_tempbuf.h \
/usr/include/c++/5/bits/stl_construct.h \
/usr/include/c++/5/ext/alloc_traits.h \
/usr/include/c++/5/bits/alloc_traits.h \
/usr/include/c++/5/bits/memoryfwd.h \
/usr/include/c++/5/random \
/usr/include/c++/5/string \
/usr/include/c++/5/bits/stringfwd.h \
/usr/include/c++/5/bits/char_traits.h \
/usr/include/c++/5/bits/postypes.h \
/usr/include/c++/5/cwchar \
/usr/include/x86_64-linux-gnu/bits/wchar.h \
/usr/include/x86_64-linux-gnu/bits/wchar2.h \
/usr/include/c++/5/cstdint \
/usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h \
/usr/include/stdint.h \
/usr/include/c++/5/bits/allocator.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/c++allocator.h \
/usr/include/c++/5/ext/new_allocator.h \
/usr/include/c++/5/bits/localefwd.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/c++locale.h \
/usr/include/c++/5/clocale \
/usr/include/locale.h \
/usr/include/x86_64-linux-gnu/bits/locale.h \
/usr/include/c++/5/iosfwd \
/usr/include/c++/5/cctype \
/usr/include/ctype.h \
/usr/include/c++/5/bits/ostream_insert.h \
/usr/include/c++/5/bits/cxxabi_forced.h \
/usr/include/c++/5/bits/stl_function.h \
/usr/include/c++/5/backward/binders.h \
/usr/include/c++/5/bits/range_access.h \
/usr/include/c++/5/bits/basic_string.h \
/usr/include/c++/5/ext/atomicity.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/gthr.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/gthr-default.h \
/usr/include/pthread.h \
/usr/include/sched.h \
/usr/include/x86_64-linux-gnu/bits/sched.h \
/usr/include/x86_64-linux-gnu/bits/setjmp.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/atomic_word.h \
/usr/include/c++/5/ext/string_conversions.h \
/usr/include/c++/5/cstdio \
/usr/include/c++/5/cerrno \
/usr/include/errno.h \
/usr/include/x86_64-linux-gnu/bits/errno.h \
/usr/include/linux/errno.h \
/usr/include/x86_64-linux-gnu/asm/errno.h \
/usr/include/asm-generic/errno.h \
/usr/include/asm-generic/errno-base.h \
/usr/include/c++/5/bits/functional_hash.h \
/usr/include/c++/5/bits/hash_bytes.h \
/usr/include/c++/5/bits/basic_string.tcc \
/usr/include/c++/5/limits \
/usr/include/c++/5/bits/random.h \
/usr/include/c++/5/vector \
/usr/include/c++/5/bits/stl_uninitialized.h \
/usr/include/c++/5/bits/stl_vector.h \
/usr/include/c++/5/bits/stl_bvector.h \
/usr/include/c++/5/bits/vector.tcc \
/usr/include/c++/5/bits/uniform_int_dist.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/opt_random.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/x86intrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/ia32intrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/mmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xmmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/mm_malloc.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/emmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/pmmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/tmmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/ammintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/smmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/popcntintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/wmmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/immintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avxintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx2intrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512fintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512erintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512pfintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512cdintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512vlintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512bwintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512dqintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512vlbwintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512vldqintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512ifmaintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512ifmavlintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512vbmiintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/avx512vbmivlintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/shaintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/lzcntintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/bmiintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/bmi2intrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/fmaintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/f16cintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/rtmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xtestintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/mm3dnow.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/prfchwintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/fma4intrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xopintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/lwpintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/tbmintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/rdseedintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/fxsrintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xsaveintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xsaveoptintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/adxintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/clwbintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/pcommitintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/clflushoptintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xsavesintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/xsavecintrin.h \
/usr/lib/gcc/x86_64-linux-gnu/5/include/mwaitxintrin.h \
/usr/include/c++/5/bits/random.tcc \
/usr/include/c++/5/numeric \
/usr/include/c++/5/bits/stl_numeric.h \
./include/caffe/layer.hpp \
./include/caffe/blob.hpp \
./include/caffe/common.hpp \
/usr/include/boost/shared_ptr.hpp \
/usr/include/boost/smart_ptr/shared_ptr.hpp \
/usr/include/boost/config.hpp \
/usr/include/boost/config/user.hpp \
/usr/include/boost/config/select_compiler_config.hpp \
/usr/include/boost/config/compiler/nvcc.hpp \
/usr/include/boost/config/compiler/gcc.hpp \
/usr/include/boost/config/select_stdlib_config.hpp \
/usr/include/c++/5/cstddef \
/usr/include/boost/config/stdlib/libstdcpp3.hpp \
/usr/include/unistd.h \
/usr/include/x86_64-linux-gnu/bits/posix_opt.h \
/usr/include/x86_64-linux-gnu/bits/environments.h \
/usr/include/x86_64-linux-gnu/bits/confname.h \
/usr/include/getopt.h \
/usr/include/x86_64-linux-gnu/bits/unistd.h \
/usr/include/boost/config/select_platform_config.hpp \
/usr/include/boost/config/platform/linux.hpp \
/usr/include/boost/config/posix_features.hpp \
/usr/include/boost/config/suffix.hpp \
/usr/include/boost/config/no_tr1/memory.hpp \
/usr/include/c++/5/memory \
/usr/include/c++/5/bits/stl_raw_storage_iter.h \
/usr/include/c++/5/typeinfo \
/usr/include/c++/5/ext/concurrence.h \
/usr/include/c++/5/bits/uses_allocator.h \
/usr/include/c++/5/functional \
/usr/include/c++/5/tuple \
/usr/include/c++/5/array \
/usr/include/c++/5/stdexcept \
/usr/include/c++/5/bits/unique_ptr.h \
/usr/include/c++/5/bits/shared_ptr.h \
/usr/include/c++/5/bits/shared_ptr_base.h \
/usr/include/c++/5/bits/allocated_ptr.h \
/usr/include/c++/5/ext/aligned_buffer.h \
/usr/include/c++/5/bits/shared_ptr_atomic.h \
/usr/include/c++/5/bits/atomic_base.h \
/usr/include/c++/5/backward/auto_ptr.h \
/usr/include/boost/assert.hpp \
/usr/include/boost/checked_delete.hpp \
/usr/include/boost/core/checked_delete.hpp \
/usr/include/boost/throw_exception.hpp \
/usr/include/boost/detail/workaround.hpp \
/usr/include/boost/exception/exception.hpp \
/usr/include/boost/current_function.hpp \
/usr/include/boost/smart_ptr/detail/shared_count.hpp \
/usr/include/boost/smart_ptr/bad_weak_ptr.hpp \
/usr/include/boost/smart_ptr/detail/sp_counted_base.hpp \
/usr/include/boost/smart_ptr/detail/sp_has_sync.hpp \
/usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp \
/usr/include/boost/detail/sp_typeinfo.hpp \
/usr/include/boost/core/typeinfo.hpp \
/usr/include/boost/core/demangle.hpp \
/usr/include/c++/5/cxxabi.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/cxxabi_tweaks.h \
/usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp \
/usr/include/boost/utility/addressof.hpp \
/usr/include/boost/core/addressof.hpp \
/usr/include/boost/smart_ptr/detail/sp_convertible.hpp \
/usr/include/boost/smart_ptr/detail/sp_nullptr_t.hpp \
/usr/include/boost/smart_ptr/detail/spinlock_pool.hpp \
/usr/include/boost/smart_ptr/detail/spinlock.hpp \
/usr/include/boost/smart_ptr/detail/spinlock_sync.hpp \
/usr/include/boost/smart_ptr/detail/yield_k.hpp \
/usr/include/boost/predef.h \
/usr/include/boost/predef/language.h \
/usr/include/boost/predef/language/stdc.h \
/usr/include/boost/predef/version_number.h \
/usr/include/boost/predef/make.h \
/usr/include/boost/predef/detail/test.h \
/usr/include/boost/predef/language/stdcpp.h \
/usr/include/boost/predef/language/objc.h \
/usr/include/boost/predef/architecture.h \
/usr/include/boost/predef/architecture/alpha.h \
/usr/include/boost/predef/architecture/arm.h \
/usr/include/boost/predef/architecture/blackfin.h \
/usr/include/boost/predef/architecture/convex.h \
/usr/include/boost/predef/architecture/ia64.h \
/usr/include/boost/predef/architecture/m68k.h \
/usr/include/boost/predef/architecture/mips.h \
/usr/include/boost/predef/architecture/parisc.h \
/usr/include/boost/predef/architecture/ppc.h \
/usr/include/boost/predef/architecture/pyramid.h \
/usr/include/boost/predef/architecture/rs6k.h \
/usr/include/boost/predef/architecture/sparc.h \
/usr/include/boost/predef/architecture/superh.h \
/usr/include/boost/predef/architecture/sys370.h \
/usr/include/boost/predef/architecture/sys390.h \
/usr/include/boost/predef/architecture/x86.h \
/usr/include/boost/predef/architecture/x86/32.h \
/usr/include/boost/predef/architecture/x86/64.h \
/usr/include/boost/predef/architecture/z.h \
/usr/include/boost/predef/compiler.h \
/usr/include/boost/predef/compiler/borland.h \
/usr/include/boost/predef/compiler/clang.h \
/usr/include/boost/predef/compiler/comeau.h \
/usr/include/boost/predef/compiler/compaq.h \
/usr/include/boost/predef/compiler/diab.h \
/usr/include/boost/predef/compiler/digitalmars.h \
/usr/include/boost/predef/compiler/dignus.h \
/usr/include/boost/predef/compiler/edg.h \
/usr/include/boost/predef/compiler/ekopath.h \
/usr/include/boost/predef/compiler/gcc_xml.h \
/usr/include/boost/predef/compiler/gcc.h \
/usr/include/boost/predef/detail/comp_detected.h \
/usr/include/boost/predef/compiler/greenhills.h \
/usr/include/boost/predef/compiler/hp_acc.h \
/usr/include/boost/predef/compiler/iar.h \
/usr/include/boost/predef/compiler/ibm.h \
/usr/include/boost/predef/compiler/intel.h \
/usr/include/boost/predef/compiler/kai.h \
/usr/include/boost/predef/compiler/llvm.h \
/usr/include/boost/predef/compiler/metaware.h \
/usr/include/boost/predef/compiler/metrowerks.h \
/usr/include/boost/predef/compiler/microtec.h \
/usr/include/boost/predef/compiler/mpw.h \
/usr/include/boost/predef/compiler/palm.h \
/usr/include/boost/predef/compiler/pgi.h \
/usr/include/boost/predef/compiler/sgi_mipspro.h \
/usr/include/boost/predef/compiler/sunpro.h \
/usr/include/boost/predef/compiler/tendra.h \
/usr/include/boost/predef/compiler/visualc.h \
/usr/include/boost/predef/compiler/watcom.h \
/usr/include/boost/predef/library.h \
/usr/include/boost/predef/library/c.h \
/usr/include/boost/predef/library/c/_prefix.h \
/usr/include/boost/predef/detail/_cassert.h \
/usr/include/boost/predef/library/c/gnu.h \
/usr/include/boost/predef/library/c/uc.h \
/usr/include/boost/predef/library/c/vms.h \
/usr/include/boost/predef/library/c/zos.h \
/usr/include/boost/predef/library/std.h \
/usr/include/boost/predef/library/std/_prefix.h \
/usr/include/boost/predef/detail/_exception.h \
/usr/include/boost/predef/library/std/cxx.h \
/usr/include/boost/predef/library/std/dinkumware.h \
/usr/include/boost/predef/library/std/libcomo.h \
/usr/include/boost/predef/library/std/modena.h \
/usr/include/boost/predef/library/std/msl.h \
/usr/include/boost/predef/library/std/roguewave.h \
/usr/include/boost/predef/library/std/sgi.h \
/usr/include/boost/predef/library/std/stdcpp3.h \
/usr/include/boost/predef/library/std/stlport.h \
/usr/include/boost/predef/library/std/vacpp.h \
/usr/include/boost/predef/os.h \
/usr/include/boost/predef/os/aix.h \
/usr/include/boost/predef/os/amigaos.h \
/usr/include/boost/predef/os/android.h \
/usr/include/boost/predef/os/beos.h \
/usr/include/boost/predef/os/bsd.h \
/usr/include/boost/predef/os/macos.h \
/usr/include/boost/predef/os/ios.h \
/usr/include/boost/predef/os/bsd/bsdi.h \
/usr/include/boost/predef/os/bsd/dragonfly.h \
/usr/include/boost/predef/os/bsd/free.h \
/usr/include/boost/predef/os/bsd/open.h \
/usr/include/boost/predef/os/bsd/net.h \
/usr/include/boost/predef/os/cygwin.h \
/usr/include/boost/predef/os/haiku.h \
/usr/include/boost/predef/os/hpux.h \
/usr/include/boost/predef/os/irix.h \
/usr/include/boost/predef/os/linux.h \
/usr/include/boost/predef/detail/os_detected.h \
/usr/include/boost/predef/os/os400.h \
/usr/include/boost/predef/os/qnxnto.h \
/usr/include/boost/predef/os/solaris.h \
/usr/include/boost/predef/os/unix.h \
/usr/include/boost/predef/os/vms.h \
/usr/include/boost/predef/os/windows.h \
/usr/include/boost/predef/other.h \
/usr/include/boost/predef/other/endian.h \
/usr/include/boost/predef/platform.h \
/usr/include/boost/predef/platform/mingw.h \
/usr/include/boost/predef/platform/windows_desktop.h \
/usr/include/boost/predef/platform/windows_store.h \
/usr/include/boost/predef/platform/windows_phone.h \
/usr/include/boost/predef/platform/windows_runtime.h \
/usr/include/boost/smart_ptr/detail/operator_bool.hpp \
/usr/include/gflags/gflags.h \
/usr/include/gflags/gflags_declare.h \
/usr/include/gflags/gflags_gflags.h \
/usr/include/glog/logging.h \
/usr/include/c++/5/ostream \
/usr/include/c++/5/ios \
/usr/include/c++/5/bits/ios_base.h \
/usr/include/c++/5/bits/locale_classes.h \
/usr/include/c++/5/bits/locale_classes.tcc \
/usr/include/c++/5/system_error \
/usr/include/x86_64-linux-gnu/c++/5/bits/error_constants.h \
/usr/include/c++/5/streambuf \
/usr/include/c++/5/bits/streambuf.tcc \
/usr/include/c++/5/bits/basic_ios.h \
/usr/include/c++/5/bits/locale_facets.h \
/usr/include/c++/5/cwctype \
/usr/include/wctype.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_base.h \
/usr/include/c++/5/bits/streambuf_iterator.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/ctype_inline.h \
/usr/include/c++/5/bits/locale_facets.tcc \
/usr/include/c++/5/bits/basic_ios.tcc \
/usr/include/c++/5/bits/ostream.tcc \
/usr/include/c++/5/sstream \
/usr/include/c++/5/istream \
/usr/include/c++/5/bits/istream.tcc \
/usr/include/c++/5/bits/sstream.tcc \
/usr/include/inttypes.h \
/usr/include/glog/log_severity.h \
/usr/include/glog/vlog_is_on.h \
/usr/include/c++/5/climits \
/usr/include/c++/5/fstream \
/usr/include/c++/5/bits/codecvt.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/basic_file.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/c++io.h \
/usr/include/c++/5/bits/fstream.tcc \
/usr/include/c++/5/iostream \
/usr/include/c++/5/map \
/usr/include/c++/5/bits/stl_tree.h \
/usr/include/c++/5/bits/stl_map.h \
/usr/include/c++/5/bits/stl_multimap.h \
/usr/include/c++/5/set \
/usr/include/c++/5/bits/stl_set.h \
/usr/include/c++/5/bits/stl_multiset.h \
./include/caffe/util/device_alternate.hpp \
/usr/local/cuda-8.0/include/cublas_v2.h \
/usr/local/cuda-8.0/include/cublas_api.h \
/usr/local/cuda-8.0/include/cuComplex.h \
/usr/local/cuda-8.0/include/cuda_fp16.h \
/usr/local/cuda-8.0/include/cuda.h \
/usr/local/cuda-8.0/include/curand.h \
./include/caffe/util/cudnn.hpp \
/usr/local/cuda-8.0/include/cudnn.h \
.build_release/src/caffe/proto/caffe.pb.h \
/usr/include/google/protobuf/stubs/common.h \
/usr/include/google/protobuf/generated_message_util.h \
/usr/include/google/protobuf/stubs/once.h \
/usr/include/google/protobuf/stubs/atomicops.h \
/usr/include/google/protobuf/stubs/platform_macros.h \
/usr/include/google/protobuf/stubs/atomicops_internals_x86_gcc.h \
/usr/include/google/protobuf/message.h \
/usr/include/google/protobuf/message_lite.h \
/usr/include/google/protobuf/descriptor.h \
/usr/include/google/protobuf/repeated_field.h \
/usr/include/c++/5/iterator \
/usr/include/c++/5/bits/stream_iterator.h \
/usr/include/google/protobuf/stubs/type_traits.h \
/usr/include/google/protobuf/stubs/template_util.h \
/usr/include/google/protobuf/extension_set.h \
/usr/include/google/protobuf/generated_enum_reflection.h \
/usr/include/google/protobuf/unknown_field_set.h \
./include/caffe/syncedmem.hpp \
./include/caffe/layer_factory.hpp \
./include/caffe/util/math_functions.hpp \
./include/caffe/util/mkl_alternate.hpp \
/usr/include/cblas.h \
/usr/include/cblas_mangling.h \
./include/caffe/layers/conv_lstm_layer.hpp \
./include/caffe/layers/recurrent_layer.hpp \
./include/caffe/net.hpp \
./include/caffe/util/format.hpp \
/usr/include/c++/5/iomanip \
/usr/include/c++/5/locale \
/usr/include/c++/5/bits/locale_facets_nonio.h \
/usr/include/c++/5/ctime \
/usr/include/x86_64-linux-gnu/c++/5/bits/time_members.h \
/usr/include/x86_64-linux-gnu/c++/5/bits/messages_members.h \
/usr/include/libintl.h \
/usr/include/c++/5/bits/locale_facets_nonio.tcc \
/usr/include/c++/5/bits/locale_conv.h \
./include/caffe/layers/conv_lstm_helper.hpp \
/usr/include/boost/lexical_cast.hpp \
/usr/include/boost/range/iterator_range_core.hpp \
/usr/include/boost/iterator/iterator_traits.hpp \
/usr/include/boost/detail/iterator.hpp \
/usr/include/boost/iterator/iterator_facade.hpp \
/usr/include/boost/iterator.hpp \
/usr/include/boost/iterator/interoperable.hpp \
/usr/include/boost/mpl/bool.hpp \
/usr/include/boost/mpl/bool_fwd.hpp \
/usr/include/boost/mpl/aux_/adl_barrier.hpp \
/usr/include/boost/mpl/aux_/config/adl.hpp \
/usr/include/boost/mpl/aux_/config/msvc.hpp \
/usr/include/boost/mpl/aux_/config/intel.hpp \
/usr/include/boost/mpl/aux_/config/gcc.hpp \
/usr/include/boost/mpl/aux_/config/workaround.hpp \
/usr/include/boost/mpl/integral_c_tag.hpp \
/usr/include/boost/mpl/aux_/config/static_constant.hpp \
/usr/include/boost/mpl/or.hpp \
/usr/include/boost/mpl/aux_/config/use_preprocessed.hpp \
/usr/include/boost/mpl/aux_/nested_type_wknd.hpp \
/usr/include/boost/mpl/aux_/na_spec.hpp \
/usr/include/boost/mpl/lambda_fwd.hpp \
/usr/include/boost/mpl/void_fwd.hpp \
/usr/include/boost/mpl/aux_/na.hpp \
/usr/include/boost/mpl/aux_/na_fwd.hpp \
/usr/include/boost/mpl/aux_/config/ctps.hpp \
/usr/include/boost/mpl/aux_/config/lambda.hpp \
/usr/include/boost/mpl/aux_/config/ttp.hpp \
/usr/include/boost/mpl/int.hpp \
/usr/include/boost/mpl/int_fwd.hpp \
/usr/include/boost/mpl/aux_/nttp_decl.hpp \
/usr/include/boost/mpl/aux_/config/nttp.hpp \
/usr/include/boost/mpl/aux_/integral_wrapper.hpp \
/usr/include/boost/mpl/aux_/static_cast.hpp \
/usr/include/boost/preprocessor/cat.hpp \
/usr/include/boost/preprocessor/config/config.hpp \
/usr/include/boost/mpl/aux_/lambda_arity_param.hpp \
/usr/include/boost/mpl/aux_/template_arity_fwd.hpp \
/usr/include/boost/mpl/aux_/arity.hpp \
/usr/include/boost/mpl/aux_/config/dtp.hpp \
/usr/include/boost/mpl/aux_/preprocessor/params.hpp \
/usr/include/boost/mpl/aux_/config/preprocessor.hpp \
/usr/include/boost/preprocessor/comma_if.hpp \
/usr/include/boost/preprocessor/punctuation/comma_if.hpp \
/usr/include/boost/preprocessor/control/if.hpp \
/usr/include/boost/preprocessor/control/iif.hpp \
/usr/include/boost/preprocessor/logical/bool.hpp \
/usr/include/boost/preprocessor/facilities/empty.hpp \
/usr/include/boost/preprocessor/punctuation/comma.hpp \
/usr/include/boost/preprocessor/repeat.hpp \
/usr/include/boost/preprocessor/repetition/repeat.hpp \
/usr/include/boost/preprocessor/debug/error.hpp \
/usr/include/boost/preprocessor/detail/auto_rec.hpp \
/usr/include/boost/preprocessor/tuple/eat.hpp \
/usr/include/boost/preprocessor/inc.hpp \
/usr/include/boost/preprocessor/arithmetic/inc.hpp \
/usr/include/boost/mpl/aux_/preprocessor/enum.hpp \
/usr/include/boost/mpl/aux_/preprocessor/def_params_tail.hpp \
/usr/include/boost/mpl/limits/arity.hpp \
/usr/include/boost/preprocessor/logical/and.hpp \
/usr/include/boost/preprocessor/logical/bitand.hpp \
/usr/include/boost/preprocessor/identity.hpp \
/usr/include/boost/preprocessor/facilities/identity.hpp \
/usr/include/boost/preprocessor/empty.hpp \
/usr/include/boost/preprocessor/arithmetic/add.hpp \
/usr/include/boost/preprocessor/arithmetic/dec.hpp \
/usr/include/boost/preprocessor/control/while.hpp \
/usr/include/boost/preprocessor/list/fold_left.hpp \
/usr/include/boost/preprocessor/list/detail/fold_left.hpp \
/usr/include/boost/preprocessor/control/expr_iif.hpp \
/usr/include/boost/preprocessor/list/adt.hpp \
/usr/include/boost/preprocessor/detail/is_binary.hpp \
/usr/include/boost/preprocessor/detail/check.hpp \
/usr/include/boost/preprocessor/logical/compl.hpp \
/usr/include/boost/preprocessor/list/fold_right.hpp \
/usr/include/boost/preprocessor/list/detail/fold_right.hpp \
/usr/include/boost/preprocessor/list/reverse.hpp \
/usr/include/boost/preprocessor/control/detail/while.hpp \
/usr/include/boost/preprocessor/tuple/elem.hpp \
/usr/include/boost/preprocessor/facilities/expand.hpp \
/usr/include/boost/preprocessor/facilities/overload.hpp \
/usr/include/boost/preprocessor/variadic/size.hpp \
/usr/include/boost/preprocessor/tuple/rem.hpp \
/usr/include/boost/preprocessor/tuple/detail/is_single_return.hpp \
/usr/include/boost/preprocessor/variadic/elem.hpp \
/usr/include/boost/preprocessor/arithmetic/sub.hpp \
/usr/include/boost/mpl/aux_/config/eti.hpp \
/usr/include/boost/mpl/aux_/config/overload_resolution.hpp \
/usr/include/boost/mpl/aux_/lambda_support.hpp \
/usr/include/boost/mpl/aux_/include_preprocessed.hpp \
/usr/include/boost/mpl/aux_/config/compiler.hpp \
/usr/include/boost/preprocessor/stringize.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/or.hpp \
/usr/include/boost/type_traits/is_convertible.hpp \
/usr/include/boost/type_traits/intrinsics.hpp \
/usr/include/boost/type_traits/config.hpp \
/usr/include/boost/type_traits/is_same.hpp \
/usr/include/boost/type_traits/detail/bool_trait_def.hpp \
/usr/include/boost/type_traits/detail/template_arity_spec.hpp \
/usr/include/boost/type_traits/integral_constant.hpp \
/usr/include/boost/mpl/integral_c.hpp \
/usr/include/boost/mpl/integral_c_fwd.hpp \
/usr/include/boost/type_traits/detail/bool_trait_undef.hpp \
/usr/include/boost/type_traits/is_reference.hpp \
/usr/include/boost/type_traits/is_lvalue_reference.hpp \
/usr/include/boost/type_traits/is_rvalue_reference.hpp \
/usr/include/boost/type_traits/ice.hpp \
/usr/include/boost/type_traits/detail/yes_no_type.hpp \
/usr/include/boost/type_traits/detail/ice_or.hpp \
/usr/include/boost/type_traits/detail/ice_and.hpp \
/usr/include/boost/type_traits/detail/ice_not.hpp \
/usr/include/boost/type_traits/detail/ice_eq.hpp \
/usr/include/boost/type_traits/is_volatile.hpp \
/usr/include/boost/type_traits/detail/cv_traits_impl.hpp \
/usr/include/boost/type_traits/is_array.hpp \
/usr/include/boost/type_traits/is_arithmetic.hpp \
/usr/include/boost/type_traits/is_integral.hpp \
/usr/include/boost/type_traits/is_float.hpp \
/usr/include/boost/type_traits/is_void.hpp \
/usr/include/boost/type_traits/is_abstract.hpp \
/usr/include/boost/type_traits/add_lvalue_reference.hpp \
/usr/include/boost/type_traits/add_reference.hpp \
/usr/include/boost/type_traits/detail/type_trait_def.hpp \
/usr/include/boost/type_traits/detail/type_trait_undef.hpp \
/usr/include/boost/type_traits/add_rvalue_reference.hpp \
/usr/include/boost/type_traits/is_function.hpp \
/usr/include/boost/type_traits/detail/false_result.hpp \
/usr/include/boost/type_traits/detail/is_function_ptr_helper.hpp \
/usr/include/boost/utility/declval.hpp \
/usr/include/boost/iterator/detail/config_def.hpp \
/usr/include/boost/iterator/detail/config_undef.hpp \
/usr/include/boost/iterator/iterator_categories.hpp \
/usr/include/boost/mpl/eval_if.hpp \
/usr/include/boost/mpl/if.hpp \
/usr/include/boost/mpl/aux_/value_wknd.hpp \
/usr/include/boost/mpl/aux_/config/integral.hpp \
/usr/include/boost/mpl/identity.hpp \
/usr/include/boost/mpl/placeholders.hpp \
/usr/include/boost/mpl/arg.hpp \
/usr/include/boost/mpl/arg_fwd.hpp \
/usr/include/boost/mpl/aux_/na_assert.hpp \
/usr/include/boost/mpl/assert.hpp \
/usr/include/boost/mpl/not.hpp \
/usr/include/boost/mpl/aux_/yes_no.hpp \
/usr/include/boost/mpl/aux_/config/arrays.hpp \
/usr/include/boost/mpl/aux_/config/gpu.hpp \
/usr/include/boost/mpl/aux_/config/pp_counter.hpp \
/usr/include/boost/mpl/aux_/arity_spec.hpp \
/usr/include/boost/mpl/aux_/arg_typedef.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/arg.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/placeholders.hpp \
/usr/include/boost/static_assert.hpp \
/usr/include/boost/iterator/detail/facade_iterator_category.hpp \
/usr/include/boost/mpl/and.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/and.hpp \
/usr/include/boost/type_traits/is_const.hpp \
/usr/include/boost/detail/indirect_traits.hpp \
/usr/include/boost/type_traits/is_pointer.hpp \
/usr/include/boost/type_traits/is_member_pointer.hpp \
/usr/include/boost/type_traits/is_member_function_pointer.hpp \
/usr/include/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp \
/usr/include/boost/type_traits/remove_cv.hpp \
/usr/include/boost/type_traits/is_class.hpp \
/usr/include/boost/type_traits/remove_reference.hpp \
/usr/include/boost/type_traits/remove_pointer.hpp \
/usr/include/boost/iterator/detail/enable_if.hpp \
/usr/include/boost/type_traits/add_const.hpp \
/usr/include/boost/type_traits/add_pointer.hpp \
/usr/include/boost/type_traits/remove_const.hpp \
/usr/include/boost/type_traits/is_pod.hpp \
/usr/include/boost/type_traits/is_scalar.hpp \
/usr/include/boost/type_traits/is_enum.hpp \
/usr/include/boost/mpl/always.hpp \
/usr/include/boost/mpl/aux_/preprocessor/default_params.hpp \
/usr/include/boost/mpl/apply.hpp \
/usr/include/boost/mpl/apply_fwd.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/apply_fwd.hpp \
/usr/include/boost/mpl/apply_wrap.hpp \
/usr/include/boost/mpl/aux_/has_apply.hpp \
/usr/include/boost/mpl/has_xxx.hpp \
/usr/include/boost/mpl/aux_/type_wrapper.hpp \
/usr/include/boost/mpl/aux_/config/has_xxx.hpp \
/usr/include/boost/mpl/aux_/config/msvc_typename.hpp \
/usr/include/boost/preprocessor/array/elem.hpp \
/usr/include/boost/preprocessor/array/data.hpp \
/usr/include/boost/preprocessor/array/size.hpp \
/usr/include/boost/preprocessor/repetition/enum_params.hpp \
/usr/include/boost/preprocessor/repetition/enum_trailing_params.hpp \
/usr/include/boost/mpl/aux_/config/has_apply.hpp \
/usr/include/boost/mpl/aux_/msvc_never_true.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp \
/usr/include/boost/mpl/lambda.hpp \
/usr/include/boost/mpl/bind.hpp \
/usr/include/boost/mpl/bind_fwd.hpp \
/usr/include/boost/mpl/aux_/config/bind.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/bind_fwd.hpp \
/usr/include/boost/mpl/next.hpp \
/usr/include/boost/mpl/next_prior.hpp \
/usr/include/boost/mpl/aux_/common_name_wknd.hpp \
/usr/include/boost/mpl/protect.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/bind.hpp \
/usr/include/boost/mpl/aux_/full_lambda.hpp \
/usr/include/boost/mpl/quote.hpp \
/usr/include/boost/mpl/void.hpp \
/usr/include/boost/mpl/aux_/has_type.hpp \
/usr/include/boost/mpl/aux_/config/bcc.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/quote.hpp \
/usr/include/boost/mpl/aux_/template_arity.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/template_arity.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/full_lambda.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/apply.hpp \
/usr/include/boost/type_traits/is_base_and_derived.hpp \
/usr/include/boost/range/functions.hpp \
/usr/include/boost/range/begin.hpp \
/usr/include/boost/range/config.hpp \
/usr/include/boost/range/iterator.hpp \
/usr/include/boost/range/range_fwd.hpp \
/usr/include/boost/range/mutable_iterator.hpp \
/usr/include/boost/range/detail/extract_optional_type.hpp \
/usr/include/boost/range/detail/msvc_has_iterator_workaround.hpp \
/usr/include/boost/range/const_iterator.hpp \
/usr/include/boost/range/end.hpp \
/usr/include/boost/range/detail/implementation_help.hpp \
/usr/include/boost/range/detail/common.hpp \
/usr/include/boost/range/detail/sfinae.hpp \
/usr/include/boost/range/size.hpp \
/usr/include/boost/range/size_type.hpp \
/usr/include/boost/range/difference_type.hpp \
/usr/include/boost/range/concepts.hpp \
/usr/include/boost/concept_check.hpp \
/usr/include/boost/concept/assert.hpp \
/usr/include/boost/concept/detail/general.hpp \
/usr/include/boost/concept/detail/backward_compatibility.hpp \
/usr/include/boost/concept/detail/has_constraints.hpp \
/usr/include/boost/type_traits/conversion_traits.hpp \
/usr/include/boost/concept/usage.hpp \
/usr/include/boost/concept/detail/concept_def.hpp \
/usr/include/boost/preprocessor/seq/for_each_i.hpp \
/usr/include/boost/preprocessor/repetition/for.hpp \
/usr/include/boost/preprocessor/repetition/detail/for.hpp \
/usr/include/boost/preprocessor/seq/seq.hpp \
/usr/include/boost/preprocessor/seq/elem.hpp \
/usr/include/boost/preprocessor/seq/size.hpp \
/usr/include/boost/preprocessor/seq/enum.hpp \
/usr/include/boost/concept/detail/concept_undef.hpp \
/usr/include/boost/iterator/iterator_concepts.hpp \
/usr/include/boost/limits.hpp \
/usr/include/boost/range/value_type.hpp \
/usr/include/boost/range/detail/misc_concept.hpp \
/usr/include/boost/utility/enable_if.hpp \
/usr/include/boost/core/enable_if.hpp \
/usr/include/boost/type_traits/make_unsigned.hpp \
/usr/include/boost/type_traits/is_signed.hpp \
/usr/include/boost/type_traits/is_unsigned.hpp \
/usr/include/boost/type_traits/add_volatile.hpp \
/usr/include/boost/range/detail/has_member_size.hpp \
/usr/include/boost/cstdint.hpp \
/usr/include/boost/utility.hpp \
/usr/include/boost/utility/base_from_member.hpp \
/usr/include/boost/preprocessor/repetition/enum_binary_params.hpp \
/usr/include/boost/preprocessor/repetition/repeat_from_to.hpp \
/usr/include/boost/utility/binary.hpp \
/usr/include/boost/preprocessor/control/deduce_d.hpp \
/usr/include/boost/preprocessor/seq/cat.hpp \
/usr/include/boost/preprocessor/seq/fold_left.hpp \
/usr/include/boost/preprocessor/seq/transform.hpp \
/usr/include/boost/preprocessor/arithmetic/mod.hpp \
/usr/include/boost/preprocessor/arithmetic/detail/div_base.hpp \
/usr/include/boost/preprocessor/comparison/less_equal.hpp \
/usr/include/boost/preprocessor/logical/not.hpp \
/usr/include/boost/utility/identity_type.hpp \
/usr/include/boost/type_traits/function_traits.hpp \
/usr/include/boost/next_prior.hpp \
/usr/include/boost/type_traits/integral_promotion.hpp \
/usr/include/boost/type_traits/make_signed.hpp \
/usr/include/boost/type_traits/has_plus.hpp \
/usr/include/boost/type_traits/detail/has_binary_operator.hpp \
/usr/include/boost/type_traits/is_base_of.hpp \
/usr/include/boost/type_traits/is_fundamental.hpp \
/usr/include/boost/type_traits/has_plus_assign.hpp \
/usr/include/boost/type_traits/has_minus.hpp \
/usr/include/boost/type_traits/has_minus_assign.hpp \
/usr/include/boost/noncopyable.hpp \
/usr/include/boost/core/noncopyable.hpp \
/usr/include/boost/range/distance.hpp \
/usr/include/boost/range/empty.hpp \
/usr/include/boost/range/rbegin.hpp \
/usr/include/boost/range/reverse_iterator.hpp \
/usr/include/boost/iterator/reverse_iterator.hpp \
/usr/include/boost/iterator/iterator_adaptor.hpp \
/usr/include/boost/range/rend.hpp \
/usr/include/boost/range/has_range_iterator.hpp \
/usr/include/boost/range/algorithm/equal.hpp \
/usr/include/boost/range/detail/safe_bool.hpp \
/usr/include/boost/lexical_cast/bad_lexical_cast.hpp \
/usr/include/boost/lexical_cast/try_lexical_convert.hpp \
/usr/include/boost/lexical_cast/detail/is_character.hpp \
/usr/include/boost/lexical_cast/detail/converter_numeric.hpp \
/usr/include/boost/numeric/conversion/cast.hpp \
/usr/include/boost/type.hpp \
/usr/include/boost/numeric/conversion/converter.hpp \
/usr/include/boost/numeric/conversion/conversion_traits.hpp \
/usr/include/boost/numeric/conversion/detail/conversion_traits.hpp \
/usr/include/boost/numeric/conversion/detail/meta.hpp \
/usr/include/boost/mpl/equal_to.hpp \
/usr/include/boost/mpl/aux_/comparison_op.hpp \
/usr/include/boost/mpl/aux_/numeric_op.hpp \
/usr/include/boost/mpl/numeric_cast.hpp \
/usr/include/boost/mpl/tag.hpp \
/usr/include/boost/mpl/aux_/has_tag.hpp \
/usr/include/boost/mpl/aux_/numeric_cast_utils.hpp \
/usr/include/boost/mpl/aux_/config/forwarding.hpp \
/usr/include/boost/mpl/aux_/msvc_eti_base.hpp \
/usr/include/boost/mpl/aux_/is_msvc_eti_arg.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/equal_to.hpp \
/usr/include/boost/numeric/conversion/detail/int_float_mixture.hpp \
/usr/include/boost/numeric/conversion/int_float_mixture_enum.hpp \
/usr/include/boost/numeric/conversion/detail/sign_mixture.hpp \
/usr/include/boost/numeric/conversion/sign_mixture_enum.hpp \
/usr/include/boost/numeric/conversion/detail/udt_builtin_mixture.hpp \
/usr/include/boost/numeric/conversion/udt_builtin_mixture_enum.hpp \
/usr/include/boost/numeric/conversion/detail/is_subranged.hpp \
/usr/include/boost/mpl/multiplies.hpp \
/usr/include/boost/mpl/times.hpp \
/usr/include/boost/mpl/aux_/arithmetic_op.hpp \
/usr/include/boost/mpl/aux_/largest_int.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/times.hpp \
/usr/include/boost/mpl/less.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/less.hpp \
/usr/include/boost/numeric/conversion/converter_policies.hpp \
/usr/include/boost/config/no_tr1/cmath.hpp \
/usr/include/boost/numeric/conversion/detail/converter.hpp \
/usr/include/boost/numeric/conversion/bounds.hpp \
/usr/include/boost/numeric/conversion/detail/bounds.hpp \
/usr/include/boost/numeric/conversion/numeric_cast_traits.hpp \
/usr/include/boost/numeric/conversion/detail/numeric_cast_traits.hpp \
/usr/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp \
/usr/include/boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp \
/usr/include/boost/lexical_cast/detail/converter_lexical.hpp \
/usr/include/boost/type_traits/has_left_shift.hpp \
/usr/include/boost/type_traits/has_right_shift.hpp \
/usr/include/boost/detail/lcast_precision.hpp \
/usr/include/boost/integer_traits.hpp \
/usr/include/boost/lexical_cast/detail/widest_char.hpp \
/usr/include/boost/array.hpp \
/usr/include/boost/swap.hpp \
/usr/include/boost/core/swap.hpp \
/usr/include/boost/functional/hash_fwd.hpp \
/usr/include/boost/functional/hash/hash_fwd.hpp \
/usr/include/boost/container/container_fwd.hpp \
/usr/include/boost/container/detail/std_fwd.hpp \
/usr/include/boost/lexical_cast/detail/converter_lexical_streams.hpp \
/usr/include/c++/5/cstring \
/usr/include/boost/lexical_cast/detail/lcast_char_constants.hpp \
/usr/include/boost/lexical_cast/detail/lcast_unsigned_converters.hpp \
/usr/include/boost/lexical_cast/detail/inf_nan.hpp \
/usr/include/boost/math/special_functions/sign.hpp \
/usr/include/boost/math/tools/config.hpp \
/usr/include/c++/5/cfloat \
/usr/lib/gcc/x86_64-linux-gnu/5/include/float.h \
/usr/include/boost/math/tools/user.hpp \
/usr/include/boost/math/special_functions/math_fwd.hpp \
/usr/include/boost/math/special_functions/detail/round_fwd.hpp \
/usr/include/boost/math/tools/promotion.hpp \
/usr/include/boost/type_traits/is_floating_point.hpp \
/usr/include/boost/math/policies/policy.hpp \
/usr/include/boost/mpl/list.hpp \
/usr/include/boost/mpl/limits/list.hpp \
/usr/include/boost/mpl/list/list20.hpp \
/usr/include/boost/mpl/list/list10.hpp \
/usr/include/boost/mpl/list/list0.hpp \
/usr/include/boost/mpl/long.hpp \
/usr/include/boost/mpl/long_fwd.hpp \
/usr/include/boost/mpl/list/aux_/push_front.hpp \
/usr/include/boost/mpl/push_front_fwd.hpp \
/usr/include/boost/mpl/list/aux_/item.hpp \
/usr/include/boost/mpl/list/aux_/tag.hpp \
/usr/include/boost/mpl/list/aux_/pop_front.hpp \
/usr/include/boost/mpl/pop_front_fwd.hpp \
/usr/include/boost/mpl/list/aux_/push_back.hpp \
/usr/include/boost/mpl/push_back_fwd.hpp \
/usr/include/boost/mpl/list/aux_/front.hpp \
/usr/include/boost/mpl/front_fwd.hpp \
/usr/include/boost/mpl/list/aux_/clear.hpp \
/usr/include/boost/mpl/clear_fwd.hpp \
/usr/include/boost/mpl/list/aux_/O1_size.hpp \
/usr/include/boost/mpl/O1_size_fwd.hpp \
/usr/include/boost/mpl/list/aux_/size.hpp \
/usr/include/boost/mpl/size_fwd.hpp \
/usr/include/boost/mpl/list/aux_/empty.hpp \
/usr/include/boost/mpl/empty_fwd.hpp \
/usr/include/boost/mpl/list/aux_/begin_end.hpp \
/usr/include/boost/mpl/begin_end_fwd.hpp \
/usr/include/boost/mpl/list/aux_/iterator.hpp \
/usr/include/boost/mpl/iterator_tags.hpp \
/usr/include/boost/mpl/deref.hpp \
/usr/include/boost/mpl/aux_/msvc_type.hpp \
/usr/include/boost/mpl/aux_/lambda_spec.hpp \
/usr/include/boost/mpl/list/aux_/include_preprocessed.hpp \
/usr/include/boost/mpl/list/aux_/preprocessed/plain/list10.hpp \
/usr/include/boost/mpl/list/aux_/preprocessed/plain/list20.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/list.hpp \
/usr/include/boost/mpl/contains.hpp \
/usr/include/boost/mpl/contains_fwd.hpp \
/usr/include/boost/mpl/sequence_tag.hpp \
/usr/include/boost/mpl/sequence_tag_fwd.hpp \
/usr/include/boost/mpl/aux_/has_begin.hpp \
/usr/include/boost/mpl/aux_/contains_impl.hpp \
/usr/include/boost/mpl/begin_end.hpp \
/usr/include/boost/mpl/aux_/begin_end_impl.hpp \
/usr/include/boost/mpl/aux_/traits_lambda_spec.hpp \
/usr/include/boost/mpl/find.hpp \
/usr/include/boost/mpl/find_if.hpp \
/usr/include/boost/mpl/aux_/find_if_pred.hpp \
/usr/include/boost/mpl/aux_/iter_apply.hpp \
/usr/include/boost/mpl/iter_fold_if.hpp \
/usr/include/boost/mpl/logical.hpp \
/usr/include/boost/mpl/pair.hpp \
/usr/include/boost/mpl/aux_/iter_fold_if_impl.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/iter_fold_if_impl.hpp \
/usr/include/boost/mpl/same_as.hpp \
/usr/include/boost/mpl/remove_if.hpp \
/usr/include/boost/mpl/fold.hpp \
/usr/include/boost/mpl/O1_size.hpp \
/usr/include/boost/mpl/aux_/O1_size_impl.hpp \
/usr/include/boost/mpl/aux_/has_size.hpp \
/usr/include/boost/mpl/aux_/fold_impl.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp \
/usr/include/boost/mpl/reverse_fold.hpp \
/usr/include/boost/mpl/aux_/reverse_fold_impl.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/reverse_fold_impl.hpp \
/usr/include/boost/mpl/aux_/inserter_algorithm.hpp \
/usr/include/boost/mpl/back_inserter.hpp \
/usr/include/boost/mpl/push_back.hpp \
/usr/include/boost/mpl/aux_/push_back_impl.hpp \
/usr/include/boost/mpl/inserter.hpp \
/usr/include/boost/mpl/front_inserter.hpp \
/usr/include/boost/mpl/push_front.hpp \
/usr/include/boost/mpl/aux_/push_front_impl.hpp \
/usr/include/boost/mpl/clear.hpp \
/usr/include/boost/mpl/aux_/clear_impl.hpp \
/usr/include/boost/mpl/vector.hpp \
/usr/include/boost/mpl/limits/vector.hpp \
/usr/include/boost/mpl/vector/vector20.hpp \
/usr/include/boost/mpl/vector/vector10.hpp \
/usr/include/boost/mpl/vector/vector0.hpp \
/usr/include/boost/mpl/vector/aux_/at.hpp \
/usr/include/boost/mpl/at_fwd.hpp \
/usr/include/boost/mpl/vector/aux_/tag.hpp \
/usr/include/boost/mpl/aux_/config/typeof.hpp \
/usr/include/boost/mpl/vector/aux_/front.hpp \
/usr/include/boost/mpl/vector/aux_/push_front.hpp \
/usr/include/boost/mpl/vector/aux_/item.hpp \
/usr/include/boost/mpl/vector/aux_/pop_front.hpp \
/usr/include/boost/mpl/vector/aux_/push_back.hpp \
/usr/include/boost/mpl/vector/aux_/pop_back.hpp \
/usr/include/boost/mpl/pop_back_fwd.hpp \
/usr/include/boost/mpl/vector/aux_/back.hpp \
/usr/include/boost/mpl/back_fwd.hpp \
/usr/include/boost/mpl/vector/aux_/clear.hpp \
/usr/include/boost/mpl/vector/aux_/vector0.hpp \
/usr/include/boost/mpl/vector/aux_/iterator.hpp \
/usr/include/boost/mpl/plus.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/plus.hpp \
/usr/include/boost/mpl/minus.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/minus.hpp \
/usr/include/boost/mpl/advance_fwd.hpp \
/usr/include/boost/mpl/distance_fwd.hpp \
/usr/include/boost/mpl/prior.hpp \
/usr/include/boost/mpl/vector/aux_/O1_size.hpp \
/usr/include/boost/mpl/vector/aux_/size.hpp \
/usr/include/boost/mpl/vector/aux_/empty.hpp \
/usr/include/boost/mpl/vector/aux_/begin_end.hpp \
/usr/include/boost/mpl/vector/aux_/include_preprocessed.hpp \
/usr/include/boost/mpl/vector/aux_/preprocessed/typeof_based/vector10.hpp \
/usr/include/boost/mpl/vector/aux_/preprocessed/typeof_based/vector20.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/vector.hpp \
/usr/include/boost/mpl/at.hpp \
/usr/include/boost/mpl/aux_/at_impl.hpp \
/usr/include/boost/mpl/advance.hpp \
/usr/include/boost/mpl/negate.hpp \
/usr/include/boost/mpl/aux_/advance_forward.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/advance_forward.hpp \
/usr/include/boost/mpl/aux_/advance_backward.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/advance_backward.hpp \
/usr/include/boost/mpl/size.hpp \
/usr/include/boost/mpl/aux_/size_impl.hpp \
/usr/include/boost/mpl/distance.hpp \
/usr/include/boost/mpl/iter_fold.hpp \
/usr/include/boost/mpl/aux_/iter_fold_impl.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/iter_fold_impl.hpp \
/usr/include/boost/mpl/iterator_range.hpp \
/usr/include/boost/mpl/comparison.hpp \
/usr/include/boost/mpl/not_equal_to.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/not_equal_to.hpp \
/usr/include/boost/mpl/greater.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/greater.hpp \
/usr/include/boost/mpl/less_equal.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/less_equal.hpp \
/usr/include/boost/mpl/greater_equal.hpp \
/usr/include/boost/mpl/aux_/preprocessed/gcc/greater_equal.hpp \
/usr/include/boost/config/no_tr1/complex.hpp \
/usr/include/c++/5/complex \
/usr/include/boost/math/special_functions/detail/fp_traits.hpp \
/usr/include/boost/detail/endian.hpp \
/usr/include/boost/predef/detail/endian_compat.h \
/usr/include/boost/math/special_functions/fpclassify.hpp \
/usr/include/boost/math/tools/real_cast.hpp \
/usr/include/boost/integer.hpp \
/usr/include/boost/integer_fwd.hpp \
/usr/include/boost/detail/basic_pointerbuf.hpp
| {
"pile_set_name": "Github"
} |
<HTML>
<HEAD>
<meta charset="UTF-8">
<title>Tagger.tagParagraphOriginal - koalanlp</title>
<link rel="stylesheet" href="../../../style.css">
</HEAD>
<BODY>
<a href="../../index.html">koalanlp</a> / <a href="../index.html">kr.bydelta.koala.hnn</a> / <a href="index.html">Tagger</a> / <a href="./tag-paragraph-original.html">tagParagraphOriginal</a><br/>
<br/>
<h1>tagParagraphOriginal</h1>
<a name="kr.bydelta.koala.hnn.Tagger$tagParagraphOriginal(kotlin.String)"></a>
<code><span class="keyword">fun </span><span class="identifier">tagParagraphOriginal</span><span class="symbol">(</span><span class="identifier" id="kr.bydelta.koala.hnn.Tagger$tagParagraphOriginal(kotlin.String)/text">text</span><span class="symbol">:</span> <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html"><span class="identifier">String</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html"><span class="identifier">List</span></a><span class="symbol"><</span><span class="identifier"><ERROR CLASS></span><span class="symbol">></span></code> <a href="https://github.com/koalanlp/koalanlp/blob/master/hannanum/src/main/kotlin/kr/bydelta/koala/hnn/proc.kt#L136">(source)</a>
<p>변환되지않은, <a href="tag-paragraph-original.html#kr.bydelta.koala.hnn.Tagger$tagParagraphOriginal(kotlin.String)/text">text</a>의 분석결과 <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html">List</a><kaist.cilab.jhannanum.common.communication.Sentence>를 반환합니다.</p>
<h3>Parameters</h3>
<p><a name="text"></a>
<code>text</code> - 분석할 String.</p>
<p><strong>Since</strong><br/>
1.x</p>
<p><strong>Return</strong><br/>
원본 분석기의 결과인 문장의 목록입니다.</p>
</BODY>
</HTML>
| {
"pile_set_name": "Github"
} |
/* 8390 core for ISA devices needing bus delays */
static const char version[] =
"8390p.c:v1.10cvs 9/23/94 Donald Becker ([email protected])\n";
#define ei_inb(_p) inb(_p)
#define ei_outb(_v, _p) outb(_v, _p)
#define ei_inb_p(_p) inb_p(_p)
#define ei_outb_p(_v, _p) outb_p(_v, _p)
#include "lib8390.c"
int eip_open(struct net_device *dev)
{
return __ei_open(dev);
}
EXPORT_SYMBOL(eip_open);
int eip_close(struct net_device *dev)
{
return __ei_close(dev);
}
EXPORT_SYMBOL(eip_close);
netdev_tx_t eip_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
return __ei_start_xmit(skb, dev);
}
EXPORT_SYMBOL(eip_start_xmit);
struct net_device_stats *eip_get_stats(struct net_device *dev)
{
return __ei_get_stats(dev);
}
EXPORT_SYMBOL(eip_get_stats);
void eip_set_multicast_list(struct net_device *dev)
{
__ei_set_multicast_list(dev);
}
EXPORT_SYMBOL(eip_set_multicast_list);
void eip_tx_timeout(struct net_device *dev)
{
__ei_tx_timeout(dev);
}
EXPORT_SYMBOL(eip_tx_timeout);
irqreturn_t eip_interrupt(int irq, void *dev_id)
{
return __ei_interrupt(irq, dev_id);
}
EXPORT_SYMBOL(eip_interrupt);
#ifdef CONFIG_NET_POLL_CONTROLLER
void eip_poll(struct net_device *dev)
{
__ei_poll(dev);
}
EXPORT_SYMBOL(eip_poll);
#endif
const struct net_device_ops eip_netdev_ops = {
.ndo_open = eip_open,
.ndo_stop = eip_close,
.ndo_start_xmit = eip_start_xmit,
.ndo_tx_timeout = eip_tx_timeout,
.ndo_get_stats = eip_get_stats,
.ndo_set_multicast_list = eip_set_multicast_list,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = eth_change_mtu,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = eip_poll,
#endif
};
EXPORT_SYMBOL(eip_netdev_ops);
struct net_device *__alloc_eip_netdev(int size)
{
struct net_device *dev = ____alloc_ei_netdev(size);
if (dev)
dev->netdev_ops = &eip_netdev_ops;
return dev;
}
EXPORT_SYMBOL(__alloc_eip_netdev);
void NS8390p_init(struct net_device *dev, int startp)
{
__NS8390_init(dev, startp);
}
EXPORT_SYMBOL(NS8390p_init);
static int __init NS8390p_init_module(void)
{
return 0;
}
static void __exit NS8390p_cleanup_module(void)
{
}
module_init(NS8390p_init_module);
module_exit(NS8390p_cleanup_module);
MODULE_LICENSE("GPL");
| {
"pile_set_name": "Github"
} |
server.port=8080
management.endpoints.web.exposure.include=*
logging.level.org.springframework.boot.actuate.trace.WebRequestTraceFilter: TRACE
spring.application.name=invoicing
logging.level.com.ewolff.microservice.invoicing.poller: TRACE
logging.level.org.springframework.http.converter.json: ERROR
order.url=http://order:80/feed
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:postgresql://postgres/dbinvoicing
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=org.postgresql.Driver
spring.sleuth.baggage.remote-fields=x-request-id,x-ot-span-context | {
"pile_set_name": "Github"
} |
################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
ocsinventory-log.pl is a sample that enables you to see your ocs server's
activity.
You have to rotate your logs daily at 00:00, using the "compressed" option to
have a day level visibility (use the provided logrotate)
This kind of scripts may help you to adjust server's settings, especially
FREQUENCY and PROLOG_FREQ parameter.
Theses are the supported parameters :
-f='log file' The log file to read
-a=day_before Look for a 'log_file_name.gz' according to logrotate naming system
-r Summary per hour of the activity
-s General summary for the day
-h="hour_num" See a specific hour
=> -m in minutes
=> -d group by ten minutes
| {
"pile_set_name": "Github"
} |
/**
* general SPI info
* Project HEXIWEAR, 2015
*/
#ifndef HG_GENERIC_SPI_INFO
#define HG_GENERIC_SPI_INFO
// total number of SPI modules
#define SPI_NUM_MAX (3)
// SPI timeout value
#define SPI_TIMEOUT (500)
#endif
| {
"pile_set_name": "Github"
} |
/* Replacement grp.h file for building GNU Emacs on Windows.
Copyright (C) 2003-2012 Free Software Foundation, Inc.
This file is part of GNU Emacs.
GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _GRP_H
#define _GRP_H
#include <pwd.h> /* gid_t defined here */
/* Emacs uses only gr_name */
struct group {
char *gr_name; /* group name */
gid_t gr_gid; /* group numerical ID */
};
extern unsigned getgid (void);
extern unsigned getegid (void);
extern struct group *getgrgid(gid_t);
#endif /* _GRP_H */
| {
"pile_set_name": "Github"
} |
///
/// Copyright (c) 2016 Dropbox, Inc. All rights reserved.
///
/// Auto-generated by Stone, do not modify.
///
#import <Foundation/Foundation.h>
#import "DBSerializableProtocol.h"
@class DBTEAMLOGSharedLinkSettingsChangePasswordType;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - API Object
///
/// The `SharedLinkSettingsChangePasswordType` struct.
///
/// This class implements the `DBSerializable` protocol (serialize and
/// deserialize instance methods), which is required for all Obj-C SDK API route
/// objects.
///
@interface DBTEAMLOGSharedLinkSettingsChangePasswordType : NSObject <DBSerializable, NSCopying>
#pragma mark - Instance fields
/// (no description).
@property (nonatomic, readonly, copy) NSString *description_;
#pragma mark - Constructors
///
/// Full constructor for the struct (exposes all instance variables).
///
/// @param description_ (no description).
///
/// @return An initialized instance.
///
- (instancetype)initWithDescription_:(NSString *)description_;
- (instancetype)init NS_UNAVAILABLE;
@end
#pragma mark - Serializer Object
///
/// The serialization class for the `SharedLinkSettingsChangePasswordType`
/// struct.
///
@interface DBTEAMLOGSharedLinkSettingsChangePasswordTypeSerializer : NSObject
///
/// Serializes `DBTEAMLOGSharedLinkSettingsChangePasswordType` instances.
///
/// @param instance An instance of the
/// `DBTEAMLOGSharedLinkSettingsChangePasswordType` API object.
///
/// @return A json-compatible dictionary representation of the
/// `DBTEAMLOGSharedLinkSettingsChangePasswordType` API object.
///
+ (nullable NSDictionary<NSString *, id> *)serialize:(DBTEAMLOGSharedLinkSettingsChangePasswordType *)instance;
///
/// Deserializes `DBTEAMLOGSharedLinkSettingsChangePasswordType` instances.
///
/// @param dict A json-compatible dictionary representation of the
/// `DBTEAMLOGSharedLinkSettingsChangePasswordType` API object.
///
/// @return An instantiation of the
/// `DBTEAMLOGSharedLinkSettingsChangePasswordType` object.
///
+ (DBTEAMLOGSharedLinkSettingsChangePasswordType *)deserialize:(NSDictionary<NSString *, id> *)dict;
@end
NS_ASSUME_NONNULL_END
| {
"pile_set_name": "Github"
} |
/**
*
* CommunityContent
*
*/
import React from 'react';
import { FormattedMessage } from 'react-intl';
import styles from './styles.scss';
/* eslint-disable jsx-a11y/accessible-emoji */
function CommunityContent() {
return (
<React.Fragment>
<FormattedMessage id="app.components.HomePage.community.content">
{message => (
<p className={styles.communityContentP}>
{message}
</p>
)}
</FormattedMessage>
</React.Fragment>
);
}
export default CommunityContent;
| {
"pile_set_name": "Github"
} |
E 席 せき 1.000000
E 一 いち 1.000000
E 行 おこな 0.500000
E 変換 へんかん 1.000000
E 感じ かんじ 1.000000
E 漢字 かんじ 1.000000
E 良 よ 1.000000
E の の 1.000000
E 幹事 かんじ 1.000000
E かな かな 1.000000
E い い 1.000000
E 行 ぎょう 0.500000
E う う 1.000000
E を を 1.000000
| {
"pile_set_name": "Github"
} |
/*
* Quicksilver.h
* Quicksilver
*
* Created by Etienne on 20/02/11.
* Copyright 2011 Etienne Samson. All rights reserved.
*
*/
#import <QSFoundation/QSFoundation.h>
#import <QSCore/QSCore.h>
#import <QSEffects/QSEffects.h>
#import <QSInterface/QSInterface.h>
#import "QSAboutWindowController.h"
#import "QSAdvancedPrefPane.h"
#import "QSApp.h"
#import "QSCatalogPrefPane.h"
#import "QSController.h"
#import "QSDefaultsManager.h"
#import "QSGetURLScriptCommand.h"
#import "QSHelpersPrefPane.h"
#import "QSMainMenuPrefPane.h"
#import "QSMainPreferencePanes.h"
#import "QSModifierKeyEvents.h"
#import "QSPlugInsPrefPane.h"
#import "QSPreferencesController.h"
#import "QSSetupAssistant.h"
#import "QSSimpleNotifier.h"
#import "QSSimpleWebWindowController.h"
#import "QSTaskViewController.h"
#import "QSTaskViewer.h"
#import "QSTitleToolbarItem.h"
#import "QSTriggersPrefPane.h"
#import "QSUpdateController.h" | {
"pile_set_name": "Github"
} |
<html lang="en">
<head>
<title>Overall Options - Using the GNU Compiler Collection (GCC)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNU Compiler Collection (GCC)">
<meta name="generator" content="makeinfo 4.7">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
<link rel="prev" href="Option-Summary.html#Option-Summary" title="Option Summary">
<link rel="next" href="Invoking-G_002b_002b.html#Invoking-G_002b_002b" title="Invoking G++">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
2008 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Funding
Free Software'', the Front-Cover texts being (a) (see below), and with
the Back-Cover Texts being (b) (see below). A copy of the license is
included in the section entitled ``GNU Free Documentation License''.
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family: serif; font-weight: normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Overall-Options"></a>Next: <a rel="next" accesskey="n" href="Invoking-G_002b_002b.html#Invoking-G_002b_002b">Invoking G++</a>,
Previous: <a rel="previous" accesskey="p" href="Option-Summary.html#Option-Summary">Option Summary</a>,
Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
<hr><br>
</div>
<h3 class="section">3.2 Options Controlling the Kind of Output</h3>
<p>Compilation can involve up to four stages: preprocessing, compilation
proper, assembly and linking, always in that order. GCC is capable of
preprocessing and compiling several files either into several
assembler input files, or into one assembler input file; then each
assembler input file produces an object file, and linking combines all
the object files (those newly compiled, and those specified as input)
into an executable file.
<p><a name="index-file-name-suffix-73"></a>For any given input file, the file name suffix determines what kind of
compilation is done:
<dl>
<dt><var>file</var><code>.c</code><dd>C source code which must be preprocessed.
<br><dt><var>file</var><code>.i</code><dd>C source code which should not be preprocessed.
<br><dt><var>file</var><code>.ii</code><dd>C++ source code which should not be preprocessed.
<br><dt><var>file</var><code>.m</code><dd>Objective-C source code. Note that you must link with the <span class="file">libobjc</span>
library to make an Objective-C program work.
<br><dt><var>file</var><code>.mi</code><dd>Objective-C source code which should not be preprocessed.
<br><dt><var>file</var><code>.mm</code><dt><var>file</var><code>.M</code><dd>Objective-C++ source code. Note that you must link with the <span class="file">libobjc</span>
library to make an Objective-C++ program work. Note that <span class="samp">.M</span> refers
to a literal capital M.
<br><dt><var>file</var><code>.mii</code><dd>Objective-C++ source code which should not be preprocessed.
<br><dt><var>file</var><code>.h</code><dd>C, C++, Objective-C or Objective-C++ header file to be turned into a
precompiled header.
<br><dt><var>file</var><code>.cc</code><dt><var>file</var><code>.cp</code><dt><var>file</var><code>.cxx</code><dt><var>file</var><code>.cpp</code><dt><var>file</var><code>.CPP</code><dt><var>file</var><code>.c++</code><dt><var>file</var><code>.C</code><dd>C++ source code which must be preprocessed. Note that in <span class="samp">.cxx</span>,
the last two letters must both be literally <span class="samp">x</span>. Likewise,
<span class="samp">.C</span> refers to a literal capital C.
<br><dt><var>file</var><code>.mm</code><dt><var>file</var><code>.M</code><dd>Objective-C++ source code which must be preprocessed.
<br><dt><var>file</var><code>.mii</code><dd>Objective-C++ source code which should not be preprocessed.
<br><dt><var>file</var><code>.hh</code><dt><var>file</var><code>.H</code><dt><var>file</var><code>.hp</code><dt><var>file</var><code>.hxx</code><dt><var>file</var><code>.hpp</code><dt><var>file</var><code>.HPP</code><dt><var>file</var><code>.h++</code><dt><var>file</var><code>.tcc</code><dd>C++ header file to be turned into a precompiled header.
<br><dt><var>file</var><code>.f</code><dt><var>file</var><code>.for</code><dt><var>file</var><code>.FOR</code><dd>Fixed form Fortran source code which should not be preprocessed.
<br><dt><var>file</var><code>.F</code><dt><var>file</var><code>.fpp</code><dt><var>file</var><code>.FPP</code><dd>Fixed form Fortran source code which must be preprocessed (with the traditional
preprocessor).
<br><dt><var>file</var><code>.f90</code><dt><var>file</var><code>.f95</code><dd>Free form Fortran source code which should not be preprocessed.
<br><dt><var>file</var><code>.F90</code><dt><var>file</var><code>.F95</code><dd>Free form Fortran source code which must be preprocessed (with the
traditional preprocessor).
<!-- FIXME: Descriptions of Java file types. -->
<!-- @var{file}.java -->
<!-- @var{file}.class -->
<!-- @var{file}.zip -->
<!-- @var{file}.jar -->
<br><dt><var>file</var><code>.ads</code><dd>Ada source code file which contains a library unit declaration (a
declaration of a package, subprogram, or generic, or a generic
instantiation), or a library unit renaming declaration (a package,
generic, or subprogram renaming declaration). Such files are also
called <dfn>specs</dfn>.
<dt><var>file</var><code>.adb</code><dd>Ada source code file containing a library unit body (a subprogram or
package body). Such files are also called <dfn>bodies</dfn>.
<!-- GCC also knows about some suffixes for languages not yet included: -->
<!-- Pascal: -->
<!-- @var{file}.p -->
<!-- @var{file}.pas -->
<!-- Ratfor: -->
<!-- @var{file}.r -->
<br><dt><var>file</var><code>.s</code><dd>Assembler code.
<br><dt><var>file</var><code>.S</code><dt><var>file</var><code>.sx</code><dd>Assembler code which must be preprocessed.
<br><dt><var>other</var><dd>An object file to be fed straight into linking.
Any file name with no recognized suffix is treated this way.
</dl>
<p><a name="index-x-74"></a>You can specify the input language explicitly with the <span class="option">-x</span> option:
<dl>
<dt><code>-x </code><var>language</var><dd>Specify explicitly the <var>language</var> for the following input files
(rather than letting the compiler choose a default based on the file
name suffix). This option applies to all following input files until
the next <span class="option">-x</span> option. Possible values for <var>language</var> are:
<pre class="smallexample"> c c-header c-cpp-output
c++ c++-header c++-cpp-output
objective-c objective-c-header objective-c-cpp-output
objective-c++ objective-c++-header objective-c++-cpp-output
assembler assembler-with-cpp
ada
f95 f95-cpp-input
java
treelang
</pre>
<br><dt><code>-x none</code><dd>Turn off any specification of a language, so that subsequent files are
handled according to their file name suffixes (as they are if <span class="option">-x</span>
has not been used at all).
<br><dt><code>-pass-exit-codes</code><dd><a name="index-pass_002dexit_002dcodes-75"></a>Normally the <span class="command">gcc</span> program will exit with the code of 1 if any
phase of the compiler returns a non-success return code. If you specify
<span class="option">-pass-exit-codes</span>, the <span class="command">gcc</span> program will instead return with
numerically highest error produced by any phase that returned an error
indication. The C, C++, and Fortran frontends return 4, if an internal
compiler error is encountered.
</dl>
<p>If you only want some of the stages of compilation, you can use
<span class="option">-x</span> (or filename suffixes) to tell <span class="command">gcc</span> where to start, and
one of the options <span class="option">-c</span>, <span class="option">-S</span>, or <span class="option">-E</span> to say where
<span class="command">gcc</span> is to stop. Note that some combinations (for example,
<span class="samp">-x cpp-output -E</span>) instruct <span class="command">gcc</span> to do nothing at all.
<dl>
<dt><code>-c</code><dd><a name="index-c-76"></a>Compile or assemble the source files, but do not link. The linking
stage simply is not done. The ultimate output is in the form of an
object file for each source file.
<p>By default, the object file name for a source file is made by replacing
the suffix <span class="samp">.c</span>, <span class="samp">.i</span>, <span class="samp">.s</span>, etc., with <span class="samp">.o</span>.
<p>Unrecognized input files, not requiring compilation or assembly, are
ignored.
<br><dt><code>-S</code><dd><a name="index-S-77"></a>Stop after the stage of compilation proper; do not assemble. The output
is in the form of an assembler code file for each non-assembler input
file specified.
<p>By default, the assembler file name for a source file is made by
replacing the suffix <span class="samp">.c</span>, <span class="samp">.i</span>, etc., with <span class="samp">.s</span>.
<p>Input files that don't require compilation are ignored.
<br><dt><code>-E</code><dd><a name="index-E-78"></a>Stop after the preprocessing stage; do not run the compiler proper. The
output is in the form of preprocessed source code, which is sent to the
standard output.
<p>Input files which don't require preprocessing are ignored.
<p><a name="index-output-file-option-79"></a><br><dt><code>-o </code><var>file</var><dd><a name="index-o-80"></a>Place output in file <var>file</var>. This applies regardless to whatever
sort of output is being produced, whether it be an executable file,
an object file, an assembler file or preprocessed C code.
<p>If <span class="option">-o</span> is not specified, the default is to put an executable
file in <span class="file">a.out</span>, the object file for
<var>source</var><span class="file">.</span><var>suffix</var> in <var>source</var><span class="file">.o</span>, its
assembler file in <var>source</var><span class="file">.s</span>, a precompiled header file in
<var>source</var><span class="file">.</span><var>suffix</var><span class="file">.gch</span>, and all preprocessed C source on
standard output.
<br><dt><code>-v</code><dd><a name="index-v-81"></a>Print (on standard error output) the commands executed to run the stages
of compilation. Also print the version number of the compiler driver
program and of the preprocessor and the compiler proper.
<br><dt><code>-###</code><dd><a name="index-_0023_0023_0023-82"></a>Like <span class="option">-v</span> except the commands are not executed and all command
arguments are quoted. This is useful for shell scripts to capture the
driver-generated command lines.
<br><dt><code>-pipe</code><dd><a name="index-pipe-83"></a>Use pipes rather than temporary files for communication between the
various stages of compilation. This fails to work on some systems where
the assembler is unable to read from a pipe; but the GNU assembler has
no trouble.
<br><dt><code>-combine</code><dd><a name="index-combine-84"></a>If you are compiling multiple source files, this option tells the driver
to pass all the source files to the compiler at once (for those
languages for which the compiler can handle this). This will allow
intermodule analysis (IMA) to be performed by the compiler. Currently the only
language for which this is supported is C. If you pass source files for
multiple languages to the driver, using this option, the driver will invoke
the compiler(s) that support IMA once each, passing each compiler all the
source files appropriate for it. For those languages that do not support
IMA this option will be ignored, and the compiler will be invoked once for
each source file in that language. If you use this option in conjunction
with <span class="option">-save-temps</span>, the compiler will generate multiple
pre-processed files
(one for each source file), but only one (combined) <span class="file">.o</span> or
<span class="file">.s</span> file.
<br><dt><code>--help</code><dd><a name="index-help-85"></a>Print (on the standard output) a description of the command line options
understood by <span class="command">gcc</span>. If the <span class="option">-v</span> option is also specified
then <span class="option">--help</span> will also be passed on to the various processes
invoked by <span class="command">gcc</span>, so that they can display the command line options
they accept. If the <span class="option">-Wextra</span> option has also been specified
(prior to the <span class="option">--help</span> option), then command line options which
have no documentation associated with them will also be displayed.
<br><dt><code>--target-help</code><dd><a name="index-target_002dhelp-86"></a>Print (on the standard output) a description of target-specific command
line options for each tool. For some targets extra target-specific
information may also be printed.
<br><dt><code>--help=</code><var>class</var><span class="roman">[</span><code>,</code><var>qualifier</var><span class="roman">]</span><dd>Print (on the standard output) a description of the command line
options understood by the compiler that fit into a specific class.
The class can be one of <span class="samp">optimizers</span>, <span class="samp">warnings</span>, <span class="samp">target</span>,
<span class="samp">params</span>, or <var>language</var>:
<dl>
<dt><span class="samp">optimizers</span><dd>This will display all of the optimization options supported by the
compiler.
<br><dt><span class="samp">warnings</span><dd>This will display all of the options controlling warning messages
produced by the compiler.
<br><dt><span class="samp">target</span><dd>This will display target-specific options. Unlike the
<span class="option">--target-help</span> option however, target-specific options of the
linker and assembler will not be displayed. This is because those
tools do not currently support the extended <span class="option">--help=</span> syntax.
<br><dt><span class="samp">params</span><dd>This will display the values recognized by the <span class="option">--param</span>
option.
<br><dt><var>language</var><dd>This will display the options supported for <var>language</var>, where
<var>language</var> is the name of one of the languages supported in this
version of GCC.
<br><dt><span class="samp">common</span><dd>This will display the options that are common to all languages.
</dl>
<p>It is possible to further refine the output of the <span class="option">--help=</span>
option by adding a comma separated list of qualifiers after the
class. These can be any from the following list:
<dl>
<dt><span class="samp">undocumented</span><dd>Display only those options which are undocumented.
<br><dt><span class="samp">joined</span><dd>Display options which take an argument that appears after an equal
sign in the same continuous piece of text, such as:
<span class="samp">--help=target</span>.
<br><dt><span class="samp">separate</span><dd>Display options which take an argument that appears as a separate word
following the original option, such as: <span class="samp">-o output-file</span>.
</dl>
<p>Thus for example to display all the undocumented target-specific
switches supported by the compiler the following can be used:
<pre class="smallexample"> --help=target,undocumented
</pre>
<p>The sense of a qualifier can be inverted by prefixing it with the
<var>^</var> character, so for example to display all binary warning
options (i.e., ones that are either on or off and that do not take an
argument), which have a description the following can be used:
<pre class="smallexample"> --help=warnings,^joined,^undocumented
</pre>
<p>A class can also be used as a qualifier, although this usually
restricts the output by so much that there is nothing to display. One
case where it does work however is when one of the classes is
<var>target</var>. So for example to display all the target-specific
optimization options the following can be used:
<pre class="smallexample"> --help=target,optimizers
</pre>
<p>The <span class="option">--help=</span> option can be repeated on the command line. Each
successive use will display its requested class of options, skipping
those that have already been displayed.
<p>If the <span class="option">-Q</span> option appears on the command line before the
<span class="option">--help=</span> option, then the descriptive text displayed by
<span class="option">--help=</span> is changed. Instead of describing the displayed
options, an indication is given as to whether the option is enabled,
disabled or set to a specific value (assuming that the compiler
knows this at the point where the <span class="option">--help=</span> option is used).
<p>Here is a truncated example from the ARM port of <span class="command">gcc</span>:
<pre class="smallexample"> % gcc -Q -mabi=2 --help=target -c
The following options are target specific:
-mabi= 2
-mabort-on-noreturn [disabled]
-mapcs [disabled]
</pre>
<p>The output is sensitive to the effects of previous command line
options, so for example it is possible to find out which optimizations
are enabled at <span class="option">-O2</span> by using:
<pre class="smallexample"> -O2 --help=optimizers
</pre>
<p>Alternatively you can discover which binary optimizations are enabled
by <span class="option">-O3</span> by using:
<pre class="smallexample"> gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
</pre>
<br><dt><code>--version</code><dd><a name="index-version-87"></a>Display the version number and copyrights of the invoked GCC.
<!-- This file is designed to be included in manuals that use -->
<!-- expandargv. -->
<br><dt><code>@</code><var>file</var><dd>Read command-line options from <var>file</var>. The options read are
inserted in place of the original @<var>file</var> option. If <var>file</var>
does not exist, or cannot be read, then the option will be treated
literally, and not removed.
<p>Options in <var>file</var> are separated by whitespace. A whitespace
character may be included in an option by surrounding the entire
option in either single or double quotes. Any character (including a
backslash) may be included by prefixing the character to be included
with a backslash. The <var>file</var> may itself contain additional
@<var>file</var> options; any such options will be processed recursively.
</dl>
</body></html>
| {
"pile_set_name": "Github"
} |
//
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
//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 3Dlabs Inc. Ltd. 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 HOLDERS 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.
//
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
NVIDIA Corporation("NVIDIA") supplies this software to you in
consideration of your agreement to the following terms, and your use,
installation, modification or redistribution of this NVIDIA software
constitutes acceptance of these terms. If you do not agree with these
terms, please do not use, install, modify or redistribute this NVIDIA
software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, NVIDIA grants you a personal, non-exclusive
license, under NVIDIA's copyrights in this original NVIDIA software (the
"NVIDIA Software"), to use, reproduce, modify and redistribute the
NVIDIA Software, with or without modifications, in source and/or binary
forms; provided that if you redistribute the NVIDIA Software, you must
retain the copyright notice of NVIDIA, this notice and the following
text and disclaimers in all such redistributions of the NVIDIA Software.
Neither the name, trademarks, service marks nor logos of NVIDIA
Corporation may be used to endorse or promote products derived from the
NVIDIA Software without specific prior written permission from NVIDIA.
Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
PRODUCTS.
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
//
// scanner.c
//
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if 0
#include <ieeefp.h>
#else
#define isinff(x) (((*(int *)&(x) & 0x7f800000L)==0x7f800000L) && \
((*(int *)&(x) & 0x007fffffL)==0000000000L))
#endif
#include "slglobals.h"
typedef struct StringInputSrc {
InputSrc base;
char *p;
} StringInputSrc;
static int eof_scan(InputSrc *is, yystypepp * yylvalpp)
{
return EOF;
} // eof_scan
static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}
static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
static int byte_scan(InputSrc *, yystypepp * yylvalpp);
#define EOL_SY '\n'
#if defined(_WIN32)
#define DBG_BREAKPOINT() __asm int 3
#elif defined(_M_AMD64)
#define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");
#else
#define DBG_BREAKPOINT()
#endif
#if defined(_WIN32) && !defined(_M_AMD64)
__int64 RDTSC ( void ) {
__int64 v;
__asm __emit 0x0f
__asm __emit 0x31
__asm mov dword ptr v, eax
__asm mov dword ptr v+4, edx
return v;
}
#endif
int InitScanner(CPPStruct *cpp)
{
// Add various atoms needed by the CPP line scanner:
if (!InitCPP())
return 0;
cpp->mostRecentToken = 0;
cpp->tokenLoc = &cpp->ltokenLoc;
cpp->ltokenLoc.file = 0;
cpp->ltokenLoc.line = 0;
cpp->currentInput = &eof_inputsrc;
cpp->previous_token = '\n';
cpp->notAVersionToken = 0;
return 1;
} // InitScanner
int FreeScanner(void)
{
return (FreeCPP());
}
/*
* str_getch()
* takes care of reading from multiple strings.
* returns the next-char from the input stream.
* returns EOF when the complete shader is parsed.
*/
static int str_getch(StringInputSrc *in)
{
for(;;){
if (*in->p){
if (*in->p == '\n') {
in->base.line++;
IncLineNumber();
}
return *in->p++;
}
if(++(cpp->PaWhichStr) < cpp->PaArgc){
free(in);
SetStringNumber(cpp->PaWhichStr);
SetLineNumber(1);
ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);
in=(StringInputSrc*)cpp->currentInput;
continue;
}
else{
cpp->currentInput = in->base.prev;
cpp->PaWhichStr=0;
free(in);
return EOF;
}
}
} // str_getch
static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {
if (in->p[-1] == ch)in->p--;
else {
*(in->p)='\0'; //this would take care of shifting to the previous string.
cpp->PaWhichStr--;
}
if (ch == '\n') {
in->base.line--;
DecLineNumber();
}
} // str_ungetch
int ScanFromString(char *s)
{
StringInputSrc *in = malloc(sizeof(StringInputSrc));
memset(in, 0, sizeof(StringInputSrc));
in->p = s;
in->base.line = 1;
in->base.scan = byte_scan;
in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;
in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;
in->base.prev = cpp->currentInput;
cpp->currentInput = &in->base;
return 1;
} // ScanFromString;
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// Floating point constants: /////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/*
* lBuildFloatValue() - Quick and dirty conversion to floating point. Since all
* we need is single precision this should be quite precise.
*/
static float lBuildFloatValue(const char *str, int len, int exp)
{
double val, expval, ten;
int ii, llen, absexp;
float rv;
val = 0.0;
llen = len;
for (ii = 0; ii < len; ii++)
val = val*10.0 + (str[ii] - '0');
if (exp != 0) {
absexp = exp > 0 ? exp : -exp;
expval = 1.0f;
ten = 10.0;
while (absexp) {
if (absexp & 1)
expval *= ten;
ten *= ten;
absexp >>= 1;
}
if (exp >= 0) {
val *= expval;
} else {
val /= expval;
}
}
rv = (float)val;
if (isinff(rv)) {
CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");
}
return rv;
} // lBuildFloatValue
/*
* lFloatConst() - Scan a floating point constant. Assumes that the scanner
* has seen at least one digit, followed by either a decimal '.' or the
* letter 'e'.
*/
static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
{
int HasDecimal, declen, exp, ExpSign;
int str_len;
float lval;
HasDecimal = 0;
declen = 0;
exp = 0;
str_len=len;
if (ch == '.') {
str[len++]=ch;
HasDecimal = 1;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
while (ch >= '0' && ch <= '9') {
if (len < MAX_SYMBOL_NAME_LEN) {
declen++;
if (len > 0 || ch != '0') {
str[len] = ch;
len++;str_len++;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else {
CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
len = 1,str_len=1;
}
}
}
// Exponent:
if (ch == 'e' || ch == 'E') {
ExpSign = 1;
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '+') {
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else if (ch == '-') {
ExpSign = -1;
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
if (ch >= '0' && ch <= '9') {
while (ch >= '0' && ch <= '9') {
exp = exp*10 + ch - '0';
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
} else {
CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");
}
exp *= ExpSign;
}
if (len == 0) {
lval = 0.0f;
strcpy(str,"0.0");
} else {
str[len]='\0';
lval = lBuildFloatValue(str, str_len, exp - declen);
}
// Suffix:
yylvalpp->sc_fval = lval;
strcpy(yylvalpp->symbol_name,str);
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return CPP_FLOATCONSTANT;
} // lFloatConst
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// Normal Scanner //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
{
char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
char string_val[MAX_STRING_LEN + 1];
int AlreadyComplained;
int len, ch, ii, ival = 0;
for (;;) {
yylvalpp->sc_int = 0;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
while (ch == ' ' || ch == '\t' || ch == '\r') {
yylvalpp->sc_int = 1;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
cpp->ltokenLoc.file = cpp->currentInput->name;
cpp->ltokenLoc.line = cpp->currentInput->line;
len = 0;
switch (ch) {
default:
return ch; // Single character token
case EOF:
return -1;
case 'A': case 'B': case 'C': case 'D': case 'E':
case 'F': case 'G': case 'H': case 'I': case 'J':
case 'K': case 'L': case 'M': case 'N': case 'O':
case 'P': case 'Q': case 'R': case 'S': case 'T':
case 'U': case 'V': case 'W': case 'X': case 'Y':
case 'Z': case '_':
case 'a': case 'b': case 'c': case 'd': case 'e':
case 'f': case 'g': case 'h': case 'i': case 'j':
case 'k': case 'l': case 'm': case 'n': case 'o':
case 'p': case 'q': case 'r': case 's': case 't':
case 'u': case 'v': case 'w': case 'x': case 'y':
case 'z':
do {
if (len < MAX_SYMBOL_NAME_LEN) {
symbol_name[len] = ch;
len++;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else {
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
} while ((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
(ch >= '0' && ch <= '9') ||
ch == '_');
if (len >= MAX_SYMBOL_NAME_LEN)
len = MAX_SYMBOL_NAME_LEN - 1;
symbol_name[len] = '\0';
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
return CPP_IDENTIFIER;
break;
case '0':
yylvalpp->symbol_name[len++] = ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == 'x' || ch == 'X') {
yylvalpp->symbol_name[len++] = ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'))
{
AlreadyComplained = 0;
ival = 0;
do {
yylvalpp->symbol_name[len++] = ch;
if (ival <= 0x0fffffff) {
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
} else if (ch >= 'A' && ch <= 'F') {
ii = ch - 'A' + 10;
} else {
ii = ch - 'a' + 10;
}
ival = (ival << 4) | ii;
} else {
if (!AlreadyComplained)
CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");
AlreadyComplained = 1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} while ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'));
} else {
CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");
}
yylvalpp->symbol_name[len] = '\0';
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
yylvalpp->sc_int = ival;
return CPP_INTCONSTANT;
} else if (ch >= '0' && ch <= '7') { // octal integer constants
AlreadyComplained = 0;
ival = 0;
do {
yylvalpp->symbol_name[len++] = ch;
if (ival <= 0x1fffffff) {
ii = ch - '0';
ival = (ival << 3) | ii;
} else {
if (!AlreadyComplained)
CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");
AlreadyComplained = 1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} while (ch >= '0' && ch <= '7');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E')
return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
yylvalpp->symbol_name[len] = '\0';
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
yylvalpp->sc_int = ival;
return CPP_INTCONSTANT;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
ch = '0';
}
// Fall through...
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
do {
if (len < MAX_SYMBOL_NAME_LEN) {
if (len > 0 || ch != '0') {
yylvalpp->symbol_name[len] = ch;
len++;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
} while (ch >= '0' && ch <= '9');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {
return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
} else {
yylvalpp->symbol_name[len] = '\0';
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
ival = 0;
AlreadyComplained = 0;
for (ii = 0; ii < len; ii++) {
ch = yylvalpp->symbol_name[ii] - '0';
if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) {
if (!AlreadyComplained)
CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");
AlreadyComplained = 1;
}
ival = ival*10 + ch;
}
yylvalpp->sc_int = ival;
if(ival==0)
strcpy(yylvalpp->symbol_name,"0");
return CPP_INTCONSTANT;
}
break;
case '-':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '-') {
return CPP_DEC_OP;
} else if (ch == '=') {
return CPP_SUB_ASSIGN;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '-';
}
case '+':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '+') {
return CPP_INC_OP;
} else if (ch == '=') {
return CPP_ADD_ASSIGN;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '+';
}
case '*':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_MUL_ASSIGN;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '*';
}
case '%':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_MOD_ASSIGN;
} else if (ch == '>'){
return CPP_RIGHT_BRACE;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '%';
}
case ':':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '>') {
return CPP_RIGHT_BRACKET;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return ':';
}
case '^':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '^') {
return CPP_XOR_OP;
} else {
if (ch == '=')
return CPP_XOR_ASSIGN;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '^';
}
}
case '=':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_EQ_OP;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '=';
}
case '!':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '=') {
return CPP_NE_OP;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '!';
}
case '|':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '|') {
return CPP_OR_OP;
} else {
if (ch == '=')
return CPP_OR_ASSIGN;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '|';
}
}
case '&':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '&') {
return CPP_AND_OP;
} else {
if (ch == '=')
return CPP_AND_ASSIGN;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '&';
}
}
case '<':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '<') {
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if(ch == '=')
return CPP_LEFT_ASSIGN;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return CPP_LEFT_OP;
}
} else {
if (ch == '=') {
return CPP_LE_OP;
} else {
if (ch == '%')
return CPP_LEFT_BRACE;
else if (ch == ':')
return CPP_LEFT_BRACKET;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '<';
}
}
}
case '>':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '>') {
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if(ch == '=')
return CPP_RIGHT_ASSIGN;
else{
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return CPP_RIGHT_OP;
}
} else {
if (ch == '=') {
return CPP_GE_OP;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '>';
}
}
case '.':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch >= '0' && ch <= '9') {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);
} else {
if (ch == '.') {
return -1; // Special EOF hack
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '.';
}
}
case '/':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '/') {
do {
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} while (ch != '\n' && ch != EOF);
if (ch == EOF)
return -1;
return '\n';
} else if (ch == '*') {
int nlcount = 0;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
do {
while (ch != '*') {
if (ch == '\n') nlcount++;
if (ch == EOF) {
CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
return -1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == EOF) {
CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
return -1;
}
} while (ch != '/');
if (nlcount) {
return '\n';
}
// Go try it again...
} else if (ch == '=') {
return CPP_DIV_ASSIGN;
} else {
cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
return '/';
}
break;
case '"':
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
while (ch != '"' && ch != '\n' && ch != EOF) {
if (ch == '\\') {
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == '\n' || ch == EOF) {
break;
}
}
if (len < MAX_STRING_LEN) {
string_val[len] = ch;
len++;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
};
string_val[len] = '\0';
if (ch == '"') {
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
return CPP_STRCONSTANT;
} else {
CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");
return ERROR_SY;
}
}
}
} // byte_scan
int yylex_CPP(char* buf, int maxSize)
{
yystypepp yylvalpp;
int token = '\n';
for(;;) {
char* tokenString = 0;
token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);
if(check_EOF(token))
return 0;
if (token == '#') {
if (cpp->previous_token == '\n'|| cpp->previous_token == 0) {
token = readCPPline(&yylvalpp);
if(check_EOF(token))
return 0;
continue;
} else {
CPPErrorToInfoLog("preprocessor command must not be preceded by any other statement in that line");
return 0;
}
}
cpp->previous_token = token;
// expand macros
if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
cpp->notAVersionToken = 1;
continue;
}
if (token == '\n')
continue;
if (token == CPP_IDENTIFIER) {
cpp->notAVersionToken = 1;
tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
} else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){
cpp->notAVersionToken = 1;
tokenString = yylvalpp.symbol_name;
} else {
cpp->notAVersionToken = 1;
tokenString = GetStringOfAtom(atable,token);
}
if (tokenString) {
if ((signed)strlen(tokenString) >= maxSize) {
cpp->tokensBeforeEOF = 1;
return maxSize;
} else if (strlen(tokenString) > 0) {
strcpy(buf, tokenString);
cpp->tokensBeforeEOF = 1;
return (int)strlen(tokenString);
}
return 0;
}
}
return 0;
} // yylex
//Checks if the token just read is EOF or not.
int check_EOF(int token)
{
if(token==-1){
if(cpp->ifdepth >0){
CPPErrorToInfoLog("#endif missing!! Compilation stopped");
cpp->CompileError=1;
}
return 1;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// End of scanner.c //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
* You may select, at your option, one of the above-listed licenses.
*/
#ifndef MEM_H_MODULE
#define MEM_H_MODULE
#if defined (__cplusplus)
extern "C" {
#endif
/*-****************************************
* Dependencies
******************************************/
#include <stddef.h> /* size_t, ptrdiff_t */
#include <string.h> /* memcpy */
/*-****************************************
* Compiler specifics
******************************************/
#if defined(_MSC_VER) /* Visual Studio */
# include <stdlib.h> /* _byteswap_ulong */
# include <intrin.h> /* _byteswap_* */
#endif
#if defined(__GNUC__)
# define MEM_STATIC static __inline __attribute__((unused))
#elif defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
# define MEM_STATIC static inline
#elif defined(_MSC_VER)
# define MEM_STATIC static __inline
#else
# define MEM_STATIC static /* this version may generate warnings for unused static functions; disable the relevant warning */
#endif
#ifndef __has_builtin
# define __has_builtin(x) 0 /* compat. with non-clang compilers */
#endif
/* code only tested on 32 and 64 bits systems */
#define MEM_STATIC_ASSERT(c) { enum { MEM_static_assert = 1/(int)(!!(c)) }; }
MEM_STATIC void MEM_check(void) { MEM_STATIC_ASSERT((sizeof(size_t)==4) || (sizeof(size_t)==8)); }
/*-**************************************************************
* Basic Types
*****************************************************************/
#if !defined (__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
# include <stdint.h>
typedef uint8_t BYTE;
typedef uint16_t U16;
typedef int16_t S16;
typedef uint32_t U32;
typedef int32_t S32;
typedef uint64_t U64;
typedef int64_t S64;
#else
# include <limits.h>
#if CHAR_BIT != 8
# error "this implementation requires char to be exactly 8-bit type"
#endif
typedef unsigned char BYTE;
#if USHRT_MAX != 65535
# error "this implementation requires short to be exactly 16-bit type"
#endif
typedef unsigned short U16;
typedef signed short S16;
#if UINT_MAX != 4294967295
# error "this implementation requires int to be exactly 32-bit type"
#endif
typedef unsigned int U32;
typedef signed int S32;
/* note : there are no limits defined for long long type in C90.
* limits exist in C99, however, in such case, <stdint.h> is preferred */
typedef unsigned long long U64;
typedef signed long long S64;
#endif
/*-**************************************************************
* Memory I/O
*****************************************************************/
/* MEM_FORCE_MEMORY_ACCESS :
* By default, access to unaligned memory is controlled by `memcpy()`, which is safe and portable.
* Unfortunately, on some target/compiler combinations, the generated assembly is sub-optimal.
* The below switch allow to select different access method for improved performance.
* Method 0 (default) : use `memcpy()`. Safe and portable.
* Method 1 : `__packed` statement. It depends on compiler extension (i.e., not portable).
* This method is safe if your compiler supports it, and *generally* as fast or faster than `memcpy`.
* Method 2 : direct access. This method is portable but violate C standard.
* It can generate buggy code on targets depending on alignment.
* In some circumstances, it's the only known way to get the most performance (i.e. GCC + ARMv6)
* See http://fastcompression.blogspot.fr/2015/08/accessing-unaligned-memory.html for details.
* Prefer these methods in priority order (0 > 1 > 2)
*/
#ifndef MEM_FORCE_MEMORY_ACCESS /* can be defined externally, on command line for example */
# if defined(__GNUC__) && ( defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) )
# define MEM_FORCE_MEMORY_ACCESS 2
# elif defined(__INTEL_COMPILER) || defined(__GNUC__)
# define MEM_FORCE_MEMORY_ACCESS 1
# endif
#endif
MEM_STATIC unsigned MEM_32bits(void) { return sizeof(size_t)==4; }
MEM_STATIC unsigned MEM_64bits(void) { return sizeof(size_t)==8; }
MEM_STATIC unsigned MEM_isLittleEndian(void)
{
const union { U32 u; BYTE c[4]; } one = { 1 }; /* don't use static : performance detrimental */
return one.c[0];
}
#if defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==2)
/* violates C standard, by lying on structure alignment.
Only use if no other choice to achieve best performance on target platform */
MEM_STATIC U16 MEM_read16(const void* memPtr) { return *(const U16*) memPtr; }
MEM_STATIC U32 MEM_read32(const void* memPtr) { return *(const U32*) memPtr; }
MEM_STATIC U64 MEM_read64(const void* memPtr) { return *(const U64*) memPtr; }
MEM_STATIC size_t MEM_readST(const void* memPtr) { return *(const size_t*) memPtr; }
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { *(U16*)memPtr = value; }
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { *(U32*)memPtr = value; }
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { *(U64*)memPtr = value; }
#elif defined(MEM_FORCE_MEMORY_ACCESS) && (MEM_FORCE_MEMORY_ACCESS==1)
/* __pack instructions are safer, but compiler specific, hence potentially problematic for some compilers */
/* currently only defined for gcc and icc */
#if defined(_MSC_VER) || (defined(__INTEL_COMPILER) && defined(WIN32))
__pragma( pack(push, 1) )
typedef struct { U16 v; } unalign16;
typedef struct { U32 v; } unalign32;
typedef struct { U64 v; } unalign64;
typedef struct { size_t v; } unalignArch;
__pragma( pack(pop) )
#else
typedef struct { U16 v; } __attribute__((packed)) unalign16;
typedef struct { U32 v; } __attribute__((packed)) unalign32;
typedef struct { U64 v; } __attribute__((packed)) unalign64;
typedef struct { size_t v; } __attribute__((packed)) unalignArch;
#endif
MEM_STATIC U16 MEM_read16(const void* ptr) { return ((const unalign16*)ptr)->v; }
MEM_STATIC U32 MEM_read32(const void* ptr) { return ((const unalign32*)ptr)->v; }
MEM_STATIC U64 MEM_read64(const void* ptr) { return ((const unalign64*)ptr)->v; }
MEM_STATIC size_t MEM_readST(const void* ptr) { return ((const unalignArch*)ptr)->v; }
MEM_STATIC void MEM_write16(void* memPtr, U16 value) { ((unalign16*)memPtr)->v = value; }
MEM_STATIC void MEM_write32(void* memPtr, U32 value) { ((unalign32*)memPtr)->v = value; }
MEM_STATIC void MEM_write64(void* memPtr, U64 value) { ((unalign64*)memPtr)->v = value; }
#else
/* default method, safe and standard.
can sometimes prove slower */
MEM_STATIC U16 MEM_read16(const void* memPtr)
{
U16 val; memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC U32 MEM_read32(const void* memPtr)
{
U32 val; memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC U64 MEM_read64(const void* memPtr)
{
U64 val; memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC size_t MEM_readST(const void* memPtr)
{
size_t val; memcpy(&val, memPtr, sizeof(val)); return val;
}
MEM_STATIC void MEM_write16(void* memPtr, U16 value)
{
memcpy(memPtr, &value, sizeof(value));
}
MEM_STATIC void MEM_write32(void* memPtr, U32 value)
{
memcpy(memPtr, &value, sizeof(value));
}
MEM_STATIC void MEM_write64(void* memPtr, U64 value)
{
memcpy(memPtr, &value, sizeof(value));
}
#endif /* MEM_FORCE_MEMORY_ACCESS */
MEM_STATIC U32 MEM_swap32(U32 in)
{
#if defined(_MSC_VER) /* Visual Studio */
return _byteswap_ulong(in);
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|| (defined(__clang__) && __has_builtin(__builtin_bswap32))
return __builtin_bswap32(in);
#else
return ((in << 24) & 0xff000000 ) |
((in << 8) & 0x00ff0000 ) |
((in >> 8) & 0x0000ff00 ) |
((in >> 24) & 0x000000ff );
#endif
}
MEM_STATIC U64 MEM_swap64(U64 in)
{
#if defined(_MSC_VER) /* Visual Studio */
return _byteswap_uint64(in);
#elif (defined (__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 403)) \
|| (defined(__clang__) && __has_builtin(__builtin_bswap64))
return __builtin_bswap64(in);
#else
return ((in << 56) & 0xff00000000000000ULL) |
((in << 40) & 0x00ff000000000000ULL) |
((in << 24) & 0x0000ff0000000000ULL) |
((in << 8) & 0x000000ff00000000ULL) |
((in >> 8) & 0x00000000ff000000ULL) |
((in >> 24) & 0x0000000000ff0000ULL) |
((in >> 40) & 0x000000000000ff00ULL) |
((in >> 56) & 0x00000000000000ffULL);
#endif
}
MEM_STATIC size_t MEM_swapST(size_t in)
{
if (MEM_32bits())
return (size_t)MEM_swap32((U32)in);
else
return (size_t)MEM_swap64((U64)in);
}
/*=== Little endian r/w ===*/
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
{
if (MEM_isLittleEndian())
return MEM_read16(memPtr);
else {
const BYTE* p = (const BYTE*)memPtr;
return (U16)(p[0] + (p[1]<<8));
}
}
MEM_STATIC void MEM_writeLE16(void* memPtr, U16 val)
{
if (MEM_isLittleEndian()) {
MEM_write16(memPtr, val);
} else {
BYTE* p = (BYTE*)memPtr;
p[0] = (BYTE)val;
p[1] = (BYTE)(val>>8);
}
}
MEM_STATIC U32 MEM_readLE24(const void* memPtr)
{
return MEM_readLE16(memPtr) + (((const BYTE*)memPtr)[2] << 16);
}
MEM_STATIC void MEM_writeLE24(void* memPtr, U32 val)
{
MEM_writeLE16(memPtr, (U16)val);
((BYTE*)memPtr)[2] = (BYTE)(val>>16);
}
MEM_STATIC U32 MEM_readLE32(const void* memPtr)
{
if (MEM_isLittleEndian())
return MEM_read32(memPtr);
else
return MEM_swap32(MEM_read32(memPtr));
}
MEM_STATIC void MEM_writeLE32(void* memPtr, U32 val32)
{
if (MEM_isLittleEndian())
MEM_write32(memPtr, val32);
else
MEM_write32(memPtr, MEM_swap32(val32));
}
MEM_STATIC U64 MEM_readLE64(const void* memPtr)
{
if (MEM_isLittleEndian())
return MEM_read64(memPtr);
else
return MEM_swap64(MEM_read64(memPtr));
}
MEM_STATIC void MEM_writeLE64(void* memPtr, U64 val64)
{
if (MEM_isLittleEndian())
MEM_write64(memPtr, val64);
else
MEM_write64(memPtr, MEM_swap64(val64));
}
MEM_STATIC size_t MEM_readLEST(const void* memPtr)
{
if (MEM_32bits())
return (size_t)MEM_readLE32(memPtr);
else
return (size_t)MEM_readLE64(memPtr);
}
MEM_STATIC void MEM_writeLEST(void* memPtr, size_t val)
{
if (MEM_32bits())
MEM_writeLE32(memPtr, (U32)val);
else
MEM_writeLE64(memPtr, (U64)val);
}
/*=== Big endian r/w ===*/
MEM_STATIC U32 MEM_readBE32(const void* memPtr)
{
if (MEM_isLittleEndian())
return MEM_swap32(MEM_read32(memPtr));
else
return MEM_read32(memPtr);
}
MEM_STATIC void MEM_writeBE32(void* memPtr, U32 val32)
{
if (MEM_isLittleEndian())
MEM_write32(memPtr, MEM_swap32(val32));
else
MEM_write32(memPtr, val32);
}
MEM_STATIC U64 MEM_readBE64(const void* memPtr)
{
if (MEM_isLittleEndian())
return MEM_swap64(MEM_read64(memPtr));
else
return MEM_read64(memPtr);
}
MEM_STATIC void MEM_writeBE64(void* memPtr, U64 val64)
{
if (MEM_isLittleEndian())
MEM_write64(memPtr, MEM_swap64(val64));
else
MEM_write64(memPtr, val64);
}
MEM_STATIC size_t MEM_readBEST(const void* memPtr)
{
if (MEM_32bits())
return (size_t)MEM_readBE32(memPtr);
else
return (size_t)MEM_readBE64(memPtr);
}
MEM_STATIC void MEM_writeBEST(void* memPtr, size_t val)
{
if (MEM_32bits())
MEM_writeBE32(memPtr, (U32)val);
else
MEM_writeBE64(memPtr, (U64)val);
}
#if defined (__cplusplus)
}
#endif
#endif /* MEM_H_MODULE */
| {
"pile_set_name": "Github"
} |
//==============================================================================
//
// This file is part of GPSTk, the GPS Toolkit.
//
// The GPSTk is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 3.0 of the License, or
// any later version.
//
// The GPSTk 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 GPSTk; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
//
// Copyright 2004-2019, The University of Texas at Austin
//
//==============================================================================
//==============================================================================
//
// This software developed by Applied Research Laboratories at the University of
// Texas at Austin, under contract to an agency or agencies within the U.S.
// Department of Defense. The U.S. Government retains all rights to use,
// duplicate, distribute, disclose, or release this software.
//
// Pursuant to DoD Directive 523024
//
// DISTRIBUTION STATEMENT A: This software has been approved for public
// release, distribution is unlimited.
//
//==============================================================================
#ifndef XBRCCLOCKCORRECTIONGPSNAVMSG_HPP
#define XBRCCLOCKCORRECTIONGPSNAVMSG_HPP
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include "BrcClockCorrection.hpp"
#include "EngEphemeris.hpp"
class xBrcClockCorrectiongpsNavMsg: public CPPUNIT_NS :: TestFixture
{
CPPUNIT_TEST_SUITE (xBrcClockCorrectiongpsNavMsg);
CPPUNIT_TEST (firstTest);
CPPUNIT_TEST_SUITE_END ();
public:
void setUp (void);
protected:
void firstTest (void);
bool fileEqualTest (char*, char*);
private:
};
#endif
| {
"pile_set_name": "Github"
} |
<?php
/**
* Locale data for 'nso_ZA'.
*
* This file is automatically generated by yiic cldr command.
*
* Copyright © 1991-2007 Unicode, Inc. All rights reserved.
* Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
*
* Copyright © 2008-2011 Yii Software LLC (http://www.yiiframework.com/license/)
*/
return array (
'version' => '4123',
'numberSymbols' =>
array (
'alias' => '',
'decimal' => ',',
'group' => ' ',
'list' => ';',
'percentSign' => '%',
'plusSign' => '+',
'minusSign' => '-',
'exponential' => 'E',
'perMille' => '‰',
'infinity' => '∞',
'nan' => 'NaN',
),
'decimalFormat' => '#,##0.###',
'scientificFormat' => '#E0',
'percentFormat' => '#,##0%',
'currencyFormat' => '¤#,##0.00',
'currencySymbols' =>
array (
'AUD' => 'AU$',
'BRL' => 'R$',
'CAD' => 'CA$',
'CNY' => 'CN¥',
'EUR' => '€',
'GBP' => '£',
'HKD' => 'HK$',
'ILS' => '₪',
'INR' => '₹',
'JPY' => 'JP¥',
'KRW' => '₩',
'MXN' => 'MX$',
'NZD' => 'NZ$',
'THB' => '฿',
'TWD' => 'NT$',
'USD' => 'US$',
'VND' => '₫',
'XAF' => 'FCFA',
'XCD' => 'EC$',
'XOF' => 'CFA',
'XPF' => 'CFPF',
'ZAR' => 'R',
),
'monthNames' =>
array (
'wide' =>
array (
1 => 'Janaware',
2 => 'Feberware',
3 => 'Matšhe',
4 => 'Aporele',
5 => 'Mei',
6 => 'June',
7 => 'Julae',
8 => 'Agostose',
9 => 'Setemere',
10 => 'Oktobore',
11 => 'Nofemere',
12 => 'Disemere',
),
'abbreviated' =>
array (
1 => 'Jan',
2 => 'Feb',
3 => 'Mat',
4 => 'Apo',
5 => 'Mei',
6 => 'Jun',
7 => 'Jul',
8 => 'Ago',
9 => 'Set',
10 => 'Okt',
11 => 'Nof',
12 => 'Dis',
),
),
'monthNamesSA' =>
array (
'narrow' =>
array (
1 => '1',
2 => '2',
3 => '3',
4 => '4',
5 => '5',
6 => '6',
7 => '7',
8 => '8',
9 => '9',
10 => '10',
11 => '11',
12 => '12',
),
),
'weekDayNames' =>
array (
'wide' =>
array (
0 => 'Sontaga',
1 => 'Mosupalogo',
2 => 'Labobedi',
3 => 'Laboraro',
4 => 'Labone',
5 => 'Labohlano',
6 => 'Mokibelo',
),
'abbreviated' =>
array (
0 => 'Son',
1 => 'Mos',
2 => 'Bed',
3 => 'Rar',
4 => 'Ne',
5 => 'Hla',
6 => 'Mok',
),
),
'weekDayNamesSA' =>
array (
'narrow' =>
array (
0 => '1',
1 => '2',
2 => '3',
3 => '4',
4 => '5',
5 => '6',
6 => '7',
),
),
'eraNames' =>
array (
'abbreviated' =>
array (
0 => 'BCE',
1 => 'CE',
),
'wide' =>
array (
0 => 'BCE',
1 => 'CE',
),
'narrow' =>
array (
0 => 'BCE',
1 => 'CE',
),
),
'dateFormats' =>
array (
'full' => 'EEEE, y MMMM dd',
'long' => 'y MMMM d',
'medium' => 'y MMM d',
'short' => 'yyyy-MM-dd',
),
'timeFormats' =>
array (
'full' => 'HH:mm:ss zzzz',
'long' => 'HH:mm:ss z',
'medium' => 'HH:mm:ss',
'short' => 'HH:mm',
),
'dateTimeFormat' => '{1} {0}',
'amName' => 'AM',
'pmName' => 'PM',
'orientation' => 'ltr',
'languages' =>
array (
'nso' => 'Sesotho sa Leboa',
),
'pluralRules' =>
array (
0 => '(n>=0&&n<=1&&fmod(n,1)==0)',
1 => 'true',
),
);
| {
"pile_set_name": "Github"
} |
# 添加FunctionalReactivePixels
一个简单的画廊弄好了,但是我们是不是想看一下高清图呢?当用户点击画廊中的某一个单元格时,我们创建一个新的视图控制器并将其推入到导航堆栈中。
```
- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
FRPFullSizePhotoViewController * viewController = [[FRPFullSizePhotoViewController alloc] initWithPhotoModels:self.photosArray currentPhotoIndex:indexPath.item];
viewController.delegate = self;
[self.navigationController pushViewController:viewController animated:YES];
}
```
这个方法没有任何特殊的,只是些一般的OC方法。当然别忘了在当前实现文件里加载视图控制器(FRPFullSizePhotoViewControler)的头文件.现在让我们来创建这个视图控制器(FRPFullSizePhotoViewControler).
创建一个UIViewController的子类FRPFullSizePhotoViewControler,这不会是一个特别的‘Reactive’的视图控制器,实际上大部分只是`UIPageViewController`子视图控制器的模版。
```
@class FRPFullSizePhotoViewController;
@protocol FRPFullSizePhotoViewControllerDelegate <NSOject>
- (void)userDidScroll:(FRPFullSizePhotoViewController *)viewController toPhotoAtIndex:(NSInteger)index;
@end
@interface FRPFullSizePhotoViewController : UIViewController
- (instancetype)initWithPhotoModels:(NSArray *)photoModelArray currentPhotoIndex:(NSInteger)photoIndex;
@property (nonatomic , readonly) NSArray *photoModelArray;
@property (nonatomic, weak) id<FRPFullSizePhotoViewControllerDelegate> delegate;
@end
```
回到画廊视图控制器实现必要的代理方法:
```
- (void)userDidScroll:(FRPFullSizePhotoViewController *)viewController toPhotoAtIndex:(NSInteger)index{
[self.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:NO];
}
```
当我们滑到一个新的图像去查看其高清图片时,这个方法将更新collectionView滑动的位置。这样一来,当用户查看完高清图回到这个界面的时候,高清图所对应的缩略图将会显示在界面上,方便用户获知自己浏览的位置以及继续往下浏览。
`#import`这些必要的数据模型的头文件并追加一下两个私有属性:
```
@interface FRPFullSizePhotoViewController () <UIPageViewControllerDataSource, UIPageViewControllerDelegate>
//Private assignment
@property (nonatomic, strong) NSArray *photoModeArray;
//Private properties
@property (nonatomic, strong) UIPageViewController *pageViewController;
@end
```
`photoModelArray`是共有的只读属性,但是内部可读写。第二个属性是我们的子视图控制器。我们这样来初始化:
```
- (instancetype)initWithPhotoModels:(NSArray *)photoModelArray currentPhotoIndex:(NSInteger)photoIndex{
self = [self init];
if (!self) return nil;
//Initialized, read-only properties
self.photoModelArray = photoModelArray;
//Configure self
self.title = [self.photoModelArray[photoIndex] photoName];
//ViewControllers
self.pageViewController = [UIPageViewController alloc]
initWithTransitionStyle:UIPageViewControlerTransitionStyleScroll
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:@{ UIPageViewControllerInterPageSpacingKey: @(30)};
self.pageViewController.dataSource = self;
self.pageViewController.delegate = self;
[self addchildViewController:self.pageViewController];
[self.pageViewController setViewController:@[[self photoViewControllerForIndex:photoIndex]]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil ];
return self;
}
```
赋值属性、设置标题、配置我们的`pageViewController`,一切都非常无聊,我们的viewDidLoad方法也同样简单。
```
- (void)viewDidLoad{
[super viewDidLoad];
self.view,backGroundColor = [UIColor blackColor];
self.pageViewController.view.frame = self.view.bounds;
[self.view addSubView:self.pageViewController.view];
}
```
我要指出的是,简便起见,在我的应用里我禁用了横向展示,因为这不是一本关于`autoresizingMask`或者`autoLayout`的书。你可以通过[Eria Sadun的书](http://www.amazon.com/Layout-Demystified-Edition-Mobile-Programming/dp/0321967194)了解更多关于`autoLayout`方面的细节。
下面我们来了解一下UIPageViewController的数据源协议和代理协议。
```
- (void)pageViewController:(UIPageViewController *)pageViewController
didFinishAnimating: (BOOL)finished
previousViewControllers:(NSArray *)previousViewControllers
transitionCompleted:(BOOL)completed{
self.title = [[self.pageViewController.viewControllers.firstObject photoModel] photoName];
[self.delegate userDidScroll:self toPhotoAtIndex:[self.pageViewController.viewControllers.firstObject photoIndex]];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(FRPPhotoViewController *)viewController{
return [self photoViewControllerForIndex:viewController.photoIndex - 1];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(FRPPhotoViewController *)viewController {
return [self photoViewControllerForIndex:viewController.photoIndex + 1];
}
```
虽然这些方法没有技术上的`reactive`,却体现出一定意义上的实用性。我很佩服这种在特殊类型的视图控制器上的抽像,干得漂亮,Apple!
我们的视图控制器创建方法,类似下面这样:
```
- (FRPPhotoViewController *)photoViewControllerForIndex:(NSInteger)index{
if (index >= 0 && index < self.photoModelArray.count){
FRPPhotoModel *photoModel = self.photoModelArray[index];
FRPPhotoViewController *photoViewController = [[FRPPhotoViewController alloc] initWithPhotoModel:photoModel index:index];
return photoViewController;
}
//Index was out of bounds, return nil
return nil;
}
```
它基本上创建比配置了一个我们将要使用的UIViewController的子视图控制器FRPPhotoViewController。下面是他的头文件:
```
@class FRPPhotoModel;
@interface FRPPhotoViewController : UIViewController
- (instancetype)initWithPhotoModel:(FRPPhotoModel *)photoModel index:(NSInteger)photoIndex;
@property (nonatomic, readonly) NSInteger photoIndex;
@property (nonatomic, readonly) FRPPhotoModel * photoModel;
@end
```
这个视图控制器非常简单:显示一个photoModel下的高清图片,并提示photoImporter(单例对象)下载这个图片。它是如此简单,我现在就告诉你它的全部实现。
```
//Model
#import "FRPPhotoModel.h"
//Utilities
#import "FRPPhotoImporter.h"
#import <SVProgressHUD.h>
@interface FRPPhotoViewController ()
//Private assignment
@property (nonatomic, assign) NSInteger photoIndex;
@property (nonatomic, strong) FRPPhotoModel *photoModel;
//Private properties
@property (nonatomic, weak) UIImageView * imageView;
@end
@implementation FRPPhotoViewController
- (instancetype)initWithPhotoModel:(FRPPhotoModel *)photoModel index:(NSInteger)photoIndex{
self = [self init];
if (!self) return nil;
self.photoModel = photoModel;
self.photoIndex = photoIndex;
return self;
}
- (void)viewDidLoad{
[super viewDidLoad];
//Configure self's view
self.view.backGroundColor = [UIColor blackColor];
//Configure subViews
UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
RAC(imageView, image) = [RACObserve(self.photoModel, fullsizeData) map:^id (id value){
return [UIImage imageWithData:value];
}];
imageView.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubView:imageView];
self.imageView = imageView;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[SVProgressHUD show];
//Fetch data
[[FRPPhotoImporter fetchPhotoDetails:self.photoModel]
subscribeError:^(NSError *error){
[SVProgressHUD showErrorWithStatus:@"Error"];
}
completed:^{
[SVProgressHUD dismiss];
}];
}
@end
```
就像我们的collectionViewCell中那样,我们将UIImageView的image属性和数据模型的某个属性映射后的值绑定,所不同的是ViewController不需要考虑复用,所以我们不必计较怎么取消imageView的订阅---当imageView对象解除分配的时候,订阅将会被取消。
这个实现里面另一个有趣的部分在`viewWillAppear:`里:
```
[SVProgressHUD show];
//Fetch data
[[FRPPhotoImporter fetchPhotoDetails:self.photoModel]
subscribeError:^(NSError * error){
[SVProgressHUD showErrorWithStatus:@"Error"];
}
completed:^{
[SVProgressHUD dismiss];
}];
```
没有收到错误或者完成信息之前,我们必须给用户展示网络请求的状态。你看,500px的受欢迎的照片的API接口只返回了一个照片的大概信息,但我们需要这个照片更详细的信息,所以我们必须调用第二个API接口来获取每一个照片的详细信息(包括全尺寸照片的URL)。
```
+ (NSURLRequest *)photoURLRequest:(FRPPhotoModel *)photoModel{
return [AppDelegate.apiHelper urlRequestForPhotoID:photoModel.identifier.integerValue];
}
```
我们还没有实现`fetchPhotoDetails:`方法,所以现在我们回到`FRPPhotoImporter`中,在头文件中定义这个方法,在实现文件中实现它。
```
+ (RACReplaySubject *)fetchPhotoDetails:(FRPPhotoModel *)photoModel {
RACReplaySubject * subject = [RACReplaySubject subject];
NSURLRequest *request = [self photoURLRequest:photoModel];
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^ (NSURLResponse *response, NSData * data, NSError *connectionError){
if(data){
id results = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil][ @"photo" ];
[self configurePhotoModel:photoModel withDictionary:results];
[self downloadFullsizedImageForPhotoModel:photoModel];
[subject sendNext:photoModel];
[subject sendCompleted];
}
else{
[subject sendError:connectionError];
}
}];
return subject;
}
```
这种方法跟前面我们看到的`importPhotos`方法模式一样,我们的`downloadFullsizedImageForPhotoModel:`方法跟`downloadThumbnailForPhotoModel:`方法也是一样的。除了这两者之外,还有什么重要的抽象方法呢?让我们来完成我们的缩略图方法。
```
+ (void)downloadThumbnailForPhotoModel:(FRPPhotoModel *)photoModel {
[self download:photoModel.thumbnailURL withCompletion:^(NSData *data){
photoModel.thumbnailData = data;
}];
}
+ (void)downloadFullsizedImageForPhotoModel:(FRPPhotoModel *)photoModel {
[self download:photoModel.fullsizedURL withCompletion:^(NSData * data){
photoModel.fullsizedData = data;
}];
}
+ (void)downloadFullsizedImageForPhotoModel:(FRPPhotoModel *)photoModel {
[self download:photoModel.fullsizedURL withCompletion:^(NSData *data){
photoModel.fullsizedData = data;
}];
}
+ (void)download:(NSString *)urlString withCompletion:(void(^)(NSData * data))completion{
NSAssert(urlString, @"URL must not be nil" );
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];
[NSURLConnnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError){
if (completion){
completion(data);
}
}];
}
```
我曾经与这样一位客户工作过,他认为如果你某行一样的代码重复写两次,这代码就应该得到某种程度的抽象。虽然我认为这有点偏激,但我喜欢这种态度。
好了。我们现在可以运行这个应用,点击一个图片去查看它的高清图片。我们也可以向前或者向后滑动来查看前一个或后一个高清图片。非常棒!

| {
"pile_set_name": "Github"
} |
/*
* Copyright(c) 2011-2015 Intel Corporation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "i915_drv.h"
#include "i915_pvinfo.h"
#include "i915_vgpu.h"
/**
* DOC: Intel GVT-g guest support
*
* Intel GVT-g is a graphics virtualization technology which shares the
* GPU among multiple virtual machines on a time-sharing basis. Each
* virtual machine is presented a virtual GPU (vGPU), which has equivalent
* features as the underlying physical GPU (pGPU), so i915 driver can run
* seamlessly in a virtual machine. This file provides vGPU specific
* optimizations when running in a virtual machine, to reduce the complexity
* of vGPU emulation and to improve the overall performance.
*
* A primary function introduced here is so-called "address space ballooning"
* technique. Intel GVT-g partitions global graphics memory among multiple VMs,
* so each VM can directly access a portion of the memory without hypervisor's
* intervention, e.g. filling textures or queuing commands. However with the
* partitioning an unmodified i915 driver would assume a smaller graphics
* memory starting from address ZERO, then requires vGPU emulation module to
* translate the graphics address between 'guest view' and 'host view', for
* all registers and command opcodes which contain a graphics memory address.
* To reduce the complexity, Intel GVT-g introduces "address space ballooning",
* by telling the exact partitioning knowledge to each guest i915 driver, which
* then reserves and prevents non-allocated portions from allocation. Thus vGPU
* emulation module only needs to scan and validate graphics addresses without
* complexity of address translation.
*
*/
/**
* intel_vgpu_detect - detect virtual GPU
* @dev_priv: i915 device private
*
* This function is called at the initialization stage, to detect whether
* running on a vGPU.
*/
void intel_vgpu_detect(struct drm_i915_private *dev_priv)
{
struct pci_dev *pdev = dev_priv->drm.pdev;
u64 magic;
u16 version_major;
void __iomem *shared_area;
BUILD_BUG_ON(sizeof(struct vgt_if) != VGT_PVINFO_SIZE);
/*
* This is called before we setup the main MMIO BAR mappings used via
* the uncore structure, so we need to access the BAR directly. Since
* we do not support VGT on older gens, return early so we don't have
* to consider differently numbered or sized MMIO bars
*/
if (INTEL_GEN(dev_priv) < 6)
return;
shared_area = pci_iomap_range(pdev, 0, VGT_PVINFO_PAGE, VGT_PVINFO_SIZE);
if (!shared_area) {
drm_err(&dev_priv->drm,
"failed to map MMIO bar to check for VGT\n");
return;
}
magic = readq(shared_area + vgtif_offset(magic));
if (magic != VGT_MAGIC)
goto out;
version_major = readw(shared_area + vgtif_offset(version_major));
if (version_major < VGT_VERSION_MAJOR) {
drm_info(&dev_priv->drm, "VGT interface version mismatch!\n");
goto out;
}
dev_priv->vgpu.caps = readl(shared_area + vgtif_offset(vgt_caps));
dev_priv->vgpu.active = true;
mutex_init(&dev_priv->vgpu.lock);
drm_info(&dev_priv->drm, "Virtual GPU for Intel GVT-g detected.\n");
out:
pci_iounmap(pdev, shared_area);
}
void intel_vgpu_register(struct drm_i915_private *i915)
{
/*
* Notify a valid surface after modesetting, when running inside a VM.
*/
if (intel_vgpu_active(i915))
intel_uncore_write(&i915->uncore, vgtif_reg(display_ready),
VGT_DRV_DISPLAY_READY);
}
bool intel_vgpu_active(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.active;
}
bool intel_vgpu_has_full_ppgtt(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_FULL_PPGTT;
}
bool intel_vgpu_has_hwsp_emulation(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HWSP_EMULATION;
}
bool intel_vgpu_has_huge_gtt(struct drm_i915_private *dev_priv)
{
return dev_priv->vgpu.caps & VGT_CAPS_HUGE_GTT;
}
struct _balloon_info_ {
/*
* There are up to 2 regions per mappable/unmappable graphic
* memory that might be ballooned. Here, index 0/1 is for mappable
* graphic memory, 2/3 for unmappable graphic memory.
*/
struct drm_mm_node space[4];
};
static struct _balloon_info_ bl_info;
static void vgt_deballoon_space(struct i915_ggtt *ggtt,
struct drm_mm_node *node)
{
struct drm_i915_private *dev_priv = ggtt->vm.i915;
if (!drm_mm_node_allocated(node))
return;
drm_dbg(&dev_priv->drm,
"deballoon space: range [0x%llx - 0x%llx] %llu KiB.\n",
node->start,
node->start + node->size,
node->size / 1024);
ggtt->vm.reserved -= node->size;
drm_mm_remove_node(node);
}
/**
* intel_vgt_deballoon - deballoon reserved graphics address trunks
* @ggtt: the global GGTT from which we reserved earlier
*
* This function is called to deallocate the ballooned-out graphic memory, when
* driver is unloaded or when ballooning fails.
*/
void intel_vgt_deballoon(struct i915_ggtt *ggtt)
{
struct drm_i915_private *dev_priv = ggtt->vm.i915;
int i;
if (!intel_vgpu_active(ggtt->vm.i915))
return;
drm_dbg(&dev_priv->drm, "VGT deballoon.\n");
for (i = 0; i < 4; i++)
vgt_deballoon_space(ggtt, &bl_info.space[i]);
}
static int vgt_balloon_space(struct i915_ggtt *ggtt,
struct drm_mm_node *node,
unsigned long start, unsigned long end)
{
struct drm_i915_private *dev_priv = ggtt->vm.i915;
unsigned long size = end - start;
int ret;
if (start >= end)
return -EINVAL;
drm_info(&dev_priv->drm,
"balloon space: range [ 0x%lx - 0x%lx ] %lu KiB.\n",
start, end, size / 1024);
ret = i915_gem_gtt_reserve(&ggtt->vm, node,
size, start, I915_COLOR_UNEVICTABLE,
0);
if (!ret)
ggtt->vm.reserved += size;
return ret;
}
/**
* intel_vgt_balloon - balloon out reserved graphics address trunks
* @ggtt: the global GGTT from which to reserve
*
* This function is called at the initialization stage, to balloon out the
* graphic address space allocated to other vGPUs, by marking these spaces as
* reserved. The ballooning related knowledge(starting address and size of
* the mappable/unmappable graphic memory) is described in the vgt_if structure
* in a reserved mmio range.
*
* To give an example, the drawing below depicts one typical scenario after
* ballooning. Here the vGPU1 has 2 pieces of graphic address spaces ballooned
* out each for the mappable and the non-mappable part. From the vGPU1 point of
* view, the total size is the same as the physical one, with the start address
* of its graphic space being zero. Yet there are some portions ballooned out(
* the shadow part, which are marked as reserved by drm allocator). From the
* host point of view, the graphic address space is partitioned by multiple
* vGPUs in different VMs. ::
*
* vGPU1 view Host view
* 0 ------> +-----------+ +-----------+
* ^ |###########| | vGPU3 |
* | |###########| +-----------+
* | |###########| | vGPU2 |
* | +-----------+ +-----------+
* mappable GM | available | ==> | vGPU1 |
* | +-----------+ +-----------+
* | |###########| | |
* v |###########| | Host |
* +=======+===========+ +===========+
* ^ |###########| | vGPU3 |
* | |###########| +-----------+
* | |###########| | vGPU2 |
* | +-----------+ +-----------+
* unmappable GM | available | ==> | vGPU1 |
* | +-----------+ +-----------+
* | |###########| | |
* | |###########| | Host |
* v |###########| | |
* total GM size ------> +-----------+ +-----------+
*
* Returns:
* zero on success, non-zero if configuration invalid or ballooning failed
*/
int intel_vgt_balloon(struct i915_ggtt *ggtt)
{
struct drm_i915_private *dev_priv = ggtt->vm.i915;
struct intel_uncore *uncore = &dev_priv->uncore;
unsigned long ggtt_end = ggtt->vm.total;
unsigned long mappable_base, mappable_size, mappable_end;
unsigned long unmappable_base, unmappable_size, unmappable_end;
int ret;
if (!intel_vgpu_active(ggtt->vm.i915))
return 0;
mappable_base =
intel_uncore_read(uncore, vgtif_reg(avail_rs.mappable_gmadr.base));
mappable_size =
intel_uncore_read(uncore, vgtif_reg(avail_rs.mappable_gmadr.size));
unmappable_base =
intel_uncore_read(uncore, vgtif_reg(avail_rs.nonmappable_gmadr.base));
unmappable_size =
intel_uncore_read(uncore, vgtif_reg(avail_rs.nonmappable_gmadr.size));
mappable_end = mappable_base + mappable_size;
unmappable_end = unmappable_base + unmappable_size;
drm_info(&dev_priv->drm, "VGT ballooning configuration:\n");
drm_info(&dev_priv->drm,
"Mappable graphic memory: base 0x%lx size %ldKiB\n",
mappable_base, mappable_size / 1024);
drm_info(&dev_priv->drm,
"Unmappable graphic memory: base 0x%lx size %ldKiB\n",
unmappable_base, unmappable_size / 1024);
if (mappable_end > ggtt->mappable_end ||
unmappable_base < ggtt->mappable_end ||
unmappable_end > ggtt_end) {
drm_err(&dev_priv->drm, "Invalid ballooning configuration!\n");
return -EINVAL;
}
/* Unmappable graphic memory ballooning */
if (unmappable_base > ggtt->mappable_end) {
ret = vgt_balloon_space(ggtt, &bl_info.space[2],
ggtt->mappable_end, unmappable_base);
if (ret)
goto err;
}
if (unmappable_end < ggtt_end) {
ret = vgt_balloon_space(ggtt, &bl_info.space[3],
unmappable_end, ggtt_end);
if (ret)
goto err_upon_mappable;
}
/* Mappable graphic memory ballooning */
if (mappable_base) {
ret = vgt_balloon_space(ggtt, &bl_info.space[0],
0, mappable_base);
if (ret)
goto err_upon_unmappable;
}
if (mappable_end < ggtt->mappable_end) {
ret = vgt_balloon_space(ggtt, &bl_info.space[1],
mappable_end, ggtt->mappable_end);
if (ret)
goto err_below_mappable;
}
drm_info(&dev_priv->drm, "VGT balloon successfully\n");
return 0;
err_below_mappable:
vgt_deballoon_space(ggtt, &bl_info.space[0]);
err_upon_unmappable:
vgt_deballoon_space(ggtt, &bl_info.space[3]);
err_upon_mappable:
vgt_deballoon_space(ggtt, &bl_info.space[2]);
err:
drm_err(&dev_priv->drm, "VGT balloon fail\n");
return ret;
}
| {
"pile_set_name": "Github"
} |
function broadcast(componentName, eventName, params) {
this.$children.forEach(child => {
var name = child.$options.componentName;
if (name === componentName) {
child.$emit.apply(child, [eventName].concat(params));
} else {
broadcast.apply(child, [componentName, eventName].concat([params]));
}
});
}
export default {
methods: {
dispatch(componentName, eventName, params) {
var parent = this.$parent || this.$root;
var name = parent.$options.componentName;
while (parent && (!name || name !== componentName)) {
parent = parent.$parent;
if (parent) {
name = parent.$options.componentName;
}
}
if (parent) {
parent.$emit.apply(parent, [eventName].concat(params));
}
},
broadcast(componentName, eventName, params) {
broadcast.call(this, componentName, eventName, params);
}
}
};
| {
"pile_set_name": "Github"
} |
fileFormatVersion: 2
guid: d6a525727079edf48b200313efcde48a
timeCreated: 1480605838
licenseType: Pro
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
| {
"pile_set_name": "Github"
} |
module Puppet::Pops
module Types
# Base class for Parameterized Object implementations. The wrapper impersonates the base
# object and extends it with methods to filter assignable types and instances based on parameter
# values.
#
# @api public
class PObjectTypeExtension < PAnyType
include TypeWithMembers
def self.register_ptype(loader, ir)
create_ptype(loader, ir, 'AnyType',
'base_type' => {
KEY_TYPE => PTypeType::DEFAULT
},
'init_parameters' => {
KEY_TYPE => PArrayType::DEFAULT
}
)
end
attr_reader :base_type, :parameters
# @api private
def self.create(base_type, init_parameters)
impl_class = Loaders.implementation_registry.module_for_type("#{base_type.name}TypeExtension") || self
impl_class.new(base_type, init_parameters)
end
# Creates an array of type parameters from the attributes of the given instance that matches the
# type parameters by name. Type parameters for which there is no matching attribute
# will have `nil` in their corresponding position on the array. The array is then passed
# as the `init_parameters` argument in a call to `create`
#
# @return [PObjectTypeExtension] the created extension
# @api private
def self.create_from_instance(base_type, instance)
type_parameters = base_type.type_parameters(true)
attrs = base_type.attributes(true)
params = type_parameters.keys.map do |pn|
attr = attrs[pn]
attr.nil? ? nil : instance.send(pn)
end
create(base_type, params)
end
def [](name)
@base_type[name]
end
# @api private
def initialize(base_type, init_parameters)
pts = base_type.type_parameters(true)
raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using []') % { label: base_type.label } if pts.empty?
@base_type = base_type
named_args = init_parameters.size == 1 && init_parameters[0].is_a?(Hash)
if named_args
# Catch case when first parameter is an assignable Hash
named_args = pts.size >= 1 && !pts.values[0].type.instance?(init_parameters[0])
end
by_name = {}
if named_args
hash = init_parameters[0]
hash.each_pair do |pn, pv|
tp = pts[pn]
if tp.nil?
raise Puppet::ParseError, _("'%{pn}' is not a known type parameter for %{label}-Type") % { pn: pn, label: base_type.label }
end
by_name[pn] = check_param(tp, pv) unless pv == :default
end
else
pts.values.each_with_index do |tp, idx|
if idx < init_parameters.size
pv = init_parameters[idx]
by_name[tp.name] = check_param(tp, pv) unless pv == :default
end
end
end
if by_name.empty?
raise Puppet::ParseError, _('The %{label}-Type cannot be parameterized using an empty parameter list') % { label: base_type.label }
end
@parameters = by_name
end
def check_param(type_param, v)
TypeAsserter.assert_instance_of(nil, type_param.type, v) { type_param.label }
end
# Return the parameter values as positional arguments with unset values as :default. The
# array is stripped from trailing :default values
# @return [Array] the parameter values
# @api private
def init_parameters
pts = @base_type.type_parameters(true)
if pts.size > 2
@parameters
else
result = pts.values.map do |tp|
pn = tp.name
@parameters.include?(pn) ? @parameters[pn] : :default
end
# Remove trailing defaults
result.pop while result.last == :default
result
end
end
# @api private
def eql?(o)
super(o) && @base_type.eql?(o.base_type) && @parameters.eql?(o.parameters)
end
# @api private
def generalize
@base_type
end
# @api private
def hash
@base_type.hash ^ @parameters.hash
end
# @api private
def loader
@base_type.loader
end
# @api private
def check_self_recursion(originator)
@base_type.check_self_recursion(originator)
end
# @api private
def create(*args)
@base_type.create(*args)
end
# @api private
def instance?(o, guard = nil)
@base_type.instance?(o, guard) && test_instance?(o, guard)
end
# @api private
def new_function
@base_type.new_function
end
# @api private
def simple_name
@base_type.simple_name
end
# @api private
def implementation_class(create = true)
@base_type.implementation_class(create)
end
# @api private
def parameter_info(impl_class)
@base_type.parameter_info(impl_class)
end
protected
# Checks that the given `param_values` hash contains all keys present in the `parameters` of
# this instance and that each keyed value is a match for the given parameter. The match is done
# using case expression semantics.
#
# This method is only called when a given type is found to be assignable to the base type of
# this extension.
#
# @param param_values[Hash] the parameter values of the assignable type
# @param guard[RecursionGuard] guard against endless recursion
# @return [Boolean] true or false to indicate assignability
# @api public
def test_assignable?(param_values, guard)
# Default implementation performs case expression style matching of all parameter values
# provided that the value exist (this should always be the case, since all defaults have
# been assigned at this point)
eval = Parser::EvaluatingParser.singleton.evaluator
@parameters.keys.all? do |pn|
if param_values.include?(pn)
a = param_values[pn]
b = @parameters[pn]
eval.match?(a, b) || a.is_a?(PAnyType) && b.is_a?(PAnyType) && b.assignable?(a)
else
false
end
end
end
# Checks that the given instance `o` has one attribute for each key present in the `parameters` of
# this instance and that each attribute value is a match for the given parameter. The match is done
# using case expression semantics.
#
# This method is only called when the given value is found to be an instance of the base type of
# this extension.
#
# @param o [Object] the instance to test
# @param guard[RecursionGuard] guard against endless recursion
# @return [Boolean] true or false to indicate if the value is an instance or not
# @api public
def test_instance?(o, guard)
eval = Parser::EvaluatingParser.singleton.evaluator
@parameters.keys.all? do |pn|
begin
m = o.public_method(pn)
m.arity == 0 ? eval.match?(m.call, @parameters[pn]) : false
rescue NameError
false
end
end
end
# @api private
def _assignable?(o, guard = nil)
if o.is_a?(PObjectTypeExtension)
@base_type.assignable?(o.base_type, guard) && test_assignable?(o.parameters, guard)
else
@base_type.assignable?(o, guard) && test_assignable?(EMPTY_HASH, guard)
end
end
end
end
end
| {
"pile_set_name": "Github"
} |
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and / or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The below copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Vulkan Cookbook
// ISBN: 9781786468154
// © Packt Publishing Limited
//
// Author: Pawel Lapinski
// LinkedIn: https://www.linkedin.com/in/pawel-lapinski-84522329
//
// Chapter: 02 Image Presentation
// Recipe: 04 Creating a logical device with WSI extensions enabled
#ifndef CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED
#define CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED
#include "01 Instance and Devices/15 Creating a logical device.h"
namespace VulkanCookbook {
bool CreateLogicalDeviceWithWsiExtensionsEnabled( VkPhysicalDevice physical_device,
std::vector< QueueInfo > queue_infos,
std::vector<char const *> & desired_extensions,
VkPhysicalDeviceFeatures * desired_features,
VkDevice & logical_device );
} // namespace VulkanCookbook
#endif // CREATING_A_LOGICAL_DEVICE_WITH_WSI_EXTENSIONS_ENABLED | {
"pile_set_name": "Github"
} |
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Select correctly applies the theme context className for default variant 1`] = `
<div
aria-describedby="terra-select-screen-reader-description-24"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="true"
aria-labelledby="terra-select-screen-reader-label-21 terra-select-screen-reader-display-22 terra-select-screen-reader-placeholder-23"
aria-required="false"
class="select default orion-fusion-theme"
data-terra-select="true"
data-terra-select-combobox="true"
role="combobox"
tabindex="0"
>
<div
class="visually-hidden-component"
hidden=""
>
<span
id="terra-select-screen-reader-label-21"
>
Terra.form.select.ariaLabel
</span>
<span
id="terra-select-screen-reader-description-24"
>
Terra.form.select.listOfTotalOptions Terra.form.select.defaultUsageGuidance
</span>
</div>
<div
aria-label="Terra.form.select.ariaLabel"
class="display"
role="textbox"
>
<div
class="placeholder"
id="terra-select-screen-reader-placeholder-23"
>
Terra.form.select.defaultDisplay
</div>
</div>
<div
class="toggle"
data-terra-form-select-toggle="true"
>
<span
class="arrow-icon"
/>
</div>
<span
aria-atomic="true"
aria-live="assertive"
aria-relevant="additions text"
class="visually-hidden-component"
/>
</div>
`;
exports[`Select should render a clear option 1`] = `
<SingleSelect
allowClear={true}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
required={false}
/>
`;
exports[`Select should render a combobox variant 1`] = `
<InjectIntl(Combobox)
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a combobox variant with a placeholder 1`] = `
<InjectIntl(Combobox)
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
placeholder="Placeholder"
required={false}
/>
`;
exports[`Select should render a default variant 1`] = `
<SingleSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
required={false}
/>
`;
exports[`Select should render a default variant with a placeholder 1`] = `
<SingleSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
placeholder="Placeholder"
required={false}
/>
`;
exports[`Select should render a disabled combobox variant 1`] = `
<TagSelect
disabled={true}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a disabled default variant 1`] = `
<SingleSelect
allowClear={false}
disabled={true}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
required={false}
/>
`;
exports[`Select should render a disabled multiple variant 1`] = `
<MultiSelect
disabled={true}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a disabled search variant 1`] = `
<SearchSelect
allowClear={false}
disabled={true}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a disabled tag variant 1`] = `
<TagSelect
disabled={true}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a multiple variant 1`] = `
<MultiSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a multiple variant with a placeholder 1`] = `
<MultiSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
placeholder="Placeholder"
required={false}
/>
`;
exports[`Select should render a required select 1`] = `
<SingleSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
required={true}
/>
`;
exports[`Select should render a search variant 1`] = `
<SearchSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a search variant with a placeholder 1`] = `
<SearchSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
placeholder="Placeholder"
required={false}
/>
`;
exports[`Select should render a select with an optgroup and an option 1`] = `
<div
aria-describedby="terra-select-screen-reader-description-14"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="true"
aria-labelledby="terra-select-screen-reader-label-11 terra-select-screen-reader-display-12 terra-select-screen-reader-placeholder-13"
aria-required="false"
class="select default"
data-terra-select="true"
data-terra-select-combobox="true"
role="combobox"
tabindex="0"
>
<div
class="visually-hidden-component"
hidden=""
>
<span
id="terra-select-screen-reader-label-11"
>
Terra.form.select.ariaLabel
</span>
<span
id="terra-select-screen-reader-description-14"
>
Terra.form.select.listOfTotalOptions Terra.form.select.defaultUsageGuidance
</span>
</div>
<div
aria-label="Terra.form.select.ariaLabel"
class="display"
role="textbox"
>
<div
class="placeholder"
id="terra-select-screen-reader-placeholder-13"
>
Terra.form.select.defaultDisplay
</div>
</div>
<div
class="toggle"
data-terra-form-select-toggle="true"
>
<span
class="arrow-icon"
/>
</div>
<span
aria-atomic="true"
aria-live="assertive"
aria-relevant="additions text"
class="visually-hidden-component"
/>
</div>
`;
exports[`Select should render a select with an optgroup and multiple options 1`] = `
<div
aria-describedby="terra-select-screen-reader-description-19"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="true"
aria-labelledby="terra-select-screen-reader-label-16 terra-select-screen-reader-display-17 terra-select-screen-reader-placeholder-18"
aria-required="false"
class="select default"
data-terra-select="true"
data-terra-select-combobox="true"
role="combobox"
tabindex="0"
>
<div
class="visually-hidden-component"
hidden=""
>
<span
id="terra-select-screen-reader-label-16"
>
Terra.form.select.ariaLabel
</span>
<span
id="terra-select-screen-reader-description-19"
>
Terra.form.select.listOfTotalOptions Terra.form.select.defaultUsageGuidance
</span>
</div>
<div
aria-label="Terra.form.select.ariaLabel"
class="display"
role="textbox"
>
<div
class="placeholder"
id="terra-select-screen-reader-placeholder-18"
>
Terra.form.select.defaultDisplay
</div>
</div>
<div
class="toggle"
data-terra-form-select-toggle="true"
>
<span
class="arrow-icon"
/>
</div>
<span
aria-atomic="true"
aria-live="assertive"
aria-relevant="additions text"
class="visually-hidden-component"
/>
</div>
`;
exports[`Select should render a select with an option 1`] = `
<div
aria-describedby="terra-select-screen-reader-description-4"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="true"
aria-labelledby="terra-select-screen-reader-label-1 terra-select-screen-reader-display-2 terra-select-screen-reader-placeholder-3"
aria-required="false"
class="select default"
data-terra-select="true"
data-terra-select-combobox="true"
role="combobox"
tabindex="0"
>
<div
class="visually-hidden-component"
hidden=""
>
<span
id="terra-select-screen-reader-label-1"
>
Terra.form.select.ariaLabel
</span>
<span
id="terra-select-screen-reader-description-4"
>
Terra.form.select.listOfTotalOptions Terra.form.select.defaultUsageGuidance
</span>
</div>
<div
aria-label="Terra.form.select.ariaLabel"
class="display"
role="textbox"
>
<div
class="placeholder"
id="terra-select-screen-reader-placeholder-3"
>
Terra.form.select.defaultDisplay
</div>
</div>
<div
class="toggle"
data-terra-form-select-toggle="true"
>
<span
class="arrow-icon"
/>
</div>
<span
aria-atomic="true"
aria-live="assertive"
aria-relevant="additions text"
class="visually-hidden-component"
/>
</div>
`;
exports[`Select should render a select with multiple options 1`] = `
<div
aria-describedby="terra-select-screen-reader-description-9"
aria-disabled="false"
aria-expanded="false"
aria-haspopup="true"
aria-labelledby="terra-select-screen-reader-label-6 terra-select-screen-reader-display-7 terra-select-screen-reader-placeholder-8"
aria-required="false"
class="select default"
data-terra-select="true"
data-terra-select-combobox="true"
role="combobox"
tabindex="0"
>
<div
class="visually-hidden-component"
hidden=""
>
<span
id="terra-select-screen-reader-label-6"
>
Terra.form.select.ariaLabel
</span>
<span
id="terra-select-screen-reader-description-9"
>
Terra.form.select.listOfTotalOptions Terra.form.select.defaultUsageGuidance
</span>
</div>
<div
aria-label="Terra.form.select.ariaLabel"
class="display"
role="textbox"
>
<div
class="placeholder"
id="terra-select-screen-reader-placeholder-8"
>
Terra.form.select.defaultDisplay
</div>
</div>
<div
class="toggle"
data-terra-form-select-toggle="true"
>
<span
class="arrow-icon"
/>
</div>
<span
aria-atomic="true"
aria-live="assertive"
aria-relevant="additions text"
class="visually-hidden-component"
/>
</div>
`;
exports[`Select should render a tag variant 1`] = `
<TagSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render a tag variant with a placeholder 1`] = `
<TagSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={false}
isTouchAccessible={false}
placeholder="Placeholder"
required={false}
/>
`;
exports[`Select should render an incomplete combobox variant 1`] = `
<InjectIntl(Combobox)
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={true}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an incomplete default variant 1`] = `
<SingleSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={true}
isInvalid={false}
required={false}
/>
`;
exports[`Select should render an incomplete multiple variant 1`] = `
<MultiSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={true}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an incomplete search variant 1`] = `
<SearchSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={true}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an incomplete tag variant 1`] = `
<TagSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={true}
isInvalid={false}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an invalid combobox variant 1`] = `
<InjectIntl(Combobox)
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={true}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an invalid default variant 1`] = `
<SingleSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={true}
required={false}
/>
`;
exports[`Select should render an invalid multiple variant 1`] = `
<MultiSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={true}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an invalid search variant 1`] = `
<SearchSelect
allowClear={false}
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={true}
isTouchAccessible={false}
required={false}
/>
`;
exports[`Select should render an invalid tag variant 1`] = `
<TagSelect
disabled={false}
intl={
Object {
"defaultFormats": Object {},
"defaultLocale": "en",
"formatDate": [Function],
"formatHTMLMessage": [Function],
"formatMessage": [Function],
"formatNumber": [Function],
"formatPlural": [Function],
"formatRelative": [Function],
"formatTime": [Function],
"formats": Object {},
"formatters": Object {
"getDateTimeFormat": [Function],
"getMessageFormat": [Function],
"getNumberFormat": [Function],
"getPluralFormat": [Function],
"getRelativeFormat": [Function],
},
"locale": "en",
"messages": null,
"now": [Function],
"onError": [Function],
"textComponent": "span",
"timeZone": null,
}
}
isIncomplete={false}
isInvalid={true}
isTouchAccessible={false}
required={false}
/>
`;
| {
"pile_set_name": "Github"
} |
<!DOCTYPE html>
<!--
Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
-->
<html>
<head>
<meta charset="utf-8">
<title>Replace Textarea with Inline Editor — CKEditor Sample</title>
<script src="../../ckeditor.js"></script>
<link href="sample.css" rel="stylesheet">
<style>
/* Style the CKEditor element to look like a textfield */
.cke_textarea_inline
{
padding: 10px;
height: 200px;
overflow: auto;
border: 1px solid gray;
-webkit-appearance: textfield;
}
</style>
</head>
<body>
<h1 class="samples">
<a href="index.html">CKEditor Samples</a> » Replace Textarea with Inline Editor
</h1>
<div class="warning deprecated">
This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/inline.html">brand new version in CKEditor SDK</a>.
</div>
<div class="description">
<p>
You can also create an inline editor from a <code>textarea</code>
element. In this case the <code>textarea</code> will be replaced
by a <code>div</code> element with inline editing enabled.
</p>
<pre class="samples">
// "article-body" is the name of a textarea element.
var editor = CKEDITOR.inline( 'article-body' );
</pre>
</div>
<form action="sample_posteddata.php" method="post">
<h2>This is a sample form with some fields</h2>
<p>
Title:<br>
<input type="text" name="title" value="Sample Form"></p>
<p>
Article Body (Textarea converted to CKEditor):<br>
<textarea name="article-body" style="height: 200px">
<h2>Technical details <a id="tech-details" name="tech-details"></a></h2>
<table align="right" border="1" bordercolor="#ccc" cellpadding="5" cellspacing="0" style="border-collapse:collapse;margin:10px 0 10px 15px;">
<caption><strong>Mission crew</strong></caption>
<thead>
<tr>
<th scope="col">Position</th>
<th scope="col">Astronaut</th>
</tr>
</thead>
<tbody>
<tr>
<td>Commander</td>
<td>Neil A. Armstrong</td>
</tr>
<tr>
<td>Command Module Pilot</td>
<td>Michael Collins</td>
</tr>
<tr>
<td>Lunar Module Pilot</td>
<td>Edwin "Buzz" E. Aldrin, Jr.</td>
</tr>
</tbody>
</table>
<p>Launched by a <strong>Saturn V</strong> rocket from <a href="http://en.wikipedia.org/wiki/Kennedy_Space_Center" title="Kennedy Space Center">Kennedy Space Center</a> in Merritt Island, Florida on July 16, Apollo 11 was the fifth manned mission of <a href="http://en.wikipedia.org/wiki/NASA" title="NASA">NASA</a>'s Apollo program. The Apollo spacecraft had three parts:</p>
<ol>
<li><strong>Command Module</strong> with a cabin for the three astronauts which was the only part which landed back on Earth</li>
<li><strong>Service Module</strong> which supported the Command Module with propulsion, electrical power, oxygen and water</li>
<li><strong>Lunar Module</strong> for landing on the Moon.</li>
</ol>
<p>After being sent to the Moon by the Saturn V's upper stage, the astronauts separated the spacecraft from it and travelled for three days until they entered into lunar orbit. Armstrong and Aldrin then moved into the Lunar Module and landed in the <a href="http://en.wikipedia.org/wiki/Mare_Tranquillitatis" title="Mare Tranquillitatis">Sea of Tranquility</a>. They stayed a total of about 21 and a half hours on the lunar surface. After lifting off in the upper part of the Lunar Module and rejoining Collins in the Command Module, they returned to Earth and landed in the <a href="http://en.wikipedia.org/wiki/Pacific_Ocean" title="Pacific Ocean">Pacific Ocean</a> on July 24.</p>
<hr />
<p style="text-align: right;"><small>Source: <a href="http://en.wikipedia.org/wiki/Apollo_11">Wikipedia.org</a></small></p>
</textarea>
</p>
<p>
<input type="submit" value="Submit">
</p>
</form>
<script>
CKEDITOR.inline( 'article-body' );
</script>
<div id="footer">
<hr>
<p>
CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">
http://ckeditor.com</a>
</p>
<p id="copy">
Copyright © 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a>
- Frederico Knabben. All rights reserved.
</p>
</div>
</body>
</html>
| {
"pile_set_name": "Github"
} |
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
package com.sun.identity.console.audit.model;
import static com.sun.identity.console.base.model.AMAdminUtils.getSuperAdminSSOToken;
import static java.util.Collections.singleton;
import com.iplanet.sso.SSOException;
import com.sun.identity.console.base.model.AMAdminConstants;
import com.sun.identity.console.base.model.AMConsoleException;
import com.sun.identity.console.base.model.AMModelBase;
import com.sun.identity.sm.SMSException;
import com.sun.identity.sm.SchemaType;
import com.sun.identity.sm.ServiceConfig;
import com.sun.identity.sm.ServiceConfigManager;
import com.sun.identity.sm.ServiceSchema;
import com.sun.identity.sm.ServiceSchemaManager;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.Set;
/**
* Realm Audit configuration UI model.
*
* @since 13.0.0
*/
public class RealmAuditConfigModel extends AbstractAuditModel {
private String realm;
private final HttpServletRequest request;
/**
* Create a new {@code RealmAuditConfigModel}.
*
* @param request The {@code HttpServletRequest}
* @param sessionAttributes The session attributes.
* @throws AMConsoleException If construction fails.
*/
public RealmAuditConfigModel(HttpServletRequest request, Map sessionAttributes) throws AMConsoleException {
super(request, sessionAttributes);
this.request = request;
this.realm = (String) sessionAttributes.get(AMAdminConstants.CURRENT_REALM);
}
@Override
protected ServiceSchema getServiceSchema() throws SMSException, SSOException {
ServiceSchemaManager schemaManager = new ServiceSchemaManager(serviceName, getSuperAdminSSOToken());
return schemaManager.getOrganizationSchema();
}
@Override
protected ServiceConfig getServiceConfig() throws SMSException, SSOException {
if (realm == null) {
realm = AMModelBase.getStartDN(request);
}
ServiceConfigManager configManager = new ServiceConfigManager(serviceName, getSuperAdminSSOToken());
return configManager.getOrganizationConfig(realm, null);
}
@Override
public Set<SchemaType> getDisplaySchemaTypes() {
return singleton(SchemaType.ORGANIZATION);
}
}
| {
"pile_set_name": "Github"
} |
// Auto generated file, don't modify.
#ifndef __META_IRRLICHT_IRRSTRING_H
#define __META_IRRLICHT_IRRSTRING_H
#include "gmetaobjectlifemanager_irrlicht_ireferencecounted.h"
#include "cpgf/gmetadefine.h"
#include "cpgf/metadata/gmetadataconfig.h"
#include "cpgf/metadata/private/gmetadata_header.h"
#include "cpgf/gmetapolicy.h"
using namespace irr;
using namespace irr::core;
namespace meta_irrlicht {
template <typename D>
void buildMetaClass_Global_irrstring(const cpgf::GMetaDataConfigFlags & config, D _d)
{
(void)config; (void)_d; (void)_d;
using namespace cpgf;
_d.CPGF_MD_TEMPLATE _field("locale_current", &locale_current);
_d.CPGF_MD_TEMPLATE _method("locale_set", (void (*) (eLocaleID))&locale_set);
_d.CPGF_MD_TEMPLATE _method("locale_lower", (u32 (*) (u32))&locale_lower);
_d.CPGF_MD_TEMPLATE _method("locale_upper", (u32 (*) (u32))&locale_upper);
_d.CPGF_MD_TEMPLATE _enum<eLocaleID>("eLocaleID")
._element("IRR_LOCALE_ANSI", irr::core::IRR_LOCALE_ANSI)
._element("IRR_LOCALE_GERMAN", irr::core::IRR_LOCALE_GERMAN)
;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAssign(string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) = other;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > opErAToRWrapper_string__opAdd(const string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) + other;
}
template <typename T, typename TAlloc>
inline T & opErAToRWrapper_string__opArrayGet(string<T, TAlloc> * self, const u32 index) {
return (*self)[index];
}
template <typename T, typename TAlloc>
inline void opErAToRWrapper_string__opArraySet(string<T, TAlloc> * self, const u32 index, const typename cpgf::RemoveReference<T & >::Result & OpsEt_vALue) {
(*self)[index] = OpsEt_vALue;
}
template <typename T, typename TAlloc>
inline const T & opErAToRWrapper_string__opArrayGet(const string<T, TAlloc> * self, const u32 index) {
return (*self)[index];
}
template <typename T, typename TAlloc>
inline bool opErAToRWrapper_string__opEqual(const string<T, TAlloc> * self, const T *const str) {
return (*self) == str;
}
template <typename T, typename TAlloc>
inline bool opErAToRWrapper_string__opEqual(const string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) == other;
}
template <typename T, typename TAlloc>
inline bool opErAToRWrapper_string__opLess(const string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) < other;
}
template <typename T, typename TAlloc>
inline bool opErAToRWrapper_string__opNotEqual(const string<T, TAlloc> * self, const T *const str) {
return (*self) != str;
}
template <typename T, typename TAlloc>
inline bool opErAToRWrapper_string__opNotEqual(const string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) != other;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, T c) {
return (*self) += c;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const T *const c) {
return (*self) += c;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const string< T, TAlloc > & other) {
return (*self) += other;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const int i) {
return (*self) += i;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const unsigned int i) {
return (*self) += i;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const long i) {
return (*self) += i;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const unsigned long i) {
return (*self) += i;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const double i) {
return (*self) += i;
}
template <typename T, typename TAlloc>
inline string< T, TAlloc > & opErAToRWrapper_string__opAddAssign(string<T, TAlloc> * self, const float i) {
return (*self) += i;
}
template <typename D, typename T, typename TAlloc>
void buildMetaClass_String(const cpgf::GMetaDataConfigFlags & config, D _d)
{
(void)config; (void)_d; (void)_d;
using namespace cpgf;
_d.CPGF_MD_TEMPLATE _constructor<void * ()>();
_d.CPGF_MD_TEMPLATE _constructor<void * (const string< T, TAlloc > &)>(cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _constructor<void * (const double)>();
_d.CPGF_MD_TEMPLATE _constructor<void * (int)>();
_d.CPGF_MD_TEMPLATE _constructor<void * (unsigned int)>();
_d.CPGF_MD_TEMPLATE _constructor<void * (long)>();
_d.CPGF_MD_TEMPLATE _constructor<void * (unsigned long)>();
_d.CPGF_MD_TEMPLATE _method("size", &D::ClassType::size);
_d.CPGF_MD_TEMPLATE _method("empty", &D::ClassType::empty);
_d.CPGF_MD_TEMPLATE _method("c_str", &D::ClassType::c_str);
_d.CPGF_MD_TEMPLATE _method("make_lower", &D::ClassType::make_lower);
_d.CPGF_MD_TEMPLATE _method("make_upper", &D::ClassType::make_upper);
_d.CPGF_MD_TEMPLATE _method("equals_ignore_case", &D::ClassType::equals_ignore_case, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("equals_substring_ignore_case", &D::ClassType::equals_substring_ignore_case, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >())
._default(copyVariantFromCopyable(0))
;
_d.CPGF_MD_TEMPLATE _method("lower_ignore_case", &D::ClassType::lower_ignore_case, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("equalsn", (bool (D::ClassType::*) (const string< T, TAlloc > &, u32) const)&D::ClassType::equalsn, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("equalsn", (bool (D::ClassType::*) (const T *const, u32) const)&D::ClassType::equalsn);
_d.CPGF_MD_TEMPLATE _method("append", (string< T, TAlloc > & (D::ClassType::*) (T))&D::ClassType::append);
_d.CPGF_MD_TEMPLATE _method("append", (string< T, TAlloc > & (D::ClassType::*) (const T *const, u32))&D::ClassType::append)
._default(copyVariantFromCopyable(0xffffffff))
;
_d.CPGF_MD_TEMPLATE _method("append", (string< T, TAlloc > & (D::ClassType::*) (const string< T, TAlloc > &))&D::ClassType::append, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("append", (string< T, TAlloc > & (D::ClassType::*) (const string< T, TAlloc > &, u32))&D::ClassType::append, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("reserve", &D::ClassType::reserve);
_d.CPGF_MD_TEMPLATE _method("findFirst", &D::ClassType::findFirst);
_d.CPGF_MD_TEMPLATE _method("findFirstChar", &D::ClassType::findFirstChar)
._default(copyVariantFromCopyable(1))
;
_d.CPGF_MD_TEMPLATE _method("findNext", &D::ClassType::findNext);
_d.CPGF_MD_TEMPLATE _method("findLast", &D::ClassType::findLast)
._default(copyVariantFromCopyable(-1))
;
_d.CPGF_MD_TEMPLATE _method("findLastChar", &D::ClassType::findLastChar)
._default(copyVariantFromCopyable(1))
;
_d.CPGF_MD_TEMPLATE _method("subString", &D::ClassType::subString)
._default(copyVariantFromCopyable(false))
;
_d.CPGF_MD_TEMPLATE _method("replace", (string< T, TAlloc > & (D::ClassType::*) (T, T))&D::ClassType::replace);
_d.CPGF_MD_TEMPLATE _method("replace", (string< T, TAlloc > & (D::ClassType::*) (const string< T, TAlloc > &, const string< T, TAlloc > &))&D::ClassType::replace, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0>, cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("remove", (string< T, TAlloc > & (D::ClassType::*) (T))&D::ClassType::remove);
_d.CPGF_MD_TEMPLATE _method("remove", (string< T, TAlloc > & (D::ClassType::*) (const string< T, TAlloc > &))&D::ClassType::remove, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("removeChars", &D::ClassType::removeChars, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >());
_d.CPGF_MD_TEMPLATE _method("trim", &D::ClassType::trim, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<0> >())
._default(copyVariantFromCopyable(" \t\n\r"))
;
_d.CPGF_MD_TEMPLATE _method("erase", &D::ClassType::erase);
_d.CPGF_MD_TEMPLATE _method("validate", &D::ClassType::validate);
_d.CPGF_MD_TEMPLATE _method("lastChar", &D::ClassType::lastChar);
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const string< T, TAlloc > &)>(mopHolder = mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > (*)(const cpgf::GMetaSelf &, const string< T, TAlloc > &)>(mopHolder + mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opAdd", (string< T, TAlloc > (*) (const string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opAdd<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<T & (*)(cpgf::GMetaSelf, const u32)>(mopHolder[0]);
_d.CPGF_MD_TEMPLATE _method("_opArrayGet", (T & (*) (string<T, TAlloc> *, const u32))&opErAToRWrapper_string__opArrayGet<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _method("_opArraySet", (void (*) (string<T, TAlloc> *, const u32, const typename cpgf::RemoveReference<T & >::Result &))&opErAToRWrapper_string__opArraySet<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<const T & (*)(const cpgf::GMetaSelf &, const u32)>(mopHolder[0]);
_d.CPGF_MD_TEMPLATE _method("_opArrayGet", (const T & (*) (const string<T, TAlloc> *, const u32))&opErAToRWrapper_string__opArrayGet<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<bool (*)(const cpgf::GMetaSelf &, const T *const)>(mopHolder == mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opEqual", (bool (*) (const string<T, TAlloc> *, const T *const))&opErAToRWrapper_string__opEqual<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<bool (*)(const cpgf::GMetaSelf &, const string< T, TAlloc > &)>(mopHolder == mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opEqual", (bool (*) (const string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opEqual<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<bool (*)(const cpgf::GMetaSelf &, const string< T, TAlloc > &)>(mopHolder < mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opLess", (bool (*) (const string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opLess<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<bool (*)(const cpgf::GMetaSelf &, const T *const)>(mopHolder != mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opNotEqual", (bool (*) (const string<T, TAlloc> *, const T *const))&opErAToRWrapper_string__opNotEqual<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<bool (*)(const cpgf::GMetaSelf &, const string< T, TAlloc > &)>(mopHolder != mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opNotEqual", (bool (*) (const string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opNotEqual<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, T)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, T))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const T *const)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const T *const))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const string< T, TAlloc > &)>(mopHolder += mopHolder, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1> >());
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const string< T, TAlloc > &))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleCopyConstReference<1>, cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const int)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const int))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const unsigned int)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const unsigned int))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const long)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const long))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const unsigned long)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const unsigned long))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const double)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const double))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
_d.CPGF_MD_TEMPLATE _operator<string< T, TAlloc > & (*)(cpgf::GMetaSelf, const float)>(mopHolder += mopHolder);
_d.CPGF_MD_TEMPLATE _method("_opAddAssign", (string< T, TAlloc > & (*) (string<T, TAlloc> *, const float))&opErAToRWrapper_string__opAddAssign<T, TAlloc>, cpgf::MakePolicy<cpgf::GMetaRuleExplicitThis >());
}
} // namespace meta_irrlicht
#include "cpgf/metadata/private/gmetadata_footer.h"
#endif
| {
"pile_set_name": "Github"
} |
/*
This file is part of KDDockWidgets.
SPDX-FileCopyrightText: 2019-2020 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
Author: Sérgio Martins <[email protected]>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
Contact KDAB at <[email protected]> for commercial licensing options.
*/
// We don't care about performance related checks in the tests
// clazy:excludeall=ctor-missing-parent-argument,missing-qobject-macro,range-loop,missing-typeinfo,detaching-member,function-args-by-ref,non-pod-global-static,reserve-candidates,qstring-allocations
#include "Fuzzer.h"
#include "DockRegistry_p.h"
#include "../utils.h"
#include <QCommandLineParser>
#include <QApplication>
#include <QTimer>
#include <QDebug>
#include <QFile>
#include <iostream>
using namespace KDDockWidgets;
using namespace KDDockWidgets::Testing;
int main(int argc, char **argv)
{
if (!qpaPassedAsArgument(argc, argv)) {
// Use offscreen by default as it's less annoying, doesn't create visible windows
qputenv("QT_QPA_PLATFORM", "offscreen");
}
QApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription("Fuzzer Help");
parser.addPositionalArgument("json", QCoreApplication::translate("main", "json file to load"));
QCommandLineOption slowDownOption("s", QCoreApplication::translate("main", "Slowdown tests. Adds a 1 second delay between operations"));
parser.addOption(slowDownOption);
QCommandLineOption forceDumpJsonOption("f", QCoreApplication::translate("main", "Dump json of the test even if we're already loading a test."));
parser.addOption(forceDumpJsonOption);
QCommandLineOption loopOption("l", QCoreApplication::translate("main", "Loops until it crashes"));
parser.addOption(loopOption);
QCommandLineOption skipLastOption("a", QCoreApplication::translate("main", "Skips the last test (presumably failing)"));
parser.addOption(skipLastOption);
QCommandLineOption noQuitOption("n", QCoreApplication::translate("main", "Don't quit at the end, keep event loop running for debugging"));
parser.addOption(noQuitOption);
parser.addHelpOption();
parser.process(app);
const bool slowDown = parser.isSet(slowDownOption);
const bool forceDumpJson = parser.isSet(forceDumpJsonOption);
const QStringList filesToLoad = parser.positionalArguments();
const bool dumpToJsonOnFatal = forceDumpJson || filesToLoad.isEmpty();
Fuzzer::Options options = Fuzzer::Option_None;
if (parser.isSet(skipLastOption))
options |= Fuzzer::Option_SkipLast;
if (parser.isSet(noQuitOption))
options |= Fuzzer::Option_NoQuit;
const bool loops = parser.isSet(loopOption);
Fuzzer fuzzer(dumpToJsonOnFatal, options);
if (slowDown)
fuzzer.setDelayBetweenOperations(1000);
for (const QString &file : filesToLoad) {
if (!QFile::exists(file)) {
std::cerr << "\nFile doesn't exist: " << file.toStdString() << "\n";
return 0;
}
}
QTimer::singleShot(0, &fuzzer, [&app, &fuzzer, filesToLoad, loops, options] {
if (filesToLoad.isEmpty()) {
do {
fuzzer.fuzz({ 1, 10, true });
} while(loops);
} else {
fuzzer.fuzz(filesToLoad);
}
if (!(options & Fuzzer::Option_NoQuit)) {
// if noQuit is true we keep the app running so it can be debugged
app.quit();
}
});
app.setQuitOnLastWindowClosed(false);
return app.exec();
}
| {
"pile_set_name": "Github"
} |
--TEST--
Bug #41693 (scandir() allows empty directory names)
--FILE--
<?php
var_dump(scandir(''));
echo "Done\n";
?>
--EXPECTF--
Warning: scandir(): Directory name cannot be empty in %s on line %d
bool(false)
Done
| {
"pile_set_name": "Github"
} |
<!-- HIT template: Survey-v3.0 --><!-- The following snippet enables the 'responsive' behavior on smaller screens -->
<meta content="width=device-width,initial-scale=1" name="viewport" />
<section class="container" id="Survey"><!-- Instructions -->
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="panel panel-primary"><!-- WARNING: the ids "collapseTrigger" and "instructionBody" are being used to enable expand/collapse feature --><a class="panel-heading" href="javascript:void(0);" id="collapseTrigger"><strong>Survey Instructions</strong> <span class="collapse-text">(Click to expand)</span> </a>
<div class="panel-body" id="instructionBody">
<h2>Instructions</h2>
<p>You will hear <strong>test samples</strong> of computer generated speech created using different methods. The purpose of this test is to evaluate the quality of each <strong>test sample</strong>, so that we (the researchers) can compare the methods and know which ones sound better to a general audience.</p>
<p> </p>
<p>Each <strong>test sample</strong> should be given a score according to the following scale, known as the MOS (mean opinion score) scale for naturalness:</p>
<table>
<tbody>
<tr>
<td align="center" width="100"><b>Score</b></td>
<td width="200"><b>Quality of the Speech</b></td>
<td width="300"><b>Naturalness</b></td>
</tr>
<tr>
<td align="center">5</td>
<td>Excellent</td>
<td>Completely natural</td>
</tr>
<tr>
<td align="center">4</td>
<td>Good</td>
<td>Mostly natural</td>
</tr>
<tr>
<td align="center">3</td>
<td>Fair</td>
<td>Equally natural and unnatural</td>
</tr>
<tr>
<td align="center">2</td>
<td>Poor</td>
<td>Mostly unnatural</td>
</tr>
<tr>
<td align="center">1</td>
<td>Bad</td>
<td>Completely unnatural</td>
</tr>
</tbody>
</table>
<p> </p>
<p>Each <strong>test sample</strong> should also be given a pronunciation accuracy score, using the scale below.</p>
<table style="background-color: rgb(255, 255, 255);">
<tbody>
<tr>
<td align="center" width="100"><b>Score</b></td>
<td width="200"><b>Accuracy of the Speech</b></td>
<td width="300"><b>Definition</b></td>
</tr>
<tr>
<td align="center">5</td>
<td>Excellent</td>
<td>No mispronunciations</td>
</tr>
<tr>
<td align="center">4</td>
<td>Good</td>
<td>Few minor mispronunciations</td>
</tr>
<tr>
<td align="center">3</td>
<td>Fair</td>
<td>Many minor mispronunciations</td>
</tr>
<tr>
<td align="center">2</td>
<td>Poor</td>
<td>Few major mispronunciations</td>
</tr>
<tr>
<td align="center">1</td>
<td>Bad</td>
<td>Many major mispronunciations<br />
</td>
</tr>
</tbody>
</table>
<p> </p>
<p>We have included a <span style="color:#FF0000;">reference</span> <span style="color:#FF0000;">sample</span> <a href="https://clyp.it/lludeoee">here</a> which should rate highly on both scales (it may not be a perfect 5 on both). You must transcribe this <span style="color:#FF0000;">reference sample</span> (this means write down what was spoken) in the given text box. Do NOT transcribe the <strong>test sample</strong>! We prefer that the transcription is translated to English, but it may be left in French. Do not worry about spelling or punctuation. This step is only for validation and is not the main purpose of the study.</p>
<p>For each HIT, you will see the sentence for the audio <strong>test sample</strong> when you click the link below. This should be useful for evaluating pronuncation accuracy. You may find that some audio samples are missing words or even large parts of a sentence; these count as major mispronunciations.</p>
<p>There are a total of 40 <strong>test samples</strong>/HITs, and we prefer you do as many as you can. </p>
<p>NOTE: The <strong>test sample</strong> and <span style="color:#FF0000;">reference sample</span> are different! <a href="https://clyp.it/lludeoee">Here is the link to the <span style="color:#FF0000;">reference sample</span></a>. The <strong>test sample</strong> can be found in the link in the HIT (it is not in the instructions).</p>
<h2>Approval/Rejection Policy</h2>
<p>To ensure that you know French well enough that you can evaluate the speech, we require that you also transcribe the <font color="#ff0000">reference</font> <span style="color:#FF0000;">sample</span>. If you decide to transcribe the <strong>test sample</strong> (which is linked below in the HIT), your HIT will be rejected, because <strong>YOU MUST TRANSCRIBE THE <span style="color:#FF0000;">REFERENCE SAMPLE</span> WHICH CAN BE FOUND INSIDE THE INSTRUCTIONS</strong>!</p>
<p>We have statistical methods to detect if you are randomly selecting scores and we will reject HITs that come from these individuals.</p>
<p>To obtain accurate results, we strongly recommend that you wear headphones and work in a quiet environment, otherwise you might not be able to discriminate between files with clearly different features.</p>
</div>
</div>
</div>
</div>
<!-- End Instructions --><!-- Survey Layout -->
<div class="row" id="workContent">
<div class="col-sm-8 col-sm-offset-2">
<div class="panel panel-default">
<div class="panel-body">
<div class="form-group"><label for="surveycode">Transcribe the <a href="https://clyp.it/lludeoee">reference sample</a> here:</label> <input class="form-control" id="surveycode" name="surveycode" placeholder="Enter reference transcription" required="" type="text" /></div>
<label>1. Please listen to the test sample in the link and rate the speech quality. </label>
<div class="well well-sm"><label><a href="${audio_link}" target="_blank">Link to the <b>test sample</b> audio.</a></label></div>
<div class="radio"><label><input name="Nat" required="" type="radio" value="5" />5. Excellent -- Completely natural </label></div>
<div class="radio"><label><input name="Nat" required="" type="radio" value="4" />4. Good -- Mostly natural </label></div>
<div class="radio"><label><input name="Nat" required="" type="radio" value="3" />3. Fair -- Equally natural and unnatural </label></div>
<div class="radio"><label><input name="Nat" required="" type="radio" value="2" />2. Poor -- Mostly unnatural </label></div>
<div class="radio"><label><input name="Nat" required="" type="radio" value="1" />1. Bad -- Completely unnatural </label></div>
<p> </p>
<b> <label>2. Please rate the pronunciation accuracy. </label> </b>
<div class="radio"><b><label><input name="Acc" required="" type="radio" value="5" />5. Excellent -- No mispronunciations </label></b></div>
<b> </b>
<div class="radio"><b><label><input name="Acc" required="" type="radio" value="4" />4. Good -- Few minor mispronunciations </label></b></div>
<b> </b>
<div class="radio"><b><label><input name="Acc" required="" type="radio" value="3" />3. Fair -- Many minor mispronunciations </label></b></div>
<b> </b>
<div class="radio"><b><label><input name="Acc" required="" type="radio" value="2" />2. Poor -- Few major mispronunciations </label></b></div>
<b> </b>
<div class="radio"><b><label><input name="Acc" required="" type="radio" value="1" />1. Bad -- Many major mispronunciations </label></b></div>
<b> </b></div>
</div>
</div>
</div>
<b><!-- End Survey Layout --></b></section>
<p><b><!-- Please note that Bootstrap CSS/JS and JQuery are 3rd party libraries that may update their url/code at any time. Amazon Mechanical Turk (MTurk) is including these libraries as a default option for you, but is not responsible for any changes to the external libraries --><!-- External CSS references --> </b></p>
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" integrity="sha384-IS73LIqjtYesmURkDE9MXKbXqYA8rvKEp/ghicjem7Vc3mGRdQRptJSz60tvrB6+" rel="stylesheet" />
<p><b><!-- Open internal style sheet -->
<style type="text/css">#collapseTrigger{
color:#fff;
display: block;
text-decoration: none;
}
#submitButton{
white-space: normal;
}
.image{
margin-bottom: 15px;
}
</style>
<!-- Close internal style sheet --><!-- External JS references --><script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" integrity="sha384-s1ITto93iSMDxlp/79qhWHi+LsIi9Gx6yL+cOKDuymvihkfol83TYbLbOw+W/wv4" crossorigin="anonymous"></script><!-- Open internal javascript --><script>
$(document).ready(function() {
// Instructions expand/collapse
var content = $('#instructionBody');
var trigger = $('#collapseTrigger');
content.hide();
$('.collapse-text').text('(Click to expand)');
trigger.click(function(){
content.toggle();
var isVisible = content.is(':visible');
if(isVisible){
$('.collapse-text').text('(Click to collapse)');
}else{
$('.collapse-text').text('(Click to expand)');
}
});
// end expand/collapse
});
</script><!-- CLose internal javascript --></b></p>
| {
"pile_set_name": "Github"
} |
// atomic = array (possible?)
int main() {
int $tainted x;
int $tainted y [];
x = y; // bad
}
| {
"pile_set_name": "Github"
} |
// RUN: %clang_cc1 -fsyntax-only -verify %s
typedef int Int;
typedef char Char;
typedef Char* Carp;
Int main(Int argc, Carp argv[], Char *env[]) {
}
| {
"pile_set_name": "Github"
} |
/****************************************************************************
* Driver for Solarflare network controllers and boards
* Copyright 2005-2006 Fen Systems Ltd.
* Copyright 2006-2012 Solarflare Communications Inc.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation, incorporated herein by reference.
*/
#include <linux/netdevice.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/kernel_stat.h>
#include <linux/pci.h>
#include <linux/ethtool.h>
#include <linux/ip.h>
#include <linux/in.h>
#include <linux/udp.h>
#include <linux/rtnetlink.h>
#include <linux/slab.h>
#include "net_driver.h"
#include "efx.h"
#include "nic.h"
#include "selftest.h"
#include "workarounds.h"
/* IRQ latency can be enormous because:
* - All IRQs may be disabled on a CPU for a *long* time by e.g. a
* slow serial console or an old IDE driver doing error recovery
* - The PREEMPT_RT patches mostly deal with this, but also allow a
* tasklet or normal task to be given higher priority than our IRQ
* threads
* Try to avoid blaming the hardware for this.
*/
#define IRQ_TIMEOUT HZ
/*
* Loopback test packet structure
*
* The self-test should stress every RSS vector, and unfortunately
* Falcon only performs RSS on TCP/UDP packets.
*/
struct efx_loopback_payload {
struct ethhdr header;
struct iphdr ip;
struct udphdr udp;
__be16 iteration;
char msg[64];
} __packed;
/* Loopback test source MAC address */
static const u8 payload_source[ETH_ALEN] __aligned(2) = {
0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
};
static const char payload_msg[] =
"Hello world! This is an Efx loopback test in progress!";
/* Interrupt mode names */
static const unsigned int efx_interrupt_mode_max = EFX_INT_MODE_MAX;
static const char *const efx_interrupt_mode_names[] = {
[EFX_INT_MODE_MSIX] = "MSI-X",
[EFX_INT_MODE_MSI] = "MSI",
[EFX_INT_MODE_LEGACY] = "legacy",
};
#define INT_MODE(efx) \
STRING_TABLE_LOOKUP(efx->interrupt_mode, efx_interrupt_mode)
/**
* efx_loopback_state - persistent state during a loopback selftest
* @flush: Drop all packets in efx_loopback_rx_packet
* @packet_count: Number of packets being used in this test
* @skbs: An array of skbs transmitted
* @offload_csum: Checksums are being offloaded
* @rx_good: RX good packet count
* @rx_bad: RX bad packet count
* @payload: Payload used in tests
*/
struct efx_loopback_state {
bool flush;
int packet_count;
struct sk_buff **skbs;
bool offload_csum;
atomic_t rx_good;
atomic_t rx_bad;
struct efx_loopback_payload payload;
};
/* How long to wait for all the packets to arrive (in ms) */
#define LOOPBACK_TIMEOUT_MS 1000
/**************************************************************************
*
* MII, NVRAM and register tests
*
**************************************************************************/
static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests)
{
int rc = 0;
if (efx->phy_op->test_alive) {
rc = efx->phy_op->test_alive(efx);
tests->phy_alive = rc ? -1 : 1;
}
return rc;
}
static int efx_test_nvram(struct efx_nic *efx, struct efx_self_tests *tests)
{
int rc = 0;
if (efx->type->test_nvram) {
rc = efx->type->test_nvram(efx);
if (rc == -EPERM)
rc = 0;
else
tests->nvram = rc ? -1 : 1;
}
return rc;
}
/**************************************************************************
*
* Interrupt and event queue testing
*
**************************************************************************/
/* Test generation and receipt of interrupts */
static int efx_test_interrupts(struct efx_nic *efx,
struct efx_self_tests *tests)
{
unsigned long timeout, wait;
int cpu;
int rc;
netif_dbg(efx, drv, efx->net_dev, "testing interrupts\n");
tests->interrupt = -1;
rc = efx_nic_irq_test_start(efx);
if (rc == -ENOTSUPP) {
netif_dbg(efx, drv, efx->net_dev,
"direct interrupt testing not supported\n");
tests->interrupt = 0;
return 0;
}
timeout = jiffies + IRQ_TIMEOUT;
wait = 1;
/* Wait for arrival of test interrupt. */
netif_dbg(efx, drv, efx->net_dev, "waiting for test interrupt\n");
do {
schedule_timeout_uninterruptible(wait);
cpu = efx_nic_irq_test_irq_cpu(efx);
if (cpu >= 0)
goto success;
wait *= 2;
} while (time_before(jiffies, timeout));
netif_err(efx, drv, efx->net_dev, "timed out waiting for interrupt\n");
return -ETIMEDOUT;
success:
netif_dbg(efx, drv, efx->net_dev, "%s test interrupt seen on CPU%d\n",
INT_MODE(efx), cpu);
tests->interrupt = 1;
return 0;
}
/* Test generation and receipt of interrupting events */
static int efx_test_eventq_irq(struct efx_nic *efx,
struct efx_self_tests *tests)
{
struct efx_channel *channel;
unsigned int read_ptr[EFX_MAX_CHANNELS];
unsigned long napi_ran = 0, dma_pend = 0, int_pend = 0;
unsigned long timeout, wait;
BUILD_BUG_ON(EFX_MAX_CHANNELS > BITS_PER_LONG);
efx_for_each_channel(channel, efx) {
read_ptr[channel->channel] = channel->eventq_read_ptr;
set_bit(channel->channel, &dma_pend);
set_bit(channel->channel, &int_pend);
efx_nic_event_test_start(channel);
}
timeout = jiffies + IRQ_TIMEOUT;
wait = 1;
/* Wait for arrival of interrupts. NAPI processing may or may
* not complete in time, but we can cope in any case.
*/
do {
schedule_timeout_uninterruptible(wait);
efx_for_each_channel(channel, efx) {
efx_stop_eventq(channel);
if (channel->eventq_read_ptr !=
read_ptr[channel->channel]) {
set_bit(channel->channel, &napi_ran);
clear_bit(channel->channel, &dma_pend);
clear_bit(channel->channel, &int_pend);
} else {
if (efx_nic_event_present(channel))
clear_bit(channel->channel, &dma_pend);
if (efx_nic_event_test_irq_cpu(channel) >= 0)
clear_bit(channel->channel, &int_pend);
}
efx_start_eventq(channel);
}
wait *= 2;
} while ((dma_pend || int_pend) && time_before(jiffies, timeout));
efx_for_each_channel(channel, efx) {
bool dma_seen = !test_bit(channel->channel, &dma_pend);
bool int_seen = !test_bit(channel->channel, &int_pend);
tests->eventq_dma[channel->channel] = dma_seen ? 1 : -1;
tests->eventq_int[channel->channel] = int_seen ? 1 : -1;
if (dma_seen && int_seen) {
netif_dbg(efx, drv, efx->net_dev,
"channel %d event queue passed (with%s NAPI)\n",
channel->channel,
test_bit(channel->channel, &napi_ran) ?
"" : "out");
} else {
/* Report failure and whether either interrupt or DMA
* worked
*/
netif_err(efx, drv, efx->net_dev,
"channel %d timed out waiting for event queue\n",
channel->channel);
if (int_seen)
netif_err(efx, drv, efx->net_dev,
"channel %d saw interrupt "
"during event queue test\n",
channel->channel);
if (dma_seen)
netif_err(efx, drv, efx->net_dev,
"channel %d event was generated, but "
"failed to trigger an interrupt\n",
channel->channel);
}
}
return (dma_pend || int_pend) ? -ETIMEDOUT : 0;
}
static int efx_test_phy(struct efx_nic *efx, struct efx_self_tests *tests,
unsigned flags)
{
int rc;
if (!efx->phy_op->run_tests)
return 0;
mutex_lock(&efx->mac_lock);
rc = efx->phy_op->run_tests(efx, tests->phy_ext, flags);
mutex_unlock(&efx->mac_lock);
if (rc == -EPERM)
rc = 0;
else
netif_info(efx, drv, efx->net_dev,
"%s phy selftest\n", rc ? "Failed" : "Passed");
return rc;
}
/**************************************************************************
*
* Loopback testing
* NB Only one loopback test can be executing concurrently.
*
**************************************************************************/
/* Loopback test RX callback
* This is called for each received packet during loopback testing.
*/
void efx_loopback_rx_packet(struct efx_nic *efx,
const char *buf_ptr, int pkt_len)
{
struct efx_loopback_state *state = efx->loopback_selftest;
struct efx_loopback_payload *received;
struct efx_loopback_payload *payload;
BUG_ON(!buf_ptr);
/* If we are just flushing, then drop the packet */
if ((state == NULL) || state->flush)
return;
payload = &state->payload;
received = (struct efx_loopback_payload *) buf_ptr;
received->ip.saddr = payload->ip.saddr;
if (state->offload_csum)
received->ip.check = payload->ip.check;
/* Check that header exists */
if (pkt_len < sizeof(received->header)) {
netif_err(efx, drv, efx->net_dev,
"saw runt RX packet (length %d) in %s loopback "
"test\n", pkt_len, LOOPBACK_MODE(efx));
goto err;
}
/* Check that the ethernet header exists */
if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) {
netif_err(efx, drv, efx->net_dev,
"saw non-loopback RX packet in %s loopback test\n",
LOOPBACK_MODE(efx));
goto err;
}
/* Check packet length */
if (pkt_len != sizeof(*payload)) {
netif_err(efx, drv, efx->net_dev,
"saw incorrect RX packet length %d (wanted %d) in "
"%s loopback test\n", pkt_len, (int)sizeof(*payload),
LOOPBACK_MODE(efx));
goto err;
}
/* Check that IP header matches */
if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) {
netif_err(efx, drv, efx->net_dev,
"saw corrupted IP header in %s loopback test\n",
LOOPBACK_MODE(efx));
goto err;
}
/* Check that msg and padding matches */
if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) {
netif_err(efx, drv, efx->net_dev,
"saw corrupted RX packet in %s loopback test\n",
LOOPBACK_MODE(efx));
goto err;
}
/* Check that iteration matches */
if (received->iteration != payload->iteration) {
netif_err(efx, drv, efx->net_dev,
"saw RX packet from iteration %d (wanted %d) in "
"%s loopback test\n", ntohs(received->iteration),
ntohs(payload->iteration), LOOPBACK_MODE(efx));
goto err;
}
/* Increase correct RX count */
netif_vdbg(efx, drv, efx->net_dev,
"got loopback RX in %s loopback test\n", LOOPBACK_MODE(efx));
atomic_inc(&state->rx_good);
return;
err:
#ifdef DEBUG
if (atomic_read(&state->rx_bad) == 0) {
netif_err(efx, drv, efx->net_dev, "received packet:\n");
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
buf_ptr, pkt_len, 0);
netif_err(efx, drv, efx->net_dev, "expected packet:\n");
print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
&state->payload, sizeof(state->payload), 0);
}
#endif
atomic_inc(&state->rx_bad);
}
/* Initialise an efx_selftest_state for a new iteration */
static void efx_iterate_state(struct efx_nic *efx)
{
struct efx_loopback_state *state = efx->loopback_selftest;
struct net_device *net_dev = efx->net_dev;
struct efx_loopback_payload *payload = &state->payload;
/* Initialise the layerII header */
ether_addr_copy((u8 *)&payload->header.h_dest, net_dev->dev_addr);
ether_addr_copy((u8 *)&payload->header.h_source, payload_source);
payload->header.h_proto = htons(ETH_P_IP);
/* saddr set later and used as incrementing count */
payload->ip.daddr = htonl(INADDR_LOOPBACK);
payload->ip.ihl = 5;
payload->ip.check = (__force __sum16) htons(0xdead);
payload->ip.tot_len = htons(sizeof(*payload) - sizeof(struct ethhdr));
payload->ip.version = IPVERSION;
payload->ip.protocol = IPPROTO_UDP;
/* Initialise udp header */
payload->udp.source = 0;
payload->udp.len = htons(sizeof(*payload) - sizeof(struct ethhdr) -
sizeof(struct iphdr));
payload->udp.check = 0; /* checksum ignored */
/* Fill out payload */
payload->iteration = htons(ntohs(payload->iteration) + 1);
memcpy(&payload->msg, payload_msg, sizeof(payload_msg));
/* Fill out remaining state members */
atomic_set(&state->rx_good, 0);
atomic_set(&state->rx_bad, 0);
smp_wmb();
}
static int efx_begin_loopback(struct efx_tx_queue *tx_queue)
{
struct efx_nic *efx = tx_queue->efx;
struct efx_loopback_state *state = efx->loopback_selftest;
struct efx_loopback_payload *payload;
struct sk_buff *skb;
int i;
netdev_tx_t rc;
/* Transmit N copies of buffer */
for (i = 0; i < state->packet_count; i++) {
/* Allocate an skb, holding an extra reference for
* transmit completion counting */
skb = alloc_skb(sizeof(state->payload), GFP_KERNEL);
if (!skb)
return -ENOMEM;
state->skbs[i] = skb;
skb_get(skb);
/* Copy the payload in, incrementing the source address to
* exercise the rss vectors */
payload = skb_put(skb, sizeof(state->payload));
memcpy(payload, &state->payload, sizeof(state->payload));
payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2));
/* Ensure everything we've written is visible to the
* interrupt handler. */
smp_wmb();
netif_tx_lock_bh(efx->net_dev);
rc = efx_enqueue_skb(tx_queue, skb);
netif_tx_unlock_bh(efx->net_dev);
if (rc != NETDEV_TX_OK) {
netif_err(efx, drv, efx->net_dev,
"TX queue %d could not transmit packet %d of "
"%d in %s loopback test\n", tx_queue->queue,
i + 1, state->packet_count,
LOOPBACK_MODE(efx));
/* Defer cleaning up the other skbs for the caller */
kfree_skb(skb);
return -EPIPE;
}
}
return 0;
}
static int efx_poll_loopback(struct efx_nic *efx)
{
struct efx_loopback_state *state = efx->loopback_selftest;
return atomic_read(&state->rx_good) == state->packet_count;
}
static int efx_end_loopback(struct efx_tx_queue *tx_queue,
struct efx_loopback_self_tests *lb_tests)
{
struct efx_nic *efx = tx_queue->efx;
struct efx_loopback_state *state = efx->loopback_selftest;
struct sk_buff *skb;
int tx_done = 0, rx_good, rx_bad;
int i, rc = 0;
netif_tx_lock_bh(efx->net_dev);
/* Count the number of tx completions, and decrement the refcnt. Any
* skbs not already completed will be free'd when the queue is flushed */
for (i = 0; i < state->packet_count; i++) {
skb = state->skbs[i];
if (skb && !skb_shared(skb))
++tx_done;
dev_kfree_skb(skb);
}
netif_tx_unlock_bh(efx->net_dev);
/* Check TX completion and received packet counts */
rx_good = atomic_read(&state->rx_good);
rx_bad = atomic_read(&state->rx_bad);
if (tx_done != state->packet_count) {
/* Don't free the skbs; they will be picked up on TX
* overflow or channel teardown.
*/
netif_err(efx, drv, efx->net_dev,
"TX queue %d saw only %d out of an expected %d "
"TX completion events in %s loopback test\n",
tx_queue->queue, tx_done, state->packet_count,
LOOPBACK_MODE(efx));
rc = -ETIMEDOUT;
/* Allow to fall through so we see the RX errors as well */
}
/* We may always be up to a flush away from our desired packet total */
if (rx_good != state->packet_count) {
netif_dbg(efx, drv, efx->net_dev,
"TX queue %d saw only %d out of an expected %d "
"received packets in %s loopback test\n",
tx_queue->queue, rx_good, state->packet_count,
LOOPBACK_MODE(efx));
rc = -ETIMEDOUT;
/* Fall through */
}
/* Update loopback test structure */
lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
lb_tests->tx_done[tx_queue->queue] += tx_done;
lb_tests->rx_good += rx_good;
lb_tests->rx_bad += rx_bad;
return rc;
}
static int
efx_test_loopback(struct efx_tx_queue *tx_queue,
struct efx_loopback_self_tests *lb_tests)
{
struct efx_nic *efx = tx_queue->efx;
struct efx_loopback_state *state = efx->loopback_selftest;
int i, begin_rc, end_rc;
for (i = 0; i < 3; i++) {
/* Determine how many packets to send */
state->packet_count = efx->txq_entries / 3;
state->packet_count = min(1 << (i << 2), state->packet_count);
state->skbs = kcalloc(state->packet_count,
sizeof(state->skbs[0]), GFP_KERNEL);
if (!state->skbs)
return -ENOMEM;
state->flush = false;
netif_dbg(efx, drv, efx->net_dev,
"TX queue %d testing %s loopback with %d packets\n",
tx_queue->queue, LOOPBACK_MODE(efx),
state->packet_count);
efx_iterate_state(efx);
begin_rc = efx_begin_loopback(tx_queue);
/* This will normally complete very quickly, but be
* prepared to wait much longer. */
msleep(1);
if (!efx_poll_loopback(efx)) {
msleep(LOOPBACK_TIMEOUT_MS);
efx_poll_loopback(efx);
}
end_rc = efx_end_loopback(tx_queue, lb_tests);
kfree(state->skbs);
if (begin_rc || end_rc) {
/* Wait a while to ensure there are no packets
* floating around after a failure. */
schedule_timeout_uninterruptible(HZ / 10);
return begin_rc ? begin_rc : end_rc;
}
}
netif_dbg(efx, drv, efx->net_dev,
"TX queue %d passed %s loopback test with a burst length "
"of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
state->packet_count);
return 0;
}
/* Wait for link up. On Falcon, we would prefer to rely on efx_monitor, but
* any contention on the mac lock (via e.g. efx_mac_mcast_work) causes it
* to delay and retry. Therefore, it's safer to just poll directly. Wait
* for link up and any faults to dissipate. */
static int efx_wait_for_link(struct efx_nic *efx)
{
struct efx_link_state *link_state = &efx->link_state;
int count, link_up_count = 0;
bool link_up;
for (count = 0; count < 40; count++) {
schedule_timeout_uninterruptible(HZ / 10);
if (efx->type->monitor != NULL) {
mutex_lock(&efx->mac_lock);
efx->type->monitor(efx);
mutex_unlock(&efx->mac_lock);
}
mutex_lock(&efx->mac_lock);
link_up = link_state->up;
if (link_up)
link_up = !efx->type->check_mac_fault(efx);
mutex_unlock(&efx->mac_lock);
if (link_up) {
if (++link_up_count == 2)
return 0;
} else {
link_up_count = 0;
}
}
return -ETIMEDOUT;
}
static int efx_test_loopbacks(struct efx_nic *efx, struct efx_self_tests *tests,
unsigned int loopback_modes)
{
enum efx_loopback_mode mode;
struct efx_loopback_state *state;
struct efx_channel *channel =
efx_get_channel(efx, efx->tx_channel_offset);
struct efx_tx_queue *tx_queue;
int rc = 0;
/* Set the port loopback_selftest member. From this point on
* all received packets will be dropped. Mark the state as
* "flushing" so all inflight packets are dropped */
state = kzalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
BUG_ON(efx->loopback_selftest);
state->flush = true;
efx->loopback_selftest = state;
/* Test all supported loopback modes */
for (mode = LOOPBACK_NONE; mode <= LOOPBACK_TEST_MAX; mode++) {
if (!(loopback_modes & (1 << mode)))
continue;
/* Move the port into the specified loopback mode. */
state->flush = true;
mutex_lock(&efx->mac_lock);
efx->loopback_mode = mode;
rc = __efx_reconfigure_port(efx);
mutex_unlock(&efx->mac_lock);
if (rc) {
netif_err(efx, drv, efx->net_dev,
"unable to move into %s loopback\n",
LOOPBACK_MODE(efx));
goto out;
}
rc = efx_wait_for_link(efx);
if (rc) {
netif_err(efx, drv, efx->net_dev,
"loopback %s never came up\n",
LOOPBACK_MODE(efx));
goto out;
}
/* Test all enabled types of TX queue */
efx_for_each_channel_tx_queue(tx_queue, channel) {
state->offload_csum = (tx_queue->queue &
EFX_TXQ_TYPE_OFFLOAD);
rc = efx_test_loopback(tx_queue,
&tests->loopback[mode]);
if (rc)
goto out;
}
}
out:
/* Remove the flush. The caller will remove the loopback setting */
state->flush = true;
efx->loopback_selftest = NULL;
wmb();
kfree(state);
if (rc == -EPERM)
rc = 0;
return rc;
}
/**************************************************************************
*
* Entry point
*
*************************************************************************/
int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests,
unsigned flags)
{
enum efx_loopback_mode loopback_mode = efx->loopback_mode;
int phy_mode = efx->phy_mode;
int rc_test = 0, rc_reset, rc;
efx_selftest_async_cancel(efx);
/* Online (i.e. non-disruptive) testing
* This checks interrupt generation, event delivery and PHY presence. */
rc = efx_test_phy_alive(efx, tests);
if (rc && !rc_test)
rc_test = rc;
rc = efx_test_nvram(efx, tests);
if (rc && !rc_test)
rc_test = rc;
rc = efx_test_interrupts(efx, tests);
if (rc && !rc_test)
rc_test = rc;
rc = efx_test_eventq_irq(efx, tests);
if (rc && !rc_test)
rc_test = rc;
if (rc_test)
return rc_test;
if (!(flags & ETH_TEST_FL_OFFLINE))
return efx_test_phy(efx, tests, flags);
/* Offline (i.e. disruptive) testing
* This checks MAC and PHY loopback on the specified port. */
/* Detach the device so the kernel doesn't transmit during the
* loopback test and the watchdog timeout doesn't fire.
*/
efx_device_detach_sync(efx);
if (efx->type->test_chip) {
rc_reset = efx->type->test_chip(efx, tests);
if (rc_reset) {
netif_err(efx, hw, efx->net_dev,
"Unable to recover from chip test\n");
efx_schedule_reset(efx, RESET_TYPE_DISABLE);
return rc_reset;
}
if ((tests->memory < 0 || tests->registers < 0) && !rc_test)
rc_test = -EIO;
}
/* Ensure that the phy is powered and out of loopback
* for the bist and loopback tests */
mutex_lock(&efx->mac_lock);
efx->phy_mode &= ~PHY_MODE_LOW_POWER;
efx->loopback_mode = LOOPBACK_NONE;
__efx_reconfigure_port(efx);
mutex_unlock(&efx->mac_lock);
rc = efx_test_phy(efx, tests, flags);
if (rc && !rc_test)
rc_test = rc;
rc = efx_test_loopbacks(efx, tests, efx->loopback_modes);
if (rc && !rc_test)
rc_test = rc;
/* restore the PHY to the previous state */
mutex_lock(&efx->mac_lock);
efx->phy_mode = phy_mode;
efx->loopback_mode = loopback_mode;
__efx_reconfigure_port(efx);
mutex_unlock(&efx->mac_lock);
efx_device_attach_if_not_resetting(efx);
return rc_test;
}
void efx_selftest_async_start(struct efx_nic *efx)
{
struct efx_channel *channel;
efx_for_each_channel(channel, efx)
efx_nic_event_test_start(channel);
schedule_delayed_work(&efx->selftest_work, IRQ_TIMEOUT);
}
void efx_selftest_async_cancel(struct efx_nic *efx)
{
cancel_delayed_work_sync(&efx->selftest_work);
}
void efx_selftest_async_work(struct work_struct *data)
{
struct efx_nic *efx = container_of(data, struct efx_nic,
selftest_work.work);
struct efx_channel *channel;
int cpu;
efx_for_each_channel(channel, efx) {
cpu = efx_nic_event_test_irq_cpu(channel);
if (cpu < 0)
netif_err(efx, ifup, efx->net_dev,
"channel %d failed to trigger an interrupt\n",
channel->channel);
else
netif_dbg(efx, ifup, efx->net_dev,
"channel %d triggered interrupt on CPU %d\n",
channel->channel, cpu);
}
}
| {
"pile_set_name": "Github"
} |
connection node_2;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
INSERT INTO t1 VALUES (1, 'a');
INSERT INTO t1 VALUES (2, 'a');
connection node_1;
SET AUTOCOMMIT=ON;
START TRANSACTION;
UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
f1 f2
2 a
connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1;
SET SESSION wsrep_sync_wait=0;
SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync';
connection node_2;
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync';
connection node_1;
COMMIT;
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=d,abort_trx_end';
SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync';
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'signal=abort_trx_end';
SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync';
connection node_1;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
COUNT(*) = 1
1
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
COUNT(*) = 1
1
wsrep_local_replays
1
connection node_2;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
COUNT(*) = 1
1
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
COUNT(*) = 1
1
DROP TABLE t1;
connection node_1;
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY, f2 CHAR(1));
INSERT INTO t1 VALUES (1, 'a');
INSERT INTO t1 VALUES (2, 'a');
connection node_1;
SET AUTOCOMMIT=ON;
START TRANSACTION;
UPDATE t1 SET f2 = 'b' WHERE f1 = 1;
SELECT * FROM t1 WHERE f1 = 2 FOR UPDATE;
f1 f2
2 a
SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync';
connection node_1;
COMMIT;
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=d,abort_trx_end';
connection node_2;
UPDATE t1 SET f2 = 'c' WHERE f1 = 2;
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'signal=abort_trx_end';
SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync';
connection node_1;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
COUNT(*) = 1
1
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
COUNT(*) = 1
1
wsrep_local_replays
1
connection node_2;
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
COUNT(*) = 1
1
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
COUNT(*) = 1
1
DROP TABLE t1;
connection node_1;
CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 0), (3, 0);
SELECT * FROM t1;
i j
1 0
3 0
SET AUTOCOMMIT=ON;
PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0";
connection node_1a;
SET SESSION wsrep_sync_wait=0;
SET GLOBAL wsrep_provider_options = 'dbug=d,apply_monitor_slave_enter_sync';
connection node_2;
INSERT INTO t1 VALUES(2,2);
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_master_enter_sync';
connection node_1;
SET SESSION wsrep_sync_wait=0;
EXECUTE stmt1;
connection node_1a;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'dbug=d,abort_trx_end';
SET GLOBAL wsrep_provider_options = 'signal=apply_monitor_slave_enter_sync';
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'signal=abort_trx_end';
SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_master_enter_sync';
connection node_1;
SET SESSION wsrep_sync_wait=7;
SELECT * FROM t1;
i j
1 1
2 2
3 1
connection node_2;
SELECT * FROM t1;
i j
1 1
2 2
3 1
connection node_1;
wsrep_local_replays
1
DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2010-2019 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
package com.evolveum.midpoint.model.impl.lens.projector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.api.context.SynchronizationIntent;
import com.evolveum.midpoint.model.api.context.SynchronizationPolicyDecision;
import com.evolveum.midpoint.model.api.expr.MidpointFunctions;
import com.evolveum.midpoint.model.impl.lens.*;
import com.evolveum.midpoint.model.impl.lens.projector.mappings.*;
import com.evolveum.midpoint.model.impl.lens.projector.util.ProcessorExecution;
import com.evolveum.midpoint.model.impl.lens.projector.util.ProcessorMethod;
import com.evolveum.midpoint.model.impl.util.ModelImplUtils;
import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.delta.PrismValueDeltaSetTriple;
import com.evolveum.midpoint.prism.delta.PropertyDelta;
import com.evolveum.midpoint.prism.path.ItemName;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.path.UniformItemPath;
import com.evolveum.midpoint.prism.util.ItemDeltaItem;
import com.evolveum.midpoint.prism.util.ObjectDeltaObject;
import com.evolveum.midpoint.repo.common.expression.ExpressionUtil;
import com.evolveum.midpoint.repo.common.expression.Source;
import com.evolveum.midpoint.schema.CapabilityUtil;
import com.evolveum.midpoint.schema.constants.ExpressionConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.DOMUtil;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationLockoutStatusCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationStatusCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationValidityCapabilityType;
/**
* The processor that takes care of user activation mapping to an account (outbound direction).
*
* @author Radovan Semancik
*/
@Component
@ProcessorExecution(focusRequired = true, focusType = FocusType.class)
public class ActivationProcessor implements ProjectorProcessor {
private static final Trace LOGGER = TraceManager.getTrace(ActivationProcessor.class);
private static final ItemName SHADOW_EXISTS_PROPERTY_NAME = new ItemName(SchemaConstants.NS_C, "shadowExists");
private static final ItemName LEGAL_PROPERTY_NAME = new ItemName(SchemaConstants.NS_C, "legal");
private static final ItemName ASSIGNED_PROPERTY_NAME = new ItemName(SchemaConstants.NS_C, "assigned");
private static final ItemName FOCUS_EXISTS_PROPERTY_NAME = new ItemName(SchemaConstants.NS_C, "focusExists");
private static final String OP_ACTIVATION = Projector.class.getName() + ".activation"; // for historical reasons
private static final String OP_PROJECTION_ACTIVATION = ActivationProcessor.class.getName() + ".projectionActivation";
@Autowired private ContextLoader contextLoader;
@Autowired private PrismContext prismContext;
@Autowired private MappingEvaluator mappingEvaluator;
@Autowired private MidpointFunctions midpointFunctions;
@Autowired private ClockworkMedic medic;
private PrismObjectDefinition<UserType> userDefinition;
private PrismContainerDefinition<ActivationType> activationDefinition;
// not a "medic-managed" entry point
<F extends ObjectType> void processActivationForAllResources(LensContext<F> context, String activityDescription,
XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException,
ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException,
SecurityViolationException {
OperationResult activationResult = result.subresult(OP_ACTIVATION)
.setMinor()
.build();
try {
LOGGER.trace("Processing activation for all contexts");
for (LensProjectionContext projectionContext : context.getProjectionContexts()) {
if (projectionContext.getSynchronizationPolicyDecision() != SynchronizationPolicyDecision.BROKEN
&& projectionContext.getSynchronizationPolicyDecision() != SynchronizationPolicyDecision.IGNORE) {
processActivation(context, projectionContext, now, task, activationResult);
}
}
context.removeIgnoredContexts();
medic.traceContext(LOGGER, activityDescription, "projection activation of all resources", true,
context, true);
context.checkConsistenceIfNeeded();
} catch (Throwable t) {
activationResult.recordFatalError(t);
throw t;
} finally {
activationResult.computeStatusIfUnknown();
}
}
private <O extends ObjectType, F extends FocusType> void processActivation(LensContext<O> context,
LensProjectionContext projectionContext, XMLGregorianCalendar now, Task task, OperationResult parentResult)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, PolicyViolationException,
CommunicationException, ConfigurationException, SecurityViolationException {
OperationResult result = parentResult.subresult(OP_PROJECTION_ACTIVATION)
.addParam("resourceOid", projectionContext.getResourceOid())
.addParam("resourceName", projectionContext.getResourceName())
.addParam("projection", projectionContext.getHumanReadableName())
.build();
try {
LensFocusContext<O> focusContext = context.getFocusContext();
if (focusContext == null || !FocusType.class.isAssignableFrom(focusContext.getObjectTypeClass())) {
processActivationMetadata(projectionContext, now);
} else {
try {
//noinspection unchecked
LensContext<F> contextCasted = (LensContext<F>) context;
processActivationMappingsCurrent(contextCasted, projectionContext, now, task, result);
processActivationMetadata(projectionContext, now);
processActivationMappingsFuture(contextCasted, projectionContext, now, task, result);
} catch (ObjectNotFoundException e) {
if (projectionContext.isTombstone()) {
// This is not critical. The projection is marked as tombstone and we can go on with processing
// No extra action is needed.
} else {
throw e;
}
}
}
projectionContext.recompute();
} catch (Throwable t) {
result.recordFatalError(t);
throw t;
} finally {
result.computeStatusIfUnknown();
}
}
private <F extends FocusType> void processActivationMappingsCurrent(LensContext<F> context, LensProjectionContext projCtx,
XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException,
ObjectNotFoundException, SchemaException, PolicyViolationException, CommunicationException, ConfigurationException,
SecurityViolationException {
String projCtxDesc = projCtx.toHumanReadableString();
SynchronizationPolicyDecision existingDecision = projCtx.getSynchronizationPolicyDecision();
SynchronizationIntent synchronizationIntent = projCtx.getSynchronizationIntent();
result.addContext("existingDecision", String.valueOf(existingDecision));
result.addContext("synchronizationIntent", String.valueOf(synchronizationIntent));
LOGGER.trace("processActivationUserCurrent starting for {}. Existing decision = {}, synchronization intent = {}",
projCtxDesc, existingDecision, synchronizationIntent);
if (existingDecision == SynchronizationPolicyDecision.BROKEN) {
LOGGER.trace("Broken projection {}, skipping further activation processing", projCtxDesc);
return;
}
if (existingDecision != null) {
throw new IllegalStateException("Decision "+existingDecision+" already present for projection "+projCtxDesc);
}
if (synchronizationIntent == SynchronizationIntent.UNLINK) {
setSynchronizationPolicyDecision(projCtx, SynchronizationPolicyDecision.UNLINK, result);
LOGGER.trace("Evaluated decision for {} to {} because of unlink synchronization intent, skipping further activation processing", projCtxDesc, SynchronizationPolicyDecision.UNLINK);
return;
}
if (projCtx.isTombstone()) {
if (projCtx.isDelete() && ModelExecuteOptions.isForce(context.getOptions())) {
setSynchronizationPolicyDecision(projCtx, SynchronizationPolicyDecision.DELETE, result);
LOGGER.trace("Evaluated decision for tombstone {} to {} (force), skipping further activation processing", projCtxDesc, SynchronizationPolicyDecision.DELETE);
} else {
// Let's keep tombstones linked until they expire. So we do not have shadows without owners.
// This is also needed for async delete operations.
setSynchronizationPolicyDecision(projCtx, SynchronizationPolicyDecision.KEEP, result);
LOGGER.trace("Evaluated decision for {} to {} because it is tombstone, skipping further activation processing", projCtxDesc, SynchronizationPolicyDecision.KEEP);
}
return;
}
if (synchronizationIntent == SynchronizationIntent.DELETE || projCtx.isDelete()) {
// TODO: is this OK?
setSynchronizationPolicyDecision(projCtx, SynchronizationPolicyDecision.DELETE, result);
LOGGER.trace("Evaluated decision for {} to {}, skipping further activation processing", projCtxDesc, SynchronizationPolicyDecision.DELETE);
return;
}
LOGGER.trace("Evaluating intended existence of projection {} (legal={})", projCtxDesc, projCtx.isLegal());
boolean shadowShouldExist = evaluateExistenceMapping(context, projCtx, now, MappingTimeEval.CURRENT, task, result);
LOGGER.trace("Evaluated intended existence of projection {} to {} (legal={})", projCtxDesc, shadowShouldExist, projCtx.isLegal());
// Let's reconcile the existence intent (shadowShouldExist) and the synchronization intent in the context
LensProjectionContext lowerOrderContext = LensUtil.findLowerOrderContext(context, projCtx);
SynchronizationPolicyDecision decision;
if (synchronizationIntent == null || synchronizationIntent == SynchronizationIntent.SYNCHRONIZE) {
if (shadowShouldExist) {
projCtx.setActive(true);
if (projCtx.isExists()) {
if (lowerOrderContext != null && lowerOrderContext.isDelete()) {
// HACK HACK HACK
decision = SynchronizationPolicyDecision.DELETE;
} else {
decision = SynchronizationPolicyDecision.KEEP;
}
} else {
if (lowerOrderContext != null) {
if (lowerOrderContext.isDelete()) {
// HACK HACK HACK
decision = SynchronizationPolicyDecision.DELETE;
} else {
// If there is a lower-order context then that one will be ADD
// and this one is KEEP. When the execution comes to this context
// then the projection already exists
decision = SynchronizationPolicyDecision.KEEP;
}
} else {
decision = SynchronizationPolicyDecision.ADD;
}
}
} else {
// Delete
if (projCtx.isExists()) {
decision = SynchronizationPolicyDecision.DELETE;
} else {
// we should delete the entire context, but then we will lose track of what
// happened. So just ignore it.
decision = SynchronizationPolicyDecision.IGNORE;
// if there are any triggers then move them to focus. We may still need them.
LensUtil.moveTriggers(projCtx, context.getFocusContext());
}
}
} else if (synchronizationIntent == SynchronizationIntent.ADD) {
if (shadowShouldExist) {
projCtx.setActive(true);
if (projCtx.isExists()) {
// Attempt to add something that is already there, but should be OK
decision = SynchronizationPolicyDecision.KEEP;
} else {
decision = SynchronizationPolicyDecision.ADD;
}
} else {
throw new PolicyViolationException("Request to add projection "+projCtxDesc+" but the activation policy decided that it should not exist");
}
} else if (synchronizationIntent == SynchronizationIntent.KEEP) {
if (shadowShouldExist) {
projCtx.setActive(true);
if (projCtx.isExists()) {
decision = SynchronizationPolicyDecision.KEEP;
} else {
decision = SynchronizationPolicyDecision.ADD;
}
} else {
throw new PolicyViolationException("Request to keep projection "+projCtxDesc+" but the activation policy decided that it should not exist");
}
} else {
throw new IllegalStateException("Unknown sync intent "+synchronizationIntent);
}
LOGGER.trace("Evaluated decision for projection {} to {}", projCtxDesc, decision);
setSynchronizationPolicyDecision(projCtx, decision, result);
PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
if (focusNew == null) {
// This must be a user delete or something similar. No point in proceeding
LOGGER.trace("focusNew is null, skipping activation processing of {}", projCtxDesc);
return;
}
if (decision == SynchronizationPolicyDecision.DELETE) {
LOGGER.trace("Decision is {}, skipping activation properties processing for {}", decision, projCtxDesc);
return;
}
ResourceObjectTypeDefinitionType resourceObjectTypeDefinition = projCtx.getResourceObjectTypeDefinitionType();
if (resourceObjectTypeDefinition == null) {
LOGGER.trace("No refined object definition, therefore also no activation outbound definition, skipping activation processing for account {}", projCtxDesc);
return;
}
ResourceActivationDefinitionType activationDefinition = resourceObjectTypeDefinition.getActivation();
if (activationDefinition == null) {
LOGGER.trace("No activation definition in projection {}, skipping activation properties processing", projCtxDesc);
return;
}
ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(projCtx.getResource(), ActivationCapabilityType.class);
if (capActivation == null) {
LOGGER.trace("Skipping activation status and validity processing because {} has no activation capability", projCtx.getResource());
return;
}
ActivationStatusCapabilityType capStatus = CapabilityUtil.getEffectiveActivationStatus(capActivation);
ActivationValidityCapabilityType capValidFrom = CapabilityUtil.getEffectiveActivationValidFrom(capActivation);
ActivationValidityCapabilityType capValidTo = CapabilityUtil.getEffectiveActivationValidTo(capActivation);
ActivationLockoutStatusCapabilityType capLockoutStatus = CapabilityUtil.getEffectiveActivationLockoutStatus(capActivation);
if (capStatus != null) {
evaluateActivationMapping(context, projCtx,
activationDefinition.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
capActivation, now, MappingTimeEval.CURRENT, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
} else {
LOGGER.trace("Skipping activation administrative status processing because {} does not have activation administrative status capability", projCtx.getResource());
}
ResourceBidirectionalMappingType validFromMappingType = activationDefinition.getValidFrom();
if (validFromMappingType == null || validFromMappingType.getOutbound() == null) {
LOGGER.trace("Skipping activation validFrom processing because {} does not have appropriate outbound mapping", projCtx.getResource());
} else if (capValidFrom == null && !ExpressionUtil.hasExplicitTarget(validFromMappingType.getOutbound())) {
LOGGER.trace("Skipping activation validFrom processing because {} does not have activation validFrom capability nor outbound mapping with explicit target", projCtx.getResource());
} else {
evaluateActivationMapping(context, projCtx, activationDefinition.getValidFrom(),
SchemaConstants.PATH_ACTIVATION_VALID_FROM,
SchemaConstants.PATH_ACTIVATION_VALID_FROM,
null, now, MappingTimeEval.CURRENT, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}
ResourceBidirectionalMappingType validToMappingType = activationDefinition.getValidTo();
if (validToMappingType == null || validToMappingType.getOutbound() == null) {
LOGGER.trace("Skipping activation validTo processing because {} does not have appropriate outbound mapping", projCtx.getResource());
} else if (capValidTo == null && !ExpressionUtil.hasExplicitTarget(validToMappingType.getOutbound())) {
LOGGER.trace("Skipping activation validTo processing because {} does not have activation validTo capability nor outbound mapping with explicit target", projCtx.getResource());
} else {
evaluateActivationMapping(context, projCtx, activationDefinition.getValidTo(),
SchemaConstants.PATH_ACTIVATION_VALID_TO,
SchemaConstants.PATH_ACTIVATION_VALID_TO,
null, now, MappingTimeEval.CURRENT, ActivationType.F_VALID_TO.getLocalPart(), task, result);
}
if (capLockoutStatus != null) {
evaluateActivationMapping(context, projCtx,
activationDefinition.getLockoutStatus(),
SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS,
capActivation, now, MappingTimeEval.CURRENT, ActivationType.F_LOCKOUT_STATUS.getLocalPart(), task, result);
} else {
LOGGER.trace("Skipping activation lockout status processing because {} does not have activation lockout status capability", projCtx.getResource());
}
}
private void setSynchronizationPolicyDecision(LensProjectionContext projCtx, SynchronizationPolicyDecision decision, OperationResult result) {
projCtx.setSynchronizationPolicyDecision(decision);
result.addReturn("decision", String.valueOf(decision));
}
private <F extends FocusType> void processActivationMetadata(LensProjectionContext projCtx, XMLGregorianCalendar now) throws SchemaException {
ObjectDelta<ShadowType> projDelta = projCtx.getCurrentDelta();
if (projDelta == null) {
return;
}
LOGGER.trace("processActivationMetadata starting for {}", projCtx);
PropertyDelta<ActivationStatusType> statusDelta = projDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (statusDelta != null && !statusDelta.isDelete()) {
// we have to determine if the status really changed
PrismObject<ShadowType> oldShadow = projCtx.getObjectOld();
ActivationStatusType statusOld;
if (oldShadow != null && oldShadow.asObjectable().getActivation() != null) {
statusOld = oldShadow.asObjectable().getActivation().getAdministrativeStatus();
} else {
statusOld = null;
}
PrismProperty<ActivationStatusType> statusPropNew = (PrismProperty<ActivationStatusType>) statusDelta.getItemNewMatchingPath(null);
ActivationStatusType statusNew = statusPropNew.getRealValue();
if (statusNew == statusOld) {
LOGGER.trace("Administrative status not changed ({}), timestamp and/or reason will not be recorded", statusNew);
} else {
// timestamps
PropertyDelta<XMLGregorianCalendar> timestampDelta = LensUtil.createActivationTimestampDelta(statusNew,
now, getActivationDefinition(), OriginType.OUTBOUND, prismContext);
projCtx.swallowToSecondaryDelta(timestampDelta);
// disableReason
if (statusNew == ActivationStatusType.DISABLED) {
PropertyDelta<String> disableReasonDelta = projDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_DISABLE_REASON);
if (disableReasonDelta == null) {
String disableReason;
ObjectDelta<ShadowType> projPrimaryDelta = projCtx.getPrimaryDelta();
ObjectDelta<ShadowType> projSecondaryDelta = projCtx.getSecondaryDelta();
if (projPrimaryDelta != null
&& projPrimaryDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS) != null
&& (projSecondaryDelta == null || projSecondaryDelta.findPropertyDelta(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS) == null)) {
disableReason = SchemaConstants.MODEL_DISABLE_REASON_EXPLICIT;
} else if (projCtx.isLegal()) {
disableReason = SchemaConstants.MODEL_DISABLE_REASON_MAPPED;
} else {
disableReason = SchemaConstants.MODEL_DISABLE_REASON_DEPROVISION;
}
PrismPropertyDefinition<String> disableReasonDef = activationDefinition.findPropertyDefinition(ActivationType.F_DISABLE_REASON);
disableReasonDelta = disableReasonDef.createEmptyDelta(
ItemPath.create(FocusType.F_ACTIVATION, ActivationType.F_DISABLE_REASON));
disableReasonDelta.setValueToReplace(prismContext.itemFactory().createPropertyValue(disableReason, OriginType.OUTBOUND, null));
projCtx.swallowToSecondaryDelta(disableReasonDelta);
}
}
}
}
}
/**
* We'll evaluate the mappings just to create the triggers.
*/
private <F extends FocusType> void processActivationMappingsFuture(LensContext<F> context, LensProjectionContext accCtx,
XMLGregorianCalendar now, Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
String accCtxDesc = accCtx.toHumanReadableString();
SynchronizationPolicyDecision decision = accCtx.getSynchronizationPolicyDecision();
LOGGER.trace("processActivationUserFuture starting for {}. Existing decision = {}", accCtx, decision);
if (accCtx.isTombstone() || decision == SynchronizationPolicyDecision.BROKEN
|| decision == SynchronizationPolicyDecision.IGNORE
|| decision == SynchronizationPolicyDecision.UNLINK || decision == SynchronizationPolicyDecision.DELETE) {
return;
}
accCtx.recompute();
evaluateExistenceMapping(context, accCtx, now, MappingTimeEval.FUTURE, task, result);
PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
if (focusNew == null) {
// This must be a user delete or something similar. No point in proceeding
LOGGER.trace("focusNew is null, skipping activation processing of {}", accCtxDesc);
return;
}
ResourceObjectTypeDefinitionType resourceAccountDefType = accCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return;
}
ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
if (activationType == null) {
return;
}
ActivationCapabilityType capActivation = ResourceTypeUtil.getEffectiveCapability(accCtx.getResource(), ActivationCapabilityType.class);
if (capActivation == null) {
return;
}
ActivationStatusCapabilityType capStatus = CapabilityUtil.getEffectiveActivationStatus(capActivation);
ActivationValidityCapabilityType capValidFrom = CapabilityUtil.getEffectiveActivationValidFrom(capActivation);
ActivationValidityCapabilityType capValidTo = CapabilityUtil.getEffectiveActivationValidTo(capActivation);
if (capStatus != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS,
capActivation, now, MappingTimeEval.FUTURE, ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart(), task, result);
}
if (capValidFrom != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_VALID_FROM, SchemaConstants.PATH_ACTIVATION_VALID_FROM,
null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}
if (capValidTo != null) {
evaluateActivationMapping(context, accCtx, activationType.getAdministrativeStatus(),
SchemaConstants.PATH_ACTIVATION_VALID_TO, SchemaConstants.PATH_ACTIVATION_VALID_TO,
null, now, MappingTimeEval.FUTURE, ActivationType.F_VALID_FROM.getLocalPart(), task, result);
}
}
private <F extends FocusType> boolean evaluateExistenceMapping(final LensContext<F> context,
final LensProjectionContext projCtx, final XMLGregorianCalendar now, final MappingTimeEval current,
Task task, final OperationResult result)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
final String projCtxDesc = projCtx.toHumanReadableString();
final Boolean legal = projCtx.isLegal();
if (legal == null) {
throw new IllegalStateException("Null 'legal' for "+projCtxDesc);
}
ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType == null) {
return legal;
}
ResourceActivationDefinitionType activationType = resourceAccountDefType.getActivation();
if (activationType == null) {
return legal;
}
ResourceBidirectionalMappingType existenceType = activationType.getExistence();
if (existenceType == null) {
return legal;
}
List<MappingType> outbound = existenceType.getOutbound();
if (outbound == null || outbound.isEmpty()) {
// "default mapping"
return legal;
}
MappingEvaluatorParams<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>, ShadowType, F> params = new MappingEvaluatorParams<>();
params.setMappingTypes(outbound);
params.setMappingDesc("outbound existence mapping in projection " + projCtxDesc);
params.setNow(now);
params.setAPrioriTargetObject(projCtx.getObjectOld());
params.setEvaluateCurrent(current);
params.setTargetContext(projCtx);
params.setFixTarget(true);
params.setContext(context);
params.setInitializer(builder -> {
builder.mappingKind(MappingKindType.OUTBOUND)
.implicitSourcePath(LEGAL_PROPERTY_NAME)
.implicitTargetPath(SHADOW_EXISTS_PROPERTY_NAME);
builder.defaultSource(new Source<>(getLegalIdi(projCtx), ExpressionConstants.VAR_LEGAL_QNAME));
builder.additionalSource(new Source<>(getAssignedIdi(projCtx), ExpressionConstants.VAR_ASSIGNED_QNAME));
builder.additionalSource(new Source<>(getFocusExistsIdi(context.getFocusContext()), ExpressionConstants.VAR_FOCUS_EXISTS_QNAME));
ObjectDeltaObject<F> focusOdoAbsolute = context.getFocusContext().getObjectDeltaObjectAbsolute();
// Variable: focus
builder.addVariableDefinition(ExpressionConstants.VAR_FOCUS, focusOdoAbsolute, context.getFocusContext().getObjectDefinition());
// Variable: user (for convenience, same as "focus"), DEPRECATED
builder.addVariableDefinition(ExpressionConstants.VAR_USER, focusOdoAbsolute, context.getFocusContext().getObjectDefinition());
builder.addAliasRegistration(ExpressionConstants.VAR_USER, ExpressionConstants.VAR_FOCUS);
// Variable: projection
// This may be tricky when creation of a new projection is considered.
// In that case we do not have any projection object (account) yet, neither new nor old. But we already have
// projection context. We have to pass projection definition explicitly here.
ObjectDeltaObject<ShadowType> projectionOdo = projCtx.getObjectDeltaObject();
builder.addVariableDefinition(ExpressionConstants.VAR_SHADOW, projectionOdo, projCtx.getObjectDefinition());
builder.addVariableDefinition(ExpressionConstants.VAR_PROJECTION, projectionOdo, projCtx.getObjectDefinition());
builder.addAliasRegistration(ExpressionConstants.VAR_SHADOW, ExpressionConstants.VAR_PROJECTION);
// Variable: resource
builder.addVariableDefinition(ExpressionConstants.VAR_RESOURCE, projCtx.getResource(), ResourceType.class);
builder.originType(OriginType.OUTBOUND);
builder.originObject(projCtx.getResource());
return builder;
});
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> aggregatedOutputTriple = prismContext.deltaFactory().createPrismValueDeltaSetTriple();
params.setProcessor((mappingOutputPath, outputStruct) -> {
// This is a very primitive implementation of output processing.
// Maybe we should somehow use the default processing in MappingEvaluator, but it's quite complex
// and therefore we should perhaps wait for general mapping cleanup (MID-3847).
PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = outputStruct.getOutputTriple();
if (outputTriple != null) {
aggregatedOutputTriple.merge(outputTriple);
}
return false;
});
MutablePrismPropertyDefinition<Boolean> shadowExistenceTargetDef = prismContext.definitionFactory().createPropertyDefinition(SHADOW_EXISTS_PROPERTY_NAME, DOMUtil.XSD_BOOLEAN);
shadowExistenceTargetDef.setMinOccurs(1);
shadowExistenceTargetDef.setMaxOccurs(1);
shadowExistenceTargetDef.freeze();
params.setTargetItemDefinition(shadowExistenceTargetDef);
mappingEvaluator.evaluateMappingSetProjection(params, task, result);
boolean output;
if (aggregatedOutputTriple.isEmpty()) {
output = legal; // the default
} else {
Collection<PrismPropertyValue<Boolean>> nonNegativeValues = aggregatedOutputTriple.getNonNegativeValues();
if (nonNegativeValues.isEmpty()) {
throw new ExpressionEvaluationException("Activation existence expression resulted in no values for projection " + projCtxDesc);
} else if (nonNegativeValues.size() > 1) {
throw new ExpressionEvaluationException("Activation existence expression resulted in too many values ("+nonNegativeValues.size()+") for projection " + projCtxDesc + ": " + nonNegativeValues);
} else {
PrismPropertyValue<Boolean> value = nonNegativeValues.iterator().next();
if (value != null && value.getRealValue() != null) {
output = value.getRealValue();
} else {
// TODO could this even occur?
throw new ExpressionEvaluationException("Activation existence expression resulted in null value for projection " + projCtxDesc);
}
}
}
return output;
}
private <T, F extends FocusType> void evaluateActivationMapping(final LensContext<F> context,
final LensProjectionContext projCtx, ResourceBidirectionalMappingType bidirectionalMappingType,
final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
final ActivationCapabilityType capActivation, XMLGregorianCalendar now, final MappingTimeEval current,
String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> initializer =
builder -> {
builder.mappingKind(MappingKindType.OUTBOUND);
builder.implicitTargetPath(projectionPropertyPath);
// Source: administrativeStatus, validFrom or validTo
ObjectDeltaObject<F> focusOdoAbsolute = context.getFocusContext().getObjectDeltaObjectAbsolute();
ItemDeltaItem<PrismPropertyValue<T>,PrismPropertyDefinition<T>> sourceIdi = focusOdoAbsolute.findIdi(focusPropertyPath);
if (capActivation != null && focusPropertyPath.equivalent(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS)) {
ActivationValidityCapabilityType capValidFrom = CapabilityUtil.getEffectiveActivationValidFrom(capActivation);
ActivationValidityCapabilityType capValidTo = CapabilityUtil.getEffectiveActivationValidTo(capActivation);
// Source: computedShadowStatus
ItemPath sourcePath;
if (capValidFrom != null && capValidTo != null) {
// "Native" validFrom and validTo, directly use administrativeStatus
sourcePath = focusPropertyPath;
} else {
// Simulate validFrom and validTo using effectiveStatus
sourcePath = SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS;
}
ItemDeltaItem<PrismPropertyValue<ActivationStatusType>, PrismPropertyDefinition<ActivationStatusType>> computedIdi =
focusOdoAbsolute.findIdi(sourcePath); // TODO wave
builder.implicitSourcePath(sourcePath);
builder.defaultSource(new Source<>(computedIdi, ExpressionConstants.VAR_INPUT_QNAME));
builder.additionalSource(new Source<>(sourceIdi, ExpressionConstants.VAR_ADMINISTRATIVE_STATUS_QNAME));
} else {
builder.defaultSource(new Source<>(sourceIdi, ExpressionConstants.VAR_INPUT_QNAME));
builder.implicitSourcePath(focusPropertyPath);
}
builder.additionalSource(new Source<>(getLegalIdi(projCtx), ExpressionConstants.VAR_LEGAL_QNAME));
builder.additionalSource(new Source<>(getAssignedIdi(projCtx), ExpressionConstants.VAR_ASSIGNED_QNAME));
builder.additionalSource(new Source<>(getFocusExistsIdi(context.getFocusContext()), ExpressionConstants.VAR_FOCUS_EXISTS_QNAME));
return builder;
};
evaluateOutboundMapping(context, projCtx, bidirectionalMappingType, focusPropertyPath, projectionPropertyPath, initializer,
now, current, desc + " outbound activation mapping", task, result);
}
private <T, F extends FocusType> void evaluateOutboundMapping(final LensContext<F> context,
final LensProjectionContext projCtx, ResourceBidirectionalMappingType bidirectionalMappingType,
final ItemPath focusPropertyPath, final ItemPath projectionPropertyPath,
final MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> initializer,
XMLGregorianCalendar now, final MappingTimeEval evaluateCurrent, String desc, final Task task, final OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException {
if (bidirectionalMappingType == null) {
LOGGER.trace("No '{}' definition in projection {}, skipping", desc, projCtx.toHumanReadableString());
return;
}
List<MappingType> outboundMappingTypes = bidirectionalMappingType.getOutbound();
if (outboundMappingTypes == null || outboundMappingTypes.isEmpty()) {
LOGGER.trace("No outbound definition in '{}' definition in projection {}, skipping", desc, projCtx.toHumanReadableString());
return;
}
String projCtxDesc = projCtx.toHumanReadableString();
PrismObject<ShadowType> shadowNew = projCtx.getObjectNew();
MappingInitializer<PrismPropertyValue<T>,PrismPropertyDefinition<T>> internalInitializer =
builder -> {
builder.addVariableDefinitions(ModelImplUtils.getDefaultExpressionVariables(context, projCtx, true));
builder.originType(OriginType.OUTBOUND);
builder.mappingKind(MappingKindType.OUTBOUND);
builder.originObject(projCtx.getResource());
builder.implicitTargetPath(projectionPropertyPath);
initializer.initialize(builder);
return builder;
};
MappingEvaluatorParams<PrismPropertyValue<T>, PrismPropertyDefinition<T>, ShadowType, F> params = new MappingEvaluatorParams<>();
params.setMappingTypes(outboundMappingTypes);
params.setMappingDesc(desc + " in projection " + projCtxDesc);
params.setNow(now);
params.setInitializer(internalInitializer);
params.setTargetLoader(new ProjectionMappingLoader<>(context, projCtx, contextLoader));
params.setAPrioriTargetObject(shadowNew);
params.setAPrioriTargetDelta(LensUtil.findAPrioriDelta(context, projCtx));
if (context.getFocusContext() != null) {
params.setSourceContext(context.getFocusContext().getObjectDeltaObjectAbsolute());
}
params.setTargetContext(projCtx);
params.setDefaultTargetItemPath(projectionPropertyPath);
params.setEvaluateCurrent(evaluateCurrent);
params.setEvaluateWeak(true);
params.setContext(context);
params.setHasFullTargetObject(projCtx.hasFullShadow());
Map<UniformItemPath, MappingOutputStruct<PrismPropertyValue<T>>> outputTripleMap = mappingEvaluator.evaluateMappingSetProjection(params, task, result);
LOGGER.trace("Mapping processing output after {} ({}):\n{}", desc, evaluateCurrent,
DebugUtil.debugDumpLazily(outputTripleMap, 1));
if (projCtx.isDoReconciliation()) {
reconcileOutboundValue(context, projCtx, outputTripleMap, desc);
}
}
/**
* TODO: can we align this with ReconciliationProcessor?
*/
private <T, F extends FocusType> void reconcileOutboundValue(LensContext<F> context, LensProjectionContext projCtx,
Map<UniformItemPath, MappingOutputStruct<PrismPropertyValue<T>>> outputTripleMap, String desc) throws SchemaException {
// TODO: check for full shadow?
for (Entry<UniformItemPath,MappingOutputStruct<PrismPropertyValue<T>>> entry: outputTripleMap.entrySet()) {
UniformItemPath mappingOutputPath = entry.getKey();
MappingOutputStruct<PrismPropertyValue<T>> mappingOutputStruct = entry.getValue();
if (mappingOutputStruct.isWeakMappingWasUsed()) {
// Thing to do. All deltas should already be in context
LOGGER.trace("Skip reconciliation of {} in {} because of weak", mappingOutputPath, desc);
continue;
}
if (!mappingOutputStruct.isStrongMappingWasUsed()) {
// Normal mappings are not processed for reconciliation
LOGGER.trace("Skip reconciliation of {} in {} because not strong", mappingOutputPath, desc);
continue;
}
LOGGER.trace("reconciliation of {} for {}", mappingOutputPath, desc);
PrismObjectDefinition<ShadowType> targetObjectDefinition = projCtx.getObjectDefinition();
PrismPropertyDefinition<T> targetItemDefinition = targetObjectDefinition.findPropertyDefinition(mappingOutputPath);
if (targetItemDefinition == null) {
throw new SchemaException("No definition for item "+mappingOutputPath+" in "+targetObjectDefinition);
}
PropertyDelta<T> targetItemDelta = targetItemDefinition.createEmptyDelta(mappingOutputPath);
PrismValueDeltaSetTriple<PrismPropertyValue<T>> outputTriple = mappingOutputStruct.getOutputTriple();
PrismProperty<T> currentTargetItem = null;
PrismObject<ShadowType> shadowCurrent = projCtx.getObjectCurrent();
if (shadowCurrent != null) {
currentTargetItem = shadowCurrent.findProperty(mappingOutputPath);
}
Collection<PrismPropertyValue<T>> hasValues = new ArrayList<>();
if (currentTargetItem != null) {
hasValues.addAll(currentTargetItem.getValues());
}
Collection<PrismPropertyValue<T>> shouldHaveValues = outputTriple.getNonNegativeValues();
LOGGER.trace("Reconciliation of {}:\n hasValues:\n{}\n shouldHaveValues\n{}",
mappingOutputPath, DebugUtil.debugDumpLazily(hasValues, 2), DebugUtil.debugDumpLazily(shouldHaveValues, 2));
for (PrismPropertyValue<T> shouldHaveValue: shouldHaveValues) {
if (!PrismValueCollectionsUtil.containsRealValue(hasValues, shouldHaveValue)) {
if (targetItemDefinition.isSingleValue()) {
targetItemDelta.setValueToReplace(shouldHaveValue.clone());
} else {
targetItemDelta.addValueToAdd(shouldHaveValue.clone());
}
}
}
if (targetItemDefinition.isSingleValue()) {
if (!targetItemDelta.isReplace() && shouldHaveValues.isEmpty()) {
targetItemDelta.setValueToReplace();
}
} else {
for (PrismPropertyValue<T> hasValue: hasValues) {
if (!PrismValueCollectionsUtil.containsRealValue(shouldHaveValues, hasValue)) {
targetItemDelta.addValueToDelete(hasValue.clone());
}
}
}
if (!targetItemDelta.isEmpty()) {
LOGGER.trace("Reconciliation delta:\n{}", targetItemDelta.debugDumpLazily(1));
projCtx.swallowToSecondaryDelta(targetItemDelta);
}
}
}
private ItemDeltaItem<PrismPropertyValue<Boolean>,PrismPropertyDefinition<Boolean>> getLegalIdi(LensProjectionContext accCtx) throws SchemaException {
Boolean legal = accCtx.isLegal();
Boolean legalOld = accCtx.isLegalOld();
return createBooleanIdi(LEGAL_PROPERTY_NAME, legalOld, legal);
}
@NotNull
private ItemDeltaItem<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> createBooleanIdi(
QName propertyName, Boolean old, Boolean current) throws SchemaException {
MutablePrismPropertyDefinition<Boolean> definition = prismContext.definitionFactory().createPropertyDefinition(propertyName, DOMUtil.XSD_BOOLEAN);
definition.setMinOccurs(1);
definition.setMaxOccurs(1);
PrismProperty<Boolean> property = definition.instantiate();
if (current != null) {
property.add(prismContext.itemFactory().createPropertyValue(current));
}
if (Objects.equals(current, old)) {
return new ItemDeltaItem<>(property);
} else {
PrismProperty<Boolean> propertyOld = property.clone();
propertyOld.setRealValue(old);
PropertyDelta<Boolean> delta = propertyOld.createDelta();
if (current != null) {
delta.setValuesToReplace(prismContext.itemFactory().createPropertyValue(current));
} else {
delta.setValuesToReplace();
}
return new ItemDeltaItem<>(propertyOld, delta, property, definition);
}
}
private ItemDeltaItem<PrismPropertyValue<Boolean>,PrismPropertyDefinition<Boolean>> getAssignedIdi(LensProjectionContext accCtx) throws SchemaException {
Boolean assigned = accCtx.isAssigned();
Boolean assignedOld = accCtx.isAssignedOld();
return createBooleanIdi(ASSIGNED_PROPERTY_NAME, assignedOld, assigned);
}
private <F extends ObjectType> ItemDeltaItem<PrismPropertyValue<Boolean>,PrismPropertyDefinition<Boolean>> getFocusExistsIdi(
LensFocusContext<F> lensFocusContext) throws SchemaException {
Boolean existsOld = null;
Boolean existsNew = null;
if (lensFocusContext != null) {
if (lensFocusContext.isDelete()) {
existsOld = true;
existsNew = false;
} else if (lensFocusContext.isAdd()) {
existsOld = false;
existsNew = true;
} else {
existsOld = true;
existsNew = true;
}
}
MutablePrismPropertyDefinition<Boolean> existsDef = prismContext.definitionFactory().createPropertyDefinition(FOCUS_EXISTS_PROPERTY_NAME,
DOMUtil.XSD_BOOLEAN);
existsDef.setMinOccurs(1);
existsDef.setMaxOccurs(1);
PrismProperty<Boolean> existsProp = existsDef.instantiate();
if (existsNew != null) {
existsProp.add(prismContext.itemFactory().createPropertyValue(existsNew));
}
if (Objects.equals(existsOld, existsNew)) {
return new ItemDeltaItem<>(existsProp);
} else {
PrismProperty<Boolean> existsPropOld = existsProp.clone();
existsPropOld.setRealValue(existsOld);
PropertyDelta<Boolean> existsDelta = existsPropOld.createDelta();
if (existsNew != null) {
//noinspection unchecked
existsDelta.setValuesToReplace(prismContext.itemFactory().createPropertyValue(existsNew));
} else {
//noinspection unchecked
existsDelta.setValuesToReplace();
}
return new ItemDeltaItem<>(existsPropOld, existsDelta, existsProp, existsDef);
}
}
@ProcessorMethod
<F extends FocusType> void processLifecycle(LensContext<F> context, LensProjectionContext projCtx,
@SuppressWarnings("unused") String activityDescription, XMLGregorianCalendar now, Task task, OperationResult result)
throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException,
CommunicationException, ConfigurationException, SecurityViolationException {
ResourceBidirectionalMappingType lifecycleStateMapping = getLifecycleStateMapping(projCtx);
if (lifecycleStateMapping == null || lifecycleStateMapping.getOutbound() == null) {
if (!projCtx.isAdd()) {
LOGGER.trace("Skipping lifecycle evaluation because this is not an add operation (default expression)");
return;
}
PrismObject<F> focusNew = context.getFocusContext().getObjectNew();
if (focusNew == null) {
LOGGER.trace("Skipping lifecycle evaluation because there is no new focus (default expression)");
return;
}
PrismObject<ShadowType> projectionNew = projCtx.getObjectNew();
if (projectionNew == null) {
LOGGER.trace("Skipping lifecycle evaluation because there is no new projection (default expression)");
return;
}
String lifecycle = midpointFunctions.computeProjectionLifecycle(
focusNew.asObjectable(), projectionNew.asObjectable(), projCtx.getResource());
LOGGER.trace("Computed projection lifecycle (default expression): {}", lifecycle);
if (lifecycle != null) {
PrismPropertyDefinition<String> propDef = projCtx.getObjectDefinition().findPropertyDefinition(SchemaConstants.PATH_LIFECYCLE_STATE);
PropertyDelta<String> lifeCycleDelta = propDef.createEmptyDelta(SchemaConstants.PATH_LIFECYCLE_STATE);
PrismPropertyValue<String> pval = prismContext.itemFactory().createPropertyValue(lifecycle);
pval.setOriginType(OriginType.OUTBOUND);
//noinspection unchecked
lifeCycleDelta.setValuesToReplace(pval);
projCtx.swallowToSecondaryDelta(lifeCycleDelta);
}
} else {
LOGGER.trace("Computing projection lifecycle (using mapping): {}", lifecycleStateMapping);
evaluateActivationMapping(context, projCtx, lifecycleStateMapping,
SchemaConstants.PATH_LIFECYCLE_STATE, SchemaConstants.PATH_LIFECYCLE_STATE,
null, now, MappingTimeEval.CURRENT, ObjectType.F_LIFECYCLE_STATE.getLocalPart(), task, result);
}
context.checkConsistenceIfNeeded();
projCtx.recompute();
context.checkConsistenceIfNeeded();
}
@Nullable
private ResourceBidirectionalMappingType getLifecycleStateMapping(LensProjectionContext projCtx) {
ResourceObjectLifecycleDefinitionType lifecycleDef;
ResourceObjectTypeDefinitionType resourceAccountDefType = projCtx.getResourceObjectTypeDefinitionType();
if (resourceAccountDefType != null) {
lifecycleDef = resourceAccountDefType.getLifecycle();
} else {
lifecycleDef = null;
}
ResourceBidirectionalMappingType lifecycleStateMapping;
if (lifecycleDef != null) {
lifecycleStateMapping = lifecycleDef.getLifecycleState();
} else {
lifecycleStateMapping = null;
}
return lifecycleStateMapping;
}
private PrismObjectDefinition<UserType> getUserDefinition() {
if (userDefinition == null) {
userDefinition = prismContext.getSchemaRegistry()
.findObjectDefinitionByCompileTimeClass(UserType.class);
}
return userDefinition;
}
private PrismContainerDefinition<ActivationType> getActivationDefinition() {
if (activationDefinition == null) {
PrismObjectDefinition<UserType> userDefinition = getUserDefinition();
activationDefinition = userDefinition.findContainerDefinition(UserType.F_ACTIVATION);
}
return activationDefinition;
}
}
| {
"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 arm,!gccgo,linux
package unix
import "syscall"
// Underlying system call writes to newoffset via pointer.
// Implemented in assembly to avoid allocation.
func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
| {
"pile_set_name": "Github"
} |
// AFURLResponseSerialization.m
// Copyright (c) 2011–2015 Alamofire Software Foundation (http://alamofire.org/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "AFURLResponseSerialization.h"
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <UIKit/UIKit.h>
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
#import <Cocoa/Cocoa.h>
#endif
NSString * const AFURLResponseSerializationErrorDomain = @"com.alamofire.error.serialization.response";
NSString * const AFNetworkingOperationFailingURLResponseErrorKey = @"com.alamofire.serialization.response.error.response";
NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey = @"com.alamofire.serialization.response.error.data";
static NSError * AFErrorWithUnderlyingError(NSError *error, NSError *underlyingError) {
if (!error) {
return underlyingError;
}
if (!underlyingError || error.userInfo[NSUnderlyingErrorKey]) {
return error;
}
NSMutableDictionary *mutableUserInfo = [error.userInfo mutableCopy];
mutableUserInfo[NSUnderlyingErrorKey] = underlyingError;
return [[NSError alloc] initWithDomain:error.domain code:error.code userInfo:mutableUserInfo];
}
static BOOL AFErrorOrUnderlyingErrorHasCodeInDomain(NSError *error, NSInteger code, NSString *domain) {
if ([error.domain isEqualToString:domain] && error.code == code) {
return YES;
} else if (error.userInfo[NSUnderlyingErrorKey]) {
return AFErrorOrUnderlyingErrorHasCodeInDomain(error.userInfo[NSUnderlyingErrorKey], code, domain);
}
return NO;
}
static id AFJSONObjectByRemovingKeysWithNullValues(id JSONObject, NSJSONReadingOptions readingOptions) {
if ([JSONObject isKindOfClass:[NSArray class]]) {
NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:[(NSArray *)JSONObject count]];
for (id value in (NSArray *)JSONObject) {
[mutableArray addObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions)];
}
return (readingOptions & NSJSONReadingMutableContainers) ? mutableArray : [NSArray arrayWithArray:mutableArray];
} else if ([JSONObject isKindOfClass:[NSDictionary class]]) {
NSMutableDictionary *mutableDictionary = [NSMutableDictionary dictionaryWithDictionary:JSONObject];
for (id <NSCopying> key in [(NSDictionary *)JSONObject allKeys]) {
id value = [(NSDictionary *)JSONObject objectForKey:key];
if (!value || [value isEqual:[NSNull null]]) {
[mutableDictionary removeObjectForKey:key];
} else if ([value isKindOfClass:[NSArray class]] || [value isKindOfClass:[NSDictionary class]]) {
[mutableDictionary setObject:AFJSONObjectByRemovingKeysWithNullValues(value, readingOptions) forKey:key];
}
}
return (readingOptions & NSJSONReadingMutableContainers) ? mutableDictionary : [NSDictionary dictionaryWithDictionary:mutableDictionary];
}
return JSONObject;
}
@implementation AFHTTPResponseSerializer
+ (instancetype)serializer {
return [[self alloc] init];
}
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.stringEncoding = NSUTF8StringEncoding;
self.acceptableStatusCodes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)];
self.acceptableContentTypes = nil;
return self;
}
#pragma mark -
- (BOOL)validateResponse:(NSHTTPURLResponse *)response
data:(NSData *)data
error:(NSError * __autoreleasing *)error
{
BOOL responseIsValid = YES;
NSError *validationError = nil;
if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) {
if ([data length] > 0 && [response URL]) {
NSMutableDictionary *mutableUserInfo = [@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
NSURLErrorFailingURLErrorKey:[response URL],
AFNetworkingOperationFailingURLResponseErrorKey: response,
} mutableCopy];
if (data) {
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
}
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:mutableUserInfo], validationError);
}
responseIsValid = NO;
}
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
NSMutableDictionary *mutableUserInfo = [@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
NSURLErrorFailingURLErrorKey:[response URL],
AFNetworkingOperationFailingURLResponseErrorKey: response,
} mutableCopy];
if (data) {
mutableUserInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] = data;
}
validationError = AFErrorWithUnderlyingError([NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorBadServerResponse userInfo:mutableUserInfo], validationError);
responseIsValid = NO;
}
}
if (error && !responseIsValid) {
*error = validationError;
}
return responseIsValid;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
[self validateResponse:(NSHTTPURLResponse *)response data:data error:error];
return data;
}
#pragma mark - NSSecureCoding
+ (BOOL)supportsSecureCoding {
return YES;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [self init];
if (!self) {
return nil;
}
self.acceptableStatusCodes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
self.acceptableContentTypes = [decoder decodeObjectOfClass:[NSIndexSet class] forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[coder encodeObject:self.acceptableStatusCodes forKey:NSStringFromSelector(@selector(acceptableStatusCodes))];
[coder encodeObject:self.acceptableContentTypes forKey:NSStringFromSelector(@selector(acceptableContentTypes))];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFHTTPResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
serializer.acceptableStatusCodes = [self.acceptableStatusCodes copyWithZone:zone];
serializer.acceptableContentTypes = [self.acceptableContentTypes copyWithZone:zone];
return serializer;
}
@end
#pragma mark -
@implementation AFJSONResponseSerializer
+ (instancetype)serializer {
return [self serializerWithReadingOptions:(NSJSONReadingOptions)0];
}
+ (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions {
AFJSONResponseSerializer *serializer = [[self alloc] init];
serializer.readingOptions = readingOptions;
return serializer;
}
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];
return self;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
return nil;
}
}
// Workaround for behavior of Rails to return a single space for `head :ok` (a workaround for a bug in Safari), which is not interpreted as valid input by NSJSONSerialization.
// See https://github.com/rails/rails/issues/1742
NSStringEncoding stringEncoding = self.stringEncoding;
if (response.textEncodingName) {
CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName);
if (encoding != kCFStringEncodingInvalidId) {
stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding);
}
}
id responseObject = nil;
NSError *serializationError = nil;
@autoreleasepool {
NSString *responseString = [[NSString alloc] initWithData:data encoding:stringEncoding];
if (responseString && ![responseString isEqualToString:@" "]) {
// Workaround for a bug in NSJSONSerialization when Unicode character escape codes are used instead of the actual character
// See http://stackoverflow.com/a/12843465/157142
data = [responseString dataUsingEncoding:NSUTF8StringEncoding];
if (data) {
if ([data length] > 0) {
responseObject = [NSJSONSerialization JSONObjectWithData:data options:self.readingOptions error:&serializationError];
} else {
return nil;
}
} else {
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: NSLocalizedStringFromTable(@"Data failed decoding as a UTF-8 string", @"AFNetworking", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Could not decode string: %@", @"AFNetworking", nil), responseString]
};
serializationError = [NSError errorWithDomain:AFURLResponseSerializationErrorDomain code:NSURLErrorCannotDecodeContentData userInfo:userInfo];
}
}
}
if (self.removesKeysWithNullValues && responseObject) {
responseObject = AFJSONObjectByRemovingKeysWithNullValues(responseObject, self.readingOptions);
}
if (error) {
*error = AFErrorWithUnderlyingError(serializationError, *error);
}
return responseObject;
}
#pragma mark - NSSecureCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}
self.readingOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readingOptions))] unsignedIntegerValue];
self.removesKeysWithNullValues = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))] boolValue];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:@(self.readingOptions) forKey:NSStringFromSelector(@selector(readingOptions))];
[coder encodeObject:@(self.removesKeysWithNullValues) forKey:NSStringFromSelector(@selector(removesKeysWithNullValues))];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFJSONResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
serializer.readingOptions = self.readingOptions;
serializer.removesKeysWithNullValues = self.removesKeysWithNullValues;
return serializer;
}
@end
#pragma mark -
@implementation AFXMLParserResponseSerializer
+ (instancetype)serializer {
AFXMLParserResponseSerializer *serializer = [[self alloc] init];
return serializer;
}
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
return self;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSHTTPURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
return nil;
}
}
return [[NSXMLParser alloc] initWithData:data];
}
@end
#pragma mark -
#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
@implementation AFXMLDocumentResponseSerializer
+ (instancetype)serializer {
return [self serializerWithXMLDocumentOptions:0];
}
+ (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask {
AFXMLDocumentResponseSerializer *serializer = [[self alloc] init];
serializer.options = mask;
return serializer;
}
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/xml", @"text/xml", nil];
return self;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
return nil;
}
}
NSError *serializationError = nil;
NSXMLDocument *document = [[NSXMLDocument alloc] initWithData:data options:self.options error:&serializationError];
if (error) {
*error = AFErrorWithUnderlyingError(serializationError, *error);
}
return document;
}
#pragma mark - NSSecureCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}
self.options = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(options))] unsignedIntegerValue];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:@(self.options) forKey:NSStringFromSelector(@selector(options))];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFXMLDocumentResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
serializer.options = self.options;
return serializer;
}
@end
#endif
#pragma mark -
@implementation AFPropertyListResponseSerializer
+ (instancetype)serializer {
return [self serializerWithFormat:NSPropertyListXMLFormat_v1_0 readOptions:0];
}
+ (instancetype)serializerWithFormat:(NSPropertyListFormat)format
readOptions:(NSPropertyListReadOptions)readOptions
{
AFPropertyListResponseSerializer *serializer = [[self alloc] init];
serializer.format = format;
serializer.readOptions = readOptions;
return serializer;
}
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"application/x-plist", nil];
return self;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
return nil;
}
}
id responseObject;
NSError *serializationError = nil;
if (data) {
responseObject = [NSPropertyListSerialization propertyListWithData:data options:self.readOptions format:NULL error:&serializationError];
}
if (error) {
*error = AFErrorWithUnderlyingError(serializationError, *error);
}
return responseObject;
}
#pragma mark - NSSecureCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}
self.format = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
self.readOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(readOptions))] unsignedIntegerValue];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:@(self.format) forKey:NSStringFromSelector(@selector(format))];
[coder encodeObject:@(self.readOptions) forKey:NSStringFromSelector(@selector(readOptions))];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFPropertyListResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
serializer.format = self.format;
serializer.readOptions = self.readOptions;
return serializer;
}
@end
#pragma mark -
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
#import <CoreGraphics/CoreGraphics.h>
static UIImage * AFImageWithDataAtScale(NSData *data, CGFloat scale) {
UIImage *image = [[UIImage alloc] initWithData:data];
if (image.images) {
return image;
}
return [[UIImage alloc] initWithCGImage:[image CGImage] scale:scale orientation:image.imageOrientation];
}
static UIImage * AFInflatedImageFromResponseWithDataAtScale(NSHTTPURLResponse *response, NSData *data, CGFloat scale) {
if (!data || [data length] == 0) {
return nil;
}
CGImageRef imageRef = NULL;
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)data);
if ([response.MIMEType isEqualToString:@"image/png"]) {
imageRef = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
} else if ([response.MIMEType isEqualToString:@"image/jpeg"]) {
imageRef = CGImageCreateWithJPEGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
if (imageRef) {
CGColorSpaceRef imageColorSpace = CGImageGetColorSpace(imageRef);
CGColorSpaceModel imageColorSpaceModel = CGColorSpaceGetModel(imageColorSpace);
// CGImageCreateWithJPEGDataProvider does not properly handle CMKY, so fall back to AFImageWithDataAtScale
if (imageColorSpaceModel == kCGColorSpaceModelCMYK) {
CGImageRelease(imageRef);
imageRef = NULL;
}
}
}
CGDataProviderRelease(dataProvider);
UIImage *image = AFImageWithDataAtScale(data, scale);
if (!imageRef) {
if (image.images || !image) {
return image;
}
imageRef = CGImageCreateCopy([image CGImage]);
if (!imageRef) {
return nil;
}
}
size_t width = CGImageGetWidth(imageRef);
size_t height = CGImageGetHeight(imageRef);
size_t bitsPerComponent = CGImageGetBitsPerComponent(imageRef);
if (width * height > 1024 * 1024 || bitsPerComponent > 8) {
CGImageRelease(imageRef);
return image;
}
// CGImageGetBytesPerRow() calculates incorrectly in iOS 5.0, so defer to CGBitmapContextCreate
size_t bytesPerRow = 0;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef);
if (colorSpaceModel == kCGColorSpaceModelRGB) {
uint32_t alpha = (bitmapInfo & kCGBitmapAlphaInfoMask);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wassign-enum"
if (alpha == kCGImageAlphaNone) {
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
bitmapInfo |= kCGImageAlphaNoneSkipFirst;
} else if (!(alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast)) {
bitmapInfo &= ~kCGBitmapAlphaInfoMask;
bitmapInfo |= kCGImageAlphaPremultipliedFirst;
}
#pragma clang diagnostic pop
}
CGContextRef context = CGBitmapContextCreate(NULL, width, height, bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo);
CGColorSpaceRelease(colorSpace);
if (!context) {
CGImageRelease(imageRef);
return image;
}
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, width, height), imageRef);
CGImageRef inflatedImageRef = CGBitmapContextCreateImage(context);
CGContextRelease(context);
UIImage *inflatedImage = [[UIImage alloc] initWithCGImage:inflatedImageRef scale:scale orientation:image.imageOrientation];
CGImageRelease(inflatedImageRef);
CGImageRelease(imageRef);
return inflatedImage;
}
#endif
@implementation AFImageResponseSerializer
- (instancetype)init {
self = [super init];
if (!self) {
return nil;
}
self.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap", nil];
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
self.imageScale = [[UIScreen mainScreen] scale];
self.automaticallyInflatesResponseImage = YES;
#endif
return self;
}
#pragma mark - AFURLResponseSerializer
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
if (![self validateResponse:(NSHTTPURLResponse *)response data:data error:error]) {
if (!error || AFErrorOrUnderlyingErrorHasCodeInDomain(*error, NSURLErrorCannotDecodeContentData, AFURLResponseSerializationErrorDomain)) {
return nil;
}
}
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
if (self.automaticallyInflatesResponseImage) {
return AFInflatedImageFromResponseWithDataAtScale((NSHTTPURLResponse *)response, data, self.imageScale);
} else {
return AFImageWithDataAtScale(data, self.imageScale);
}
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
// Ensure that the image is set to it's correct pixel width and height
NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:data];
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])];
[image addRepresentation:bitimage];
return image;
#endif
return nil;
}
#pragma mark - NSSecureCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
NSNumber *imageScale = [decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(imageScale))];
#if CGFLOAT_IS_DOUBLE
self.imageScale = [imageScale doubleValue];
#else
self.imageScale = [imageScale floatValue];
#endif
self.automaticallyInflatesResponseImage = [decoder decodeBoolForKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
#endif
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
[coder encodeObject:@(self.imageScale) forKey:NSStringFromSelector(@selector(imageScale))];
[coder encodeBool:self.automaticallyInflatesResponseImage forKey:NSStringFromSelector(@selector(automaticallyInflatesResponseImage))];
#endif
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFImageResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
#if defined(__IPHONE_OS_VERSION_MIN_REQUIRED)
serializer.imageScale = self.imageScale;
serializer.automaticallyInflatesResponseImage = self.automaticallyInflatesResponseImage;
#endif
return serializer;
}
@end
#pragma mark -
@interface AFCompoundResponseSerializer ()
@property (readwrite, nonatomic, copy) NSArray *responseSerializers;
@end
@implementation AFCompoundResponseSerializer
+ (instancetype)compoundSerializerWithResponseSerializers:(NSArray *)responseSerializers {
AFCompoundResponseSerializer *serializer = [[self alloc] init];
serializer.responseSerializers = responseSerializers;
return serializer;
}
#pragma mark - AFURLResponseSerialization
- (id)responseObjectForResponse:(NSURLResponse *)response
data:(NSData *)data
error:(NSError *__autoreleasing *)error
{
for (id <AFURLResponseSerialization> serializer in self.responseSerializers) {
if (![serializer isKindOfClass:[AFHTTPResponseSerializer class]]) {
continue;
}
NSError *serializerError = nil;
id responseObject = [serializer responseObjectForResponse:response data:data error:&serializerError];
if (responseObject) {
if (error) {
*error = AFErrorWithUnderlyingError(serializerError, *error);
}
return responseObject;
}
}
return [super responseObjectForResponse:response data:data error:error];
}
#pragma mark - NSSecureCoding
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (!self) {
return nil;
}
self.responseSerializers = [decoder decodeObjectOfClass:[NSArray class] forKey:NSStringFromSelector(@selector(responseSerializers))];
return self;
}
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:self.responseSerializers forKey:NSStringFromSelector(@selector(responseSerializers))];
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone {
AFCompoundResponseSerializer *serializer = [[[self class] allocWithZone:zone] init];
serializer.responseSerializers = self.responseSerializers;
return serializer;
}
@end
| {
"pile_set_name": "Github"
} |
#!/usr/bin/env bash
################################################################################
# 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.
################################################################################
### Some general purpose helper functions that can be used in test scripts.
_on_exit_commands=()
function _on_exit_callback {
# Export the exit code so that it could be used by the callback commands
export TRAPPED_EXIT_CODE=$?
# Un-register the callback, to avoid multiple invocations: some shells may treat some signals as subset of others.
trap "" INT EXIT
# Fast exit, if there is another keyboard interrupt.
trap "exit -1" INT
for command in "${_on_exit_commands[@]-}"; do
eval "${command}"
done
}
# Register for multiple signals: some shells interpret them as mutually exclusive.
trap _on_exit_callback INT EXIT
# Helper method to register a command that should be called on current script exit.
# It allows to have multiple "on exit" commands to be called, compared to the built-in `trap "$command" EXIT`.
# Note: tests should not use `trap $command INT|EXIT` directly, to avoid having "Highlander" situation.
function on_exit {
local command="$1"
# Keep commands in reverse order, so commands would be executed in LIFO order.
_on_exit_commands=("${command}" "${_on_exit_commands[@]-}")
}
| {
"pile_set_name": "Github"
} |
/*
* Copyright © 2004 Carl Worth
* Copyright © 2006 Red Hat, Inc.
* Copyright © 2007 David Turner
* Copyright © 2008 M Joonas Pihlaja
* Copyright © 2008 Chris Wilson
* Copyright © 2009 Intel Corporation
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (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.mozilla.org/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* The Original Code is the cairo graphics library.
*
* The Initial Developer of the Original Code is Carl Worth
*
* Contributor(s):
* Carl D. Worth <[email protected]>
* M Joonas Pihlaja <[email protected]>
* Chris Wilson <[email protected]>
*/
/* Provide definitions for standalone compilation */
#include "cairoint.h"
#include "cairo-error-private.h"
#include "cairo-list-inline.h"
#include "cairo-freelist-private.h"
#include "cairo-combsort-inline.h"
#include <setjmp.h>
#define STEP_X CAIRO_FIXED_ONE
#define STEP_Y CAIRO_FIXED_ONE
#define UNROLL3(x) x x x
#define STEP_XY (2*STEP_X*STEP_Y) /* Unit area in the step. */
#define AREA_TO_ALPHA(c) (((c)*255 + STEP_XY/2) / STEP_XY)
typedef struct _cairo_bo_intersect_ordinate {
int32_t ordinate;
enum { EXACT, INEXACT } exactness;
} cairo_bo_intersect_ordinate_t;
typedef struct _cairo_bo_intersect_point {
cairo_bo_intersect_ordinate_t x;
cairo_bo_intersect_ordinate_t y;
} cairo_bo_intersect_point_t;
struct quorem {
cairo_fixed_t quo;
cairo_fixed_t rem;
};
struct run {
struct run *next;
int sign;
cairo_fixed_t y;
};
typedef struct edge {
cairo_list_t link;
cairo_edge_t edge;
/* Current x coordinate and advancement.
* Initialised to the x coordinate of the top of the
* edge. The quotient is in cairo_fixed_t units and the
* remainder is mod dy in cairo_fixed_t units.
*/
cairo_fixed_t dy;
struct quorem x;
struct quorem dxdy;
struct quorem dxdy_full;
cairo_bool_t vertical;
unsigned int flags;
int current_sign;
struct run *runs;
} edge_t;
enum {
START = 0x1,
STOP = 0x2,
};
/* the parent is always given by index/2 */
#define PQ_PARENT_INDEX(i) ((i) >> 1)
#define PQ_FIRST_ENTRY 1
/* left and right children are index * 2 and (index * 2) +1 respectively */
#define PQ_LEFT_CHILD_INDEX(i) ((i) << 1)
typedef enum {
EVENT_TYPE_STOP,
EVENT_TYPE_INTERSECTION,
EVENT_TYPE_START
} event_type_t;
typedef struct _event {
cairo_fixed_t y;
event_type_t type;
} event_t;
typedef struct _start_event {
cairo_fixed_t y;
event_type_t type;
edge_t *edge;
} start_event_t;
typedef struct _queue_event {
cairo_fixed_t y;
event_type_t type;
edge_t *e1;
edge_t *e2;
} queue_event_t;
typedef struct _pqueue {
int size, max_size;
event_t **elements;
event_t *elements_embedded[1024];
} pqueue_t;
struct cell {
struct cell *prev;
struct cell *next;
int x;
int uncovered_area;
int covered_height;
};
typedef struct _sweep_line {
cairo_list_t active;
cairo_list_t stopped;
cairo_list_t *insert_cursor;
cairo_bool_t is_vertical;
cairo_fixed_t current_row;
cairo_fixed_t current_subrow;
struct coverage {
struct cell head;
struct cell tail;
struct cell *cursor;
int count;
cairo_freepool_t pool;
} coverage;
struct event_queue {
pqueue_t pq;
event_t **start_events;
cairo_freepool_t pool;
} queue;
cairo_freepool_t runs;
jmp_buf unwind;
} sweep_line_t;
cairo_always_inline static struct quorem
floored_divrem (int a, int b)
{
struct quorem qr;
qr.quo = a/b;
qr.rem = a%b;
if ((a^b)<0 && qr.rem) {
qr.quo--;
qr.rem += b;
}
return qr;
}
static struct quorem
floored_muldivrem(int x, int a, int b)
{
struct quorem qr;
long long xa = (long long)x*a;
qr.quo = xa/b;
qr.rem = xa%b;
if ((xa>=0) != (b>=0) && qr.rem) {
qr.quo--;
qr.rem += b;
}
return qr;
}
static cairo_fixed_t
line_compute_intersection_x_for_y (const cairo_line_t *line,
cairo_fixed_t y)
{
cairo_fixed_t x, dy;
if (y == line->p1.y)
return line->p1.x;
if (y == line->p2.y)
return line->p2.x;
x = line->p1.x;
dy = line->p2.y - line->p1.y;
if (dy != 0) {
x += _cairo_fixed_mul_div_floor (y - line->p1.y,
line->p2.x - line->p1.x,
dy);
}
return x;
}
/*
* We need to compare the x-coordinates of a pair of lines for a particular y,
* without loss of precision.
*
* The x-coordinate along an edge for a given y is:
* X = A_x + (Y - A_y) * A_dx / A_dy
*
* So the inequality we wish to test is:
* A_x + (Y - A_y) * A_dx / A_dy ∘ B_x + (Y - B_y) * B_dx / B_dy,
* where ∘ is our inequality operator.
*
* By construction, we know that A_dy and B_dy (and (Y - A_y), (Y - B_y)) are
* all positive, so we can rearrange it thus without causing a sign change:
* A_dy * B_dy * (A_x - B_x) ∘ (Y - B_y) * B_dx * A_dy
* - (Y - A_y) * A_dx * B_dy
*
* Given the assumption that all the deltas fit within 32 bits, we can compute
* this comparison directly using 128 bit arithmetic. For certain, but common,
* input we can reduce this down to a single 32 bit compare by inspecting the
* deltas.
*
* (And put the burden of the work on developing fast 128 bit ops, which are
* required throughout the tessellator.)
*
* See the similar discussion for _slope_compare().
*/
static int
edges_compare_x_for_y_general (const cairo_edge_t *a,
const cairo_edge_t *b,
int32_t y)
{
/* XXX: We're assuming here that dx and dy will still fit in 32
* bits. That's not true in general as there could be overflow. We
* should prevent that before the tessellation algorithm
* begins.
*/
int32_t dx;
int32_t adx, ady;
int32_t bdx, bdy;
enum {
HAVE_NONE = 0x0,
HAVE_DX = 0x1,
HAVE_ADX = 0x2,
HAVE_DX_ADX = HAVE_DX | HAVE_ADX,
HAVE_BDX = 0x4,
HAVE_DX_BDX = HAVE_DX | HAVE_BDX,
HAVE_ADX_BDX = HAVE_ADX | HAVE_BDX,
HAVE_ALL = HAVE_DX | HAVE_ADX | HAVE_BDX
} have_dx_adx_bdx = HAVE_ALL;
/* don't bother solving for abscissa if the edges' bounding boxes
* can be used to order them. */
{
int32_t amin, amax;
int32_t bmin, bmax;
if (a->line.p1.x < a->line.p2.x) {
amin = a->line.p1.x;
amax = a->line.p2.x;
} else {
amin = a->line.p2.x;
amax = a->line.p1.x;
}
if (b->line.p1.x < b->line.p2.x) {
bmin = b->line.p1.x;
bmax = b->line.p2.x;
} else {
bmin = b->line.p2.x;
bmax = b->line.p1.x;
}
if (amax < bmin) return -1;
if (amin > bmax) return +1;
}
ady = a->line.p2.y - a->line.p1.y;
adx = a->line.p2.x - a->line.p1.x;
if (adx == 0)
have_dx_adx_bdx &= ~HAVE_ADX;
bdy = b->line.p2.y - b->line.p1.y;
bdx = b->line.p2.x - b->line.p1.x;
if (bdx == 0)
have_dx_adx_bdx &= ~HAVE_BDX;
dx = a->line.p1.x - b->line.p1.x;
if (dx == 0)
have_dx_adx_bdx &= ~HAVE_DX;
#define L _cairo_int64x32_128_mul (_cairo_int32x32_64_mul (ady, bdy), dx)
#define A _cairo_int64x32_128_mul (_cairo_int32x32_64_mul (adx, bdy), y - a->line.p1.y)
#define B _cairo_int64x32_128_mul (_cairo_int32x32_64_mul (bdx, ady), y - b->line.p1.y)
switch (have_dx_adx_bdx) {
default:
case HAVE_NONE:
return 0;
case HAVE_DX:
/* A_dy * B_dy * (A_x - B_x) ∘ 0 */
return dx; /* ady * bdy is positive definite */
case HAVE_ADX:
/* 0 ∘ - (Y - A_y) * A_dx * B_dy */
return adx; /* bdy * (y - a->top.y) is positive definite */
case HAVE_BDX:
/* 0 ∘ (Y - B_y) * B_dx * A_dy */
return -bdx; /* ady * (y - b->top.y) is positive definite */
case HAVE_ADX_BDX:
/* 0 ∘ (Y - B_y) * B_dx * A_dy - (Y - A_y) * A_dx * B_dy */
if ((adx ^ bdx) < 0) {
return adx;
} else if (a->line.p1.y == b->line.p1.y) { /* common origin */
cairo_int64_t adx_bdy, bdx_ady;
/* ∴ A_dx * B_dy ∘ B_dx * A_dy */
adx_bdy = _cairo_int32x32_64_mul (adx, bdy);
bdx_ady = _cairo_int32x32_64_mul (bdx, ady);
return _cairo_int64_cmp (adx_bdy, bdx_ady);
} else
return _cairo_int128_cmp (A, B);
case HAVE_DX_ADX:
/* A_dy * (A_x - B_x) ∘ - (Y - A_y) * A_dx */
if ((-adx ^ dx) < 0) {
return dx;
} else {
cairo_int64_t ady_dx, dy_adx;
ady_dx = _cairo_int32x32_64_mul (ady, dx);
dy_adx = _cairo_int32x32_64_mul (a->line.p1.y - y, adx);
return _cairo_int64_cmp (ady_dx, dy_adx);
}
case HAVE_DX_BDX:
/* B_dy * (A_x - B_x) ∘ (Y - B_y) * B_dx */
if ((bdx ^ dx) < 0) {
return dx;
} else {
cairo_int64_t bdy_dx, dy_bdx;
bdy_dx = _cairo_int32x32_64_mul (bdy, dx);
dy_bdx = _cairo_int32x32_64_mul (y - b->line.p1.y, bdx);
return _cairo_int64_cmp (bdy_dx, dy_bdx);
}
case HAVE_ALL:
/* XXX try comparing (a->line.p2.x - b->line.p2.x) et al */
return _cairo_int128_cmp (L, _cairo_int128_sub (B, A));
}
#undef B
#undef A
#undef L
}
/*
* We need to compare the x-coordinate of a line for a particular y wrt to a
* given x, without loss of precision.
*
* The x-coordinate along an edge for a given y is:
* X = A_x + (Y - A_y) * A_dx / A_dy
*
* So the inequality we wish to test is:
* A_x + (Y - A_y) * A_dx / A_dy ∘ X
* where ∘ is our inequality operator.
*
* By construction, we know that A_dy (and (Y - A_y)) are
* all positive, so we can rearrange it thus without causing a sign change:
* (Y - A_y) * A_dx ∘ (X - A_x) * A_dy
*
* Given the assumption that all the deltas fit within 32 bits, we can compute
* this comparison directly using 64 bit arithmetic.
*
* See the similar discussion for _slope_compare() and
* edges_compare_x_for_y_general().
*/
static int
edge_compare_for_y_against_x (const cairo_edge_t *a,
int32_t y,
int32_t x)
{
int32_t adx, ady;
int32_t dx, dy;
cairo_int64_t L, R;
if (a->line.p1.x <= a->line.p2.x) {
if (x < a->line.p1.x)
return 1;
if (x > a->line.p2.x)
return -1;
} else {
if (x < a->line.p2.x)
return 1;
if (x > a->line.p1.x)
return -1;
}
adx = a->line.p2.x - a->line.p1.x;
dx = x - a->line.p1.x;
if (adx == 0)
return -dx;
if (dx == 0 || (adx ^ dx) < 0)
return adx;
dy = y - a->line.p1.y;
ady = a->line.p2.y - a->line.p1.y;
L = _cairo_int32x32_64_mul (dy, adx);
R = _cairo_int32x32_64_mul (dx, ady);
return _cairo_int64_cmp (L, R);
}
static int
edges_compare_x_for_y (const cairo_edge_t *a,
const cairo_edge_t *b,
int32_t y)
{
/* If the sweep-line is currently on an end-point of a line,
* then we know its precise x value (and considering that we often need to
* compare events at end-points, this happens frequently enough to warrant
* special casing).
*/
enum {
HAVE_NEITHER = 0x0,
HAVE_AX = 0x1,
HAVE_BX = 0x2,
HAVE_BOTH = HAVE_AX | HAVE_BX
} have_ax_bx = HAVE_BOTH;
int32_t ax, bx;
/* XXX given we have x and dx? */
if (y == a->line.p1.y)
ax = a->line.p1.x;
else if (y == a->line.p2.y)
ax = a->line.p2.x;
else
have_ax_bx &= ~HAVE_AX;
if (y == b->line.p1.y)
bx = b->line.p1.x;
else if (y == b->line.p2.y)
bx = b->line.p2.x;
else
have_ax_bx &= ~HAVE_BX;
switch (have_ax_bx) {
default:
case HAVE_NEITHER:
return edges_compare_x_for_y_general (a, b, y);
case HAVE_AX:
return -edge_compare_for_y_against_x (b, y, ax);
case HAVE_BX:
return edge_compare_for_y_against_x (a, y, bx);
case HAVE_BOTH:
return ax - bx;
}
}
static inline int
slope_compare (const edge_t *a,
const edge_t *b)
{
cairo_int64_t L, R;
int cmp;
cmp = a->dxdy.quo - b->dxdy.quo;
if (cmp)
return cmp;
if (a->dxdy.rem == 0)
return -b->dxdy.rem;
if (b->dxdy.rem == 0)
return a->dxdy.rem;
L = _cairo_int32x32_64_mul (b->dy, a->dxdy.rem);
R = _cairo_int32x32_64_mul (a->dy, b->dxdy.rem);
return _cairo_int64_cmp (L, R);
}
static inline int
line_equal (const cairo_line_t *a, const cairo_line_t *b)
{
return a->p1.x == b->p1.x && a->p1.y == b->p1.y &&
a->p2.x == b->p2.x && a->p2.y == b->p2.y;
}
static inline int
sweep_line_compare_edges (const edge_t *a,
const edge_t *b,
cairo_fixed_t y)
{
int cmp;
if (line_equal (&a->edge.line, &b->edge.line))
return 0;
cmp = edges_compare_x_for_y (&a->edge, &b->edge, y);
if (cmp)
return cmp;
return slope_compare (a, b);
}
static inline cairo_int64_t
det32_64 (int32_t a, int32_t b,
int32_t c, int32_t d)
{
/* det = a * d - b * c */
return _cairo_int64_sub (_cairo_int32x32_64_mul (a, d),
_cairo_int32x32_64_mul (b, c));
}
static inline cairo_int128_t
det64x32_128 (cairo_int64_t a, int32_t b,
cairo_int64_t c, int32_t d)
{
/* det = a * d - b * c */
return _cairo_int128_sub (_cairo_int64x32_128_mul (a, d),
_cairo_int64x32_128_mul (c, b));
}
/* Compute the intersection of two lines as defined by two edges. The
* result is provided as a coordinate pair of 128-bit integers.
*
* Returns %CAIRO_BO_STATUS_INTERSECTION if there is an intersection or
* %CAIRO_BO_STATUS_PARALLEL if the two lines are exactly parallel.
*/
static cairo_bool_t
intersect_lines (const edge_t *a, const edge_t *b,
cairo_bo_intersect_point_t *intersection)
{
cairo_int64_t a_det, b_det;
/* XXX: We're assuming here that dx and dy will still fit in 32
* bits. That's not true in general as there could be overflow. We
* should prevent that before the tessellation algorithm begins.
* What we're doing to mitigate this is to perform clamping in
* cairo_bo_tessellate_polygon().
*/
int32_t dx1 = a->edge.line.p1.x - a->edge.line.p2.x;
int32_t dy1 = a->edge.line.p1.y - a->edge.line.p2.y;
int32_t dx2 = b->edge.line.p1.x - b->edge.line.p2.x;
int32_t dy2 = b->edge.line.p1.y - b->edge.line.p2.y;
cairo_int64_t den_det;
cairo_int64_t R;
cairo_quorem64_t qr;
den_det = det32_64 (dx1, dy1, dx2, dy2);
/* Q: Can we determine that the lines do not intersect (within range)
* much more cheaply than computing the intersection point i.e. by
* avoiding the division?
*
* X = ax + t * adx = bx + s * bdx;
* Y = ay + t * ady = by + s * bdy;
* ∴ t * (ady*bdx - bdy*adx) = bdx * (by - ay) + bdy * (ax - bx)
* => t * L = R
*
* Therefore we can reject any intersection (under the criteria for
* valid intersection events) if:
* L^R < 0 => t < 0, or
* L<R => t > 1
*
* (where top/bottom must at least extend to the line endpoints).
*
* A similar substitution can be performed for s, yielding:
* s * (ady*bdx - bdy*adx) = ady * (ax - bx) - adx * (ay - by)
*/
R = det32_64 (dx2, dy2,
b->edge.line.p1.x - a->edge.line.p1.x,
b->edge.line.p1.y - a->edge.line.p1.y);
if (_cairo_int64_negative (den_det)) {
if (_cairo_int64_ge (den_det, R))
return FALSE;
} else {
if (_cairo_int64_le (den_det, R))
return FALSE;
}
R = det32_64 (dy1, dx1,
a->edge.line.p1.y - b->edge.line.p1.y,
a->edge.line.p1.x - b->edge.line.p1.x);
if (_cairo_int64_negative (den_det)) {
if (_cairo_int64_ge (den_det, R))
return FALSE;
} else {
if (_cairo_int64_le (den_det, R))
return FALSE;
}
/* We now know that the two lines should intersect within range. */
a_det = det32_64 (a->edge.line.p1.x, a->edge.line.p1.y,
a->edge.line.p2.x, a->edge.line.p2.y);
b_det = det32_64 (b->edge.line.p1.x, b->edge.line.p1.y,
b->edge.line.p2.x, b->edge.line.p2.y);
/* x = det (a_det, dx1, b_det, dx2) / den_det */
qr = _cairo_int_96by64_32x64_divrem (det64x32_128 (a_det, dx1,
b_det, dx2),
den_det);
if (_cairo_int64_eq (qr.rem, den_det))
return FALSE;
#if 0
intersection->x.exactness = _cairo_int64_is_zero (qr.rem) ? EXACT : INEXACT;
#else
intersection->x.exactness = EXACT;
if (! _cairo_int64_is_zero (qr.rem)) {
if (_cairo_int64_negative (den_det) ^ _cairo_int64_negative (qr.rem))
qr.rem = _cairo_int64_negate (qr.rem);
qr.rem = _cairo_int64_mul (qr.rem, _cairo_int32_to_int64 (2));
if (_cairo_int64_ge (qr.rem, den_det)) {
qr.quo = _cairo_int64_add (qr.quo,
_cairo_int32_to_int64 (_cairo_int64_negative (qr.quo) ? -1 : 1));
} else
intersection->x.exactness = INEXACT;
}
#endif
intersection->x.ordinate = _cairo_int64_to_int32 (qr.quo);
/* y = det (a_det, dy1, b_det, dy2) / den_det */
qr = _cairo_int_96by64_32x64_divrem (det64x32_128 (a_det, dy1,
b_det, dy2),
den_det);
if (_cairo_int64_eq (qr.rem, den_det))
return FALSE;
#if 0
intersection->y.exactness = _cairo_int64_is_zero (qr.rem) ? EXACT : INEXACT;
#else
intersection->y.exactness = EXACT;
if (! _cairo_int64_is_zero (qr.rem)) {
/* compute ceiling away from zero */
qr.quo = _cairo_int64_add (qr.quo,
_cairo_int32_to_int64 (_cairo_int64_negative (qr.quo) ? -1 : 1));
intersection->y.exactness = INEXACT;
}
#endif
intersection->y.ordinate = _cairo_int64_to_int32 (qr.quo);
return TRUE;
}
static int
bo_intersect_ordinate_32_compare (int32_t a, int32_t b, int exactness)
{
int cmp;
/* First compare the quotient */
cmp = a - b;
if (cmp)
return cmp;
/* With quotient identical, if remainder is 0 then compare equal */
/* Otherwise, the non-zero remainder makes a > b */
return -(INEXACT == exactness);
}
/* Does the given edge contain the given point. The point must already
* be known to be contained within the line determined by the edge,
* (most likely the point results from an intersection of this edge
* with another).
*
* If we had exact arithmetic, then this function would simply be a
* matter of examining whether the y value of the point lies within
* the range of y values of the edge. But since intersection points
* are not exact due to being rounded to the nearest integer within
* the available precision, we must also examine the x value of the
* point.
*
* The definition of "contains" here is that the given intersection
* point will be seen by the sweep line after the start event for the
* given edge and before the stop event for the edge. See the comments
* in the implementation for more details.
*/
static cairo_bool_t
bo_edge_contains_intersect_point (const edge_t *edge,
cairo_bo_intersect_point_t *point)
{
int cmp_top, cmp_bottom;
/* XXX: When running the actual algorithm, we don't actually need to
* compare against edge->top at all here, since any intersection above
* top is eliminated early via a slope comparison. We're leaving these
* here for now only for the sake of the quadratic-time intersection
* finder which needs them.
*/
cmp_top = bo_intersect_ordinate_32_compare (point->y.ordinate,
edge->edge.top,
point->y.exactness);
if (cmp_top < 0)
return FALSE;
cmp_bottom = bo_intersect_ordinate_32_compare (point->y.ordinate,
edge->edge.bottom,
point->y.exactness);
if (cmp_bottom > 0)
return FALSE;
if (cmp_top > 0 && cmp_bottom < 0)
return TRUE;
/* At this stage, the point lies on the same y value as either
* edge->top or edge->bottom, so we have to examine the x value in
* order to properly determine containment. */
/* If the y value of the point is the same as the y value of the
* top of the edge, then the x value of the point must be greater
* to be considered as inside the edge. Similarly, if the y value
* of the point is the same as the y value of the bottom of the
* edge, then the x value of the point must be less to be
* considered as inside. */
if (cmp_top == 0) {
cairo_fixed_t top_x;
top_x = line_compute_intersection_x_for_y (&edge->edge.line,
edge->edge.top);
return bo_intersect_ordinate_32_compare (top_x, point->x.ordinate, point->x.exactness) < 0;
} else { /* cmp_bottom == 0 */
cairo_fixed_t bot_x;
bot_x = line_compute_intersection_x_for_y (&edge->edge.line,
edge->edge.bottom);
return bo_intersect_ordinate_32_compare (point->x.ordinate, bot_x, point->x.exactness) < 0;
}
}
static cairo_bool_t
edge_intersect (const edge_t *a,
const edge_t *b,
cairo_point_t *intersection)
{
cairo_bo_intersect_point_t quorem;
if (! intersect_lines (a, b, &quorem))
return FALSE;
if (a->edge.top != a->edge.line.p1.y || a->edge.bottom != a->edge.line.p2.y) {
if (! bo_edge_contains_intersect_point (a, &quorem))
return FALSE;
}
if (b->edge.top != b->edge.line.p1.y || b->edge.bottom != b->edge.line.p2.y) {
if (! bo_edge_contains_intersect_point (b, &quorem))
return FALSE;
}
/* Now that we've correctly compared the intersection point and
* determined that it lies within the edge, then we know that we
* no longer need any more bits of storage for the intersection
* than we do for our edge coordinates. We also no longer need the
* remainder from the division. */
intersection->x = quorem.x.ordinate;
intersection->y = quorem.y.ordinate;
return TRUE;
}
static inline int
event_compare (const event_t *a, const event_t *b)
{
return a->y - b->y;
}
static void
pqueue_init (pqueue_t *pq)
{
pq->max_size = ARRAY_LENGTH (pq->elements_embedded);
pq->size = 0;
pq->elements = pq->elements_embedded;
}
static void
pqueue_fini (pqueue_t *pq)
{
if (pq->elements != pq->elements_embedded)
free (pq->elements);
}
static cairo_bool_t
pqueue_grow (pqueue_t *pq)
{
event_t **new_elements;
pq->max_size *= 2;
if (pq->elements == pq->elements_embedded) {
new_elements = _cairo_malloc_ab (pq->max_size,
sizeof (event_t *));
if (unlikely (new_elements == NULL))
return FALSE;
memcpy (new_elements, pq->elements_embedded,
sizeof (pq->elements_embedded));
} else {
new_elements = _cairo_realloc_ab (pq->elements,
pq->max_size,
sizeof (event_t *));
if (unlikely (new_elements == NULL))
return FALSE;
}
pq->elements = new_elements;
return TRUE;
}
static inline void
pqueue_push (sweep_line_t *sweep_line, event_t *event)
{
event_t **elements;
int i, parent;
if (unlikely (sweep_line->queue.pq.size + 1 == sweep_line->queue.pq.max_size)) {
if (unlikely (! pqueue_grow (&sweep_line->queue.pq))) {
longjmp (sweep_line->unwind,
_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
}
elements = sweep_line->queue.pq.elements;
for (i = ++sweep_line->queue.pq.size;
i != PQ_FIRST_ENTRY &&
event_compare (event,
elements[parent = PQ_PARENT_INDEX (i)]) < 0;
i = parent)
{
elements[i] = elements[parent];
}
elements[i] = event;
}
static inline void
pqueue_pop (pqueue_t *pq)
{
event_t **elements = pq->elements;
event_t *tail;
int child, i;
tail = elements[pq->size--];
if (pq->size == 0) {
elements[PQ_FIRST_ENTRY] = NULL;
return;
}
for (i = PQ_FIRST_ENTRY;
(child = PQ_LEFT_CHILD_INDEX (i)) <= pq->size;
i = child)
{
if (child != pq->size &&
event_compare (elements[child+1],
elements[child]) < 0)
{
child++;
}
if (event_compare (elements[child], tail) >= 0)
break;
elements[i] = elements[child];
}
elements[i] = tail;
}
static inline void
event_insert (sweep_line_t *sweep_line,
event_type_t type,
edge_t *e1,
edge_t *e2,
cairo_fixed_t y)
{
queue_event_t *event;
event = _cairo_freepool_alloc (&sweep_line->queue.pool);
if (unlikely (event == NULL)) {
longjmp (sweep_line->unwind,
_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
event->y = y;
event->type = type;
event->e1 = e1;
event->e2 = e2;
pqueue_push (sweep_line, (event_t *) event);
}
static void
event_delete (sweep_line_t *sweep_line,
event_t *event)
{
_cairo_freepool_free (&sweep_line->queue.pool, event);
}
static inline event_t *
event_next (sweep_line_t *sweep_line)
{
event_t *event, *cmp;
event = sweep_line->queue.pq.elements[PQ_FIRST_ENTRY];
cmp = *sweep_line->queue.start_events;
if (event == NULL ||
(cmp != NULL && event_compare (cmp, event) < 0))
{
event = cmp;
sweep_line->queue.start_events++;
}
else
{
pqueue_pop (&sweep_line->queue.pq);
}
return event;
}
CAIRO_COMBSORT_DECLARE (start_event_sort, event_t *, event_compare)
static inline void
event_insert_stop (sweep_line_t *sweep_line,
edge_t *edge)
{
event_insert (sweep_line,
EVENT_TYPE_STOP,
edge, NULL,
edge->edge.bottom);
}
static inline void
event_insert_if_intersect_below_current_y (sweep_line_t *sweep_line,
edge_t *left,
edge_t *right)
{
cairo_point_t intersection;
/* start points intersect */
if (left->edge.line.p1.x == right->edge.line.p1.x &&
left->edge.line.p1.y == right->edge.line.p1.y)
{
return;
}
/* end points intersect, process DELETE events first */
if (left->edge.line.p2.x == right->edge.line.p2.x &&
left->edge.line.p2.y == right->edge.line.p2.y)
{
return;
}
if (slope_compare (left, right) <= 0)
return;
if (! edge_intersect (left, right, &intersection))
return;
event_insert (sweep_line,
EVENT_TYPE_INTERSECTION,
left, right,
intersection.y);
}
static inline edge_t *
link_to_edge (cairo_list_t *link)
{
return (edge_t *) link;
}
static void
sweep_line_insert (sweep_line_t *sweep_line,
edge_t *edge)
{
cairo_list_t *pos;
cairo_fixed_t y = sweep_line->current_subrow;
pos = sweep_line->insert_cursor;
if (pos == &sweep_line->active)
pos = sweep_line->active.next;
if (pos != &sweep_line->active) {
int cmp;
cmp = sweep_line_compare_edges (link_to_edge (pos),
edge,
y);
if (cmp < 0) {
while (pos->next != &sweep_line->active &&
sweep_line_compare_edges (link_to_edge (pos->next),
edge,
y) < 0)
{
pos = pos->next;
}
} else if (cmp > 0) {
do {
pos = pos->prev;
} while (pos != &sweep_line->active &&
sweep_line_compare_edges (link_to_edge (pos),
edge,
y) > 0);
}
}
cairo_list_add (&edge->link, pos);
sweep_line->insert_cursor = &edge->link;
}
inline static void
coverage_rewind (struct coverage *cells)
{
cells->cursor = &cells->head;
}
static void
coverage_init (struct coverage *cells)
{
_cairo_freepool_init (&cells->pool,
sizeof (struct cell));
cells->head.prev = NULL;
cells->head.next = &cells->tail;
cells->head.x = INT_MIN;
cells->tail.prev = &cells->head;
cells->tail.next = NULL;
cells->tail.x = INT_MAX;
cells->count = 0;
coverage_rewind (cells);
}
static void
coverage_fini (struct coverage *cells)
{
_cairo_freepool_fini (&cells->pool);
}
inline static void
coverage_reset (struct coverage *cells)
{
cells->head.next = &cells->tail;
cells->tail.prev = &cells->head;
cells->count = 0;
_cairo_freepool_reset (&cells->pool);
coverage_rewind (cells);
}
static struct cell *
coverage_alloc (sweep_line_t *sweep_line,
struct cell *tail,
int x)
{
struct cell *cell;
cell = _cairo_freepool_alloc (&sweep_line->coverage.pool);
if (unlikely (NULL == cell)) {
longjmp (sweep_line->unwind,
_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
tail->prev->next = cell;
cell->prev = tail->prev;
cell->next = tail;
tail->prev = cell;
cell->x = x;
cell->uncovered_area = 0;
cell->covered_height = 0;
sweep_line->coverage.count++;
return cell;
}
inline static struct cell *
coverage_find (sweep_line_t *sweep_line, int x)
{
struct cell *cell;
cell = sweep_line->coverage.cursor;
if (unlikely (cell->x > x)) {
do {
if (cell->prev->x < x)
break;
cell = cell->prev;
} while (TRUE);
} else {
if (cell->x == x)
return cell;
do {
UNROLL3({
cell = cell->next;
if (cell->x >= x)
break;
});
} while (TRUE);
}
if (cell->x != x)
cell = coverage_alloc (sweep_line, cell, x);
return sweep_line->coverage.cursor = cell;
}
static void
coverage_render_cells (sweep_line_t *sweep_line,
cairo_fixed_t left, cairo_fixed_t right,
cairo_fixed_t y1, cairo_fixed_t y2,
int sign)
{
int fx1, fx2;
int ix1, ix2;
int dx, dy;
/* Orient the edge left-to-right. */
dx = right - left;
if (dx >= 0) {
ix1 = _cairo_fixed_integer_part (left);
fx1 = _cairo_fixed_fractional_part (left);
ix2 = _cairo_fixed_integer_part (right);
fx2 = _cairo_fixed_fractional_part (right);
dy = y2 - y1;
} else {
ix1 = _cairo_fixed_integer_part (right);
fx1 = _cairo_fixed_fractional_part (right);
ix2 = _cairo_fixed_integer_part (left);
fx2 = _cairo_fixed_fractional_part (left);
dx = -dx;
sign = -sign;
dy = y1 - y2;
y1 = y2 - dy;
y2 = y1 + dy;
}
/* Add coverage for all pixels [ix1,ix2] on this row crossed
* by the edge. */
{
struct quorem y = floored_divrem ((STEP_X - fx1)*dy, dx);
struct cell *cell;
cell = sweep_line->coverage.cursor;
if (cell->x != ix1) {
if (unlikely (cell->x > ix1)) {
do {
if (cell->prev->x < ix1)
break;
cell = cell->prev;
} while (TRUE);
} else do {
UNROLL3({
if (cell->x >= ix1)
break;
cell = cell->next;
});
} while (TRUE);
if (cell->x != ix1)
cell = coverage_alloc (sweep_line, cell, ix1);
}
cell->uncovered_area += sign * y.quo * (STEP_X + fx1);
cell->covered_height += sign * y.quo;
y.quo += y1;
cell = cell->next;
if (cell->x != ++ix1)
cell = coverage_alloc (sweep_line, cell, ix1);
if (ix1 < ix2) {
struct quorem dydx_full = floored_divrem (STEP_X*dy, dx);
do {
cairo_fixed_t y_skip = dydx_full.quo;
y.rem += dydx_full.rem;
if (y.rem >= dx) {
++y_skip;
y.rem -= dx;
}
y.quo += y_skip;
y_skip *= sign;
cell->covered_height += y_skip;
cell->uncovered_area += y_skip*STEP_X;
cell = cell->next;
if (cell->x != ++ix1)
cell = coverage_alloc (sweep_line, cell, ix1);
} while (ix1 != ix2);
}
cell->uncovered_area += sign*(y2 - y.quo)*fx2;
cell->covered_height += sign*(y2 - y.quo);
sweep_line->coverage.cursor = cell;
}
}
inline static void
full_inc_edge (edge_t *edge)
{
edge->x.quo += edge->dxdy_full.quo;
edge->x.rem += edge->dxdy_full.rem;
if (edge->x.rem >= 0) {
++edge->x.quo;
edge->x.rem -= edge->dy;
}
}
static void
full_add_edge (sweep_line_t *sweep_line, edge_t *edge, int sign)
{
struct cell *cell;
cairo_fixed_t x1, x2;
int ix1, ix2;
int frac;
edge->current_sign = sign;
ix1 = _cairo_fixed_integer_part (edge->x.quo);
if (edge->vertical) {
frac = _cairo_fixed_fractional_part (edge->x.quo);
cell = coverage_find (sweep_line, ix1);
cell->covered_height += sign * STEP_Y;
cell->uncovered_area += sign * 2 * frac * STEP_Y;
return;
}
x1 = edge->x.quo;
full_inc_edge (edge);
x2 = edge->x.quo;
ix2 = _cairo_fixed_integer_part (edge->x.quo);
/* Edge is entirely within a column? */
if (likely (ix1 == ix2)) {
frac = _cairo_fixed_fractional_part (x1) +
_cairo_fixed_fractional_part (x2);
cell = coverage_find (sweep_line, ix1);
cell->covered_height += sign * STEP_Y;
cell->uncovered_area += sign * frac * STEP_Y;
return;
}
coverage_render_cells (sweep_line, x1, x2, 0, STEP_Y, sign);
}
static void
full_nonzero (sweep_line_t *sweep_line)
{
cairo_list_t *pos;
sweep_line->is_vertical = TRUE;
pos = sweep_line->active.next;
do {
edge_t *left = link_to_edge (pos), *right;
int winding = left->edge.dir;
sweep_line->is_vertical &= left->vertical;
pos = left->link.next;
do {
if (unlikely (pos == &sweep_line->active)) {
full_add_edge (sweep_line, left, +1);
return;
}
right = link_to_edge (pos);
pos = pos->next;
sweep_line->is_vertical &= right->vertical;
winding += right->edge.dir;
if (0 == winding) {
if (pos == &sweep_line->active ||
link_to_edge (pos)->x.quo != right->x.quo)
{
break;
}
}
if (! right->vertical)
full_inc_edge (right);
} while (TRUE);
full_add_edge (sweep_line, left, +1);
full_add_edge (sweep_line, right, -1);
} while (pos != &sweep_line->active);
}
static void
full_evenodd (sweep_line_t *sweep_line)
{
cairo_list_t *pos;
sweep_line->is_vertical = TRUE;
pos = sweep_line->active.next;
do {
edge_t *left = link_to_edge (pos), *right;
int winding = 0;
sweep_line->is_vertical &= left->vertical;
pos = left->link.next;
do {
if (pos == &sweep_line->active) {
full_add_edge (sweep_line, left, +1);
return;
}
right = link_to_edge (pos);
pos = pos->next;
sweep_line->is_vertical &= right->vertical;
if (++winding & 1) {
if (pos == &sweep_line->active ||
link_to_edge (pos)->x.quo != right->x.quo)
{
break;
}
}
if (! right->vertical)
full_inc_edge (right);
} while (TRUE);
full_add_edge (sweep_line, left, +1);
full_add_edge (sweep_line, right, -1);
} while (pos != &sweep_line->active);
}
static void
render_rows (cairo_botor_scan_converter_t *self,
sweep_line_t *sweep_line,
int y, int height,
cairo_span_renderer_t *renderer)
{
cairo_half_open_span_t spans_stack[CAIRO_STACK_ARRAY_LENGTH (cairo_half_open_span_t)];
cairo_half_open_span_t *spans = spans_stack;
struct cell *cell;
int prev_x, cover;
int num_spans;
cairo_status_t status;
if (unlikely (sweep_line->coverage.count == 0)) {
status = renderer->render_rows (renderer, y, height, NULL, 0);
if (unlikely (status))
longjmp (sweep_line->unwind, status);
return;
}
/* Allocate enough spans for the row. */
num_spans = 2*sweep_line->coverage.count+2;
if (unlikely (num_spans > ARRAY_LENGTH (spans_stack))) {
spans = _cairo_malloc_ab (num_spans, sizeof (cairo_half_open_span_t));
if (unlikely (spans == NULL)) {
longjmp (sweep_line->unwind,
_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
}
/* Form the spans from the coverage and areas. */
num_spans = 0;
prev_x = self->xmin;
cover = 0;
cell = sweep_line->coverage.head.next;
do {
int x = cell->x;
int area;
if (x > prev_x) {
spans[num_spans].x = prev_x;
spans[num_spans].inverse = 0;
spans[num_spans].coverage = AREA_TO_ALPHA (cover);
++num_spans;
}
cover += cell->covered_height*STEP_X*2;
area = cover - cell->uncovered_area;
spans[num_spans].x = x;
spans[num_spans].coverage = AREA_TO_ALPHA (area);
++num_spans;
prev_x = x + 1;
} while ((cell = cell->next) != &sweep_line->coverage.tail);
if (prev_x <= self->xmax) {
spans[num_spans].x = prev_x;
spans[num_spans].inverse = 0;
spans[num_spans].coverage = AREA_TO_ALPHA (cover);
++num_spans;
}
if (cover && prev_x < self->xmax) {
spans[num_spans].x = self->xmax;
spans[num_spans].inverse = 1;
spans[num_spans].coverage = 0;
++num_spans;
}
status = renderer->render_rows (renderer, y, height, spans, num_spans);
if (unlikely (spans != spans_stack))
free (spans);
coverage_reset (&sweep_line->coverage);
if (unlikely (status))
longjmp (sweep_line->unwind, status);
}
static void
full_repeat (sweep_line_t *sweep)
{
edge_t *edge;
cairo_list_foreach_entry (edge, edge_t, &sweep->active, link) {
if (edge->current_sign)
full_add_edge (sweep, edge, edge->current_sign);
else if (! edge->vertical)
full_inc_edge (edge);
}
}
static void
full_reset (sweep_line_t *sweep)
{
edge_t *edge;
cairo_list_foreach_entry (edge, edge_t, &sweep->active, link)
edge->current_sign = 0;
}
static void
full_step (cairo_botor_scan_converter_t *self,
sweep_line_t *sweep_line,
cairo_fixed_t row,
cairo_span_renderer_t *renderer)
{
int top, bottom;
top = _cairo_fixed_integer_part (sweep_line->current_row);
bottom = _cairo_fixed_integer_part (row);
if (cairo_list_is_empty (&sweep_line->active)) {
cairo_status_t status;
status = renderer->render_rows (renderer, top, bottom - top, NULL, 0);
if (unlikely (status))
longjmp (sweep_line->unwind, status);
return;
}
if (self->fill_rule == CAIRO_FILL_RULE_WINDING)
full_nonzero (sweep_line);
else
full_evenodd (sweep_line);
if (sweep_line->is_vertical || bottom == top + 1) {
render_rows (self, sweep_line, top, bottom - top, renderer);
full_reset (sweep_line);
return;
}
render_rows (self, sweep_line, top++, 1, renderer);
do {
full_repeat (sweep_line);
render_rows (self, sweep_line, top, 1, renderer);
} while (++top != bottom);
full_reset (sweep_line);
}
cairo_always_inline static void
sub_inc_edge (edge_t *edge,
cairo_fixed_t height)
{
if (height == 1) {
edge->x.quo += edge->dxdy.quo;
edge->x.rem += edge->dxdy.rem;
if (edge->x.rem >= 0) {
++edge->x.quo;
edge->x.rem -= edge->dy;
}
} else {
edge->x.quo += height * edge->dxdy.quo;
edge->x.rem += height * edge->dxdy.rem;
if (edge->x.rem >= 0) {
int carry = edge->x.rem / edge->dy + 1;
edge->x.quo += carry;
edge->x.rem -= carry * edge->dy;
}
}
}
static void
sub_add_run (sweep_line_t *sweep_line, edge_t *edge, int y, int sign)
{
struct run *run;
run = _cairo_freepool_alloc (&sweep_line->runs);
if (unlikely (run == NULL))
longjmp (sweep_line->unwind, _cairo_error (CAIRO_STATUS_NO_MEMORY));
run->y = y;
run->sign = sign;
run->next = edge->runs;
edge->runs = run;
edge->current_sign = sign;
}
inline static cairo_bool_t
edges_coincident (edge_t *left, edge_t *right, cairo_fixed_t y)
{
/* XXX is compare_x_for_y() worth executing during sub steps? */
return line_equal (&left->edge.line, &right->edge.line);
//edges_compare_x_for_y (&left->edge, &right->edge, y) >= 0;
}
static void
sub_nonzero (sweep_line_t *sweep_line)
{
cairo_fixed_t y = sweep_line->current_subrow;
cairo_fixed_t fy = _cairo_fixed_fractional_part (y);
cairo_list_t *pos;
pos = sweep_line->active.next;
do {
edge_t *left = link_to_edge (pos), *right;
int winding = left->edge.dir;
pos = left->link.next;
do {
if (unlikely (pos == &sweep_line->active)) {
if (left->current_sign != +1)
sub_add_run (sweep_line, left, fy, +1);
return;
}
right = link_to_edge (pos);
pos = pos->next;
winding += right->edge.dir;
if (0 == winding) {
if (pos == &sweep_line->active ||
! edges_coincident (right, link_to_edge (pos), y))
{
break;
}
}
if (right->current_sign)
sub_add_run (sweep_line, right, fy, 0);
} while (TRUE);
if (left->current_sign != +1)
sub_add_run (sweep_line, left, fy, +1);
if (right->current_sign != -1)
sub_add_run (sweep_line, right, fy, -1);
} while (pos != &sweep_line->active);
}
static void
sub_evenodd (sweep_line_t *sweep_line)
{
cairo_fixed_t y = sweep_line->current_subrow;
cairo_fixed_t fy = _cairo_fixed_fractional_part (y);
cairo_list_t *pos;
pos = sweep_line->active.next;
do {
edge_t *left = link_to_edge (pos), *right;
int winding = 0;
pos = left->link.next;
do {
if (unlikely (pos == &sweep_line->active)) {
if (left->current_sign != +1)
sub_add_run (sweep_line, left, fy, +1);
return;
}
right = link_to_edge (pos);
pos = pos->next;
if (++winding & 1) {
if (pos == &sweep_line->active ||
! edges_coincident (right, link_to_edge (pos), y))
{
break;
}
}
if (right->current_sign)
sub_add_run (sweep_line, right, fy, 0);
} while (TRUE);
if (left->current_sign != +1)
sub_add_run (sweep_line, left, fy, +1);
if (right->current_sign != -1)
sub_add_run (sweep_line, right, fy, -1);
} while (pos != &sweep_line->active);
}
cairo_always_inline static void
sub_step (cairo_botor_scan_converter_t *self,
sweep_line_t *sweep_line)
{
if (cairo_list_is_empty (&sweep_line->active))
return;
if (self->fill_rule == CAIRO_FILL_RULE_WINDING)
sub_nonzero (sweep_line);
else
sub_evenodd (sweep_line);
}
static void
coverage_render_runs (sweep_line_t *sweep, edge_t *edge,
cairo_fixed_t y1, cairo_fixed_t y2)
{
struct run tail;
struct run *run = &tail;
tail.next = NULL;
tail.y = y2;
/* Order the runs top->bottom */
while (edge->runs) {
struct run *r;
r = edge->runs;
edge->runs = r->next;
r->next = run;
run = r;
}
if (run->y > y1)
sub_inc_edge (edge, run->y - y1);
do {
cairo_fixed_t x1, x2;
y1 = run->y;
y2 = run->next->y;
x1 = edge->x.quo;
if (y2 - y1 == STEP_Y)
full_inc_edge (edge);
else
sub_inc_edge (edge, y2 - y1);
x2 = edge->x.quo;
if (run->sign) {
int ix1, ix2;
ix1 = _cairo_fixed_integer_part (x1);
ix2 = _cairo_fixed_integer_part (x2);
/* Edge is entirely within a column? */
if (likely (ix1 == ix2)) {
struct cell *cell;
int frac;
frac = _cairo_fixed_fractional_part (x1) +
_cairo_fixed_fractional_part (x2);
cell = coverage_find (sweep, ix1);
cell->covered_height += run->sign * (y2 - y1);
cell->uncovered_area += run->sign * (y2 - y1) * frac;
} else {
coverage_render_cells (sweep, x1, x2, y1, y2, run->sign);
}
}
run = run->next;
} while (run->next != NULL);
}
static void
coverage_render_vertical_runs (sweep_line_t *sweep, edge_t *edge, cairo_fixed_t y2)
{
struct cell *cell;
struct run *run;
int height = 0;
for (run = edge->runs; run != NULL; run = run->next) {
if (run->sign)
height += run->sign * (y2 - run->y);
y2 = run->y;
}
cell = coverage_find (sweep, _cairo_fixed_integer_part (edge->x.quo));
cell->covered_height += height;
cell->uncovered_area += 2 * _cairo_fixed_fractional_part (edge->x.quo) * height;
}
cairo_always_inline static void
sub_emit (cairo_botor_scan_converter_t *self,
sweep_line_t *sweep,
cairo_span_renderer_t *renderer)
{
edge_t *edge;
sub_step (self, sweep);
/* convert the runs into coverages */
cairo_list_foreach_entry (edge, edge_t, &sweep->active, link) {
if (edge->runs == NULL) {
if (! edge->vertical) {
if (edge->flags & START) {
sub_inc_edge (edge,
STEP_Y - _cairo_fixed_fractional_part (edge->edge.top));
edge->flags &= ~START;
} else
full_inc_edge (edge);
}
} else {
if (edge->vertical) {
coverage_render_vertical_runs (sweep, edge, STEP_Y);
} else {
int y1 = 0;
if (edge->flags & START) {
y1 = _cairo_fixed_fractional_part (edge->edge.top);
edge->flags &= ~START;
}
coverage_render_runs (sweep, edge, y1, STEP_Y);
}
}
edge->current_sign = 0;
edge->runs = NULL;
}
cairo_list_foreach_entry (edge, edge_t, &sweep->stopped, link) {
int y2 = _cairo_fixed_fractional_part (edge->edge.bottom);
if (edge->vertical) {
coverage_render_vertical_runs (sweep, edge, y2);
} else {
int y1 = 0;
if (edge->flags & START)
y1 = _cairo_fixed_fractional_part (edge->edge.top);
coverage_render_runs (sweep, edge, y1, y2);
}
}
cairo_list_init (&sweep->stopped);
_cairo_freepool_reset (&sweep->runs);
render_rows (self, sweep,
_cairo_fixed_integer_part (sweep->current_row), 1,
renderer);
}
static void
sweep_line_init (sweep_line_t *sweep_line,
event_t **start_events,
int num_events)
{
cairo_list_init (&sweep_line->active);
cairo_list_init (&sweep_line->stopped);
sweep_line->insert_cursor = &sweep_line->active;
sweep_line->current_row = INT32_MIN;
sweep_line->current_subrow = INT32_MIN;
coverage_init (&sweep_line->coverage);
_cairo_freepool_init (&sweep_line->runs, sizeof (struct run));
start_event_sort (start_events, num_events);
start_events[num_events] = NULL;
sweep_line->queue.start_events = start_events;
_cairo_freepool_init (&sweep_line->queue.pool,
sizeof (queue_event_t));
pqueue_init (&sweep_line->queue.pq);
sweep_line->queue.pq.elements[PQ_FIRST_ENTRY] = NULL;
}
static void
sweep_line_delete (sweep_line_t *sweep_line,
edge_t *edge)
{
if (sweep_line->insert_cursor == &edge->link)
sweep_line->insert_cursor = edge->link.prev;
cairo_list_del (&edge->link);
if (edge->runs)
cairo_list_add_tail (&edge->link, &sweep_line->stopped);
edge->flags |= STOP;
}
static void
sweep_line_swap (sweep_line_t *sweep_line,
edge_t *left,
edge_t *right)
{
right->link.prev = left->link.prev;
left->link.next = right->link.next;
right->link.next = &left->link;
left->link.prev = &right->link;
left->link.next->prev = &left->link;
right->link.prev->next = &right->link;
}
static void
sweep_line_fini (sweep_line_t *sweep_line)
{
pqueue_fini (&sweep_line->queue.pq);
_cairo_freepool_fini (&sweep_line->queue.pool);
coverage_fini (&sweep_line->coverage);
_cairo_freepool_fini (&sweep_line->runs);
}
static cairo_status_t
botor_generate (cairo_botor_scan_converter_t *self,
event_t **start_events,
cairo_span_renderer_t *renderer)
{
cairo_status_t status;
sweep_line_t sweep_line;
cairo_fixed_t ybot;
event_t *event;
cairo_list_t *left, *right;
edge_t *e1, *e2;
int bottom;
sweep_line_init (&sweep_line, start_events, self->num_edges);
if ((status = setjmp (sweep_line.unwind)))
goto unwind;
ybot = self->extents.p2.y;
sweep_line.current_subrow = self->extents.p1.y;
sweep_line.current_row = _cairo_fixed_floor (self->extents.p1.y);
event = *sweep_line.queue.start_events++;
do {
/* Can we process a full step in one go? */
if (event->y >= sweep_line.current_row + STEP_Y) {
bottom = _cairo_fixed_floor (event->y);
full_step (self, &sweep_line, bottom, renderer);
sweep_line.current_row = bottom;
sweep_line.current_subrow = bottom;
}
do {
if (event->y > sweep_line.current_subrow) {
sub_step (self, &sweep_line);
sweep_line.current_subrow = event->y;
}
do {
/* Update the active list using Bentley-Ottmann */
switch (event->type) {
case EVENT_TYPE_START:
e1 = ((start_event_t *) event)->edge;
sweep_line_insert (&sweep_line, e1);
event_insert_stop (&sweep_line, e1);
left = e1->link.prev;
right = e1->link.next;
if (left != &sweep_line.active) {
event_insert_if_intersect_below_current_y (&sweep_line,
link_to_edge (left), e1);
}
if (right != &sweep_line.active) {
event_insert_if_intersect_below_current_y (&sweep_line,
e1, link_to_edge (right));
}
break;
case EVENT_TYPE_STOP:
e1 = ((queue_event_t *) event)->e1;
event_delete (&sweep_line, event);
left = e1->link.prev;
right = e1->link.next;
sweep_line_delete (&sweep_line, e1);
if (left != &sweep_line.active &&
right != &sweep_line.active)
{
event_insert_if_intersect_below_current_y (&sweep_line,
link_to_edge (left),
link_to_edge (right));
}
break;
case EVENT_TYPE_INTERSECTION:
e1 = ((queue_event_t *) event)->e1;
e2 = ((queue_event_t *) event)->e2;
event_delete (&sweep_line, event);
if (e1->flags & STOP)
break;
if (e2->flags & STOP)
break;
/* skip this intersection if its edges are not adjacent */
if (&e2->link != e1->link.next)
break;
left = e1->link.prev;
right = e2->link.next;
sweep_line_swap (&sweep_line, e1, e2);
/* after the swap e2 is left of e1 */
if (left != &sweep_line.active) {
event_insert_if_intersect_below_current_y (&sweep_line,
link_to_edge (left), e2);
}
if (right != &sweep_line.active) {
event_insert_if_intersect_below_current_y (&sweep_line,
e1, link_to_edge (right));
}
break;
}
event = event_next (&sweep_line);
if (event == NULL)
goto end;
} while (event->y == sweep_line.current_subrow);
} while (event->y < sweep_line.current_row + STEP_Y);
bottom = sweep_line.current_row + STEP_Y;
sub_emit (self, &sweep_line, renderer);
sweep_line.current_subrow = bottom;
sweep_line.current_row = sweep_line.current_subrow;
} while (TRUE);
end:
/* flush any partial spans */
if (sweep_line.current_subrow != sweep_line.current_row) {
sub_emit (self, &sweep_line, renderer);
sweep_line.current_row += STEP_Y;
sweep_line.current_subrow = sweep_line.current_row;
}
/* clear the rest */
if (sweep_line.current_subrow < ybot) {
bottom = _cairo_fixed_integer_part (sweep_line.current_row);
status = renderer->render_rows (renderer,
bottom, _cairo_fixed_integer_ceil (ybot) - bottom,
NULL, 0);
}
unwind:
sweep_line_fini (&sweep_line);
return status;
}
static cairo_status_t
_cairo_botor_scan_converter_generate (void *converter,
cairo_span_renderer_t *renderer)
{
cairo_botor_scan_converter_t *self = converter;
start_event_t stack_events[CAIRO_STACK_ARRAY_LENGTH (start_event_t)];
start_event_t *events;
event_t *stack_event_ptrs[ARRAY_LENGTH (stack_events) + 1];
event_t **event_ptrs;
struct _cairo_botor_scan_converter_chunk *chunk;
cairo_status_t status;
int num_events;
int i, j;
num_events = self->num_edges;
if (unlikely (0 == num_events)) {
return renderer->render_rows (renderer,
_cairo_fixed_integer_floor (self->extents.p1.y),
_cairo_fixed_integer_ceil (self->extents.p2.y) -
_cairo_fixed_integer_floor (self->extents.p1.y),
NULL, 0);
}
events = stack_events;
event_ptrs = stack_event_ptrs;
if (unlikely (num_events >= ARRAY_LENGTH (stack_events))) {
events = _cairo_malloc_ab_plus_c (num_events,
sizeof (start_event_t) + sizeof (event_t *),
sizeof (event_t *));
if (unlikely (events == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
event_ptrs = (event_t **) (events + num_events);
}
j = 0;
for (chunk = &self->chunks; chunk != NULL; chunk = chunk->next) {
edge_t *edge;
edge = chunk->base;
for (i = 0; i < chunk->count; i++) {
event_ptrs[j] = (event_t *) &events[j];
events[j].y = edge->edge.top;
events[j].type = EVENT_TYPE_START;
events[j].edge = edge;
edge++, j++;
}
}
status = botor_generate (self, event_ptrs, renderer);
if (events != stack_events)
free (events);
return status;
}
static edge_t *
botor_allocate_edge (cairo_botor_scan_converter_t *self)
{
struct _cairo_botor_scan_converter_chunk *chunk;
chunk = self->tail;
if (chunk->count == chunk->size) {
int size;
size = chunk->size * 2;
chunk->next = _cairo_malloc_ab_plus_c (size,
sizeof (edge_t),
sizeof (struct _cairo_botor_scan_converter_chunk));
if (unlikely (chunk->next == NULL))
return NULL;
chunk = chunk->next;
chunk->next = NULL;
chunk->count = 0;
chunk->size = size;
chunk->base = chunk + 1;
self->tail = chunk;
}
return (edge_t *) chunk->base + chunk->count++;
}
static cairo_status_t
botor_add_edge (cairo_botor_scan_converter_t *self,
const cairo_edge_t *edge)
{
edge_t *e;
cairo_fixed_t dx, dy;
e = botor_allocate_edge (self);
if (unlikely (e == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
cairo_list_init (&e->link);
e->edge = *edge;
dx = edge->line.p2.x - edge->line.p1.x;
dy = edge->line.p2.y - edge->line.p1.y;
e->dy = dy;
if (dx == 0) {
e->vertical = TRUE;
e->x.quo = edge->line.p1.x;
e->x.rem = 0;
e->dxdy.quo = 0;
e->dxdy.rem = 0;
e->dxdy_full.quo = 0;
e->dxdy_full.rem = 0;
} else {
e->vertical = FALSE;
e->dxdy = floored_divrem (dx, dy);
if (edge->top == edge->line.p1.y) {
e->x.quo = edge->line.p1.x;
e->x.rem = 0;
} else {
e->x = floored_muldivrem (edge->top - edge->line.p1.y,
dx, dy);
e->x.quo += edge->line.p1.x;
}
if (_cairo_fixed_integer_part (edge->bottom) - _cairo_fixed_integer_part (edge->top) > 1) {
e->dxdy_full = floored_muldivrem (STEP_Y, dx, dy);
} else {
e->dxdy_full.quo = 0;
e->dxdy_full.rem = 0;
}
}
e->x.rem = -e->dy;
e->current_sign = 0;
e->runs = NULL;
e->flags = START;
self->num_edges++;
return CAIRO_STATUS_SUCCESS;
}
static void
_cairo_botor_scan_converter_destroy (void *converter)
{
cairo_botor_scan_converter_t *self = converter;
struct _cairo_botor_scan_converter_chunk *chunk, *next;
for (chunk = self->chunks.next; chunk != NULL; chunk = next) {
next = chunk->next;
free (chunk);
}
}
void
_cairo_botor_scan_converter_init (cairo_botor_scan_converter_t *self,
const cairo_box_t *extents,
cairo_fill_rule_t fill_rule)
{
self->base.destroy = _cairo_botor_scan_converter_destroy;
self->base.generate = _cairo_botor_scan_converter_generate;
self->extents = *extents;
self->fill_rule = fill_rule;
self->xmin = _cairo_fixed_integer_floor (extents->p1.x);
self->xmax = _cairo_fixed_integer_ceil (extents->p2.x);
self->chunks.base = self->buf;
self->chunks.next = NULL;
self->chunks.count = 0;
self->chunks.size = sizeof (self->buf) / sizeof (edge_t);
self->tail = &self->chunks;
self->num_edges = 0;
}
| {
"pile_set_name": "Github"
} |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jinq</groupId>
<artifactId>jinq</artifactId>
<version>1.8.32-SNAPSHOT</version>
</parent>
<artifactId>jinq-jpa-test</artifactId>
<packaging>jar</packaging>
<name>Jinq for JPA shared test code</name>
<description>JPA entities used for testing Jinq for JPA and related projects</description>
<build>
<plugins>
<!--
<plugin>
<groupId>de.empulse.eclipselink</groupId>
<artifactId>staticweave-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>weave</goal>
</goals>
<configuration>
<persistenceXMLLocation>META-INF/persistence.xml</persistenceXMLLocation>
<logLevel>FINE</logLevel>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</plugin>
-->
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project> | {
"pile_set_name": "Github"
} |
local wrk = {
scheme = "http",
host = "localhost",
port = nil,
method = "GET",
path = "/",
headers = {},
body = nil,
thread = nil,
}
function wrk.resolve(host, service)
local addrs = wrk.lookup(host, service)
for i = #addrs, 1, -1 do
if not wrk.connect(addrs[i]) then
table.remove(addrs, i)
end
end
wrk.addrs = addrs
end
function wrk.setup(thread)
thread.addr = wrk.addrs[1]
if type(setup) == "function" then
setup(thread)
end
end
function wrk.init(args)
if not wrk.headers["Host"] then
local host = wrk.host
local port = wrk.port
host = host:find(":") and ("[" .. host .. "]") or host
host = port and (host .. ":" .. port) or host
wrk.headers["Host"] = host
end
if type(init) == "function" then
init(args)
end
local req = wrk.format()
wrk.request = function()
return req
end
end
function wrk.format(method, path, headers, body)
local method = method or wrk.method
local path = path or wrk.path
local headers = headers or wrk.headers
local body = body or wrk.body
local s = {}
if not headers["Host"] then
headers["Host"] = wrk.headers["Host"]
end
headers["Content-Length"] = body and string.len(body)
s[1] = string.format("%s %s HTTP/1.1", method, path)
for name, value in pairs(headers) do
s[#s+1] = string.format("%s: %s", name, value)
end
s[#s+1] = ""
s[#s+1] = body or ""
return table.concat(s, "\r\n")
end
return wrk
| {
"pile_set_name": "Github"
} |
{
"Name": "Nazwa",
"Species": "Rasa",
"Class": "Klasa",
"Career": "Profesja",
"Career-tier": "Stanowisko",
"Career-Path": "Kariera",
"Status": "Status",
"Age": "Wiek",
"Height": "Wzrost",
"Hair": "Włosy",
"Eyes": "Oczy",
"Nationality": "Narodowość",
"Birthplace": "Miejsce Urodzenia",
"Religion": "Wyznanie",
"Star-sign": "Znak Gwiezdny",
"CHARACTERISTICS": "CECHY",
"WS": "WW",
"BS": "US",
"S": "S",
"T": "Wt",
"I": "I",
"Ag": "Zw",
"Dex": "Zr",
"Int": "Int",
"WP": "SW",
"Fel": "Ogd",
"Initial": "Bazowa",
"Talents": "Talenty",
"Advances": "Rozwinięcia",
"Modifier": "Modyfikator",
"Current": "Aktualna",
"CHARACTERISTICS BONUSES": "BONUSY CECH",
"FATE": "PRZEZNACZENIE",
"RESILIENCE": "BOHATER",
"EXPERIENCE": "DOŚWIADCZENIE",
"Fate": "Przeznaczenie",
"Resilience": "P. Bohatera",
"Total": "Suma",
"Fortune": "Szczęście",
"Resolve": "Determinacja",
"Spent": "Wydane",
"Motivation": "Motywacja",
"Left": "Pozostało",
"AMBITIONS": "AMBICJE",
"Personal-Short-Term": "Krótki Cel Personalny",
"Personal-Long-Term": "Długi Cel Personalny",
"Party-Short-Term": "Krótki Cel Drużyny",
"Party-Long-Term": "Długi Cel Drużyny",
"MOVEMENT": "SZYBKOŚĆ",
"Walk": "Chód",
"Run": "Bieg",
"INITIATIVE": "INICJATYWA",
"I Test /No Tracker/": "Test I (Bez Śledzenia)",
"I Bonus": "Bonus I",
"I+Ag Bonus": "I + Bonus Zw",
"Roll": "Rzuć",
"ENCUMBERANCE": "OBCIĄŻENIE",
"Weapons": "Bronie",
"Armour": "Pancerz",
"Trappings": "Wyposażenie",
"Mod": "Mod.",
"Max-Enc": "Max Obc.",
"WEALTH": "ZAMOŻNOŚĆ",
"Gold Crowns": "Złote Korony",
"Silver Shillings": "Srebrne Szylingi",
"Brass Pennies": "Brązowe Pensy",
"WOUNDS": "ŻYWOTNOŚĆ",
"Hardy": "Twardziel",
"Hardy-1": "Twardziel:1",
"Hardy-2": "Twardziel:2",
"Hardy-3": "Twardziel:3",
"Hardy-4": "Twardziel:4",
"Hardy-5": "Twardziel:5",
"Hardy-6": "Twardziel:6",
"Hardy-7": "Twardziel:7",
"Hardy-8": "Twardziel:8",
"Hardy-9": "Twardziel:9",
"Hardy-10": "Twardziel:10",
"Tiny": "Drobny",
"Little": "Malutki",
"Small": "Mały",
"Average": "Przeciętny",
"Large": "Duży",
"Enormous": "Ogromny",
"Monstrous": "Gigantyczny",
"Maximum": "Maksymalne",
"BASIC SKILLS": "Umiejętności Podstawowe",
"Char.": "Cecha",
"Adv.": "Rozw.",
"Mod.": "Mod.",
"Art": "Sztuka",
"WS-p": "(WW)",
"BS-p": "(US)",
"S-p": "(S)",
"T-p": "(Wt)",
"I-p": "(I)",
"Ag-p": "(Zw)",
"Dex-p": "(Zr)",
"Int-p": "(Int)",
"WP-p": "(SW)",
"Fel-p": "(Ogd)",
"Athletics": "Atletyka",
"Bribery": "Przekupstwo",
"Charm": "Charyzma",
"Charm-Animal": "Oswajanie",
"Climb": "Wspinaczka",
"Cool": "Opanowanie",
"Consume Alcohol": "Mocna Głowa",
"Dodge": "Unik",
"Drive": "Powożenie",
"Endurance": "Odporność",
"Entertain": "Występy",
"Gamble": "Hazard",
"Gossip": "Plotkowanie",
"Haggle": "Targowanie",
"Intimidate": "Zastraszanie",
"Intuition": "Intuicja",
"Leadership": "Dowodzenie",
"Navigation": "Nawigacja",
"Outdoor-Survival": "Sztuka Przetrwania",
"Perception": "Percepcja",
"Ride": "Jeździectwo",
"Row": "Wioślarstwo",
"Stealth": "Skradanie",
"MELEE-SPECIALISATIONS-(BASIC)": "SPECJALIZACJE BRONI BIAŁEJ (PODSTAWOWE)",
"Melee-i-Basic": "<i>Broń Biała</i> (Podstawowa)",
"Melee-i-Brawling": "<i>Broń Biała</i> (Bijatyka)",
"Melee-i-Cavalry": "<i>Broń Biała</i> (Kawaleryjska)",
"Melee-i-Fencing": "<i>Broń Biała</i> (Szermiercza)",
"Melee-i-Flail": "<i>Broń Biała</i> (Korbacze)",
"Melee-i-Parry": "<i>Broń Biała</i> (Parująca)",
"Melee-i-Pole-Arm": "<i>Broń Biała</i> (Drzewcowa)",
"Melee-i-2H": "<i>Broń Biała</i> (Dwuręczna)",
"RANGED-SPECIAlZATION-ADVANCED": "SPECJALIZACJE BRONI DYSTANSOWEJ (ZAAWANSOWANE)",
"Ranged-i-Blackpowder": "<i>Broń Zasięg.</i> (Prochowa)",
"Ranged-i-Bow": "<i>Broń Zasięg.</i> (Łuki)",
"Ranged-i-Crossbow": "<i>Broń Zasięg.</i> (Kusze) †",
"Ranged-i-Engineering": "<i>Broń Zasięg.</i> (Eksperymentalna)",
"Ranged-i-Entangling": "<i>Broń Zasięg.</i> (Oplątująca)",
"Ranged-i-Explosives": "<i>Broń Zasięg. </i> (Materiały Wybuchowe)",
"Ranged-i-Sling": "<i>Broń Zasięg.</i> (Proce)",
"Ranged-i-Throwing": "<i>Broń Zasięg.</i> (Miotana) †",
"Magic-Notice": "†= Może być użyta, nie będąc wyszkolonym, lecz traci wszystkie Zalety",
"MAGIC-BLESSINGS-AND-MIRACLES-ADVANCED": "MAGIA, BŁOGOSŁAWIEŃSTWA I CUDY (ZAAWANSOWANE)",
"Language-i-Magick-p": "<i>Język</i> (Magiczny)",
"Pray": "Modlitwa",
"GROUPED-&-ADVANCED-SKILLS": "UMIEJĘTNOŚCI GRUPOWE & ZAAWANSOWANE",
"Head": "Głowa",
"R.Arm": "P.Ręk",
"L.Arm": "L.Ręk",
"Body": "Korpus",
"R.Leg": "P.Nog",
"L.Leg": "L.Nog",
"Shield": "Tarcza",
"AP": "PP",
"Enc.": "Obc.",
"ARMOUR-POINTS": "PUNKTY PANCERZA",
"Right Arm": "Prawe ramię",
"Left Arm": "Lewe ramię",
"Right Leg": "Prawa noga",
"Leg Left": "Lewa noga",
"WEAPONS": "BRONIE",
"Group": "Kategoria",
"Range/Reach": "Zasięg",
"Damage": "Obrażenia",
"Qualities": "Cechy oręża",
"Melee-Basic": "Broń Biała (Podstawowa)",
"Melee-Brawling": "Broń Biała (Bijatyka)",
"Melee-Cavalry": "Broń Biała (Kawaleryjska)",
"Melee-Fencing": "Broń Biała (Szermiercza)",
"Melee-Flail": "Broń Biała (Korbacze)",
"Melee-Parry": "Broń Biała (Parująca)",
"Melee-Pole-Arm": "Broń Biała (Drzewcowa)",
"Melee-2H": "Broń Biała (Dwuręczna)",
"Ranged-Blackpowder": "Broń Zasięg. (Prochowa)",
"Ranged-Bow": "Broń Zasięg. (Łuki)",
"Ranged-Crossbow": "Broń Zasięg. (Kusze)",
"Ranged-Engineering": "Broń Zasięg. (Eksperymentalna)",
"Ranged-Entangling": "Broń Zasięg. (Oplątująca)",
"Ranged-Explosives": "Broń Zasięg. (Materiały Wybuchowe)",
"Ranged-Sling": "Broń Zasięg. (Proce)",
"Ranged-Throwing": "Broń Zasięg. (Miotana)",
"Weapon-Skill": "Walka Wręcz",
"Ballistic-Skill": "Umiejętności Strzeleckie",
"SPELLS-AND-PRAYERS": "CZARY I MODLITWY",
"Extended-Channeling-SL": "Uzyskany PS Splatania",
"Sin-Points": "P. Grzechu",
"Type": "Rodzaj",
"CN": "PZ",
"Range": "Zasięg",
"Target": "Cel",
"Duration": "Czas",
"Effect": "Efekt",
"INJURIES-AFFLICTIONS-PYSCHOLOGY-&-MUTATIONS": "RANY, SCHORZENIA, PSYCHOLOGIA I MUTACJE",
"Current-Corruption": "Aktualne Zepsucie",
"Max-Corruption": "Maks. Zepsucie",
"Time": "Czas",
"Enc": "Obc",
"PERSONALITY": "OSOBOWOŚĆ",
"APPEARANCE": "WYGLĄD",
"CONTACTS/FRIENDS": "ZNAJOMOŚCI / PRZYJACIELE",
"ENEMIES": "WROGOWIE",
"HISTORY": "HISTORIA",
"NOTES": "NOTATKI",
"Experience-Points": "Punkty doświadczenia",
"Total-XP": "Suma PD",
"Spent-XP": "Wydane PD",
"Left-XP": "Pozostałe PD",
"Advancements-Taken-Calculated-p": "Wzięte Rozwinięcia (Policzone):",
"main": "Główna",
"skills-talent": "Umiej. i Talenty",
"gear-magic": "Wypos. i Magia",
"information": "Informacje",
"experience": "Doświadczenie",
"SBx3": "BSx3",
"SBx2": "BSx2",
"SB": "BS",
"TBx3": "BWtx3",
"TBx2": "BWtx2",
"TB": "BWt",
"WPBx3": "BSWx3",
"WPBx2": "BSWx2",
"WPB": "BSW"
} | {
"pile_set_name": "Github"
} |
@c-link: #e50053;
@c-body: #222;
@w-body: 612px;
@font-fancy: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
html {
overflow-y: scroll;
}
body {
text-rendering: optimizeLegibility;
color: @c-body;
position: relative;
a {
text-decoration: none;
color: @c-link;
&:hover {
text-decoration: underline;
}
}
h1, h2, h3, h4, h5, h6 {
font-family: @font-fancy;
font-weight: normal;
a {
color: @c-body;
&:hover {
color: @c-link;
text-decoration: none;
}
}
.amp {
font-style: italic;
}
}
h1 { font-size: 45px; line-height: 50px; margin: 25px 0; } // 3
h2 { font-size: 32px; line-height: 50px; margin: 25px 0; } // m7
h3 { font-size: 23px; line-height: 25px; margin: 25px 0; } // 3
h4 { font-size: 18px; line-height: 25px; margin: 25px 0; } // r
code, pre {
font-family: Consolas, Menlo, "Courier New", monospace;
font-size: 14px;
}
.codehilite {
code, pre {
font-family: Consolas, Menlo, "Courier New", monospace;
font-size: 16px;
line-height: 25px;
overflow-x: auto;
border: 1px solid #d5d5d5;
border-left: 10px solid #d5d5d5;
background-color: #fafafa;
padding: 11px 15px 12px;
margin-left: -25px;
}
pre::-webkit-scrollbar {
height: 25px;
}
pre::-webkit-scrollbar-button:start,
pre::-webkit-scrollbar-button:end {
display: none;
}
pre::-webkit-scrollbar-track-piece {
background-color: #eee;
}
pre::-webkit-scrollbar-thumb {
background-color: #bbb;
border: 7px solid #eee;
-webkit-background-clip: padding-box;
-webkit-border-radius: 12px;
}
}
p code, li code, table code {
border: 1px solid #ccc;
background-color: #fafafa;
font-size: 13px;
padding: 1px 3px;
line-height: 20px;
margin: 0;
white-space: nowrap;
}
.wrap {
width: @w-body;
margin: 0 auto;
margin-bottom: 5em;
.top {
header {
float: left;
font-family: @font-fancy;
font-size: 23px; // 3
line-height: 50px;
text-transform: lowercase;
padding-left: 2px;
width: 612px - 2px - 400px;
.amp {
font-style: italic;
}
a {
color: @c-body;
&:hover {
color: @c-link;
}
}
}
nav {
font: normal 18px/50px @font-fancy; // 1
text-align: right;
text-transform: lowercase;
padding-right: 2px;
width: 400px - 2px;
float: left;
.sep {
padding: 0 4px;
color: #666;
}
}
}
.hr {
margin-top: -12px;
margin-bottom: 12px + 25px;
height: 25px;
background: transparent url('/media/images/hr.png') top left no-repeat;
}
.hrb {
height: 25px;
margin-top: 50px;
background: transparent url('/media/images/hrb.png') top left no-repeat;
}
footer {
text-align: center;
p {
font-size: 14px;
font-style: italic;
line-height: 50px;
margin-bottom: 0px;
}
.rochester-made {
img {
opacity: 0.7;
padding: 5px 20px;
}
}
}
}
}
hr {
border: none;
background: #ccc;
height: 1px;
margin-bottom: 24px;
}
.splash {
@color: #454545;
color: @color;
text-align: center;
font: normal 27px/32px @font-fancy;
margin-bottom: -1px;
padding-top: 0;
p {
margin-bottom: 24px;
}
.amp {
font-style: italic;
}
.fn {
color: @color;
text-decoration: none;
&:hover {
color: @c-link;
text-decoration: none;
}
.last-name {
display: none;
}
}
}
.section-listing {
margin-bottom: -50px;
ol {
list-style-type: none;
@w-listing-item: 612px/2;
@w-listing-col-padding: 50px;
li {
float: left;
width: @w-listing-item - (@w-listing-col-padding / 2);
height: 150px;
margin: 0;
text-align: center;
a {
font: normal 23px/32px @font-fancy; // 3
color: @c-body;
display: block;
&:hover {
color: @c-link;
text-decoration: none;
}
}
span.snip {
font-size: 18px; // 1
color: #333;
font-family: @font-fancy;
line-height: 25px;
font-style: italic;
}
.amp {
font-style: italic;
}
&:nth-child(odd) {
margin-right: @w-listing-col-padding / 2;
}
&:nth-child(even) {
margin-left: @w-listing-col-padding / 2;
}
}
}
}
blockquote {
border: 1px solid #ccc;
background-color: #fafafa;
padding: 11px 15px 12px;
margin-left: 2em;
overflow: auto;
p:last-child {
margin-bottom: 0;
}
}
span.dquo {
margin-left: -0.23em;
}
#leaf-stats p {
color: #666;
margin-top: -22px;
margin-bottom: 22px;
}
#leaf-content {
img {
display: block;
margin: 25px auto 26px;
border: 11px solid #e5e5e5;
padding: 1px;
background: black;
max-width: 590px;
}
img.left, img.right {
border: none;
background: none;
padding: none;
}
img.left {
margin: 0 1.5em 1em 0;
}
img.right {
margin: 0 0 .75em 1em;
}
.gallery img {
background: none;
padding: 0;
border: none;
display: inline;
margin-bottom: 25px;
margin-right: 25px;
}
.toc {
ul {
list-style: none;
}
ul:first-child>li {
margin-left: 0em;
}
}
table {
padding: 0px;
margin-top: -8px;
margin-bottom: 25px;
tr {
margin: 0px;
padding: 0px;
td, th {
margin: 0px;
padding: 5px 5px;
line-height: 23px;
}
td {
border: 1px solid #666;
}
}
}
}
#leaf-content.with-diagrams img {
display: block;
margin: 25px auto;
padding: 0;
background: none;
border: none;
}
.print-links {
display: none;
}
img.self {
border: none;
padding: 0;
margin: 0;
margin-right: -108px;
margin-top: -15px;
margin-left: 30px;
margin-bottom: 20px;
}
div#cboxCurrent {
bottom: -30px;
font-size: 17px;
font-weight: normal;
left: 60px;
}
div.screenshots {
img {
max-width: 580px;
}
}
#scrolling-header {
color: #999;
font-size: 23px;
font-style: italic;
font: italic 23px @font-fancy;
line-height: 30px;
position: fixed;
top: 75px;
text-align: right;
width: 180px;
}
.flattr {
float: right;
padding-top: 1px;
}
| {
"pile_set_name": "Github"
} |
.lists > #users, .lists > #customers, .lists > #activities, .lists > #projects {
height:175px;
border-top:none;
z-index:1;
border:1px solid black;
margin:0;
padding:0;
background-color:#eee;
position:absolute;
overflow:auto;
left:10px;
}
#users_head, #customers_head, #projects_head, #activities_head {
border:1px solid black;
border-bottom:none;
position:absolute;
height:25px;
text-align:left;
color:#FFF;
left:10px;
font-size:11px;
font-weight:bold;
padding:3px 0 0 5px;
background: -moz-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ff3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(102,102,102,1)), color-stop(100%, rgba(51,51,51,1))); /* safari4+,chrome */
background: -webkit-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* safari5.1+,chrome10+ */
background: -o-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* opera 11.10+ */
background: -ms-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ie10+ */
background: linear-gradient(180deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* w3c */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#666666', endColorstr='#333333',GradientType=0 ); /* ie6-9 */
}
#users_foot, #customers_foot, #projects_foot, #activities_foot {
border:1px solid black;
border-top:none;
position:absolute;
height:20px;
text-align:left;
color:#FFF;
left:10px;
font-size:11px;
font-weight:bold;
padding:3px 0 0 5px;
background: -moz-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ff3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(102,102,102,1)), color-stop(100%, rgba(51,51,51,1))); /* safari4+,chrome */
background: -webkit-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* safari5.1+,chrome10+ */
background: -o-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* opera 11.10+ */
background: -ms-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ie10+ */
background: linear-gradient(180deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* w3c */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#666666', endColorstr='#333333',GradientType=0 ); /* ie6-9 */
}
#customersShrink {
cursor: pointer;
background-color:transparent;
background-image:url('grfx/customerShrink_left.png');
background-position:center;
background-repeat:no-repeat;
position:absolute;
font-size:1px;
line-height:1px;
width:10px;
height:100px;
left:10px;
z-index:31;
opacity: 0.8;
-moz-opacity: 0.8;
filter:alpha(opacity=80);
}
#usersShrink {
cursor: pointer;
background-color:transparent;
background-image:url('grfx/customerShrink_left.png');
background-position:center;
background-repeat:no-repeat;
position:absolute;
font-size:1px;
line-height:1px;
width:10px;
height:100px;
left:10px;
z-index:31;
opacity: 0.8;
-moz-opacity: 0.8;
filter:alpha(opacity=80);
}
#extensionShrink {
cursor: pointer;
background-color:transparent;
background-image:url('grfx/timeSheetShrink_up.png');
background-position:center;
background-repeat:no-repeat;
position:absolute;
font-size:1px;
line-height:1px;
width:500px;
height:10px;
left:10px;
z-index:30;
opacity: 0.8;
-moz-opacity: 0.8;
filter:alpha(opacity=80);
}
div#users>table>tbody>tr>td.annotation,
div#customers>table>tbody>tr>td.annotation,
div#projects>table>tbody>tr>td.annotation,
div#activities>table>tbody>tr>td.annotation {
border-right: none;
}
div#users td.option img,
div#customers td.option img,
div#projects td.option img,
div#activities td.option img
{
margin-top:2px;
}
div#users td.annotation,
div#customers td.annotation,
div#projects td.annotation,
div#activities td.annotation
{
width:60px;
text-align: right;
}
div#users td,
div#customers td,
div#projects td,
div#activities td
{
border-right:none;
}
a.addLink
{
background-image: url('grfx/add.png');
overflow:hidden;
display:block;
width:22px;
height:16px;
float:left;
margin-right:5px;
}
a.selectAllLink
{
background-image: url('grfx/select_all.png');
overflow:hidden;
display:block;
width:22px;
height:16px;
float:left;
margin-right:5px;
}
a.deselectAllLink
{
background-image: url('grfx/deselect_all.png');
overflow:hidden;
display:block;
width:22px;
height:16px;
float:left;
margin-right:5px;
}
a.selectInvertLink
{
background-image: url('grfx/invert_select.png');
overflow:hidden;
display:block;
width:22px;
height:16px;
float:left;
margin-right:5px;
}
.livefilterfield {
float:right;
border:1px solid #555;
height:12px;
margin:0;
padding:1px;
margin-left:10px;
margin-right:8px;
color:#fff;
font-size:9px;
background: -moz-linear-gradient(270deg, rgba(136,136,136,1) 0%, rgba(96,96,96,1) 100%); /* ff3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(136,136,136,1)), color-stop(100%, rgba(96,96,96,1))); /* safari4+,chrome */
background: -webkit-linear-gradient(270deg, rgba(136,136,136,1) 0%, rgba(96,96,96,1) 100%); /* safari5.1+,chrome10+ */
background: -o-linear-gradient(270deg, rgba(136,136,136,1) 0%, rgba(96,96,96,1) 100%); /* opera 11.10+ */
background: -ms-linear-gradient(270deg, rgba(136,136,136,1) 0%, rgba(96,96,96,1) 100%); /* ie10+ */
background: linear-gradient(180deg, rgba(136,136,136,1) 0%, rgba(96,96,96,1) 100%); /* w3c */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#888888', endColorstr='#606060',GradientType=0 ); /* ie6-9 */
}
.livefilterfield:focus {
background: #fff;
color:#333;
}
.highlightProjectForPreselection td
{
background: #C5E6C3 !important;
cursor:pointer !important;
font-weight:bold;
}
.filterProjectForPreselection td
{
background: #64BE5E !important;
}
.ids {
width:25px;
color:#C4C4C4;
display:block;
float:left;
}
.filterProjectForPreselection td .ids {
color:#4D9247 !important;
}
.TableRowInvisible {
display:none;
}
.lighter {
color:#777;
}
/* below two definitions still used? */
.error {
padding: 5px;
color: #f00;
font-weight: bold;
}
.floater_content .error {
font-size: 13px;
}
div.lists table {
border-collapse: collapse;
font-size: 11px;
color: #363636;
border-bottom:1px solid #888;
}
div.lists table a {
text-decoration: none;
}
div.lists table a.preselect_lnk {
color: #363636;
text-decoration:none;
border-bottom:1px dotted #bbb;
}
div.lists table a:hover {
color: #0F9E00;
border-bottom:none;
}
div.lists table thead {
height:25px;
text-align:left;
color:#FFF;
}
div.lists table thead th {
background: -moz-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ff3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(102,102,102,1)), color-stop(100%, rgba(51,51,51,1))); /* safari4+,chrome */
background: -webkit-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* safari5.1+,chrome10+ */
background: -o-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* opera 11.10+ */
background: -ms-linear-gradient(270deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* ie10+ */
background: linear-gradient(180deg, rgba(102,102,102,1) 0%, rgba(51,51,51,1) 100%); /* w3c */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#666666', endColorstr='#333333',GradientType=0 ); /* ie6-9 */
}
div.lists tr.even td,
div.lists tr.odd td
{
border-bottom: none;
border-left: none;
border-right: 1px dotted #CCC;
padding: 3px 4px 4px 5px;
}
div.lists tr.hover td {
background: #FFC !important;
}
div.lists tr.even td {
background: #FFF;
}
div.lists tr.odd td {
background: #EEE;
}
.fhighlighted td {
background: #89C0F3 !important;
} | {
"pile_set_name": "Github"
} |
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package sagemakerruntime provides the client and types for making API
// requests to Amazon SageMaker Runtime.
//
// The Amazon SageMaker runtime API.
//
// See https://docs.aws.amazon.com/goto/WebAPI/runtime.sagemaker-2017-05-13 for more information on this service.
//
// See sagemakerruntime package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/sagemakerruntime/
//
// Using the Client
//
// To contact Amazon SageMaker Runtime with the SDK use the New function to create
// a new service client. With that client you can make API requests to the service.
// These clients are safe to use concurrently.
//
// See the SDK's documentation for more information on how to use the SDK.
// https://docs.aws.amazon.com/sdk-for-go/api/
//
// See aws.Config documentation for more information on configuring SDK clients.
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
//
// See the Amazon SageMaker Runtime client SageMakerRuntime for more
// information on creating client for this service.
// https://docs.aws.amazon.com/sdk-for-go/api/service/sagemakerruntime/#New
package sagemakerruntime
| {
"pile_set_name": "Github"
} |
cmake_minimum_required(VERSION 2.8.3)
project(prune_pointcloud)
add_definitions(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
tf
sensor_msgs
pcl_conversions
pcl_ros
geometry_msgs
)
catkin_package(
INCLUDE_DIRS include
)
add_executable(prune_node src/prune_node.cc src/prune.cc)
include_directories(
include
${catkin_INCLUDE_DIRS}
${Eigen_INCLUDE_DIRS}
)
target_link_libraries(prune_node
${catkin_LIBRARIES}
)
| {
"pile_set_name": "Github"
} |
Delfi 5.4 - 2008/07/24
Chess engine for Winboard/UCI.
For more info: http://www.msbsoftware.it/delfi
Requirements:
Delfi 5.4 requires a CPU with MMX extensions.
Installation:
1) To play with the Winboard version ("Delfi.exe") you need
to download and configure Winboard:
http://www.tim-mann.org/xboard.html
2) To play with a UCI chessboard (Fritz, Arena, Chessbase, etc.)
see your chessboard instructions.
Easy levels:
To set a easy level modify the file Delfi.ini, (standard version
is limited to 1000 ELO or full strength).
Parallel version:
To enable parallel processing on dual core processors set
the option CPU_THREADS in Delfi.ini
Author:
Dr. Fabio Cavicchio.
All right reserved.
| {
"pile_set_name": "Github"
} |
---
title: "Configuring Transmit"
description: ""
menu:
riak_cs-2.1.0:
name: "Configuring Transmit"
identifier: "config_transmit"
weight: 104
parent: "api_s3"
project: "riak_cs"
project_version: "2.1.0"
aliases:
- /riakcs/2.1.0/cookbooks/configuration/Configuring-Transmit/
- /riak/cs/2.1.0/cookbooks/configuration/Configuring-Transmit/
---
[Transmit](https://www.panic.com/transmit/) is an S3-compatible client with a
graphical user interface for Mac OS X. The following guide describes configuration of Transmit for use with Riak CS.
{{% note title="Note" %}}
S3 support was added in Transmit version 4.4, so ensure that you're following
along with a version that supports S3 before continuing.
{{% /note %}}
## Define a Connection
When Transmit is started, a new connection window appears. Ensure that you've
selected the **S3** tab, then complete the details in the **Connect to S3**
dialog as follows:
* **Server** --- Enter the fully qualified domain name of the Riak CS server here. Be sure that this matches the value specified for `cs_root_host` in the Riak CS `app.config`.
* **Access Key ID** --- Enter the Access Key ID (`key_id`) for the user account you will use to connect to Riak CS.
* **Secret** --- Enter the Access Key Secret (`key_secret`) matching the user account you entered for the Access Key ID above.
* **Initial Path** --- If you're connecting to a Riak CS instance with existing buckets to which the user account has access, you can optionally enter a specific bucket name to use for this connection here.
Defining a connection looks like this:

> **Note**
>
> Transmit expects a secure connection, so ensure that your Riak CS proxy server is configured with SSL support. For information on configuring a software solution like HAProxy with SSL for use with Riak CS, see [Load Balancing and Proxy Configuration](/riak/cs/2.1.0/cookbooks/configuration/load-balancing-proxy).
Finally, test the connection to Riak CS by clicking **Connect**.
## Create a Bucket
After successfully connecting to Riak CS, verify that you can create a bucket.
1. From the **File** menu, select **New Bucket...**
2. In the bucket creation dialog, enter the name of the new bucket
3. Click **Create**
The new bucket creation dialog looks like this:

The newly created bucket is listed in the right hand pane of the Transmit interface:

## Copy Files
Now that you've created a bucket, you can perform a basic file copy test.
Double-click the bucket icon in the right hand pane of the Transmit interface
to access the bucket.
Drag and drop one or more files to the right hand pane to initiate
copying of the files to the bucket.
After copying, the files will appear in the bucket:

You have now successfully configured a Transmit connection to Riak CS and
verified basic file copying capabilities.
| {
"pile_set_name": "Github"
} |
"use strict";
var vows = require('vows')
, assert = require('assert')
, sandbox = require('sandboxed-module')
, log4js = require('../lib/log4js')
, realLayouts = require('../lib/layouts')
, setupLogging = function(options, category, compressedLength) {
var fakeDgram = {
sent: false,
socket: {
packetLength: 0,
closed: false,
close: function() {
this.closed = true;
},
send: function(pkt, offset, pktLength, port, host) {
fakeDgram.sent = true;
this.packet = pkt;
this.offset = offset;
this.packetLength = pktLength;
this.port = port;
this.host = host;
}
},
createSocket: function(type) {
this.type = type;
return this.socket;
}
}
, fakeZlib = {
gzip: function(objectToCompress, callback) {
fakeZlib.uncompressed = objectToCompress;
if (this.shouldError) {
callback({ stack: "oh noes" });
return;
}
if (compressedLength) {
callback(null, { length: compressedLength });
} else {
callback(null, "I've been compressed");
}
}
}
, exitHandler
, fakeConsole = {
error: function(message) {
this.message = message;
}
}
, fakeLayouts = {
layout: function(type, options) {
this.type = type;
this.options = options;
return realLayouts.messagePassThroughLayout;
},
messagePassThroughLayout: realLayouts.messagePassThroughLayout
}
, appender = sandbox.require('../lib/appenders/gelf', {
requires: {
dgram: fakeDgram,
zlib: fakeZlib,
'../layouts': fakeLayouts
},
globals: {
process: {
on: function(evt, handler) {
if (evt === 'exit') {
exitHandler = handler;
}
}
},
console: fakeConsole
}
});
log4js.clearAppenders();
log4js.addAppender(appender.configure(options || {}), category || "gelf-test");
return {
dgram: fakeDgram,
compress: fakeZlib,
exitHandler: exitHandler,
console: fakeConsole,
layouts: fakeLayouts,
logger: log4js.getLogger(category || "gelf-test")
};
};
vows.describe('log4js gelfAppender').addBatch({
'with default gelfAppender settings': {
topic: function() {
var setup = setupLogging();
setup.logger.info("This is a test");
return setup;
},
'the dgram packet': {
topic: function(setup) {
return setup.dgram;
},
'should be sent via udp to the localhost gelf server': function(dgram) {
assert.equal(dgram.type, "udp4");
assert.equal(dgram.socket.host, "localhost");
assert.equal(dgram.socket.port, 12201);
assert.equal(dgram.socket.offset, 0);
assert.ok(dgram.socket.packetLength > 0, "Received blank message");
},
'should be compressed': function(dgram) {
assert.equal(dgram.socket.packet, "I've been compressed");
}
},
'the uncompressed log message': {
topic: function(setup) {
var message = JSON.parse(setup.compress.uncompressed);
return message;
},
'should be in the gelf format': function(message) {
assert.equal(message.version, '1.1');
assert.equal(message.host, require('os').hostname());
assert.equal(message.level, 6); //INFO
<<<<<<< HEAD
assert.equal(message.facility, 'nodejs-server');
assert.equal(message.short_message, 'This is a test');
=======
assert.equal(message.full_message, message.short_message);
assert.equal(message.full_message, 'This is a test');
>>>>>>> 52b4aa18746bbc7608f892d49c0f0b18a79fc846
}
}
},
'with a message longer than 8k': {
topic: function() {
var setup = setupLogging(undefined, undefined, 10240);
setup.logger.info("Blah.");
return setup;
},
'the dgram packet': {
topic: function(setup) {
return setup.dgram;
},
'should not be sent': function(dgram) {
assert.equal(dgram.sent, false);
}
}
},
'with non-default options': {
topic: function() {
var setup = setupLogging({
host: 'somewhere',
port: 12345,
hostname: 'cheese',
facility: 'nonsense'
});
setup.logger.debug("Just testing.");
return setup;
},
'the dgram packet': {
topic: function(setup) {
return setup.dgram;
},
'should pick up the options': function(dgram) {
assert.equal(dgram.socket.host, 'somewhere');
assert.equal(dgram.socket.port, 12345);
}
},
'the uncompressed packet': {
topic: function(setup) {
var message = JSON.parse(setup.compress.uncompressed);
return message;
},
'should pick up the options': function(message) {
assert.equal(message.host, 'cheese');
assert.equal(message._facility, 'nonsense');
}
}
},
'on process.exit': {
topic: function() {
var setup = setupLogging();
setup.exitHandler();
return setup;
},
'should close open sockets': function(setup) {
assert.isTrue(setup.dgram.socket.closed);
}
},
'on zlib error': {
topic: function() {
var setup = setupLogging();
setup.compress.shouldError = true;
setup.logger.info('whatever');
return setup;
},
'should output to console.error': function(setup) {
assert.equal(setup.console.message, 'oh noes');
}
},
'with layout in configuration': {
topic: function() {
var setup = setupLogging({
layout: {
type: 'madeuplayout',
earlgrey: 'yes, please'
}
});
return setup;
},
'should pass options to layout': function(setup) {
assert.equal(setup.layouts.type, 'madeuplayout');
assert.equal(setup.layouts.options.earlgrey, 'yes, please');
}
},
'with custom fields options': {
topic: function() {
var setup = setupLogging({
host: 'somewhere',
port: 12345,
hostname: 'cheese',
facility: 'nonsense',
customFields: {
_every1: 'Hello every one',
_every2: 'Hello every two'
}
});
var myFields = {
GELF: true,
_every2: 'Overwritten!',
_myField: 'This is my field!'
};
setup.logger.debug(myFields, "Just testing.");
return setup;
},
'the dgram packet': {
topic: function(setup) {
return setup.dgram;
},
'should pick up the options': function(dgram) {
assert.equal(dgram.socket.host, 'somewhere');
assert.equal(dgram.socket.port, 12345);
}
},
'the uncompressed packet': {
topic: function(setup) {
var message = JSON.parse(setup.compress.uncompressed);
return message;
},
'should pick up the options': function(message) {
assert.equal(message.host, 'cheese');
assert.equal(message._facility, 'nonsense');
assert.equal(message._every1, 'Hello every one'); // the default value
assert.equal(message._every2, 'Overwritten!'); // the overwritten value
assert.equal(message._myField, 'This is my field!'); // the value for this message only
assert.equal(message.short_message, 'Just testing.'); // skip the field object
}
}
}
}).export(module);
| {
"pile_set_name": "Github"
} |
(** A process module processes entries. It is parameterized by an environment. *)
(** {1 How to use processors} *)
(** As a user of the API of Dedukti, processors are the main entry point.
The point of processors is to handle automatically inputs and files for you.
The API of Dedukti has already defined 5 processors for you, but you are free
to define more. This 5 processors are:
- TypeChecker : to type check the input
- SignatureBuilder : to construct a signature without type checking it
- Printer : to pretty print the input
- Dependencies : Compute dependencies of the input
- TopLevel : TypeCheck and prints and standard output
Processors should be used through the methods:
- handle_input : to process one input
- handle_files : to process a set of files
- fold_files : to process a set of files and fold the results
Mose of the time, we want to apply some operations before processing one
file and some operations after. To do so, the API declares a type [hook]
that can be given optionaly to the functions mentioned above.
In particular, a hook allows to handle errors that may have been raised
by the processor. By default, any error raised by the processor stops
the execution of the processor and are pretty printed via the module [Errors].
This applies also for errors generated at parsing/scoping time for the functions
which handle files.
We also recall that for [handle_input], a processor consumes an [input]. As such,
the [input] will not be reusable once it has been processed. This is because a
Dedukti [input] is an abstraction for a stream of [Entry.entry].
If you want to create your own processor, we invite you to go to Section {2} of
this documentation.
*)
(** Each constructor corresponds to a processor. This type is extensible so that
we can use this API with your own processors. *)
type _ t = ..
type _ t +=
| TypeChecker : unit t (** TypeCheck *)
| SignatureBuilder : Kernel.Signature.t t (** Build a signature without type checking *)
| PrettyPrinter : unit t (** Pretty print *)
| Dependencies : Dep.t t (** Compute dependencies *)
| TopLevel : unit t (** TypeCheck and prints result on standard output *)
(** This is the type of errors returned by a processor *)
type processor_error = Env.t * Kernel.Basic.loc * exn
(** To hook an input before and after it is being processed *)
type hook =
{
before : Env.t -> unit ;
(** hook_before is executed by the processor before processing the input *)
after : Env.t -> processor_error option -> unit
(** hook_after is executed by the processor after processing the output *)
}
module type Interface =
sig
type 'a t
val handle_input : Parsers.Parser.input -> ?hook:hook -> 'a t -> 'a
(** [handle_input input hook processor] applies the processor [processor]
on the [input]. [hook.hook_before] is executed once before the processor
and [hook.hook_after] is executed once after the processor.
By default (without hooks), if an exception [exn] has been raised while
processing the data it is raised at top-level. *)
val handle_files : string list -> ?hook:hook -> 'a t -> 'a
(** [handle_files files hook processor] apply a processor on each file of [files].
[hook] is used once by file. The result is the one given once each file has
been processed. *)
val fold_files : string list -> ?hook:hook -> f:('a -> 'b -> 'b) -> default:'b ->'a t -> 'b
end
include Interface with type 'a t := 'a t
(** [fold_files files fold default processor] is similar to [handle_files]
except that the result of a processor is given to the function [fold] every
time a file is processed. *)
(** {2 Implement its own processor} *)
(** The type [t] given above hides the complexity of a processor. Under the hood,
a processor is actually a module of type [S] (see below). This module declares
one type and two function. The type [S.t] is the type of the result computed by
the processor. It is the same as ['a] in ['a t], the type declared above.
For example, the processor [Dependencies] as type [Deps.t t]. It is implemented
by a module of type [S] where [S.t = Deps.t].
A processor acts on top-level commands of Dedukti which are represented by the
type [Parsers.Entry.entry] and are paremeterized by an environement [Env.t].
The module [Env] is the view of the API of the kernel of Dedukti. The type [Env.t]
are paremeters for the kernel. In particular, it knows where to look for the next
[entry], how to reduce a term, how to type check a term etc...
Hence, a processor implements a function [handle_entry env entry] which is
called successively on each entry (if no exception are triggered).
Finally, to get the result of a processor, we use the function [get_data env].
These are the three things you need to define to declare a new processor.
Once your processor has been defined, to be able to use the API above, you need
to register you processor. The registration step is actually really easy.
To register a processor, you need to do three things.
1. First, you need to extend the type [t] with a new constructor for your processor
2. Declare a trivial equality function for your new constructor (see below)
3. Call the Register function with your new constructor, your processor (as a module) and
your equality function.
If you look at the type of the equality function and the register function it seems ugly.
To understand how it works, we will give you an example. Assume your new processor is
a module [Foo] such that [Foo.t = foo]. Then for the first step you do :
type _ t += Foo : foo t
For the second step you declare the following function
let equal_foo (type a b) : (a t * b t) -> (a t,b t) Registration.equal option =
function
| Foo, Foo -> Some (Registration.Refl (Foo))
| _ -> None
For the third step you call the registration function this way :
let () = Registration.register_processor Foo {equal = equal_foo} (module Foo);
And then you are ready to go!
The current version allows you to shadow a previously known [Processor], be careful with that.
Finally, in this section we declare an [of pure] function which allows you to define a processor
by calling a function and without using the syntax of modules.
*)
(** The actual type of the processor as a module *)
module type S =
sig
type t
(** result type of the processor *)
val handle_entry : Env.t -> Parsers.Entry.entry -> unit
(** [handle_entry env entry] processed the entry [entry] in the environment [env] *)
val get_data : Env.t -> t
(** [get_data ()] returns the data computed by the current processor *)
end
module Registration :
sig
exception Not_registered_processor
(** raise by get_processor if the processor has not be registered *)
(** we used GADTs of OCaml to declare an equality type *)
type (_,_) equal =
| Refl : 'a -> ('a,'a) equal
(** This record uses polymorism of rank 2. This is because internally we need to compare
values of types ['a t] and ['b t]. Hence the "for all quantifier" on types cannot be
in prenex form in the function [register_processor]. We use the GADT above to keep
track of the dependency. *)
type equality =
{
equal: 'a 'b. ('a t * 'b t) -> ('a t,'b t) equal option
}
(** [register_processor processor f_eq (module P) associate the [processor] to the module [P].
ASSERT: f_eq processor processor = (Some Refl processor)
ASSERT: f_eq _ _ = None *)
val register_processor : 'a t -> equality -> (module S with type t = 'a) -> unit
end
val get_processor : 'a t -> (module S with type t = 'a)
(** [get_processor processor] returns the module associated to the processor.
Raise [Not_registered_processor] if the processor has not been registered. *)
val of_pure : f:('a -> Env.t -> Parsers.Entry.entry -> 'a) -> init:'a
-> (module S with type t = 'a)
(** [of_pure ~f ~init] returns processor from the fold-like function [f]. [f acc
env ent] folds entry [ent] on accumulator [acc] in environment [env]. *)
module T : Interface with type 'a t := (module S with type t = 'a)
(** {3 Define processors with a custom environement} *)
(** It may be possible that for the default processors defined in this API,
you want to use them with another module [Env] (for example for debugging or
to hook yourself in one of the functions declared by the module). This is
possible using the functors below. For your custom processors, this is not
needed because you can already do it. The only requirement is to keep the same
[Env.t] type. *)
module type CustomEnv = (module type of Env) with type t = Env.t
module MakeTypeChecker(E:CustomEnv) : S with type t = unit
module MakeSignatureBuilder(E:CustomEnv) : S with type t = Kernel.Signature.t
module MakeEntryPrinter(E:CustomEnv) : S with type t = unit
module MakeDependencies(E:CustomEnv) : S with type t = Dep.t
| {
"pile_set_name": "Github"
} |
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "xrtl/gfx/es3/es3_pixel_format.h"
namespace xrtl {
namespace gfx {
namespace es3 {
bool ConvertPixelFormatToTextureParams(PixelFormat pixel_format,
ES3TextureParams* out_texture_params) {
static const ES3TextureParams kTable[] = {
{GL_NONE, GL_NONE, GL_NONE}, // kUndefined
//
{GL_RGBA4, GL_RGBA, GL_UNSIGNED_BYTE}, // kR4G4B4A4UNorm
{GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5}, // kR5G6B5UNorm
{GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1}, // kR5G5B5A1UNorm
//
{GL_R8, GL_RED, GL_UNSIGNED_BYTE}, // kR8UNorm
{GL_R8_SNORM, GL_RED, GL_BYTE}, // kR8SNorm
{GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE}, // kR8UInt
{GL_R8I, GL_RED_INTEGER, GL_BYTE}, // kR8SInt
//
{GL_RG8, GL_RG, GL_UNSIGNED_BYTE}, // kR8G8UNorm
{GL_RG8_SNORM, GL_RG, GL_BYTE}, // kR8G8SNorm
{GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE}, // kR8G8UInt
{GL_RG8I, GL_RG_INTEGER, GL_BYTE}, // kR8G8SInt
//
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // kR8G8B8A8UNorm
{GL_RGBA8_SNORM, GL_RGBA, GL_BYTE}, // kR8G8B8A8SNorm
{GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE}, // kR8G8B8A8UInt
{GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE}, // kR8G8B8A8SInt
{GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, // kR8G8B8A8Srgb
//
{GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE}, // kB8G8R8A8UNorm
{GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE}, // kB8G8R8A8Srgb
//
{GL_RGB10_A2, GL_RGBA, //
GL_UNSIGNED_INT_2_10_10_10_REV}, // kA2B10G10R10UNorm
{GL_RGB10_A2, GL_RGBA, //
GL_UNSIGNED_INT_2_10_10_10_REV}, // kA2B10G10R10SNorm
{GL_RGB10_A2UI, GL_RGBA_INTEGER, //
GL_UNSIGNED_INT_2_10_10_10_REV}, // kA2B10G10R10UInt
{GL_RGB10_A2UI, GL_RGBA_INTEGER, //
GL_UNSIGNED_INT_2_10_10_10_REV}, // kA2B10G10R10SInt
//
{GL_R16F, GL_RED, GL_HALF_FLOAT}, // kR16UNorm
{GL_R16F, GL_RED, GL_HALF_FLOAT}, // kR16SNorm
{GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT}, // kR16UInt
{GL_R16I, GL_RED_INTEGER, GL_SHORT}, // kR16SInt
{GL_R16F, GL_RED, GL_HALF_FLOAT}, // kR16SFloat
//
{GL_RG16F, GL_RG, GL_HALF_FLOAT}, // kR16G16UNorm
{GL_RG16F, GL_RG, GL_HALF_FLOAT}, // kR16G16SNorm
{GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT}, // kR16G16UInt
{GL_RG16I, GL_RG_INTEGER, GL_SHORT}, // kR16G16SInt
{GL_RG16F, GL_RG, GL_HALF_FLOAT}, // kR16G16SFloat
//
{GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}, // kR16G16B16A16UNorm
{GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}, // kR16G16B16A16SNorm
{GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT}, // kR16G16B16A16UInt
{GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT}, // kR16G16B16A16SInt
{GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT}, // kR16G16B16A16SFloat
//
{GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT}, // kR32UInt
{GL_R32I, GL_RED_INTEGER, GL_INT}, // kR32SInt
{GL_R32F, GL_RED, GL_FLOAT}, // kR32SFloat
//
{GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT}, // kR32G32UInt
{GL_RG32I, GL_RG_INTEGER, GL_INT}, // kR32G32SInt
{GL_RG32F, GL_RG, GL_FLOAT}, // kR32G32SFloat
//
{GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT}, // kR32G32B32UInt
{GL_RGB32I, GL_RGB_INTEGER, GL_INT}, // kR32G32B32SInt
{GL_RGB32F, GL_RGB, GL_FLOAT}, // kR32G32B32SFloat
//
{GL_R32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT}, // kR32G32B32A32UInt
{GL_RGBA32I, GL_RGBA_INTEGER, GL_INT}, // kR32G32B32A32SInt
{GL_RGBA32F, GL_RGBA, GL_FLOAT}, // kR32G32B32A32SFloat
//
{GL_R11F_G11F_B10F, GL_RGB, //
GL_UNSIGNED_INT_10F_11F_11F_REV}, // kB10G11R11UFloat
{GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV}, // kE5B9G9R9UFloat
//
{GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}, // kD32SFloat
{GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, //
GL_UNSIGNED_INT_24_8}, // kD24UNormS8UInt
{GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, //
GL_FLOAT_32_UNSIGNED_INT_24_8_REV}, // kD32SFloatS8UInt
//
{GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_NONE}, // kBC1RGBAUNorm
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV, GL_RGBA, //
GL_NONE}, // kBC1RGBASrgb
{GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_NONE}, // kBC2UNorm
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV, GL_RGBA, GL_NONE}, // kBC2Srgb
{GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_NONE}, // kBC3UNorm
{GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV, GL_RGBA, GL_NONE}, // kBC3Srgb
{GL_NONE, GL_NONE, GL_NONE}, // kBC4UNorm
{GL_NONE, GL_NONE, GL_NONE}, // kBC4SNorm
{GL_NONE, GL_NONE, GL_NONE}, // kBC5UNorm
{GL_NONE, GL_NONE, GL_NONE}, // kBC5SNorm
{GL_NONE, GL_NONE, GL_NONE}, // kBC6HUFloat
{GL_NONE, GL_NONE, GL_NONE}, // kBC6HSFloat
{GL_NONE, GL_NONE, GL_NONE}, // kBC7UNorm
{GL_NONE, GL_NONE, GL_NONE}, // kBC7Srgb
//
{GL_COMPRESSED_RGB8_ETC2, GL_RGB, GL_NONE}, // kEtc2R8G8B8UNorm
{GL_COMPRESSED_SRGB8_ETC2, GL_RGB, GL_NONE}, // kEtc2R8G8B8Srgb
{GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_RGBA, //
GL_NONE}, // kEtc2R8G8B8A1UNorm
{GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_RGBA, //
GL_NONE}, // kEtc2R8G8B8A1Srgb
{GL_COMPRESSED_RGBA8_ETC2_EAC, GL_RGBA, GL_NONE}, // kEtc2R8G8B8A8UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_RGBA, //
GL_NONE}, // kEtc2R8G8B8A8Srgb
//
{GL_COMPRESSED_R11_EAC, GL_RED, GL_NONE}, // kEacR11UNorm
{GL_COMPRESSED_SIGNED_R11_EAC, GL_RED, GL_NONE}, // kEacR11SNorm
{GL_COMPRESSED_RG11_EAC, GL_RG, GL_NONE}, // kEacR11G11UNorm
{GL_COMPRESSED_SIGNED_RG11_EAC, GL_RED, GL_NONE}, // kEacR11G11SNorm
//
{GL_COMPRESSED_RGBA_ASTC_4x4, GL_RGBA, GL_NONE}, // kAstc4x4UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4, GL_RGBA, GL_NONE}, // kAstc4x4Srgb
{GL_COMPRESSED_RGBA_ASTC_5x4, GL_RGBA, GL_NONE}, // kAstc5x4UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4, GL_RGBA, GL_NONE}, // kAstc5x4Srgb
{GL_COMPRESSED_RGBA_ASTC_5x5, GL_RGBA, GL_NONE}, // kAstc5x5UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5, GL_RGBA, GL_NONE}, // kAstc5x5Srgb
{GL_COMPRESSED_RGBA_ASTC_6x5, GL_RGBA, GL_NONE}, // kAstc6x5UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5, GL_RGBA, GL_NONE}, // kAstc6x5Srgb
{GL_COMPRESSED_RGBA_ASTC_6x6, GL_RGBA, GL_NONE}, // kAstc6x6UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6, GL_RGBA, GL_NONE}, // kAstc6x6Srgb
{GL_COMPRESSED_RGBA_ASTC_8x5, GL_RGBA, GL_NONE}, // kAstc8x5UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5, GL_RGBA, GL_NONE}, // kAstc8x5Srgb
{GL_COMPRESSED_RGBA_ASTC_8x6, GL_RGBA, GL_NONE}, // kAstc8x6UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6, GL_RGBA, GL_NONE}, // kAstc8x6Srgb
{GL_COMPRESSED_RGBA_ASTC_8x8, GL_RGBA, GL_NONE}, // kAstc8x8UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8, GL_RGBA, GL_NONE}, // kAstc8x8Srgb
{GL_COMPRESSED_RGBA_ASTC_10x5, GL_RGBA, GL_NONE}, // kAstc10x5UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5, GL_RGBA, //
GL_NONE}, // kAstc10x5Srgb
{GL_COMPRESSED_RGBA_ASTC_10x6, GL_RGBA, GL_NONE}, // kAstc10x6UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6, GL_RGBA, //
GL_NONE}, // kAstc10x6Srgb
{GL_COMPRESSED_RGBA_ASTC_10x8, GL_RGBA, GL_NONE}, // kAstc10x8UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8, GL_RGBA, //
GL_NONE}, // kAstc10x8Srgb
{GL_COMPRESSED_RGBA_ASTC_10x10, GL_RGBA, GL_NONE}, // kAstc10x10UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10, GL_RGBA, //
GL_NONE}, // kAstc10x10Srgb
{GL_COMPRESSED_RGBA_ASTC_12x10, GL_RGBA, GL_NONE}, // kAstc12x10UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10, GL_RGBA, //
GL_NONE}, // kAstc12x10Srgb
{GL_COMPRESSED_RGBA_ASTC_12x12, GL_RGBA, GL_NONE}, // kAstc12x12UNorm
{GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12, GL_RGBA, //
GL_NONE}, // kAstc12x12Srgb
};
static const PixelFormatTable<ES3TextureParams, PixelFormats::kUndefined,
PixelFormats::kAstc12x12Srgb>
kLookupTable(kTable);
const auto& texture_params = kLookupTable.Find(pixel_format.unique_id());
if (texture_params.internal_format == GL_NONE) {
return false;
}
*out_texture_params = texture_params;
return true;
}
} // namespace es3
} // namespace gfx
} // namespace xrtl
| {
"pile_set_name": "Github"
} |
package java.lang;
public class String {
interface FunctionalIf {
public int f(int x);
}
public static int usesLambdas(int x) {
FunctionalIf lambda = (n -> n + 1);
return lambda.f(x);
}
}
| {
"pile_set_name": "Github"
} |
# WebDNN examples
This directory contains some examples to illustrate typical usage of WebDNN.
## Common setup
Before running these examples, you have to install `webdnn` python library and start a HTTP server on the repository root directory.
You can run a HTTP server with standard python feature.
```
python -m http.server
```
## List of Examples
### MNIST training and conversion
`mnist` directory contains the example to train and convert a DNN for classifying the MNIST dataset.
### SqueezeNet model conversion
`squeeze_net` directory contains the example to convert the pre-trained SqueezeNet image classification DNN for WebDNN.
### ResNet-50 model conversion
`resnet` directory contains the example to convert the pre-trained ResNet-50 large-scale image classification DNN for WebDNN.
### Caffe model conversion
`convert_caffe` directory contains the example to convert the CaffeNet large-scale DNN for WebDNN.
This example illustrates how to use Caffe model for WebDNN.
### Neural Style Transfer
`neural_style_transfer` directory contains the example to convert the [Neural Style Transfer model](https://github.com/gafr/chainer-fast-neuralstyle-models) for WebDNN.
This is intended to be example of interactive application.
### Sentence sentiment classification
`lstm` directory contains the example to train and convert LSTM-based model to classify sentiments of movie reviews.
This example illustrates how to use LSTM model.
### Text generation
`text_generation` directory contains the example to convert LSTM-based text generation model to generate text like Nietzsche.
This example illustrates how to iteratively predict character probability and sample a character.
### Benchmark
`benchmark` directory contains the speed benchmark to compare WebDNN with other frameworks.
| {
"pile_set_name": "Github"
} |
---
layout: news_item
title: "Jekyll 1.0.4 Released"
date: "2013-07-25 09:08:38 +0200"
author: mattr-
version: 1.0.4
categories: [release]
---
Version 1.0.4 fixes a minor, but nonetheless important security vulnerability affecting several third-party Jekyll plugins. If your Jekyll site does not use plugins, you may, but are not required to upgrade at this time.
Community and custom plugins extending the `Liquid::Drop` class may inadvertently disclose some system information such as directory structure or software configuration to users with access to the Liquid templating system.
We recommend you upgrade to Jekyll v1.0.4 immediately if you use `Liquid::Drop` plugins on your Jekyll site.
Many thanks for [Ben Balter](https://github.com/benbalter) for alerting us to the problem
and [submitting a patch][1349] so quickly.
[230]: https://github.com/Shopify/liquid/pull/230
[1349]: {{ site.repository }}/issues/1349
| {
"pile_set_name": "Github"
} |
# Copyright 2018 The Cornac 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.
# ============================================================================
import os
import copy
from tqdm.auto import trange
from ..recommender import Recommender
from ...exception import ScoreException
from ...utils import get_rng
class NCFBase(Recommender):
"""Base class of NCF family.
Parameters
----------
num_epochs: int, optional, default: 20
Number of epochs.
batch_size: int, optional, default: 256
Batch size.
num_neg: int, optional, default: 4
Number of negative instances to pair with a positive instance.
lr: float, optional, default: 0.001
Learning rate.
learner: str, optional, default: 'adam'
Specify an optimizer: adagrad, adam, rmsprop, sgd
early_stopping: {min_delta: float, patience: int}, optional, default: None
If `None`, no early stopping. Meaning of the arguments:
- `min_delta`: the minimum increase in monitored value on validation set to be considered as improvement, \
i.e. an increment of less than min_delta will count as no improvement.
- `patience`: number of epochs with no improvement after which training should be stopped.
name: string, optional, default: 'NCF'
Name of the recommender model.
trainable: boolean, optional, default: True
When False, the model is not trained and Cornac assumes that the model is already \
pre-trained.
verbose: boolean, optional, default: False
When True, some running logs are displayed.
References
----------
* He, X., Liao, L., Zhang, H., Nie, L., Hu, X., & Chua, T. S. (2017, April). Neural collaborative filtering. \
In Proceedings of the 26th international conference on world wide web (pp. 173-182).
"""
def __init__(
self,
name="NCF",
num_epochs=20,
batch_size=256,
num_neg=4,
lr=0.001,
learner="adam",
early_stopping=None,
trainable=True,
verbose=True,
seed=None,
):
super().__init__(name=name, trainable=trainable, verbose=verbose)
self.num_epochs = num_epochs
self.batch_size = batch_size
self.num_neg = num_neg
self.lr = lr
self.learner = learner
self.early_stopping = early_stopping
self.seed = seed
self.rng = get_rng(seed)
self.ignored_attrs.extend(
[
"graph",
"user_id",
"item_id",
"labels",
"interaction",
"prediction",
"loss",
"train_op",
"initializer",
"saver",
"sess",
]
)
def fit(self, train_set, val_set=None):
"""Fit the model to observations.
Parameters
----------
train_set: :obj:`cornac.data.Dataset`, required
User-Item preference data as well as additional modalities.
val_set: :obj:`cornac.data.Dataset`, optional, default: None
User-Item preference data for model selection purposes (e.g., early stopping).
Returns
-------
self : object
"""
Recommender.fit(self, train_set, val_set)
if self.trainable:
if not hasattr(self, "graph"):
self.num_users = self.train_set.num_users
self.num_items = self.train_set.num_items
self._build_graph()
self._fit_tf()
return self
def _build_graph(self):
import tensorflow.compat.v1 as tf
# less verbose TF
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
tf.logging.set_verbosity(tf.logging.ERROR)
self.graph = tf.Graph()
def _sess_init(self):
import tensorflow.compat.v1 as tf
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
self.sess = tf.Session(graph=self.graph, config=config)
self.sess.run(self.initializer)
def _step_update(self, batch_users, batch_items, batch_ratings):
_, _loss = self.sess.run(
[self.train_op, self.loss],
feed_dict={
self.user_id: batch_users,
self.item_id: batch_items,
self.labels: batch_ratings.reshape(-1, 1),
},
)
return _loss
def _fit_tf(self):
import tensorflow.compat.v1 as tf
loop = trange(self.num_epochs, disable=not self.verbose)
for _ in loop:
count = 0
sum_loss = 0
for i, (batch_users, batch_items, batch_ratings) in enumerate(
self.train_set.uir_iter(
self.batch_size, shuffle=True, binary=True, num_zeros=self.num_neg
)
):
_loss = self._step_update(batch_users, batch_items, batch_ratings)
count += len(batch_ratings)
sum_loss += _loss * len(batch_ratings)
if i % 10 == 0:
loop.set_postfix(loss=(sum_loss / count))
if self.early_stopping is not None and self.early_stop(
**self.early_stopping
):
break
loop.close()
def save(self, save_dir=None):
"""Save a recommender model to the filesystem.
Parameters
----------
save_dir: str, default: None
Path to a directory for the model to be stored.
"""
if save_dir is None:
return
model_file = Recommender.save(self, save_dir)
# save TF weights
self.saver.save(self.sess, model_file.replace(".pkl", ".cpt"))
return model_file
@staticmethod
def load(model_path, trainable=False):
"""Load a recommender model from the filesystem.
Parameters
----------
model_path: str, required
Path to a file or directory where the model is stored. If a directory is
provided, the latest model will be loaded.
trainable: boolean, optional, default: False
Set it to True if you would like to finetune the model. By default,
the model parameters are assumed to be fixed after being loaded.
Returns
-------
self : object
"""
model = Recommender.load(model_path, trainable)
if hasattr(model, "pretrained"): # NeuMF
model.pretrained = False
model._build_graph()
model.saver.restore(model.sess, model.load_from.replace(".pkl", ".cpt"))
return model
def monitor_value(self):
"""Calculating monitored value used for early stopping on validation set (`val_set`).
This function will be called by `early_stop()` function.
Returns
-------
res : float
Monitored value on validation set.
Return `None` if `val_set` is `None`.
"""
if self.val_set is None:
return None
from ...metrics import NDCG
from ...eval_methods import ranking_eval
ndcg_100 = ranking_eval(
model=self,
metrics=[NDCG(k=100)],
train_set=self.train_set,
test_set=self.val_set,
)[0][0]
return ndcg_100
| {
"pile_set_name": "Github"
} |
require('../../modules/es6.math.cbrt');
module.exports = require('../../modules/_core').Math.cbrt;
| {
"pile_set_name": "Github"
} |
//
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Jul 6 2018 12:02:43).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <SketchModel/MSAssetContainer.h>
@class MSColor;
@interface _MSColorAsset : MSAssetContainer
{
MSColor *_color;
}
+ (BOOL)allowsFaulting;
+ (Class)immutableClass;
- (void).cxx_destruct;
- (void)refaultChildrenAgainst:(id)arg1;
- (void)setRaw_color:(id)arg1;
- (id)childCollaborationObjectWithID:(id)arg1 removing:(BOOL)arg2;
- (void)pluginDiffCompareChildrenAgainst:(id)arg1 treeComparison:(id)arg2;
- (void)syncPropertiesFromObject:(id)arg1;
- (BOOL)propertiesAreEqual:(id)arg1 forPurpose:(unsigned long long)arg2;
- (void)copyPropertiesToObject:(id)arg1 options:(unsigned long long)arg2;
- (void)setAsParentOnChildren;
- (void)initializeUnsetObjectPropertiesWithDefaults;
- (BOOL)hasDefaultValues;
- (void)performInitEmptyObject;
@property(retain, nonatomic) MSColor *color; // @synthesize color=_color;
- (void)performInitWithImmutableModelObject:(id)arg1;
- (void)enumerateChildrenUsingBlock:(CDUnknownBlockType)arg1;
- (void)enumerateProperties:(CDUnknownBlockType)arg1;
@end
| {
"pile_set_name": "Github"
} |
package tooltips.example.structure;
/*Generated by MPS */
import jetbrains.mps.smodel.runtime.BaseStructureAspectDescriptor;
import jetbrains.mps.smodel.runtime.ConceptDescriptor;
import java.util.Collection;
import java.util.Arrays;
import org.jetbrains.annotations.Nullable;
import jetbrains.mps.smodel.adapter.ids.SConceptId;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.smodel.runtime.impl.ConceptDescriptorBuilder2;
import jetbrains.mps.smodel.adapter.ids.PrimitiveTypeId;
public class StructureAspectDescriptor extends BaseStructureAspectDescriptor {
/*package*/ final ConceptDescriptor myConceptList = createDescriptorForList();
private final LanguageConceptSwitch myIndexSwitch;
public StructureAspectDescriptor() {
myIndexSwitch = new LanguageConceptSwitch();
}
@Override
public void reportDependencies(jetbrains.mps.smodel.runtime.StructureAspectDescriptor.Dependencies deps) {
deps.extendedLanguage(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, "jetbrains.mps.lang.core");
}
@Override
public Collection<ConceptDescriptor> getDescriptors() {
return Arrays.asList(myConceptList);
}
@Override
@Nullable
public ConceptDescriptor getDescriptor(SConceptId id) {
switch (myIndexSwitch.index(id)) {
case LanguageConceptSwitch.List:
return myConceptList;
default:
return null;
}
}
/*package*/ int internalIndex(SAbstractConcept c) {
return myIndexSwitch.index(c);
}
private static ConceptDescriptor createDescriptorForList() {
ConceptDescriptorBuilder2 b = new ConceptDescriptorBuilder2("tooltips.example", "List", 0xa8c4631e640d42a1L, 0xba26250ba067c2c2L, 0x2e602a53d6175dbaL);
b.class_(false, false, true);
b.origin("r:785fbfdf-4d16-46ea-8112-f67d04b451d9(tooltips.example.structure)/3341717463071415738");
b.version(2);
b.property("a", 0x61349daa9dd5fb71L).type(PrimitiveTypeId.INTEGER).origin("7004396676586011505").done();
return b.create();
}
}
| {
"pile_set_name": "Github"
} |
package org.libsdl.app;
import android.content.Context;
import java.lang.reflect.*;
/**
SDL library initialization
*/
public class SDL {
// This function should be called first and sets up the native code
// so it can call into the Java classes
public static void setupJNI() {
SDLActivity.nativeSetupJNI();
SDLAudioManager.nativeSetupJNI();
SDLControllerManager.nativeSetupJNI();
}
// This function should be called each time the activity is started
public static void initialize() {
setContext(null);
SDLActivity.initialize();
SDLAudioManager.initialize();
SDLControllerManager.initialize();
}
// This function stores the current activity (SDL or not)
public static void setContext(Context context) {
mContext = context;
}
public static Context getContext() {
return mContext;
}
public static void loadLibrary(String libraryName) throws UnsatisfiedLinkError, SecurityException, NullPointerException {
if (libraryName == null) {
throw new NullPointerException("No library name provided.");
}
try {
// Let's see if we have ReLinker available in the project. This is necessary for
// some projects that have huge numbers of local libraries bundled, and thus may
// trip a bug in Android's native library loader which ReLinker works around. (If
// loadLibrary works properly, ReLinker will simply use the normal Android method
// internally.)
//
// To use ReLinker, just add it as a dependency. For more information, see
// https://github.com/KeepSafe/ReLinker for ReLinker's repository.
//
Class relinkClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker");
Class relinkListenerClass = mContext.getClassLoader().loadClass("com.getkeepsafe.relinker.ReLinker$LoadListener");
Class contextClass = mContext.getClassLoader().loadClass("android.content.Context");
Class stringClass = mContext.getClassLoader().loadClass("java.lang.String");
// Get a 'force' instance of the ReLinker, so we can ensure libraries are reinstalled if
// they've changed during updates.
Method forceMethod = relinkClass.getDeclaredMethod("force");
Object relinkInstance = forceMethod.invoke(null);
Class relinkInstanceClass = relinkInstance.getClass();
// Actually load the library!
Method loadMethod = relinkInstanceClass.getDeclaredMethod("loadLibrary", contextClass, stringClass, stringClass, relinkListenerClass);
loadMethod.invoke(relinkInstance, mContext, libraryName, null, null);
}
catch (final Throwable e) {
// Fall back
try {
System.loadLibrary(libraryName);
}
catch (final UnsatisfiedLinkError ule) {
throw ule;
}
catch (final SecurityException se) {
throw se;
}
}
}
protected static Context mContext;
}
| {
"pile_set_name": "Github"
} |
# 序
**灵魂大师的人格魅力,严肃文学的锤片精髓: Mindfuck**
[吕琮霖](https://www.zhihu.com/people/sigmod)
觉大家对锤片的解读大方向错了。不少锤粉想去模仿大师,却只看到了只言片语的皮毛,一种摸不到精髓,只是一种 Cargo cult。肥肠、一个狗、保定、驴、老王、狗熊、嗷、昏古七这些都是不过指纹,魔幻现实主义的叙事、充满节奏感的语言结构,这些也只是一种姿态。你不能用一个人的指纹和姿态去描述一个人,理解一个人。要触及灵魂。锤片的灵魂是什么?大师的文学素养、人生阅历、音乐品味。所谓厚积薄发,”我见到过地狱与天堂的婚礼,战舰在猎户座肩旁熊熊燃烧!”,85 年春晚的罗文,科室里的勾心斗角,全都信手拈来。讲真,深不可测。感觉大师经历过 8、90 年代诗歌狂潮,理想的幻灭与沧桑,青春的荷尔蒙跟录像厅一起埋葬。
大师这种厚重的积淀,继而在他那雄奇的大脑中发酵成了技巧,化成了 mindfuck。最浅层却又最震撼的一个技巧,就是语言的节奏和韵律。方言只是最肤浅易见的一层,可以令人莞尔,但远非锤片的灵魂,莫让浮云遮蔽眼。运用的典范可以在我老公、我丈母娘系列看到。只是一种塑造市井形像,在小品文中为叙事服务的技巧。
非常奇怪,真的,按理说文字不应该是这样的,是被动的,是被你的眼球去扫描,被你的大脑所理解,但大师的文字不一样。一眼扫过去,大脑还没来得及对字符完全解码,就被镇住了。只言片语,几个碎片,老张、驴、叶尼塞河、bobo 树、醉日逐舟、土拔鼠、电子绵羊、六个骑士整齐走过,在青石板路面发出啪啪声、印度人打板球。。。大师的情绪、经历 rou 一下全都往你脑袋里钻,懵了,对灵魂的一记重锤(300 磅)。就像突然被 USB 3.0 接了脑袋,每秒 500 兆字节的信息灌进来,硬盘读写跟不上。大师的文字不是线性的,绝对不是,行与行,词和词之间都有联系,更像一幅画,整一篇在传递着一种(或者几种)情绪。当然这只是初看。再仔细读,隐隐约约感觉到一种韵律。噫!嗬!大师的文字是有节奏的,长短句,定语、修饰语、状语、碎了,化在文字的脉搏中,产生一种酣畅淋漓的阅读体验,信息流往你脑袋里流得慢了,文字开始有意义了,情绪体会到了,意境浮现了。你想去解构,想用晦涩的术语去分析,想把大师的文字肢解,但我做不到,一种无法挣脱的无力。人和人之间的差距太大了。同样是个排球大小的脑袋,差的就是这么几个突触的链接,大师却有了天才的驾驭文字能力,一种摄人心魄的力量。
在语言之上,更触及灵魂的一层是叙事。当然两者也是不能被割裂的。由于叙事之重要,大师曾专门发了一首微博,只有两个字:叙事。普通文学是叙事的,抒情的,记录思绪的,这些叙的事,抒的情大多是我们所能感知的,是基于人类共通的欲望,情感和逻辑。锤片就利用了这一种常规,产生了一种出其不意,一种 mindfuck。
锤片先是营造了一种合理的叙事,老张、科室、数位产品、老公、丈母娘、加利福尼亚老家,引诱你套入自己的逻辑和情感,去期许情节的发展。结果冷不丁蹦出来一个狗熊、野生郭东林、大叫驴,结果你就懵了,逻辑没用了,悲伤、喜悦、骄傲、贪欲种种情感完全套不进去了,只能跟着大师的思绪走。有些锤粉或许会疑惑锤片里的动物是什么意象?我的一个猜想:就是为了mindfuck。人类的大脑是很奇妙的,你看到“阿拉伯半岛狒狒”的时候,脑子里并不止出现这七个字,而是沙漠、椰枣树、红屁股,各种关联。想象一下,当一个动物园出现的时候是什么情况你的思绪被淹没于信息的洪流,灵魂受到一记重锤!总而言之,大师级叙事的关键在于抽离于现实的情感,超脱于世俗的叙事,信息洪流的冲击。感觉佛搂蜜可能还是个法号,不是单纯的 follow me,是一种循循善诱,渡人般若波罗蜜多。而特师早已六欲皆空了,看破世间虚妄了。
而在所有的这些技法和叙事之上,在严肃文学的金字塔的顶端,在锤片皇冠上的明珠,是大师的人格魅力,是他的一种超越中产阶级生活的境界,还有一种和他厚重阅历极不相称却弥足珍贵的童趣。
如果说在 TGFC 的岁月,是大师以数位产品圈子为靶子,将中产阶级肤浅的物欲和虚荣颠覆成一场闹剧,那微博就提供了一个让大师在更广阔的 audience 面前对当代生活翻江倒海的机会。媒介即信息。微博这个平台不仅给了大师一种新的表达形式,也同时给了大师一种新的平台和 context。尤其是大师与段子手们抱团,更是有了一种 context,用浅薄无聊的段子手一众为背景,大师用刻意、生硬的广告和网络乞讨,硬生生地撕开了段子手们的强颜欢笑,将网路上面的物欲与虚荣赤裸裸地暴露出来(当然也可能是大师确实不要脸。
大师的微博最独特的一点是从现实生活的超脱。没错,大师的灵感来自于生活,叙事也关于生活,但你却从来看不到大师的生活。月入 2300,白白胖胖的保定中年男子(或是对老公绝望的家庭主妇是一个很容易竖起的靶子,很容易诱惑你放弃去思考大师的真实生活,但大师又是一个活生生存在的人。你看不到大师的七情六欲,你不知道大师最近经历了什么,你不知道他有没有在生活中受到挫折,你不知道他有没有因为涨粉而欣喜。当段子手们迎合着粉丝时,大师却爱理不理,偶尔骂一句“你妈死了”,率性,牛逼!你看不到他的虚荣,他的沾沾自喜,你看不到他对热门话题表态,你看不到他对网路潮流的附和。大师非常成功地塑造了一个(或者几个灵魂,而不只是一个微博账号。这种对于生活的超脱,常常让微博上的哈哈党,政论狗,各种主义者无所适从,无从下口,给人当头一击,懵了,忘了蜗角虚名,忘了浮生若梦,忘了风花雪月,只感觉到一种渺小,一种茫茫宇宙间,自己那颅内的一点化学反应算得了什么。这时评论狗们就惊诧了,那种触动之下,任何评论都显得苍白,显得俗气。拷问灵魂!灵魂大师名符其实!
这是我对严肃文学的一点管窥蠡测。在此抛砖引玉,希望能看到更多锤粉炸裂、触及灵魂的严肃文学评论。荣耀赐予你们。
附:我最喜爱的锤片:《七月一言以蔽之,思无邪,《出大事儿了,老王开花了》魔幻,寓言,炸裂!《武汉某幸福中产家庭里一个狗,的波澜壮阔大计》画面呼之欲出,节奏直击面门!《生活,就是你逐渐活明白了》催人泪下,白白胖胖微秃的大师跃然纸上!《说一说在我老家,庄稼的种植情况。。。》魔幻现实主义!抽离、割裂、浓得化不开!
吕琮霖
2014.09.24 于知乎
| {
"pile_set_name": "Github"
} |
---
title: "Compiler Error CS2021"
ms.date: 07/20/2015
f1_keywords:
- "CS2021"
helpviewer_keywords:
- "CS2021"
ms.assetid: 8379d77e-6586-4e43-9aab-7cdf3ffecf51
---
# Compiler Error CS2021
File name 'file' is too long or invalid
All file names passed to the C# compiler must be no longer than `_MAX_PATH` (defined in a Windows header file). the compiler will give this error in the following situations:
- A file name (including the path) is longer than `_MAX_PATH`.
- The file name contains invalid characters.
- The file name contains wildcards where wildcards are not allowed (such as in resource file names).
| {
"pile_set_name": "Github"
} |
From [email protected] Sun Nov 23 00:17:22 2008
Date: Sun, 23 Nov 2008 00:17:22 -0500
From: "Dwayne C. Litzenberger" <[email protected]>
To: "A. M. Kuchling" <[email protected]>
Subject: PyCrypto license clarification
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature"; boundary="YiEDa0DAkWCtVeE4"
Content-Disposition: inline
X-Primary-Address: [email protected]
X-Homepage: http://www.dlitz.net/
X-OpenPGP: url=http://www.dlitz.net/go/gpgkey/;
id=19E11FE8B3CFF273ED174A24928CEC1339C25CF7 (only for key signing);
preference=unprotected
X-OpenPGP: url=http://www.dlitz.net/go/gpgkey/;
id=4B2AFD82FC7D9E3838D9179F1C11B877E7804B45 (2008);
preference=signencrypt
User-Agent: Mutt/1.5.16 (2007-06-11)
Status: RO
Content-Length: 3461
Lines: 78
--YiEDa0DAkWCtVeE4
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi Andrew,
People often ask me what license PyCrypto is covered by, if it's=20
GPL-compatible, etc. Right now, I'm not really sure what to tell them. =20
The text in the current LICENSE file (quoted below) is not entirely clear=
=20
on the point of whether distributing modified versions is allowed. (It=20
says "distribute and use", but not "modify".)
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Distribute and use freely; there are no restrictions on further
dissemination and usage except those imposed by the laws of your
country of residence. This software is provided "as is" without
warranty of fitness for use or suitability for any purpose, express
or implied. Use at your own risk or not at all.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Incorporating the code into commercial products is permitted; you do
not have to make source available or contribute your changes back
(though that would be nice).
--amk (www.amk.ca)
For the next PyCrypto release, I'd like to take steps to move toward a=20
clearer licensing regime. I'm asking as many copyright holders as I can=20
find, starting with you, if I can release PyCrypto under something clearer=
=20
and more standard. Below, I have quoted a public domain dedication that=20
was recommended in _Intellectual Property and Open Source: A Practical=20
Guide to Protecting Code_, by Van Lindberg.
May I, on your behalf, dedicate to the public domain your considerable=20
contributions to PyCrypto, with the following notice?
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
The contents of this file are dedicated to the public domain. To the
extent that dedication to the public domain is not available, everyone
is granted a worldwide, perpetual, royalty-free, non-exclusive license
to exercise all rights associated with the contents of this file for
any purpose whatsoever. No rights are reserved.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Regards,
- Dwayne
--=20
Dwayne C. Litzenberger <[email protected]>
Key-signing key - 19E1 1FE8 B3CF F273 ED17 4A24 928C EC13 39C2 5CF7
Annual key (2008) - 4B2A FD82 FC7D 9E38 38D9 179F 1C11 B877 E780 4B45
--YiEDa0DAkWCtVeE4
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
iEYEARECAAYFAkko52IACgkQHBG4d+eAS0XPPQCfcyQ2DdAXKg9N7Z+jeSFFD5EZ
yloAn33a3ZjkteyJaTbzEqImOEW8JGpf
=aBEW
-----END PGP SIGNATURE-----
--YiEDa0DAkWCtVeE4--
From [email protected] Sun Nov 23 07:51:59 2008
X-Maildir-Dup-Checked: Yes
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from goedel.dlitz.net (unknown [10.159.255.6])
by rivest.dlitz.net (Postfix) with ESMTP id 5C2C75047D
for <[email protected]>; Sun, 23 Nov 2008 07:51:59 -0500 (EST)
Received: from localhost (localhost [127.0.0.1])
by goedel.dlitz.net (Postfix) with QMQP id D632D10111
for <[email protected]>; Sun, 23 Nov 2008 06:51:58 -0600 (CST)
Received: (vmailmgr-postfix 12026 invoked by uid 1003); 23 Nov 2008 06:51:58 -0600
Delivered-To: [email protected]
Received-SPF: none (goedel.dlitz.net: domain of [email protected] does not designate permitted sender hosts)
Received: from mail5.sea5.speakeasy.net (mail5.sea5.speakeasy.net [69.17.117.7])
by goedel.dlitz.net (Postfix) with ESMTP id 97DC710105
for <[email protected]>; Sun, 23 Nov 2008 06:51:58 -0600 (CST)
Received: (qmail 3992 invoked from network); 23 Nov 2008 12:51:52 -0000
Received: from dsl092-163-165.wdc2.dsl.speakeasy.net (HELO localhost) (akuchling@[66.92.163.165])
(envelope-sender <[email protected]>)
by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP
for <[email protected]>; 23 Nov 2008 12:51:52 -0000
Date: Sun, 23 Nov 2008 07:51:34 -0500
From: "A.M. Kuchling" <[email protected]>
To: "Dwayne C. Litzenberger" <[email protected]>
Subject: Re: PyCrypto license clarification
Message-ID: <[email protected]>
Reply-To: [email protected]
References: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <[email protected]>
User-Agent: Mutt/1.5.13 (2006-08-11)
Status: RO
Content-Length: 537
Lines: 15
> People often ask me what license PyCrypto is covered by, if it's
> GPL-compatible, etc. Right now, I'm not really sure what to tell them.
> The text in the current LICENSE file (quoted below) is not entirely clear
> on the point of whether distributing modified versions is allowed. (It
> says "distribute and use", but not "modify".)
The intention is that it be public domain.
> May I, on your behalf, dedicate to the public domain your considerable
> contributions to PyCrypto, with the following notice?
You may.
--amk
| {
"pile_set_name": "Github"
} |
/*=========================================================================
*
* Copyright NumFOCUS
*
* 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.txt
*
* 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.
*
*=========================================================================*/
#ifndef itkRescaleIntensityImageFilter_h
#define itkRescaleIntensityImageFilter_h
#include "itkUnaryFunctorImageFilter.h"
#include "itkMath.h"
namespace itk
{
// This functor class applies a linear transformation A.x + B
// to input values.
namespace Functor
{
template <typename TInput, typename TOutput>
class ITK_TEMPLATE_EXPORT IntensityLinearTransform
{
public:
using RealType = typename NumericTraits<TInput>::RealType;
IntensityLinearTransform()
{
m_Factor = 1.0;
m_Offset = 0.0;
m_Minimum = NumericTraits<TOutput>::NonpositiveMin();
m_Maximum = NumericTraits<TOutput>::max();
#if defined(__GNUC__) && (__GNUC__ == 5) && (__GNUC_MINOR__ == 2) && defined(NDEBUG) && defined(__i386__)
m_EpsilonCompensation = static_cast<RealType>(std::numeric_limits<TOutput>::epsilon());
if (m_EpsilonCompensation == 0)
{
m_EpsilonCompensation = std::numeric_limits<RealType>::epsilon();
}
#endif
}
~IntensityLinearTransform() = default;
void
SetFactor(RealType a)
{
m_Factor = a;
}
void
SetOffset(RealType b)
{
m_Offset = b;
}
void
SetMinimum(TOutput min)
{
m_Minimum = min;
}
void
SetMaximum(TOutput max)
{
m_Maximum = max;
}
bool
operator!=(const IntensityLinearTransform & other) const
{
if (Math::NotExactlyEquals(m_Factor, other.m_Factor) || Math::NotExactlyEquals(m_Offset, other.m_Offset) ||
Math::NotExactlyEquals(m_Maximum, other.m_Maximum) || Math::NotExactlyEquals(m_Minimum, other.m_Minimum))
{
return true;
}
return false;
}
bool
operator==(const IntensityLinearTransform & other) const
{
return !(*this != other);
}
inline TOutput
operator()(const TInput & x) const
{
#if defined(__GNUC__) && (__GNUC__ == 5) && (__GNUC_MINOR__ == 2) && defined(NDEBUG) && defined(__i386__)
RealType value = static_cast<RealType>(x) * m_Factor + m_Offset + m_EpsilonCompensation;
TOutput result = static_cast<TOutput>(value) - static_cast<TOutput>(m_EpsilonCompensation);
#else
RealType value = static_cast<RealType>(x) * m_Factor + m_Offset;
auto result = static_cast<TOutput>(value);
#endif
result = (result > m_Maximum) ? m_Maximum : result;
result = (result < m_Minimum) ? m_Minimum : result;
return result;
}
private:
RealType m_Factor;
RealType m_Offset;
TOutput m_Maximum;
TOutput m_Minimum;
#if defined(__GNUC__) && (__GNUC__ == 5) && (__GNUC_MINOR__ == 2) && defined(NDEBUG) && defined(__i386__)
RealType m_EpsilonCompensation;
#endif
};
} // end namespace Functor
/**
*\class RescaleIntensityImageFilter
* \brief Applies a linear transformation to the intensity levels of the
* input Image.
*
* RescaleIntensityImageFilter applies pixel-wise a linear transformation
* to the intensity values of input image pixels. The linear transformation
* is defined by the user in terms of the minimum and maximum values that
* the output image should have.
*
* The following equation gives the mapping of the intensity values
*
* \par
* \f[
* outputPixel = ( inputPixel - inputMin) \cdot
* \frac{(outputMax - outputMin )}{(inputMax - inputMin)} + outputMin
* \f]
*
* All computations are performed in the precision of the input pixel's
* RealType. Before assigning the computed value to the output pixel.
*
* NOTE: In this filter the minimum and maximum values of the input image are
* computed internally using the MinimumMaximumImageCalculator. Users are not
* supposed to set those values in this filter. If you need a filter where you
* can set the minimum and maximum values of the input, please use the
* IntensityWindowingImageFilter. If you want a filter that can use a
* user-defined linear transformation for the intensity, then please use the
* ShiftScaleImageFilter.
*
* \sa IntensityWindowingImageFilter
*
* \ingroup IntensityImageFilters MultiThreaded
*
* \ingroup ITKImageIntensity
*
* \sphinx
* \sphinxexample{Filtering/ImageIntensity/RescaleAnImage,Rescale An Image}
* \endsphinx
*/
template <typename TInputImage, typename TOutputImage = TInputImage>
class ITK_TEMPLATE_EXPORT RescaleIntensityImageFilter
: public UnaryFunctorImageFilter<
TInputImage,
TOutputImage,
Functor::IntensityLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
{
public:
ITK_DISALLOW_COPY_AND_ASSIGN(RescaleIntensityImageFilter);
/** Standard class type aliases. */
using Self = RescaleIntensityImageFilter;
using Superclass = UnaryFunctorImageFilter<
TInputImage,
TOutputImage,
Functor::IntensityLinearTransform<typename TInputImage::PixelType, typename TOutputImage::PixelType>>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;
using OutputPixelType = typename TOutputImage::PixelType;
using InputPixelType = typename TInputImage::PixelType;
using RealType = typename NumericTraits<InputPixelType>::RealType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Runtime information support. */
itkTypeMacro(RescaleIntensityImageFilter, UnaryFunctorImageFilter);
itkSetMacro(OutputMinimum, OutputPixelType);
itkSetMacro(OutputMaximum, OutputPixelType);
itkGetConstReferenceMacro(OutputMinimum, OutputPixelType);
itkGetConstReferenceMacro(OutputMaximum, OutputPixelType);
/** Get the Scale and Shift used for the linear transformation
of gray level values.
\warning These Values are only valid after the filter has been updated */
itkGetConstReferenceMacro(Scale, RealType);
itkGetConstReferenceMacro(Shift, RealType);
/** Get the Minimum and Maximum values of the input image.
\warning These Values are only valid after the filter has been updated */
itkGetConstReferenceMacro(InputMinimum, InputPixelType);
itkGetConstReferenceMacro(InputMaximum, InputPixelType);
/** Process to execute before entering the multithreaded section */
void
BeforeThreadedGenerateData() override;
/** Print internal ivars */
void
PrintSelf(std::ostream & os, Indent indent) const override;
#ifdef ITK_USE_CONCEPT_CHECKING
// Begin concept checking
itkConceptMacro(InputHasNumericTraitsCheck, (Concept::HasNumericTraits<InputPixelType>));
itkConceptMacro(OutputHasNumericTraitsCheck, (Concept::HasNumericTraits<OutputPixelType>));
itkConceptMacro(RealTypeMultiplyOperatorCheck, (Concept::MultiplyOperator<RealType>));
itkConceptMacro(RealTypeAdditiveOperatorsCheck, (Concept::AdditiveOperators<RealType>));
// End concept checking
#endif
protected:
RescaleIntensityImageFilter();
~RescaleIntensityImageFilter() override = default;
private:
RealType m_Scale;
RealType m_Shift;
InputPixelType m_InputMinimum;
InputPixelType m_InputMaximum;
OutputPixelType m_OutputMinimum;
OutputPixelType m_OutputMaximum;
};
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
# include "itkRescaleIntensityImageFilter.hxx"
#endif
#endif
| {
"pile_set_name": "Github"
} |
/*
* DateJS Culture String File
* Country Code: he-IL
* Name: Hebrew (Israel)
* Format: "key" : "value"
* Key is the en-US term, Value is the Key in the current language.
*/
Date.CultureStrings = Date.CultureStrings || {};
Date.CultureStrings["he-IL"] = {
"name": "he-IL",
"englishName": "Hebrew (Israel)",
"nativeName": "עברית (ישראל)",
"Sunday": "יום ראשון",
"Monday": "יום שני",
"Tuesday": "יום שלישי",
"Wednesday": "יום רביעי",
"Thursday": "יום חמישי",
"Friday": "יום שישי",
"Saturday": "שבת",
"Sun": "יום א",
"Mon": "יום ב",
"Tue": "יום ג",
"Wed": "יום ד",
"Thu": "יום ה",
"Fri": "יום ו",
"Sat": "שבת",
"Su": "א",
"Mo": "ב",
"Tu": "ג",
"We": "ד",
"Th": "ה",
"Fr": "ו",
"Sa": "ש",
"S_Sun_Initial": "א",
"M_Mon_Initial": "ב",
"T_Tue_Initial": "ג",
"W_Wed_Initial": "ד",
"T_Thu_Initial": "ה",
"F_Fri_Initial": "ו",
"S_Sat_Initial": "ש",
"January": "ינואר",
"February": "פברואר",
"March": "מרץ",
"April": "אפריל",
"May": "מאי",
"June": "יוני",
"July": "יולי",
"August": "אוגוסט",
"September": "ספטמבר",
"October": "אוקטובר",
"November": "נובמבר",
"December": "דצמבר",
"Jan_Abbr": "ינו",
"Feb_Abbr": "פבר",
"Mar_Abbr": "מרץ",
"Apr_Abbr": "אפר",
"May_Abbr": "מאי",
"Jun_Abbr": "יונ",
"Jul_Abbr": "יול",
"Aug_Abbr": "אוג",
"Sep_Abbr": "ספט",
"Oct_Abbr": "אוק",
"Nov_Abbr": "נוב",
"Dec_Abbr": "דצמ",
"AM": "AM",
"PM": "PM",
"firstDayOfWeek": 0,
"twoDigitYearMax": 2029,
"mdy": "dmy",
"M/d/yyyy": "dd/MM/yyyy",
"dddd, MMMM dd, yyyy": "dddd dd MMMM yyyy",
"h:mm tt": "HH:mm",
"h:mm:ss tt": "HH:mm:ss",
"dddd, MMMM dd, yyyy h:mm:ss tt": "dddd dd MMMM yyyy HH:mm:ss",
"yyyy-MM-ddTHH:mm:ss": "yyyy-MM-ddTHH:mm:ss",
"yyyy-MM-dd HH:mm:ssZ": "yyyy-MM-dd HH:mm:ssZ",
"ddd, dd MMM yyyy HH:mm:ss": "ddd, dd MMM yyyy HH:mm:ss",
"MMMM dd": "dd MMMM",
"MMMM, yyyy": "MMMM yyyy",
"/jan(uary)?/": "ינו(אר)?",
"/feb(ruary)?/": "פבר(ואר)?",
"/mar(ch)?/": "מרץ",
"/apr(il)?/": "אפר(יל)?",
"/may/": "מאי",
"/jun(e)?/": "יונ(י)?",
"/jul(y)?/": "יול(י)?",
"/aug(ust)?/": "אוג(וסט)?",
"/sep(t(ember)?)?/": "ספט(מבר)?",
"/oct(ober)?/": "אוק(טובר)?",
"/nov(ember)?/": "נוב(מבר)?",
"/dec(ember)?/": "דצמ(בר)?",
"/^su(n(day)?)?/": "^א(ום א(אשון)?)?",
"/^mo(n(day)?)?/": "^ב(ום ב(ני)?)?",
"/^tu(e(s(day)?)?)?/": "^ג(ום ג(לישי)?)?",
"/^we(d(nesday)?)?/": "^ד(ום ד(ביעי)?)?",
"/^th(u(r(s(day)?)?)?)?/": "^ה(ום ה(מישי)?)?",
"/^fr(i(day)?)?/": "^ו(ום ו(ישי)?)?",
"/^sa(t(urday)?)?/": "^ש(1)?",
"/^next/": "^next",
"/^last|past|prev(ious)?/": "^last|past|prev(ious)?",
"/^(\\+|aft(er)?|from|hence)/": "^(\\+|aft(er)?|from|hence)",
"/^(\\-|bef(ore)?|ago)/": "^(\\-|bef(ore)?|ago)",
"/^yes(terday)?/": "^yes(terday)?",
"/^t(od(ay)?)?/": "^t(od(ay)?)?",
"/^tom(orrow)?/": "^tom(orrow)?",
"/^n(ow)?/": "^n(ow)?",
"/^ms|milli(second)?s?/": "^ms|milli(second)?s?",
"/^sec(ond)?s?/": "^sec(ond)?s?",
"/^mn|min(ute)?s?/": "^mn|min(ute)?s?",
"/^h(our)?s?/": "^h(our)?s?",
"/^w(eek)?s?/": "^w(eek)?s?",
"/^m(onth)?s?/": "^m(onth)?s?",
"/^d(ay)?s?/": "^d(ay)?s?",
"/^y(ear)?s?/": "^y(ear)?s?",
"/^(a|p)/": "^(a|p)",
"/^(a\\.?m?\\.?|p\\.?m?\\.?)/": "^(a\\.?m?\\.?|p\\.?m?\\.?)",
"/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)/": "^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\\s*(\\+|\\-)\\s*\\d\\d\\d\\d?)|gmt|utc)",
"/^\\s*(st|nd|rd|th)/": "^\\s*(st|nd|rd|th)",
"/^\\s*(\\:|a(?!u|p)|p)/": "^\\s*(\\:|a(?!u|p)|p)",
"LINT": "LINT",
"TOT": "TOT",
"CHAST": "CHAST",
"NZST": "NZST",
"NFT": "NFT",
"SBT": "SBT",
"AEST": "AEST",
"ACST": "ACST",
"JST": "JST",
"CWST": "CWST",
"CT": "CT",
"ICT": "ICT",
"MMT": "MMT",
"BIOT": "BST",
"NPT": "NPT",
"IST": "IST",
"PKT": "PKT",
"AFT": "AFT",
"MSK": "MSK",
"IRST": "IRST",
"FET": "FET",
"EET": "EET",
"CET": "CET",
"UTC": "UTC",
"GMT": "GMT",
"CVT": "CVT",
"GST": "GST",
"BRT": "BRT",
"NST": "NST",
"AST": "AST",
"EST": "EST",
"CST": "CST",
"MST": "MST",
"PST": "PST",
"AKST": "AKST",
"MIT": "MIT",
"HST": "HST",
"SST": "SST",
"BIT": "BIT",
"CHADT": "CHADT",
"NZDT": "NZDT",
"AEDT": "AEDT",
"ACDT": "ACDT",
"AZST": "AZST",
"IRDT": "IRDT",
"EEST": "EEST",
"CEST": "CEST",
"BST": "BST",
"PMDT": "PMDT",
"ADT": "ADT",
"NDT": "NDT",
"EDT": "EDT",
"CDT": "CDT",
"MDT": "MDT",
"PDT": "PDT",
"AKDT": "AKDT",
"HADT": "HADT"
};
Date.CultureStrings.lang = "he-IL";
| {
"pile_set_name": "Github"
} |
/*
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
* Copyright 2016 NXP
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o 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.
*
* o Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _USB_MSC_UFI_H
#define _USB_MSC_UFI_H 1
/*!
* @addtogroup msc_ufi
* @{
*/
/*Sense Key of REQUEST SENSE command, refer to UFI specification chapter 5*/
/*! @brief Indicates that there is no specific sense key information to be reported*/
#define USB_DEVICE_MSC_UFI_NO_SENSE 0x00U
/*! @brief Indicates that the last command completed successfully with some recovery action performed by the UFI
* device*/
#define USB_DEVICE_MSC_UFI_RECOVERED_ERROR 0x01U
/*! @brief Indicates that the UFI device cannot be accessed*/
#define USB_DEVICE_MSC_UFI_NOT_READY 0x02U
/*! @brief Indicates that the command terminated with a non-recovered
error condition that was probably caused by a flaw in the medium or an error in the
recorded data*/
#define USB_DEVICE_MSC_UFI_MEDIUM_ERROR 0x03U
/*! @brief Indicates that the UFI device detected a non-recoverable hardware failure while performing the command or
* during a self test*/
#define USB_DEVICE_MSC_UFI_HARDWARE_ERROR 0x04U
/*! @brief Indicates that there was an illegal parameter in the Command
Packet or in the additional parameters supplied as data for some commands*/
#define USB_DEVICE_MSC_UFI_ILLEGAL_REQUEST 0x05U
/*! @brief Indicates that the removable medium may have been changed or the UFI device has been reset*/
#define USB_DEVICE_MSC_UFI_UNIT_ATTENTION 0x06U
/*! @brief Indicates that a command that writes the medium was attempted on a block that is protected from this
* operation*/
#define USB_DEVICE_MSC_UFI_DATA_PROTECT 0x07U
/*! @brief Indicates that a write-once device or a sequential-access device
encountered blank medium or format-defined end-of-data indication while reading or
a write-once device encountered a non-blank medium while writing*/
#define USB_DEVICE_MSC_UFI_BLANK_CHECK 0x08U
/*! @brief This sense key is available for reporting vendor-specific conditions*/
#define USB_DEVICE_MSC_UFI_VENDOR_SPECIFIC_ERROR 0x09U
/*! @brief Indicates that the UFI device has aborted the command
The host may be able to recover by trying the command again*/
#define USB_DEVICE_MSC_UFI_ABORTED_COMMAND 0x0BU
/*! @brief Indicates that a buffered peripheral device has reached the
end-of-partition and data may remain in the buffer that has not been written to the medium*/
#define USB_DEVICE_MSC_UFI_VOLUME_OVERFLOW 0x0DU
/*! @brief Indicates that the source data did not match the data read from the medium*/
#define USB_DEVICE_MSC_UFI_MISCOMPARE 0x0EU
/*! @brief Invalid command operation code*/
#define USB_DEVICE_MSC_UFI_INVALID_COMMAND_OPCODE 0x20U
/*! @brief Write fault*/
#define USB_DEVICE_MSC_UFI_WRITE_FAULT 0x03U
/*! @brief Not recovered read error*/
#define USB_DEVICE_MSC_UFI_UNRECOVERED_READ_ERROR 0x11U
/*! @brief Unknown error*/
#define USB_DEVICE_MSC_UFI_UNKNOWN_ERROR 0xFFU
/*! @brief Invalid field in command packet*/
#define USB_DEVICE_MSC_UFI_INVALID_FIELD_IN_COMMAND_PKT 0x24U
/*! @brief Invalid logical block address out of range*/
#define USB_DEVICE_MSC_UFI_LBA_OUT_OF_RANGE 0x21U
/*! @brief Valid error code, 70h indicate current errors*/
#define USB_DEVICE_MSC_UFI_REQ_SENSE_VALID_ERROR_CODE 0x70U
/*! @brief The UFI device sets the value of this field to ten, to indicate that ten more bytes of sense data follow this
* field*/
#define USB_DEVICE_MSC_UFI_REQ_SENSE_ADDITIONAL_SENSE_LEN 0x0AU
/*! @brief Prevent media removal flag*/
#define USB_DEVICE_MSC_UFI_PREVENT_ALLOW_REMOVAL_MASK 0x01U
/*! @brief LoEj Start flag */
#define USB_DEVICE_MSC_UFI_LOAD_EJECT_START_MASK 0x03U
/*! @brief Formatted Media - Current media capacity */
#define USB_DEVICE_MSC_UFI_FORMATTED_MEDIA 0x02U
/*! @brief Unformatted Media - Maximum formatting capacity for this cartridge*/
#define USB_DEVICE_MSC_UFI_UNFORMATTED_MEDIA 0x01U
/*! @brief No Cartridge in Drive - Maximum formating capacity for any cartridge*/
#define USB_DEVICE_MSC_UFI_NO_CARTRIDGE_IN_DRIVE 0x03U
/*! @brief INQUIRY Data length of INQUIRY Command*/
#define USB_DEVICE_MSC_UFI_INQUIRY_ALLOCATION_LENGTH 0x24U
/*! @brief Request Sense Data length of REQUEST SENSE Command*/
#define USB_DEVICE_MSC_UFI_REQ_SENSE_DATA_LENGTH 18U
/*! @brief READ CAPACITY Data length of READ CAPACITY Command*/
#define USB_DEVICE_MSC_UFI_READ_CAPACITY_DATA_LENGTH 0x08U
/*! @brief READ CAPACITY Data length of READ CAPACITY Command*/
#define USB_DEVICE_MSC_UFI_READ_CAPACITY16_DATA_LENGTH 0x0CU
/*! @brief Reserved*/
#define USB_DEVICE_MSC_UFI_PERIPHERAL_QUALIFIER 0U
/*! @brief Peripheral Device Type shift*/
#define USB_DEVICE_MSC_UFI_PERIPHERAL_QUALIFIER_SHIFT 5U
/*! @brief Version value*/
#define USB_DEVICE_MSC_UFI_VERSIONS 4U
/*! @brief Peripheral Device Type value of INQUIRY Data*/
#define USB_DEVICE_MSC_UFI_PERIPHERAL_DEVICE_TYPE 0x00U
/*! @brief Removable Media Bit value, this shall be set to one to indicate removable media*/
#define USB_DEVICE_MSC_UFI_REMOVABLE_MEDIUM_BIT 1U
/*! @brief Removable Media Bit shift*/
#define USB_DEVICE_MSC_UFI_REMOVABLE_MEDIUM_BIT_SHIFT 7U
/*! @brief Additional Length*/
#define USB_DEVICE_MSC_UFI_ADDITIONAL_LENGTH 0x20U
/*! @brief UFI inquiry command structure*/
typedef struct _usb_device_inquiry_command_struct
{
uint8_t operationCode; /*!< Operation Code*/
uint8_t logicalUnitNumber; /*!< Specifies the logical unit (0~7) for which Inquiry data should be returned*/
uint8_t pageCode; /*!< Page Code*/
uint8_t reserved; /*!< Reserved*/
uint8_t allocationLength; /*!< Specifies the maximum number of bytes of inquiry data to be returned*/
uint8_t reserved1[7]; /*!< Reserved*/
} usb_device_inquiry_command_struct_t;
/*! @brief UFI request sense command structure*/
typedef struct _usb_device_request_sense_command_struct
{
uint8_t operationCode; /*!< Operation Code*/
uint8_t logicalUnitNumber; /*!< Logical Unit Number*/
uint8_t reserved[2]; /*!< reserved*/
uint8_t allocationLength; /*!< Allocation Length*/
uint8_t reserved1[7]; /*!< reserved*/
} usb_device_request_sense_command_struct_t;
/*! @brief UFI read format capacities command structure*/
typedef struct _usb_device_read_format_capacities_command_struct
{
uint8_t operationCode; /*!< Operation Code*/
uint8_t logicalUnitNumber; /*!< Logical Unit Number*/
uint8_t reserved[5]; /*!< reserved*/
uint16_t allocationLength; /*!< Allocation Length*/
uint8_t reserved1[3]; /*!< reserved*/
} usb_device_read_format_capacities_command_struct_t;
/*! @brief UFI read capacities command structure*/
typedef struct _usb_device_read_capacities_command_struct
{
uint8_t operationCode; /*!< Operation Code*/
uint8_t logicalUnitNumber; /*!< Logical Unit Number*/
uint32_t lba; /*!< Logical Block Address*/
uint8_t reserved[2]; /*!< Reserved*/
uint8_t pmi; /*!< This bit should be set to zero for UFI*/
uint8_t reserved1[3]; /*!< Reserved*/
} usb_device_read_capacities_command_struct_t;
/*! @brief UFI read write 10 structure*/
typedef struct _usb_device_read_write_10_command_struct
{
uint8_t operationCode; /*!< Operation Code*/
uint8_t lunDpoFuaReladr; /*!< Logical Unit Number DPO FUA RelAdr*/
uint32_t lba; /*!< Logical Block Address*/
uint8_t reserved; /*!< Reserved*/
uint8_t transferLengthMsb; /*!< Transfer Length (MSB)*/
uint8_t transferLengthLsb; /*!< Transfer Length (LSB)*/
uint8_t reserved1[3]; /*!< Reserved*/
} usb_device_read_write_10_command_struct_t;
/*! @brief UFI inquiry data format structure*/
typedef struct _usb_device_inquiry_data_fromat_struct
{
uint8_t peripheralDeviceType; /*!< Peripheral Device Type*/
uint8_t rmb; /*!< Removable Media Bit*/
uint8_t versions; /*!< ISO Version, ECMA Version, ANSI Version*/
uint8_t responseDataFormat; /*!< Response Data Format*/
uint8_t additionalLength; /*!< The Additional Length field shall specify the length in bytes of the parameters*/
uint8_t reserved[3]; /*!< reserved*/
uint8_t vendorInformatin[8]; /*!< Vendor Identification*/
uint8_t productId[16]; /*!< Product Identification*/
uint8_t productVersionLevel[4]; /*!< Product Revision Level*/
} usb_device_inquiry_data_fromat_struct_t;
/*! @brief UFI request sense data structure*/
typedef struct _usb_device_request_sense_data_struct
{
uint8_t validErrorCode; /*!< Error Code*/
uint8_t reserved; /*!< reserved*/
uint8_t senseKey; /*!< Sense Key*/
uint8_t information[4]; /*!< Information*/
uint8_t additionalSenseLength; /*!< Additional Sense Length*/
uint8_t reserved1[4]; /*!< reserved*/
uint8_t additionalSenseCode; /*!< Additional Sense Code*/
uint8_t additionalSenseQualifer; /*!< Additional Sense Code Qualifier*/
uint8_t reserved2[4]; /*!< reserved*/
} usb_device_request_sense_data_struct_t;
/*! @brief UFI read capacity data structure*/
typedef struct _usb_device_read_capacity_struct
{
uint32_t lastLogicalBlockAddress; /*!< Last Logical Block Address*/
uint32_t blockSize; /*!< Block Length In Bytes*/
} usb_device_read_capacity_struct_t;
/*! @brief UFI read capacity data structure*/
typedef struct _usb_device_read_capacity16_data_struct
{
uint32_t lastLogicalBlockAddress0; /*!< Last Logical Block Address*/
uint32_t lastLogicalBlockAddress1; /*!< Last Logical Block Address*/
uint32_t blockSize; /*!< Block Length In Bytes*/
} usb_device_read_capacity16_data_struct_t;
/*! @brief UFI capacity list header structure*/
typedef struct _usb_device_capacity_list_header_struct
{
uint8_t reserverd[3]; /*!< reserved*/
uint8_t capacityListLength; /*!< Capacity List Length*/
} usb_device_capacity_list_header_struct_t;
/*! @brief UFI current maximum capacity structure*/
typedef struct _usb_device_current_max_capacity_descriptor_struct
{
uint32_t blockNumber; /*!< Number of Blocks*/
uint32_t descriptorCodeBlockLength; /*!< Byte 4 Descriptor Code , byte 5-7 Block Length*/
} usb_device_current_max_capacity_descriptor_struct_t;
/*! @brief UFI formatting capacity structure*/
typedef struct _usb_device_formattable_capacity_descriptor_struct
{
uint32_t blockNumber; /*!< Number of Blocks*/
uint32_t blockLength; /*!< Block Length*/
} usb_device_formattable_capacity_descriptor_struct_t;
/*! @brief UFI mode parameters header structure*/
typedef struct _usb_device_mode_parameters_header_struct
{
uint16_t modeDataLength; /*!< Mode Data Length*/
uint8_t mediumTypeCode; /*!< The Medium Type Code field specifies the inserted medium type*/
uint8_t wpDpfua; /*!< WP and DPOFUA bit*/
uint8_t reserved[4]; /*!< Reserved*/
} usb_device_mode_parameters_header_struct_t;
/*! @brief UFI Capacity List structure*/
typedef struct _usb_device_format_capacity_response_data_struct
{
uint8_t capacityListHead[sizeof(usb_device_capacity_list_header_struct_t)]; /*!<Capacity List Header*/
uint8_t currentMaxCapacityDesccriptor[sizeof(
usb_device_current_max_capacity_descriptor_struct_t)]; /*!<Current/Maximum Capacity Header*/
uint8_t formattableCapacityDesccriptor[sizeof(usb_device_formattable_capacity_descriptor_struct_t) *
3]; /*!<Formatting Capacity Descriptor*/
} usb_device_format_capacity_response_data_struct_t;
/*! @}*/
#endif
| {
"pile_set_name": "Github"
} |
// RUN: %clang_cc1 -fsyntax-only -verify %s
class c {
virtual void f1(const char* a, ...)
__attribute__ (( __format__(__printf__,2,3) )) = 0;
virtual void f2(const char* a, ...)
__attribute__ (( __format__(__printf__,2,3) )) {}
};
template <typename T> class X {
template <typename S> void X<S>::f() __attribute__((locks_excluded())); // expected-error{{nested name specifier 'X<S>::' for declaration does not refer into a class, class template or class template partial specialization}} \
// expected-warning{{attribute locks_excluded ignored, because it is not attached to a declaration}}
};
namespace PR17666 {
const int A = 1;
typedef int __attribute__((__aligned__(A))) T1;
int check1[__alignof__(T1) == 1 ? 1 : -1];
typedef int __attribute__((aligned(int(1)))) T1;
typedef int __attribute__((aligned(int))) T2; // expected-error {{expected '(' for function-style cast}}
}
__attribute((typename)) int x; // expected-warning {{unknown attribute 'typename' ignored}}
| {
"pile_set_name": "Github"
} |
<?php
namespace oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2;
/**
* @xmlNamespace urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2
* @xmlType LineReferenceType
* @xmlName DespatchLineReference
* @var oasis\names\specification\ubl\schema\xsd\CommonAggregateComponents_2\DespatchLineReference
*/
class DespatchLineReference extends LineReferenceType
{
} // end class DespatchLineReference
| {
"pile_set_name": "Github"
} |
Version 0.6 (9/5/2004)
======================
Important fixes for running as root systems with /dev/ptmx! Earlier
versions screwed up permissions on /dev/ptmx on some systems, making a
real mess.
Other features useful for running as root: Can now set permissions on
pty, and also chroot and switch UID/GID after opening devices.
If permissions are set on the pty, create a process to monitor
interceptty for exit, and when it finishes fix up permissions. This
makes sure permissions get reset even if interceptty dies
unexpectedly, and also allows us to reset a pty owner even if we've
dropped privileges. This isn't necessary on modern systems, but
doesn't hurt.
Version 0.5 (7/3/2004)
======================
Many portability fixes. Lifted PTY code from OpenSSH. Tested on RedHat
7.2, Fedora Core 2, Solaris 2.8, OpenBSD 2.9. Should be portable to
all platforms OpenSSH is, although it may need some fixes.
Version 0.4 (6/27/2004)
=======================
Added all sorts of new backends, and some new frontends too, including
new VMWare compatability. See the manpage for more information.
Added a manpage.
We don't poll when our first client goes away now.
Signal handling using sigaction, and should be more reliable.
Add some switches, to reduce the amount of output and print the
version.
Use -Wall compiler flags.
Version 0.3
===========
Fixed a problem with option parsing that prevented the 'front-device'
option from working.
Version 0.2b
============
Replaced accidental inclusion of an incorrect COPYING file.
Version 0.2
===========
Modified to use GNU autoconf.
Fixed a problem with option parsing that prevented '-t' from working.
Re-formatted the whole thing, converting from the ttysnoop-style to my
own preferred style.
Version 0.1b
===========
Fixed a compilation problem.
Version 0.1
===========
This is the first release.
$Id: NEWS,v 7.7 2004/09/05 22:42:29 gifford Exp $
| {
"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>Main cib file base name</key>
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>BindingContiniouslyUpdatesValue</string>
</dict>
</plist>
| {
"pile_set_name": "Github"
} |
#!/bin/sh
initializeANSI()
{
esc=""
blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m"
yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m"
cyanf="${esc}[36m"; whitef="${esc}[37m"
blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m"
yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m"
cyanb="${esc}[46m"; whiteb="${esc}[47m"
boldon="${esc}[1m"; boldoff="${esc}[22m"
italicson="${esc}[3m"; italicsoff="${esc}[23m"
ulon="${esc}[4m"; uloff="${esc}[24m"
invon="${esc}[7m"; invoff="${esc}[27m"
reset="${esc}[0m"
}
initializeANSI
cat << EOF
${reset}${blackf}| | | | |${reset}
${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset}
${redf}███████${reset} ${blackf}|${reset} ${greenf}███████${reset} ${blackf}|${reset} ${yellowf}███████${reset} ${blackf}|${reset} ${bluef}███████${reset} ${blackf}|${reset} ${purplef}███████${reset} ${blackf}|${reset} ${cyanf}███████${reset}
${redf}███${boldon}${redb}██${reset}${redf}█${boldon}${redb}██${reset}${redf}███${reset} ${blackf}|${reset} ${greenf}███${boldon}${greenb}██${reset}${greenf}█${boldon}${greenb}██${reset}${greenf}███${reset} ${blackf}|${reset} ${yellowf}███${boldon}${yellowb}██${reset}${yellowf}█${boldon}${yellowb}██${reset}${yellowf}███${reset} ${blackf}|${reset} ${bluef}███${boldon}${blueb}██${reset}${bluef}█${boldon}${blueb}██${reset}${bluef}███${reset} ${blackf}|${reset} ${purplef}███${boldon}${purpleb}██${reset}${purplef}█${boldon}${purpleb}██${reset}${purplef}███${reset} ${blackf}|${reset} ${cyanf}███${boldon}${cyanb}██${reset}${cyanf}█${boldon}${cyanb}██${reset}${cyanf}███${reset}
${redf}████${boldon}${redb}█${reset}${redf}████${reset} ${blackf}|${reset} ${greenf}████${boldon}${greenb}█${reset}${greenf}████${reset} ${blackf}|${reset} ${yellowf}████${boldon}${yellowb}█${reset}${yellowf}████${reset} ${blackf}|${reset} ${bluef}████${boldon}${blueb}█${reset}${bluef}████${reset} ${blackf}|${reset} ${purplef}████${boldon}${purpleb}█${reset}${purplef}████${reset} ${blackf}|${reset} ${cyanf}████${boldon}${cyanb}█${reset}${cyanf}████${reset}
${redf}█ █ ${boldon}█${reset} ${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █ ${boldon}█${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █ ${boldon}█${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █ ${boldon}█${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █ ${boldon}█${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █ ${boldon}█${reset} ${cyanf}█ █${reset}
${redf}█ █${reset} ${blackf}|${reset} ${greenf}█ █${reset} ${blackf}|${reset} ${yellowf}█ █${reset} ${blackf}|${reset} ${bluef}█ █${reset} ${blackf}|${reset} ${purplef}█ █${reset} ${blackf}|${reset} ${cyanf}█ █${reset}
${blackf}| | | | |${reset}
EOF | {
"pile_set_name": "Github"
} |
/*
This file is part of TON Blockchain Library.
TON Blockchain 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.
TON Blockchain 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 TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
Copyright 2020 Telegram Systems LLP
*/
namespace td {
class LinearAllocator {
std::size_t size;
char *ptr, *cur, *end;
public:
LinearAllocator(std::size_t _size) : size(_size) {
cur = ptr = (char*)malloc(size);
if (!ptr) {
throw std::bad_alloc();
}
end = ptr + size;
}
~LinearAllocator() {
free(ptr);
}
void* allocate(std::size_t count) {
char* t = cur;
cur += (count + 7) & -8;
if (cur > end) {
throw std::bad_alloc();
}
return (void*)t;
}
};
} // namespace td
inline void* operator new(std::size_t count, td::LinearAllocator& alloc) {
return alloc.allocate(count);
}
| {
"pile_set_name": "Github"
} |
namespace ClassLib048
{
public class Class061
{
public static string Property => "ClassLib048";
}
}
| {
"pile_set_name": "Github"
} |
<!-- ((! set title Streams !)) ((! set learn !)) -->
*Table of contents*
# Streams
Suppose you need to process each line of a text file. One way to do this
is to read the file in as a single large string and use something like
`Str.split` to turn it into a list. This works when the file is small,
but because the entire file is loaded into memory, it does not scale
well when the file is large.
More commonly, the `input_line` function can be used to read one line at
a time from a channel. This typically looks like:
```ocaml
let in_channel = open_in "lines.txt" in
try
while true do
let line = input_line in_channel in
(* do something with line *)
done
with End_of_file ->
close_in in_channel
```
The above code is efficient with memory, but it can be inconvenient in
other ways. Since `input_line` only works with the `in_channel` type, it
cannot be reused in cases where the text is already in memory. The
`End_of_file` exception can be raised at any point during iteration, and
it is the programmer's responsibility to ensure that the file is closed
appropriately. In fact, if there is any other exception in the above
example, the file will not be closed at all. Altogether, there is a lot
going on: channels, I/O, exceptions, and files.
Streams offer an abstraction over one part of this process: reading
items from a sequence. They don't assume anything about files or
channels, and they replace the `End_of_file` exception with a more
structured approach to dealing with the end of input. Here is a function
that builds a stream of lines from an input channel:
```ocamltop
let line_stream_of_channel channel =
Stream.from
(fun _ ->
try Some (input_line channel) with End_of_file -> None)
```
The "Stream.from" function builds a stream from a callback function.
This function is passed the current stream count (starting with 0) as an
argument and is expected to return an `'a option`. If the option has a
value (`Some x`), that value will be the next item in the stream. If it
has no value (`None`), this indicates that the stream is empty and no
further reads will be attempted. Since the option is polymorphic,
`Stream.from` can construct streams of any type. These streams have a
type of `'a Stream.t`.
With this simple function, we can now easily construct line streams from
any input channel:
```ocamltop
let in_channel = open_in "README.md";;
let lines = line_stream_of_channel in_channel;;
```
This variable `lines` is a stream of strings, one string per line. We
can now begin reading lines from it by passing it to `Stream.next`:
```ocamltop
Stream.next lines;;
Stream.next lines;;
Stream.next lines;;
Stream.next lines;;
while true do ignore(Stream.next lines) done;;
```
As you can see, `Stream.next` either returns the next item in the stream
or raises a `Stream.Failure` exception indicating that the stream is
empty. Likewise, with a little help from the `Stream.of_list`
constructor and the `Str` regular expression module, we could build a
stream of lines from a string in memory:
```ocamltop
#load "str.cma";;
let line_stream_of_string string =
Stream.of_list (Str.split (Str.regexp "\n") string)
```
and these streams could be used exactly the same way:
```ocamltop
let lines = line_stream_of_string "hello\nstream\nworld";;
Stream.next lines;;
Stream.next lines;;
Stream.next lines;;
Stream.next lines;;
```
Since both cases raise `Stream.Failure` on an empty stream, there is no
need to worry about catching `End_of_file` in the case of file I/O. This
unified interface makes it much easier to write functions that can
receive data from multiple sources.
The `Stream.iter` function automates the common task of performing an
operation for each item. With it, we can rewrite the original example as
follows:
```ocaml
let in_channel = open_in "README.md" in
try
Stream.iter
(fun line ->
(* do something with line *)
print_endline line)
(line_stream_of_channel in_channel);
close_in in_channel
with e ->
close_in in_channel;
raise e
```
Note how much easier it is to handle I/O exceptions properly, since we
can deal with them independently from the end-of-file condition. This
separation of concerns allows us to decompose this into simpler and more
reusable functions:
```ocamltop
let process_line line =
print_endline line
let process_lines lines =
Stream.iter process_line lines
let process_file filename =
let in_channel = open_in filename in
try
process_lines (line_stream_of_channel in_channel);
close_in in_channel
with e ->
close_in in_channel;
raise e
let process_string string =
process_lines (line_stream_of_string string)
```
## Constructing streams
In the above examples, we saw two methods for constructing streams:
* Stream.from, which builds a stream from a callback function
* Stream.of_list, which builds a stream from a list in memory
The `Stream` module provides a few other stream builders:
* Stream.of_string, which builds a character stream from a string
* Stream.of_channel, which builds a character stream from a channel
`Stream.from` is the most general, and it can be used to produce streams
of any type. It is not limited to I/O and can even produce infinite
sequences. Here are a few simple stream builders defined with
`Stream.from`:
```ocamltop
(* A stream that is always empty. *)
let empty_stream () = Stream.from (fun _ -> None);;
(* A stream that yields the same item repeatedly. *)
let const_stream k = Stream.from (fun _ -> Some k);;
(* A stream that yields consecutive integers starting with 'i'. *)
let count_stream i = Stream.from (fun j -> Some (i + j));;
```
## Deconstructing streams
We already saw the `Stream.next` function, which retrieves a single item
from a stream. There is another way to work with streams that is often
preferable: `Stream.peek` and `Stream.junk`. When used together, these
functions allow you to see what the next item would be. This feature,
known as "look ahead", is very useful when writing parsers. Even if you
don't need to look ahead, the peek/junk protocol may be nicer to work
with because it uses options instead of exceptions:
```ocamltop
let lines = line_stream_of_string "hello\nworld";;
Stream.peek lines;;
Stream.peek lines;;
Stream.junk lines;;
Stream.peek lines;;
Stream.junk lines;;
Stream.peek lines;;
```
As you can see, it is necessary to call `Stream.junk` to advance to the
next item. `Stream.peek` will always give you either the next item or
`None`, and it will never fail. Likewise, `Stream.junk` always succeeds
(even if the stream is empty).
## A more complex `Stream.from` example
Here is a function that converts a line stream into a paragraph stream.
As such, it is both a stream consumer and a stream producer.
```ocamltop
let paragraphs lines =
let rec next para_lines i =
match Stream.peek lines, para_lines with
| None, [] -> None
| Some "", [] ->
Stream.junk lines;
next para_lines i
| Some "", _ | None, _ ->
Some (String.concat "\n" (List.rev para_lines))
| Some line, _ ->
Stream.junk lines;
next (line :: para_lines) i in
Stream.from (next [])
```
This function uses an extra parameter to `next` (the `Stream.from`
callback) called `para_lines` in order to collect the lines for each
paragraph. Paragraphs are delimited by any number of blank lines.
Each time `next` is called, a `match` expression tests two values: the
next line in the stream, and the contents of `para_lines`. Four cases
are handled:
1. If the end of the stream is reached and no lines have been
collected, the paragraph stream ends as well.
1. If the next line is blank and no lines have been collected, the
blank is ignored and `next` is called recursively to keep looking
for a non-blank line.
1. If a blank line or end of stream is reached and lines **have** been
collected, the paragraph is returned by concatenating `para_lines`
to a single string.
1. Finally, if a non-blank line has been reached, the line is collected
by recursively calling `para_lines`.
Happily, we can rely on the OCaml compiler's exhaustiveness checking to
ensure that we are handling all possible cases.
With this new tool, we can now work just as easily with paragraphs as we
could before with lines:
```ocaml
(* Print each paragraph, followed by a separator. *)
let lines = line_stream_of_channel in_channel in
Stream.iter
(fun para ->
print_endline para;
print_endline "--")
(paragraphs lines)
```
Functions like `paragraphs` that produce and consume streams can be
composed together in a manner very similar to UNIX pipes and filters.
## Stream combinators
Just like lists and arrays, common iteration patterns such as `map`,
`filter`, and `fold` can be very useful. The `Stream` module does not
provide such functions, but they can be built easily using
`Stream.from`:
```ocamltop
let stream_map f stream =
let rec next i =
try Some (f (Stream.next stream))
with Stream.Failure -> None in
Stream.from next
let stream_filter p stream =
let rec next i =
try
let value = Stream.next stream in
if p value then Some value else next i
with Stream.Failure -> None in
Stream.from next
let stream_fold f stream init =
let result = ref init in
Stream.iter
(fun x -> result := f x !result)
stream;
!result
```
For example, here is a stream of leap years starting with 2000:
```ocamltop
let is_leap year =
year mod 4 = 0 && (year mod 100 <> 0 || year mod 400 = 0)
let leap_years = stream_filter is_leap (count_stream 2000)
```
We can use the `Stream.npeek` function to look ahead by more than one
item. In this case, we'll peek at the next 30 items to make sure that
the year 2100 is not a leap year (since it's divisible by 100 but not
400!):
```ocamltop
Stream.npeek 30 leap_years;;
```
Note that we must be careful not to use `Stream.iter` on an infinite
stream like `leap_years`. This applies to `stream_fold`, as well as any
function that attempts to consume the entire stream.
```ocamltop
stream_fold (+) (Stream.of_list [1; 2; 3]) 0;;
```
`stream_fold (+) (count_stream 0) 0` runs forever.
## Other useful stream builders
The previously defined `const_stream` function builds a stream that
repeats a single value. It is also useful to build a stream that repeats
a sequence of values. The following function does just that:
```ocamltop
let cycle items =
let buf = ref [] in
let rec next i =
if !buf = [] then buf := items;
match !buf with
| h :: t -> (buf := t; Some h)
| [] -> None in
Stream.from next
```
One common task that can benefit from this kind of stream is the
generation of alternating background colors for HTML. By using `cycle`
with `stream_combine`, explained in the next section, an infinite stream
of background colors can be combined with a finite stream of data to
produce a sequence of HTML blocks:
```ocamltop
let stream_combine stream1 stream2 =
let rec next i =
try Some (Stream.next stream1, Stream.next stream2)
with Stream.Failure -> None in
Stream.from next;;
Stream.iter print_endline
(stream_map
(fun (bg, s) ->
Printf.sprintf "<div style='background: %s'>%s</div>" bg s)
(stream_combine
(cycle ["#eee"; "#fff"])
(Stream.of_list ["hello"; "html"; "world"])))
```
Here is a simple `range` function that produces a sequence of integers:
```ocamltop
let range ?(start=0) ?(stop=0) ?(step=1) () =
let in_range = if step < 0 then (>) else (<) in
let current = ref start in
let rec next i =
if in_range !current stop
then let result = !current in (current := !current + step;
Some result)
else None in
Stream.from next
```
This works just like Python's `xrange` built-in function, providing an
easy way to produce an assortment of lazy integer sequences by
specifying combinations of `start`, `stop`, or `step` values:
```ocamltop
Stream.npeek 10 (range ~start:5 ~stop:10 ());;
Stream.npeek 10 (range ~stop:10 ~step:2 ());;
Stream.npeek 10 (range ~start:10 ~step:(-1) ());;
Stream.npeek 10 (range ~start:10 ~stop:5 ~step:(-1) ());;
```
## Combining streams
There are several ways to combine streams. One is to produce a stream of
streams and then concatenate them into a single stream. The following
function works just like `List.concat`, but instead of turning a list of
lists into a list, it turns a stream of streams into a stream:
```ocamltop
let stream_concat streams =
let current_stream = ref None in
let rec next i =
try
let stream =
match !current_stream with
| Some stream -> stream
| None ->
let stream = Stream.next streams in
current_stream := Some stream;
stream in
try Some (Stream.next stream)
with Stream.Failure -> (current_stream := None; next i)
with Stream.Failure -> None in
Stream.from next
```
Here is a sequence of ranges which are themselves derived from a range,
concatenated with `stream_concat` to produce a flattened `int Stream.t`.
```ocamltop
Stream.npeek 10
(stream_concat
(stream_map
(fun i -> range ~stop:i ())
(range ~stop:5 ())))
```
Another way to combine streams is to iterate through them in a pairwise
fashion:
```ocamltop
let stream_combine stream1 stream2 =
let rec next i =
try Some (Stream.next stream1, Stream.next stream2)
with Stream.Failure -> None in
Stream.from next
```
This is useful, for instance, if you have a stream of keys and a stream
of corresponding values. Iterating through key value pairs is then as
simple as:
```ocaml
Stream.iter
(fun (key, value) ->
(* do something with 'key' and 'value' *)
())
(stream_combine key_stream value_stream)
```
Since `stream_combine` stops as soon as either of its input streams runs
out, it can be used to combine an infinite stream with a finite one.
This provides a neat way to add indexes to a sequence:
```ocamltop
let items = ["this"; "is"; "a"; "test"];;
Stream.iter
(fun (index, value) ->
Printf.printf "%d. %s\n%!" index value)
(stream_combine (count_stream 1) (Stream.of_list items))
```
## Copying streams
Streams are destructive; once you discard an item in a stream, it is no
longer available unless you save a copy somewhere. What if you want to
use the same stream more than once? One way is to create a "tee". The
following function creates two output streams from one input stream,
intelligently queueing unseen values until they have been produced by
both streams:
```ocamltop
let stream_tee stream =
let next self other i =
try
if Queue.is_empty self
then
let value = Stream.next stream in
Queue.add value other;
Some value
else
Some (Queue.take self)
with Stream.Failure -> None in
let q1 = Queue.create () in
let q2 = Queue.create () in
(Stream.from (next q1 q2), Stream.from (next q2 q1))
```
Here is an example of a stream tee in action:
```ocamltop
let letters = Stream.of_list ['a'; 'b'; 'c'; 'd'; 'e'];;
let s1, s2 = stream_tee letters;;
Stream.next s1;;
Stream.next s1;;
Stream.next s2;;
Stream.next s1;;
Stream.next s2;;
Stream.next s2;;
```
Again, since streams are destructive, you probably want to leave the
original stream alone or you will lose items from the copied streams:
```ocamltop
Stream.next letters;;
Stream.next s1;;
Stream.next s2;;
```
## Converting streams
Here are a few functions for converting between streams and lists,
arrays, and hash tables. These probably belong in the standard library,
but they are simple to define anyhow. Again, beware of infinite streams,
which will cause these functions to hang.
```ocamltop
(* This one is free. *)
let stream_of_list = Stream.of_list
let list_of_stream stream =
let result = ref [] in
Stream.iter (fun value -> result := value :: !result) stream;
List.rev !result
let stream_of_array array =
Stream.of_list (Array.to_list array)
let array_of_stream stream =
Array.of_list (list_of_stream stream)
let stream_of_hash hash =
let result = ref [] in
Hashtbl.iter
(fun key value -> result := (key, value) :: !result)
hash;
Stream.of_list !result
let hash_of_stream stream =
let result = Hashtbl.create 0 in
Stream.iter
(fun (key, value) -> Hashtbl.replace result key value)
stream;
result
```
What if you want to convert arbitrary data types to streams? Well, if the
data type defines an `iter` function, and you don't mind using threads,
you can use a producer-consumer arrangement to invert control:
```ocamltop
#directory "+threads";;
#load "threads.cma";;
let elements iter coll =
let channel = Event.new_channel () in
let producer () =
let () =
iter (fun x -> Event.sync (Event.send channel (Some x))) coll in
Event.sync (Event.send channel None) in
let consumer i =
Event.sync (Event.receive channel) in
ignore (Thread.create producer ());
Stream.from consumer
```
Now it is possible to build a stream from an `iter` function and a
corresponding value:
```ocamltop
module StringSet = Set.Make(String);;
let set = StringSet.empty;;
let set = StringSet.add "here" set;;
let set = StringSet.add "are" set;;
let set = StringSet.add "some" set;;
let set = StringSet.add "values" set;;
let stream = elements StringSet.iter set;;
Stream.iter print_endline stream;;
```
Some data types, like Hashtbl and Map, provide an `iter` function that
iterates through key-value pairs. Here's a function for those, too:
```ocamltop
let items iter coll =
let channel = Event.new_channel () in
let producer () =
let () =
iter (fun k v ->
Event.sync (Event.send channel (Some (k, v)))) coll in
Event.sync (Event.send channel None) in
let consumer i =
Event.sync (Event.receive channel) in
ignore (Thread.create producer ());
Stream.from consumer
```
If we want just the keys, or just the values, it is simple to transform
the output of `items` using `stream_map`:
```ocamltop
let keys iter coll = stream_map (fun (k, v) -> k) (items iter coll)
let values iter coll = stream_map (fun (k, v) -> v) (items iter coll)
```
Keep in mind that these techniques spawn producer threads which carry a
few risks: they only terminate when they have finished iterating, and
any change to the original data structure while iterating may produce
unexpected results.
## Other built-in Stream functions
There are a few other documented methods in the `Stream` module:
* Stream.empty, which raises `Stream.Failure` unless a stream is empty
* Stream.count, which returns the stream count (number of discarded
elements)
In addition, there are a few undocumented functions: `iapp`, `icons`,
`ising`, `lapp`, `lcons`, `lsing`, `sempty`, `slazy`, and `dump`. They
are visible in the interface with the caveat: "For system use only, not
for the casual user".
| {
"pile_set_name": "Github"
} |
/*
* Bluetooth supports for Qualcomm Atheros chips
*
* Copyright (c) 2015 The Linux Foundation. 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 version 2
* as published by the Free Software Foundation
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <linux/module.h>
#include <linux/firmware.h>
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include "btqca.h"
#define VERSION "0.1"
static int rome_patch_ver_req(struct hci_dev *hdev, u32 *rome_version)
{
struct sk_buff *skb;
struct edl_event_hdr *edl;
struct rome_version *ver;
char cmd;
int err = 0;
BT_DBG("%s: ROME Patch Version Request", hdev->name);
cmd = EDL_PATCH_VER_REQ_CMD;
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN,
&cmd, HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: Failed to read version of ROME (%d)", hdev->name,
err);
return err;
}
if (skb->len != sizeof(*edl) + sizeof(*ver)) {
BT_ERR("%s: Version size mismatch len %d", hdev->name,
skb->len);
err = -EILSEQ;
goto out;
}
edl = (struct edl_event_hdr *)(skb->data);
if (!edl) {
BT_ERR("%s: TLV with no header", hdev->name);
err = -EILSEQ;
goto out;
}
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
edl->rtype != EDL_APP_VER_RES_EVT) {
BT_ERR("%s: Wrong packet received %d %d", hdev->name,
edl->cresp, edl->rtype);
err = -EIO;
goto out;
}
ver = (struct rome_version *)(edl->data);
BT_DBG("%s: Product:0x%08x", hdev->name, le32_to_cpu(ver->product_id));
BT_DBG("%s: Patch :0x%08x", hdev->name, le16_to_cpu(ver->patch_ver));
BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rome_ver));
BT_DBG("%s: SOC :0x%08x", hdev->name, le32_to_cpu(ver->soc_id));
/* ROME chipset version can be decided by patch and SoC
* version, combination with upper 2 bytes from SoC
* and lower 2 bytes from patch will be used.
*/
*rome_version = (le32_to_cpu(ver->soc_id) << 16) |
(le16_to_cpu(ver->rome_ver) & 0x0000ffff);
out:
kfree_skb(skb);
return err;
}
static int rome_reset(struct hci_dev *hdev)
{
struct sk_buff *skb;
int err;
BT_DBG("%s: ROME HCI_RESET", hdev->name);
skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: Reset failed (%d)", hdev->name, err);
return err;
}
kfree_skb(skb);
return 0;
}
static void rome_tlv_check_data(struct rome_config *config,
const struct firmware *fw)
{
const u8 *data;
u32 type_len;
u16 tag_id, tag_len;
int idx, length;
struct tlv_type_hdr *tlv;
struct tlv_type_patch *tlv_patch;
struct tlv_type_nvm *tlv_nvm;
tlv = (struct tlv_type_hdr *)fw->data;
type_len = le32_to_cpu(tlv->type_len);
length = (type_len >> 8) & 0x00ffffff;
BT_DBG("TLV Type\t\t : 0x%x", type_len & 0x000000ff);
BT_DBG("Length\t\t : %d bytes", length);
switch (config->type) {
case TLV_TYPE_PATCH:
tlv_patch = (struct tlv_type_patch *)tlv->data;
BT_DBG("Total Length\t\t : %d bytes",
le32_to_cpu(tlv_patch->total_size));
BT_DBG("Patch Data Length\t : %d bytes",
le32_to_cpu(tlv_patch->data_length));
BT_DBG("Signing Format Version : 0x%x",
tlv_patch->format_version);
BT_DBG("Signature Algorithm\t : 0x%x",
tlv_patch->signature);
BT_DBG("Reserved\t\t : 0x%x",
le16_to_cpu(tlv_patch->reserved1));
BT_DBG("Product ID\t\t : 0x%04x",
le16_to_cpu(tlv_patch->product_id));
BT_DBG("Rom Build Version\t : 0x%04x",
le16_to_cpu(tlv_patch->rom_build));
BT_DBG("Patch Version\t\t : 0x%04x",
le16_to_cpu(tlv_patch->patch_version));
BT_DBG("Reserved\t\t : 0x%x",
le16_to_cpu(tlv_patch->reserved2));
BT_DBG("Patch Entry Address\t : 0x%x",
le32_to_cpu(tlv_patch->entry));
break;
case TLV_TYPE_NVM:
idx = 0;
data = tlv->data;
while (idx < length) {
tlv_nvm = (struct tlv_type_nvm *)(data + idx);
tag_id = le16_to_cpu(tlv_nvm->tag_id);
tag_len = le16_to_cpu(tlv_nvm->tag_len);
/* Update NVM tags as needed */
switch (tag_id) {
case EDL_TAG_ID_HCI:
/* HCI transport layer parameters
* enabling software inband sleep
* onto controller side.
*/
tlv_nvm->data[0] |= 0x80;
/* UART Baud Rate */
tlv_nvm->data[2] = config->user_baud_rate;
break;
case EDL_TAG_ID_DEEP_SLEEP:
/* Sleep enable mask
* enabling deep sleep feature on controller.
*/
tlv_nvm->data[0] |= 0x01;
break;
}
idx += (sizeof(u16) + sizeof(u16) + 8 + tag_len);
}
break;
default:
BT_ERR("Unknown TLV type %d", config->type);
break;
}
}
static int rome_tlv_send_segment(struct hci_dev *hdev, int idx, int seg_size,
const u8 *data)
{
struct sk_buff *skb;
struct edl_event_hdr *edl;
struct tlv_seg_resp *tlv_resp;
u8 cmd[MAX_SIZE_PER_TLV_SEGMENT + 2];
int err = 0;
BT_DBG("%s: Download segment #%d size %d", hdev->name, idx, seg_size);
cmd[0] = EDL_PATCH_TLV_REQ_CMD;
cmd[1] = seg_size;
memcpy(cmd + 2, data, seg_size);
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, cmd,
HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: Failed to send TLV segment (%d)", hdev->name, err);
return err;
}
if (skb->len != sizeof(*edl) + sizeof(*tlv_resp)) {
BT_ERR("%s: TLV response size mismatch", hdev->name);
err = -EILSEQ;
goto out;
}
edl = (struct edl_event_hdr *)(skb->data);
if (!edl) {
BT_ERR("%s: TLV with no header", hdev->name);
err = -EILSEQ;
goto out;
}
tlv_resp = (struct tlv_seg_resp *)(edl->data);
if (edl->cresp != EDL_CMD_REQ_RES_EVT ||
edl->rtype != EDL_TVL_DNLD_RES_EVT || tlv_resp->result != 0x00) {
BT_ERR("%s: TLV with error stat 0x%x rtype 0x%x (0x%x)",
hdev->name, edl->cresp, edl->rtype, tlv_resp->result);
err = -EIO;
}
out:
kfree_skb(skb);
return err;
}
static int rome_tlv_download_request(struct hci_dev *hdev,
const struct firmware *fw)
{
const u8 *buffer, *data;
int total_segment, remain_size;
int ret, i;
if (!fw || !fw->data)
return -EINVAL;
total_segment = fw->size / MAX_SIZE_PER_TLV_SEGMENT;
remain_size = fw->size % MAX_SIZE_PER_TLV_SEGMENT;
BT_DBG("%s: Total segment num %d remain size %d total size %zu",
hdev->name, total_segment, remain_size, fw->size);
data = fw->data;
for (i = 0; i < total_segment; i++) {
buffer = data + i * MAX_SIZE_PER_TLV_SEGMENT;
ret = rome_tlv_send_segment(hdev, i, MAX_SIZE_PER_TLV_SEGMENT,
buffer);
if (ret < 0)
return -EIO;
}
if (remain_size) {
buffer = data + total_segment * MAX_SIZE_PER_TLV_SEGMENT;
ret = rome_tlv_send_segment(hdev, total_segment, remain_size,
buffer);
if (ret < 0)
return -EIO;
}
return 0;
}
static int rome_download_firmware(struct hci_dev *hdev,
struct rome_config *config)
{
const struct firmware *fw;
int ret;
BT_INFO("%s: ROME Downloading %s", hdev->name, config->fwname);
ret = request_firmware(&fw, config->fwname, &hdev->dev);
if (ret) {
BT_ERR("%s: Failed to request file: %s (%d)", hdev->name,
config->fwname, ret);
return ret;
}
rome_tlv_check_data(config, fw);
ret = rome_tlv_download_request(hdev, fw);
if (ret) {
BT_ERR("%s: Failed to download file: %s (%d)", hdev->name,
config->fwname, ret);
}
release_firmware(fw);
return ret;
}
int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr)
{
struct sk_buff *skb;
u8 cmd[9];
int err;
cmd[0] = EDL_NVM_ACCESS_SET_REQ_CMD;
cmd[1] = 0x02; /* TAG ID */
cmd[2] = sizeof(bdaddr_t); /* size */
memcpy(cmd + 3, bdaddr, sizeof(bdaddr_t));
skb = __hci_cmd_sync_ev(hdev, EDL_NVM_ACCESS_OPCODE, sizeof(cmd), cmd,
HCI_VENDOR_PKT, HCI_INIT_TIMEOUT);
if (IS_ERR(skb)) {
err = PTR_ERR(skb);
BT_ERR("%s: Change address command failed (%d)",
hdev->name, err);
return err;
}
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome);
int qca_uart_setup_rome(struct hci_dev *hdev, uint8_t baudrate)
{
u32 rome_ver = 0;
struct rome_config config;
int err;
BT_DBG("%s: ROME setup on UART", hdev->name);
config.user_baud_rate = baudrate;
/* Get ROME version information */
err = rome_patch_ver_req(hdev, &rome_ver);
if (err < 0 || rome_ver == 0) {
BT_ERR("%s: Failed to get version 0x%x", hdev->name, err);
return err;
}
BT_INFO("%s: ROME controller version 0x%08x", hdev->name, rome_ver);
/* Download rampatch file */
config.type = TLV_TYPE_PATCH;
snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin",
rome_ver);
err = rome_download_firmware(hdev, &config);
if (err < 0) {
BT_ERR("%s: Failed to download patch (%d)", hdev->name, err);
return err;
}
/* Download NVM configuration */
config.type = TLV_TYPE_NVM;
snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin",
rome_ver);
err = rome_download_firmware(hdev, &config);
if (err < 0) {
BT_ERR("%s: Failed to download NVM (%d)", hdev->name, err);
return err;
}
/* Perform HCI reset */
err = rome_reset(hdev);
if (err < 0) {
BT_ERR("%s: Failed to run HCI_RESET (%d)", hdev->name, err);
return err;
}
BT_INFO("%s: ROME setup on UART is completed", hdev->name);
return 0;
}
EXPORT_SYMBOL_GPL(qca_uart_setup_rome);
MODULE_AUTHOR("Ben Young Tae Kim <[email protected]>");
MODULE_DESCRIPTION("Bluetooth support for Qualcomm Atheros family ver " VERSION);
MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL");
| {
"pile_set_name": "Github"
} |
task :default do
sh "compass compile"
end
task :pages do
require 'git'
require 'fileutils'
repo = Git.open('.')
# copy tests into a temp dir before switching branch
FileUtils.rm_rf "tmp"
FileUtils.mkdir("tmp")
(FileList.new('tests/**/*.html')+FileList.new('tests/**/*.css')).each do |file|
FileUtils.mkdir_p(File.dirname("tmp/#{file[6..-1]}"))
FileUtils.cp(file, "tmp/#{file[6..-1]}")
end
# switch branch
repo.branch("gh-pages").checkout
# Prepare gh-pages
FileUtils.rm_rf "recipes/*"
htmlHeader = File.open("layout/header.html", "r").read
htmlFooter = File.open("layout/footer.html", "r").read
# HTML files need header and footer
FileList.new('tmp/**/*.html').each do |file|
FileUtils.mkdir_p(File.dirname("#{file[4..-1]}"))
htmlfile = File.open("#{file[4..-1]}", "w")
contents = File.open(file, "rb").read
htmlfile.write(htmlHeader+contents+htmlFooter)
htmlfile.close
end
# CSS: just copy
FileList.new('tmp/**/*.css').each do |file|
FileUtils.mkdir_p(File.dirname("#{file[4..-1]}"))
FileUtils.cp(file, "#{file[4..-1]}")
end
FileUtils.rm_rf("tmp")
# Commit gh-pages changes
# @todo make this optional ?
Dir["recipes/**/*"].each {|f| repo.add(f) }
repo.status.deleted.each {|f, s| repo.remove(f)}
message = ENV["MESSAGE"] || "Updated at #{Time.now.utc}"
repo.commit(message)
# back to master (maybe it's not appropriate if we are not working on master ?!)
repo.branch("master").checkout
end | {
"pile_set_name": "Github"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.