diff --git a/.travis.yml b/.travis.yml index 943c1b12..f75b3d89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ rvm: - 1.9.2 - 1.9.3 - 2.0.0 + - 2.1.1 - ree notifications: disabled: true diff --git a/github-linguist.gemspec b/github-linguist.gemspec index f10f8d1f..ca7647b8 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'github-linguist' - s.version = '2.10.11' + s.version = '2.10.12' s.summary = "GitHub Language detection" s.description = 'We use this library at GitHub to detect blob languages, highlight code, ignore binary files, suppress generated files in diffs, and generate language breakdown graphs.' diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb index a3de46e9..c1116780 100644 --- a/lib/linguist/heuristics.rb +++ b/lib/linguist/heuristics.rb @@ -28,6 +28,9 @@ module Linguist if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } disambiguate_cl(data, languages) end + if languages.all? { |l| ["Rebol", "R"].include?(l) } + disambiguate_r(data, languages) + end end end @@ -73,6 +76,13 @@ module Linguist matches end + def self.disambiguate_r(data, languages) + matches = [] + matches << Language["Rebol"] if /\bRebol\b/i.match(data) + matches << Language["R"] if data.include?("<-") + matches + end + def self.active? !!ACTIVE end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index bb91d126..955becb3 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -485,7 +485,7 @@ module Linguist # # Returns html String def colorize(text, options = {}) - lexer.highlight(text, options = {}) + lexer.highlight(text, options) end # Public: Return name as String representation diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index d1598190..6267be92 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -10,7 +10,7 @@ # ace_mode - A String name of Ace Mode (if available) # wrap - Boolean wrap to enable line wrapping (default: false) # extension - An Array of associated extensions -# interpreter - An Array of associated interpreters +# interpreters - An Array of associated interpreters # primary_extension - A String for the main extension associated with # the language. Must be unique. Used when a Language is picked # from a dropdown and we need to automatically choose an @@ -86,6 +86,12 @@ Agda: color: "#467C91" primary_extension: .agda +Alloy: + type: programming # 'modeling' would be more appropiate + lexer: Text only + color: "#cc5c24" + primary_extension: .als + ApacheConf: type: markup aliases: @@ -129,6 +135,12 @@ AsciiDoc: - .adoc - .asc +AspectJ: + type: programming + lexer: AspectJ + color: "#1957b0" + primary_extension: .aj + Assembly: type: programming lexer: NASM @@ -261,6 +273,7 @@ C++: - .hh - .hpp - .hxx + - .inl - .tcc - .tpp @@ -300,7 +313,7 @@ COBOL: CSS: ace_mode: css - color: "#1f085e" + color: "#563d7c" primary_extension: .css Ceylon: @@ -488,10 +501,19 @@ DCPU-16 ASM: Diff: primary_extension: .diff +Dogescript: + type: programming + lexer: Text only + color: "#cca760" + primary_extension: .djs + Dylan: type: programming color: "#3ebc27" primary_extension: .dylan + extensions: + - .intr + - .lid Ecere Projects: type: data @@ -507,6 +529,14 @@ ECL: extensions: - .eclxml +Eagle: + type: markup + color: "#3994bc" + lexer: XML + primary_extension: .sch + extensions: + - .brd + Eiffel: type: programming lexer: Text only @@ -603,7 +633,7 @@ Fancy: - .fancypack filenames: - Fakefile - + Fantom: type: programming color: "#dbded5" @@ -617,6 +647,17 @@ Forth: extensions: - .4th +Frege: + type: programming + color: "#00cafe" + lexer: Haskell + primary_extension: .fr + +Game Maker Language: + type: programming + lexer: JavaScript + primary_extension: .gml + GAS: type: programming group: Assembly @@ -664,6 +705,17 @@ Glyph: lexer: Tcl primary_extension: .glf +Gnuplot: + type: programming + color: "#f0a9f0" + lexer: Gnuplot + primary_extension: .gp + extensions: + - .gnu + - .gnuplot + - .plot + - .plt + Go: type: programming color: "#a89b4d" @@ -674,6 +726,16 @@ Gosu: color: "#82937f" primary_extension: .gs +Grammatical Framework: + type: programming + lexer: Haskell + aliases: + - gf + wrap: false + primary_extension: .gf + searchable: true + color: "#ff0000" + Groff: primary_extension: .man extensions: @@ -865,6 +927,12 @@ JSONLD: lexer: JavaScript primary_extension: .jsonld +JSONiq: + type: programming + ace_mode: jsoniq + lexer: XQuery + primary_extension: .jq + Jade: group: HTML type: markup @@ -887,7 +955,7 @@ Java Server Pages: JavaScript: type: programming ace_mode: javascript - color: "#f15501" + color: "#f7df1e" aliases: - js - node @@ -907,6 +975,8 @@ JavaScript: - .ssjs filenames: - Jakefile + interpreters: + - node Julia: type: programming @@ -1060,6 +1130,11 @@ Mask: ace_mode: scss primary_extension: .mask +Mathematica: + type: programming + primary_extension: .mathematica + lexer: Text only + Matlab: type: programming color: "#bb92ac" @@ -1186,9 +1261,14 @@ Objective-C: - obj-c - objc primary_extension: .m - extensions: - - .h - - .mm + +Objective-C++: + type: programming + color: "#4886FC" + aliases: + - obj-c++ + - objc++ + primary_extension: .mm Objective-J: type: programming @@ -1391,6 +1471,12 @@ Pure Data: lexer: Text only primary_extension: .pd +PureScript: + type: programming + color: "#f3ce45" + lexer: Haskell + primary_extension: .purs + Python: type: programming ace_mode: python @@ -1494,10 +1580,12 @@ Rebol: type: programming lexer: REBOL color: "#358a5b" - primary_extension: .rebol + primary_extension: .reb extensions: + - .r - .r2 - .r3 + - .rebol Redcode: primary_extension: .cw @@ -1636,6 +1724,11 @@ Shell: filenames: - Dockerfile +ShellSession: + type: programming + lexer: Bash Session + primary_extension: .sh-session + Shen: type: programming color: "#120F14" @@ -1655,6 +1748,13 @@ Smalltalk: Smarty: primary_extension: .tpl +SourcePawn: + type: programming + color: "#f69e1d" + aliases: + - sourcemod + primary_extension: .sp + Squirrel: type: programming lexer: C++ @@ -1669,6 +1769,19 @@ Standard ML: extensions: - .fun +Stata: + type: programming + lexer: Text only + extensions: + - .ado + - .do + - .doh + - .ihlp + - .mata + - .matah + - .sthlp + primary_extension: .do + Stylus: type: markup group: CSS @@ -1681,6 +1794,15 @@ SuperCollider: lexer: Text only primary_extension: .scd +SystemVerilog: + type: programming + color: "#343761" + lexer: systemverilog + primary_extension: .sv + extensions: + - .svh + - .vh + TOML: type: data primary_extension: .toml @@ -1696,6 +1818,7 @@ Tcl: primary_extension: .tcl extensions: - .adp + - .tm Tcsh: type: programming @@ -1858,6 +1981,7 @@ XML: - .kml - .launch - .mxml + - .osm - .plist - .pluginspec - .ps1xml @@ -1938,6 +2062,12 @@ YAML: - .rviz - .yaml +Zephir: + type: programming + lexer: PHP + color: "#118f9e" + primary_extension: .zep + eC: type: programming search_term: ec diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 6d26388a..8e205c94 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -6,6 +6,9 @@ "Agda": [ ".agda" ], + "Alloy": [ + ".als" + ], "Apex": [ ".cls" ], @@ -20,6 +23,9 @@ ".asc", ".asciidoc" ], + "AspectJ": [ + ".aj" + ], "ATS": [ ".atxt", ".dats", @@ -54,7 +60,8 @@ ".cc", ".cpp", ".h", - ".hpp" + ".hpp", + ".inl" ], "Ceylon": [ ".ceylon" @@ -105,6 +112,13 @@ "DM": [ ".dm" ], + "Dogescript": [ + ".djs" + ], + "Eagle": [ + ".brd", + ".sch" + ], "ECL": [ ".ecl" ], @@ -129,6 +143,12 @@ ".forth", ".fth" ], + "Frege": [ + ".fr" + ], + "Game Maker Language": [ + ".gml" + ], "GAS": [ ".s" ], @@ -136,12 +156,19 @@ ".fp", ".glsl" ], + "Gnuplot": [ + ".gnu", + ".gp" + ], "Gosu": [ ".gs", ".gst", ".gsx", ".vark" ], + "Grammatical Framework": [ + ".gf" + ], "Groovy": [ ".gradle", ".script!" @@ -186,6 +213,9 @@ "JSON5": [ ".json5" ], + "JSONiq": [ + ".jq" + ], "JSONLD": [ ".jsonld" ], @@ -237,6 +267,12 @@ "Markdown": [ ".md" ], + "Mask": [ + ".mask" + ], + "Mathematica": [ + ".m" + ], "Matlab": [ ".m" ], @@ -275,6 +311,9 @@ ".h", ".m" ], + "Objective-C++": [ + ".mm" + ], "OCaml": [ ".eliom", ".ml" @@ -350,6 +389,9 @@ "Protocol Buffer": [ ".proto" ], + "PureScript": [ + ".purs" + ], "Python": [ ".py", ".script!" @@ -369,7 +411,11 @@ ".rdoc" ], "Rebol": [ - ".r" + ".r", + ".r2", + ".r3", + ".reb", + ".rebol" ], "RMarkdown": [ ".rmd" @@ -417,9 +463,18 @@ ".sh", ".zsh" ], + "ShellSession": [ + ".sh-session" + ], + "Shen": [ + ".shen" + ], "Slash": [ ".sl" ], + "SourcePawn": [ + ".sp" + ], "Squirrel": [ ".nut" ], @@ -428,12 +483,29 @@ ".sig", ".sml" ], + "Stata": [ + ".ado", + ".do", + ".doh", + ".ihlp", + ".mata", + ".matah", + ".sthlp" + ], "Stylus": [ ".styl" ], "SuperCollider": [ ".scd" ], + "SystemVerilog": [ + ".sv", + ".svh", + ".vh" + ], + "Tcl": [ + ".tm" + ], "Tea": [ ".tea" ], @@ -488,6 +560,12 @@ ], "Xtend": [ ".xtend" + ], + "YAML": [ + ".yml" + ], + "Zephir": [ + ".zep" ] }, "interpreters": { @@ -551,8 +629,8 @@ ".gemrc" ] }, - "tokens_total": 450556, - "languages_total": 548, + "tokens_total": 534678, + "languages_total": 662, "tokens": { "ABAP": { "*/**": 1, @@ -871,6 +949,241 @@ "zero": 1, "Nat": 1 }, + "Alloy": { + "module": 3, + "examples/systems/file_system": 1, + "abstract": 2, + "sig": 20, + "Object": 10, + "{": 54, + "}": 60, + "Name": 2, + "File": 1, + "extends": 10, + "some": 3, + "d": 3, + "Dir": 8, + "|": 19, + "this": 14, + "in": 19, + "d.entries.contents": 1, + "entries": 3, + "set": 10, + "DirEntry": 2, + "parent": 3, + "lone": 6, + "this.": 4, + "@contents.": 1, + "@entries": 1, + "all": 16, + "e1": 2, + "e2": 2, + "e1.name": 1, + "e2.name": 1, + "@parent": 2, + "Root": 5, + "one": 8, + "no": 8, + "Cur": 1, + "name": 1, + "contents": 2, + "pred": 16, + "OneParent_buggyVersion": 2, + "-": 41, + "d.parent": 2, + "OneParent_correctVersion": 2, + "(": 12, + "&&": 2, + "contents.d": 1, + ")": 9, + "NoDirAliases": 3, + "o": 1, + "o.": 1, + "check": 6, + "for": 7, + "expect": 6, + "examples/systems/marksweepgc": 1, + "Node": 10, + "HeapState": 5, + "left": 3, + "right": 1, + "marked": 1, + "freeList": 1, + "clearMarks": 1, + "[": 82, + "hs": 16, + ".marked": 3, + ".right": 4, + "hs.right": 3, + "fun": 1, + "reachable": 1, + "n": 5, + "]": 80, + "+": 14, + "n.": 1, + "hs.left": 2, + "mark": 1, + "from": 2, + "hs.reachable": 1, + "setFreeList": 1, + ".freeList.*": 3, + ".left": 5, + "hs.marked": 1, + "GC": 1, + "root": 5, + "assert": 3, + "Soundness1": 2, + "h": 9, + "live": 3, + "h.reachable": 1, + "h.right": 1, + "Soundness2": 2, + ".reachable": 2, + "h.GC": 1, + ".freeList": 1, + "Completeness": 1, + "examples/systems/views": 1, + "open": 2, + "util/ordering": 1, + "State": 16, + "as": 2, + "so": 1, + "util/relation": 1, + "rel": 1, + "Ref": 19, + "t": 16, + "b": 13, + "v": 25, + "views": 2, + "when": 1, + "is": 1, + "view": 2, + "of": 3, + "type": 1, + "backing": 1, + "dirty": 3, + "contains": 1, + "refs": 7, + "that": 1, + "have": 1, + "been": 1, + "invalidated": 1, + "obj": 1, + "ViewType": 8, + "anyviews": 2, + "visualization": 1, + "ViewType.views": 1, + "Map": 2, + "keys": 3, + "map": 2, + "s": 6, + "Ref.map": 1, + "s.refs": 3, + "MapRef": 4, + "fact": 4, + "State.obj": 3, + "Iterator": 2, + "done": 3, + "lastRef": 2, + "IteratorRef": 5, + "Set": 2, + "elts": 2, + "SetRef": 5, + "KeySetView": 6, + "State.views": 1, + "IteratorView": 3, + "s.views": 2, + "handle": 1, + "possibility": 1, + "modifying": 1, + "an": 1, + "object": 1, + "and": 1, + "its": 1, + "at": 1, + "once": 1, + "*": 1, + "should": 1, + "we": 1, + "limit": 1, + "frame": 1, + "conds": 1, + "to": 1, + "non": 1, + "*/": 1, + "modifies": 5, + "pre": 15, + "post": 14, + "rs": 4, + "let": 5, + "vr": 1, + "pre.views": 8, + "mods": 3, + "rs.*vr": 1, + "r": 3, + "pre.refs": 6, + "pre.obj": 10, + "post.obj": 7, + "viewFrame": 4, + "post.dirty": 1, + "pre.dirty": 1, + "allocates": 5, + "&": 3, + "post.refs": 1, + ".map": 3, + ".elts": 3, + "dom": 1, + "<:>": 1, + "setRefs": 1, + "MapRef.put": 1, + "k": 5, + "none": 4, + "post.views": 4, + "SetRef.iterator": 1, + "iterRef": 4, + "i": 7, + "i.left": 3, + "i.done": 1, + "i.lastRef": 1, + "IteratorRef.remove": 1, + ".lastRef": 2, + "IteratorRef.next": 1, + "ref": 3, + "IteratorRef.hasNext": 1, + "s.obj": 1, + "zippishOK": 2, + "ks": 6, + "vs": 6, + "m": 4, + "ki": 2, + "vi": 2, + "s0": 4, + "so/first": 1, + "s1": 4, + "so/next": 7, + "s2": 6, + "s3": 4, + "s4": 4, + "s5": 4, + "s6": 4, + "s7": 2, + "precondition": 2, + "s0.dirty": 1, + "ks.iterator": 1, + "vs.iterator": 1, + "ki.hasNext": 1, + "vi.hasNext": 1, + "ki.this/next": 1, + "vi.this/next": 1, + "m.put": 1, + "ki.remove": 1, + "vi.remove": 1, + "State.dirty": 1, + "ViewType.pre.views": 2, + "but": 1, + "#s.obj": 1, + "<": 1 + }, "ApacheConf": { "ServerSignature": 1, "Off": 1, @@ -2048,6 +2361,90 @@ ".Section": 1, "list": 1 }, + "AspectJ": { + "package": 2, + "com.blogspot.miguelinlas3.aspectj.cache": 1, + ";": 29, + "import": 5, + "java.util.Map": 2, + "java.util.WeakHashMap": 1, + "org.aspectj.lang.JoinPoint": 1, + "com.blogspot.miguelinlas3.aspectj.cache.marker.Cachable": 1, + "public": 6, + "aspect": 2, + "CacheAspect": 1, + "{": 11, + "pointcut": 3, + "cache": 3, + "(": 46, + "Cachable": 2, + "cachable": 5, + ")": 46, + "execution": 1, + "@Cachable": 2, + "*": 2, + "..": 1, + "&&": 2, + "@annotation": 1, + "Object": 15, + "around": 2, + "String": 3, + "evaluatedKey": 6, + "this.evaluateKey": 1, + "cachable.scriptKey": 1, + "thisJoinPoint": 1, + "if": 2, + "cache.containsKey": 1, + "System.out.println": 5, + "+": 7, + "return": 5, + "this.cache.get": 1, + "}": 11, + "value": 3, + "proceed": 2, + "cache.put": 1, + "protected": 2, + "evaluateKey": 1, + "key": 2, + "JoinPoint": 1, + "joinPoint": 1, + "//": 1, + "TODO": 1, + "add": 1, + "some": 1, + "smart": 1, + "staff": 1, + "to": 1, + "allow": 1, + "simple": 1, + "scripting": 1, + "in": 1, + "annotation": 1, + "Map": 3, + "": 2, + "new": 1, + "WeakHashMap": 1, + "aspects.caching": 1, + "abstract": 3, + "OptimizeRecursionCache": 2, + "@SuppressWarnings": 3, + "private": 1, + "_cache": 2, + "getCache": 2, + "operation": 4, + "o": 16, + "topLevelOperation": 4, + "cflowbelow": 1, + "before": 1, + "cachedValue": 4, + "_cache.get": 1, + "null": 1, + "after": 2, + "returning": 2, + "result": 3, + "_cache.put": 1, + "_cache.size": 1 + }, "ATS": { "//": 211, "#include": 16, @@ -9383,18 +9780,18 @@ "C++": { "class": 40, "Bar": 2, - "{": 581, + "{": 629, "protected": 4, "char": 127, "*name": 6, - ";": 2471, + ";": 2564, "public": 33, - "void": 225, + "void": 226, "hello": 2, - "(": 2729, - ")": 2731, - "}": 581, - "//": 278, + "(": 2853, + ")": 2855, + "}": 629, + "//": 292, "///": 843, "mainpage": 1, "C": 6, @@ -9407,22 +9804,22 @@ "in": 165, "Raspberry": 6, "Pi": 5, - "This": 18, - "is": 100, - "a": 156, + "This": 19, + "is": 102, + "a": 157, "RPi": 17, ".": 16, "It": 7, "provides": 3, "access": 17, - "to": 253, + "to": 254, "GPIO": 87, "and": 118, "other": 17, "IO": 2, "functions": 19, "on": 55, - "the": 537, + "the": 541, "chip": 9, "allowing": 3, "pins": 40, @@ -9435,7 +9832,7 @@ "can": 21, "control": 17, "interface": 9, - "with": 32, + "with": 33, "various": 4, "external": 3, "devices.": 1, @@ -9458,14 +9855,14 @@ "polling": 1, "interrupts": 1, "are": 36, - "not": 26, - "+": 60, + "not": 29, + "+": 70, "compatible": 1, "installs": 1, "header": 7, "file": 31, "non": 2, - "-": 349, + "-": 360, "shared": 2, "any": 23, "Linux": 2, @@ -9474,16 +9871,16 @@ "but": 5, "clearly": 1, "no": 7, - "use": 34, + "use": 37, "except": 2, "or": 44, "another": 1, "The": 50, "version": 38, - "of": 211, + "of": 215, "package": 1, - "that": 33, - "this": 52, + "that": 36, + "this": 55, "documentation": 3, "refers": 1, "be": 35, @@ -9568,7 +9965,7 @@ "must": 6, "friends": 2, "make": 6, - "sure": 3, + "sure": 6, "disable": 2, "bcm2835_gpio_cler_len": 1, "after": 18, @@ -9596,14 +9993,14 @@ "xx": 2, "./configure": 1, "sudo": 2, - "check": 3, + "check": 4, "endcode": 2, "Physical": 21, "Addresses": 6, "bcm2835_peri_read": 3, "bcm2835_peri_write": 3, "bcm2835_peri_set_bits": 2, - "low": 2, + "low": 5, "level": 10, "peripheral": 14, "register": 17, @@ -9635,7 +10032,7 @@ "Ennnnnn": 1, "available": 6, "nnnnnn.": 1, - "base": 4, + "base": 6, "registers": 12, "following": 2, "externals": 1, @@ -9749,7 +10146,7 @@ "subject": 1, "paging": 1, "swapping": 2, - "while": 12, + "while": 13, "does": 4, "things": 1, "besides": 1, @@ -9769,7 +10166,7 @@ "guarantee": 1, "bcm2835_delay": 5, "bcm2835_delayMicroseconds": 6, - "return": 164, + "return": 221, "exactly": 2, "requested.": 1, "fact": 2, @@ -9782,7 +10179,7 @@ "longer": 1, "delay": 9, "times": 2, - "than": 5, + "than": 6, "one": 73, "asked": 1, "for.": 1, @@ -9798,7 +10195,7 @@ "sched_param": 1, "sp": 4, "memset": 3, - "&": 149, + "&": 161, "sizeof": 15, "sp.sched_priority": 1, "sched_get_priority_max": 1, @@ -9806,7 +10203,7 @@ "sched_setscheduler": 1, "mlockall": 1, "MCL_CURRENT": 1, - "|": 14, + "|": 19, "MCL_FUTURE": 1, "Open": 2, "Source": 2, @@ -9814,7 +10211,7 @@ "GPL": 2, "appropriate": 7, "option": 1, - "if": 306, + "if": 316, "want": 5, "share": 2, "source": 12, @@ -9868,7 +10265,7 @@ "sar": 1, "Ortiz": 1, "Document": 1, - "testing": 1, + "testing": 2, "Functions": 1, "bcm2835_gpio_ren": 3, "bcm2835_gpio_fen": 3, @@ -9917,15 +10314,15 @@ "mallocs": 1, "frees": 1, "found": 1, - "calling": 8, + "calling": 9, "nanosleep": 7, "takes": 1, "least": 2, "us.": 1, - "need": 3, + "need": 6, "link": 3, "version.": 1, - "s": 18, + "s": 24, "doc": 1, "Also": 1, "added": 2, @@ -9984,7 +10381,7 @@ "Changes": 1, "timer": 2, "counter": 1, - "instead": 1, + "instead": 4, "clock_gettime": 1, "improved": 1, "accuracy.": 1, @@ -10034,11 +10431,11 @@ "completing.": 1, "Patched": 1, "p": 6, - "[": 274, + "[": 276, "atched": 1, "his": 1, "submitted": 1, - "high": 1, + "high": 5, "load": 1, "processes.": 1, "Updated": 1, @@ -10063,9 +10460,9 @@ "DIRECTLY": 1, "USE": 1, "LISTS": 1, - "#ifndef": 27, + "#ifndef": 28, "BCM2835_H": 3, - "#define": 341, + "#define": 342, "#include": 121, "": 2, "defgroup": 7, @@ -10085,7 +10482,7 @@ "clock": 21, "core_clk": 1, "BCM2835_CORE_CLK_HZ": 1, - "<": 247, + "<": 250, "Base": 17, "Address": 10, "BCM2835_PERI_BASE": 9, @@ -10140,7 +10537,7 @@ "BCM2835_GPFSEL1": 1, "BCM2835_GPFSEL2": 1, "BCM2835_GPFSEL3": 1, - "c": 62, + "c": 72, "BCM2835_GPFSEL4": 1, "BCM2835_GPFSEL5": 1, "BCM2835_GPSET0": 1, @@ -10185,7 +10582,7 @@ "brief": 12, "bcm2835PortFunction": 1, "Port": 1, - "function": 18, + "function": 19, "select": 9, "modes": 1, "bcm2835_gpio_fsel": 2, @@ -10261,7 +10658,7 @@ "BCM2835_PAD_GROUP_GPIO_46_53": 1, "Numbers": 1, "Here": 1, - "we": 4, + "we": 10, "terms": 4, "numbers.": 1, "These": 6, @@ -10363,7 +10760,7 @@ "Full": 1, "BCM2835_SPI0_CS_RXR": 1, "RXR": 3, - "needs": 3, + "needs": 4, "Reading": 1, "full": 9, "BCM2835_SPI0_CS_TXD": 1, @@ -10533,7 +10930,7 @@ "BCM2835_I2C_REASON_ERROR_CLKT": 1, "BCM2835_I2C_REASON_ERROR_DATA": 1, "sent": 1, - "/": 14, + "/": 15, "BCM2835_ST_CS": 1, "Control/Status": 1, "BCM2835_ST_CLO": 1, @@ -10573,8 +10970,8 @@ "BCM2835_PWM0_REPEATFF": 1, "BCM2835_PWM0_SERIAL": 1, "BCM2835_PWM0_ENABLE": 1, - "x": 48, - "#endif": 89, + "x": 86, + "#endif": 98, "#ifdef": 19, "__cplusplus": 12, "init": 2, @@ -10601,8 +10998,8 @@ "case": 34, "errors.": 1, "successful": 2, - "else": 48, - "int": 161, + "else": 50, + "int": 192, "Close": 1, "deallocating": 1, "allocated": 2, @@ -10615,14 +11012,14 @@ "out": 5, "what": 2, "would": 2, - "do": 9, + "do": 13, "rather": 2, "causes": 1, "normal": 1, "operation.": 2, "Call": 2, "param": 72, - "]": 273, + "]": 275, "level.": 3, "uint8_t": 43, "lowlevel": 2, @@ -10850,7 +11247,7 @@ "placed": 1, "rbuf.": 1, "rbuf": 3, - "long": 11, + "long": 14, "tbuf": 4, "Buffer": 10, "send.": 5, @@ -10895,7 +11292,7 @@ "nothing": 1, "driver": 1, "const": 170, - "*": 161, + "*": 177, "receive.": 2, "received.": 2, "Allows": 2, @@ -10941,7 +11338,7 @@ "": 4, "": 4, "": 2, - "namespace": 31, + "namespace": 32, "std": 52, "DEFAULT_DELIMITER": 1, "CsvStreamer": 5, @@ -10990,12 +11387,12 @@ "leading/trailing": 1, "spaces": 3, "trimmed": 1, - "bool": 104, + "bool": 105, "Like": 1, "specify": 1, "trim": 2, "keep": 1, - "float": 8, + "float": 74, "double": 25, "writeln": 1, "Flushes": 1, @@ -11152,7 +11549,7 @@ "*rr": 1, "*zero": 1, "n": 28, - "i": 47, + "i": 83, "BN_CTX_start": 1, "BN_CTX_get": 8, "EC_GROUP_get_order": 1, @@ -11218,11 +11615,11 @@ "nBitsR": 3, "BN_num_bits": 2, "nBitsS": 3, - "&&": 23, + "&&": 24, "nRecId": 4, "<4;>": 1, "keyRec": 5, - "1": 2, + "1": 4, "GetPubKey": 5, "break": 34, "BN_bn2bin": 2, @@ -11286,7 +11683,7 @@ "vchSecret": 1, "GetPrivKey": 1, "SetPubKey": 1, - "Sign": 1, + "Sign": 2, "LIBCANIH": 2, "": 1, "": 1, @@ -11294,7 +11691,7 @@ "//#define": 1, "DEBUG": 5, "dout": 2, - "#else": 25, + "#else": 31, "cerr": 1, "libcanister": 2, "//the": 8, @@ -11353,7 +11750,7 @@ "canister*": 1, "parent": 1, "//internal": 1, - "id": 1, + "id": 4, "//use": 1, "own.": 1, "newline": 2, @@ -11417,14 +11814,14 @@ "avoid": 1, "uncaching": 1, "//really": 1, - "just": 1, + "just": 2, "internally": 1, "harm.": 1, "cacheclean": 1, "dFlush": 1, "Q_OS_LINUX": 2, "": 1, - "#if": 44, + "#if": 52, "QT_VERSION": 1, "QT_VERSION_CHECK": 1, "#error": 9, @@ -11460,6 +11857,141 @@ "phantom.execute": 1, "app.exec": 1, "phantom.returnValue": 1, + "__OG_MATH_INL__": 2, + "og": 1, + "OG_INLINE": 41, + "Math": 41, + "Abs": 1, + "MASK_SIGNED": 2, + "y": 16, + "Fabs": 1, + "f": 104, + "uInt": 1, + "*pf": 1, + "reinterpret_cast": 8, + "": 1, + "pf": 1, + "fabsf": 1, + "Round": 1, + "floorf": 2, + "Floor": 1, + "Ceil": 1, + "ceilf": 1, + "Ftoi": 1, + "@todo": 1, + "note": 1, + "sse": 1, + "cvttss2si": 2, + "OG_ASM_MSVC": 4, + "defined": 23, + "OG_FTOI_USE_SSE": 2, + "SysInfo": 2, + "cpu.general.SSE": 2, + "__asm": 8, + "eax": 5, + "mov": 6, + "fld": 4, + "fistp": 3, + "//__asm": 3, + "O_o": 3, + "#elif": 7, + "OG_ASM_GNU": 4, + "__asm__": 4, + "__volatile__": 4, + "cast": 7, + "why": 3, + "did": 3, + "static_cast": 11, + "": 3, + "FtoiFast": 2, + "Ftol": 1, + "": 1, + "Fmod": 1, + "numerator": 2, + "denominator": 2, + "fmodf": 1, + "Modf": 2, + "modff": 2, + "Sqrt": 2, + "sqrtf": 2, + "InvSqrt": 1, + "OG_ASSERT": 4, + "RSqrt": 1, + "g": 2, + "*reinterpret_cast": 3, + "guess": 1, + "f375a86": 1, + "": 1, + "Newtons": 1, + "calculation": 1, + "Log": 1, + "logf": 3, + "Log2": 1, + "INV_LN_2": 1, + "Log10": 1, + "INV_LN_10": 1, + "Pow": 1, + "exp": 2, + "powf": 1, + "Exp": 1, + "expf": 1, + "IsPowerOfTwo": 4, + "faster": 3, + "two": 2, + "known": 1, + "methods": 2, + "moved": 1, + "beginning": 1, + "HigherPowerOfTwo": 4, + "LowerPowerOfTwo": 2, + "FloorPowerOfTwo": 1, + "CeilPowerOfTwo": 1, + "ClosestPowerOfTwo": 1, + "Digits": 1, + "digits": 6, + "step": 3, + "Sin": 2, + "sinf": 1, + "ASin": 1, + "<=>": 2, + "0f": 2, + "HALF_PI": 2, + "asinf": 1, + "Cos": 2, + "cosf": 1, + "ACos": 1, + "PI": 1, + "acosf": 1, + "Tan": 1, + "tanf": 1, + "ATan": 2, + "atanf": 1, + "f1": 2, + "f2": 2, + "atan2f": 1, + "SinCos": 1, + "sometimes": 1, + "assembler": 1, + "waaayy": 1, + "_asm": 1, + "fsincos": 1, + "ecx": 2, + "edx": 2, + "fstp": 2, + "dword": 2, + "ptr": 2, + "asm": 1, + "Deg2Rad": 1, + "DEG_TO_RAD": 1, + "Rad2Deg": 1, + "RAD_TO_DEG": 1, + "Square": 1, + "v": 10, + "Cube": 1, + "Sec2Ms": 1, + "sec": 2, + "Ms2Sec": 1, + "ms": 2, "NINJA_METRICS_H_": 3, "int64_t.": 1, "Metrics": 2, @@ -11524,7 +12056,6 @@ "Seconds": 1, "call.": 1, "Elapsed": 1, - "static_cast": 8, "": 1, "primary": 1, "metrics.": 1, @@ -11700,7 +12231,6 @@ "u": 9, "*name_": 1, "assign": 3, - "reinterpret_cast": 7, "temp": 2, "SWIG": 2, "QSCICOMMAND_H": 2, @@ -11713,7 +12243,6 @@ "represents": 1, "editor": 1, "command": 9, - "two": 1, "keys": 3, "bound": 4, "Methods": 1, @@ -12061,7 +12590,6 @@ "drawing": 4, "actually": 1, "sized.": 1, - "methods": 1, "area": 5, "draw": 1, "text.": 3, @@ -12122,7 +12650,6 @@ "expected_length": 4, "ASSERT": 17, "overflow": 1, - "digits": 3, "c0_": 64, "d": 8, "HexValue": 2, @@ -12140,7 +12667,6 @@ "COLON": 2, "SEMICOLON": 2, "CONDITIONAL": 2, - "f": 5, "LBRACK": 2, "RBRACK": 2, "LBRACE": 2, @@ -12220,7 +12746,6 @@ "IsCarriageReturn": 2, "IsLineFeed": 2, "fall": 2, - "v": 3, "xxx": 1, "immediately": 1, "octal": 1, @@ -12233,7 +12758,6 @@ "E": 3, "l": 1, "w": 1, - "y": 13, "keyword": 1, "Unescaped": 1, "in_character_class": 2, @@ -12304,7 +12828,6 @@ "": 6, "kASCIISize": 1, "ConvertToUtf16": 2, - "*reinterpret_cast": 1, "": 2, "kUC16Size": 2, "is_ascii": 3, @@ -12530,7 +13053,6 @@ "r.double_value": 3, "r.uint64_t_value": 1, "HeapNumber": 1, - "cast": 1, "set_value": 1, "InitializeOncePerProcessImpl": 3, "SetUp": 4, @@ -12551,7 +13073,6 @@ "ExternalReference": 1, "CallOnce": 1, "V8_V8_H_": 3, - "defined": 21, "GOOGLE3": 2, "NDEBUG": 4, "both": 1, @@ -12764,7 +13285,6 @@ "CYTHON_INLINE": 68, "__GNUC__": 5, "__inline__": 1, - "#elif": 3, "__inline": 1, "__STDC_VERSION__": 2, "L": 1, @@ -16644,6 +17164,530 @@ "#undef": 1, "Undefine": 1 }, + "Dogescript": { + "quiet": 1, + "wow": 4, + "such": 2, + "language": 3, + "very": 1, + "syntax": 1, + "github": 1, + "recognized": 1, + "loud": 1, + "much": 1, + "friendly": 2, + "rly": 1, + "is": 2, + "true": 1, + "plz": 2, + "console.loge": 2, + "with": 2, + "but": 1, + "module.exports": 1 + }, + "Eagle": { + "": 2, + "version=": 4, + "encoding=": 2, + "": 2, + "eagle": 4, + "SYSTEM": 2, + "dtd": 2, + "": 2, + "": 2, + "": 2, + "": 4, + "alwaysvectorfont=": 2, + "verticaltext=": 2, + "": 2, + "": 2, + "distance=": 2, + "unitdist=": 2, + "unit=": 2, + "style=": 2, + "multiple=": 2, + "display=": 2, + "altdistance=": 2, + "altunitdist=": 2, + "altunit=": 2, + "": 2, + "": 118, + "number=": 119, + "name=": 447, + "color=": 118, + "fill=": 118, + "visible=": 118, + "active=": 125, + "": 2, + "": 1, + "": 1, + "": 497, + "x1=": 630, + "y1=": 630, + "x2=": 630, + "y2=": 630, + "width=": 512, + "layer=": 822, + "": 1, + "": 2, + "": 4, + "": 60, + "&": 5501, + "lt": 2665, + ";": 5567, + "b": 64, + "gt": 2770, + "Resistors": 2, + "Capacitors": 4, + "Inductors": 2, + "/b": 64, + "p": 65, + "Based": 2, + "on": 2, + "the": 5, + "previous": 2, + "libraries": 2, + "ul": 2, + "li": 12, + "r.lbr": 2, + "cap.lbr": 2, + "cap": 2, + "-": 768, + "fe.lbr": 2, + "captant.lbr": 2, + "polcap.lbr": 2, + "ipc": 2, + "smd.lbr": 2, + "/ul": 2, + "All": 2, + "SMD": 4, + "packages": 2, + "are": 2, + "defined": 2, + "according": 2, + "to": 3, + "IPC": 2, + "specifications": 2, + "and": 5, + "CECC": 2, + "author": 3, + "Created": 3, + "by": 3, + "librarian@cadsoft.de": 3, + "/author": 3, + "for": 5, + "Electrolyt": 2, + "see": 4, + "also": 2, + "www.bccomponents.com": 2, + "www.panasonic.com": 2, + "www.kemet.com": 2, + "http": 4, + "//www.secc.co.jp/pdf/os_e/2004/e_os_all.pdf": 2, + "(": 4, + "SANYO": 2, + ")": 4, + "trimmer": 2, + "refence": 2, + "u": 2, + "www.electrospec": 2, + "inc.com/cross_references/trimpotcrossref.asp": 2, + "/u": 2, + "table": 2, + "border": 2, + "cellspacing": 2, + "cellpadding": 2, + "width": 6, + "cellpaddding": 2, + "tr": 2, + "valign": 2, + "td": 4, + "amp": 66, + "nbsp": 66, + "/td": 4, + "font": 2, + "color": 20, + "size": 2, + "TRIM": 4, + "POT": 4, + "CROSS": 4, + "REFERENCE": 4, + "/font": 2, + "P": 128, + "TABLE": 4, + "BORDER": 4, + "CELLSPACING": 4, + "CELLPADDING": 4, + "TR": 36, + "TD": 170, + "COLSPAN": 16, + "FONT": 166, + "SIZE": 166, + "FACE": 166, + "ARIAL": 166, + "B": 106, + "RECTANGULAR": 2, + "MULTI": 6, + "TURN": 10, + "/B": 90, + "/FONT": 166, + "/TD": 170, + "/TR": 36, + "ALIGN": 124, + "CENTER": 124, + "BOURNS": 6, + "BI": 10, + "TECH": 10, + "DALE": 10, + "VISHAY": 10, + "PHILIPS/MEPCO": 10, + "MURATA": 6, + "PANASONIC": 10, + "SPECTROL": 6, + "MILSPEC": 6, + "BGCOLOR": 76, + "BR": 1478, + "W": 92, + "Y": 36, + "J": 12, + "L": 18, + "X": 82, + "PH": 2, + "XH": 2, + "SLT": 2, + "ALT": 42, + "T8S": 2, + "T18/784": 2, + "/1897": 2, + "/1880": 2, + "EKP/CT20/RJ": 2, + "RJ": 14, + "EKQ": 4, + "EKR": 4, + "EKJ": 2, + "EKL": 2, + "S": 18, + "EVMCOG": 2, + "T602": 2, + "RT/RTR12": 6, + "RJ/RJR12": 6, + "SQUARE": 2, + "BOURN": 4, + "H": 24, + "Z": 16, + "T63YB": 2, + "T63XB": 2, + "T93Z": 2, + "T93YA": 2, + "T93XA": 2, + "T93YB": 2, + "T93XB": 2, + "EKP": 8, + "EKW": 6, + "EKM": 4, + "EKB": 2, + "EKN": 2, + "P/CT9P": 2, + "P/3106P": 2, + "W/3106W": 2, + "X/3106X": 2, + "Y/3106Y": 2, + "Z/3105Z": 2, + "EVMCBG": 2, + "EVMCCG": 2, + "RT/RTR22": 8, + "RJ/RJR22": 6, + "RT/RTR26": 6, + "RJ/RJR26": 12, + "RT/RTR24": 6, + "RJ/RJR24": 12, + "SINGLE": 4, + "E": 6, + "K": 4, + "T": 10, + "V": 10, + "M": 10, + "R": 6, + "U": 4, + "C": 6, + "F": 4, + "RX": 6, + "PA": 2, + "A": 16, + "XW": 2, + "XL": 2, + "PM": 2, + "PX": 2, + "RXW": 2, + "RXL": 2, + "T7YB": 2, + "T7YA": 2, + "TXD": 2, + "TYA": 2, + "TYP": 2, + "TYD": 2, + "TX": 4, + "SX": 6, + "ET6P": 2, + "ET6S": 2, + "ET6X": 2, + "W/8014EMW": 2, + "P/8014EMP": 2, + "X/8014EMX": 2, + "TM7W": 2, + "TM7P": 2, + "TM7X": 2, + "SMS": 2, + "SMB": 2, + "SMA": 2, + "CT": 12, + "EKV": 2, + "EKX": 2, + "EKZ": 2, + "N": 2, + "RVA0911V304A": 2, + "RVA0911H413A": 2, + "RVG0707V100A": 2, + "RVA0607V": 2, + "RVA1214H213A": 2, + "EVMQ0G": 4, + "EVMQIG": 2, + "EVMQ3G": 2, + "EVMS0G": 2, + "EVMG0G": 2, + "EVMK4GA00B": 2, + "EVM30GA00B": 2, + "EVMK0GA00B": 2, + "EVM38GA00B": 2, + "EVMB6": 2, + "EVLQ0": 2, + "EVMMSG": 2, + "EVMMBG": 2, + "EVMMAG": 2, + "EVMMCS": 2, + "EVMM1": 2, + "EVMM0": 2, + "EVMM3": 2, + "RJ/RJR50": 6, + "/TABLE": 4, + "TOCOS": 4, + "AUX/KYOCERA": 4, + "G": 10, + "ST63Z": 2, + "ST63Y": 2, + "ST5P": 2, + "ST5W": 2, + "ST5X": 2, + "A/B": 2, + "C/D": 2, + "W/X": 2, + "ST5YL/ST53YL": 2, + "ST5YJ/5T53YJ": 2, + "ST": 14, + "EVM": 8, + "YS": 2, + "D": 2, + "G4B": 2, + "G4A": 2, + "TR04": 2, + "S1": 4, + "TRG04": 2, + "DVR": 2, + "CVR": 4, + "A/C": 2, + "ALTERNATE": 2, + "/tr": 2, + "/table": 2, + "": 60, + "": 4, + "": 53, + "RESISTOR": 52, + "": 64, + "x=": 240, + "y=": 242, + "dx=": 64, + "dy=": 64, + "": 108, + "size=": 114, + "NAME": 52, + "": 108, + "VALUE": 52, + "": 132, + "": 52, + "": 3, + "": 3, + "Pin": 1, + "Header": 1, + "Connectors": 1, + "PIN": 1, + "HEADER": 1, + "": 39, + "drill=": 41, + "shape=": 39, + "ratio=": 41, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "language=": 2, + "EAGLE": 2, + "Design": 5, + "Rules": 5, + "Die": 1, + "Standard": 1, + "sind": 1, + "so": 2, + "gew": 1, + "hlt": 1, + "dass": 1, + "sie": 1, + "f": 1, + "r": 1, + "die": 3, + "meisten": 1, + "Anwendungen": 1, + "passen.": 1, + "Sollte": 1, + "ihre": 1, + "Platine": 1, + "besondere": 1, + "Anforderungen": 1, + "haben": 1, + "treffen": 1, + "Sie": 1, + "erforderlichen": 1, + "Einstellungen": 1, + "hier": 1, + "und": 1, + "speichern": 1, + "unter": 1, + "einem": 1, + "neuen": 1, + "Namen": 1, + "ab.": 1, + "The": 1, + "default": 1, + "have": 2, + "been": 1, + "set": 1, + "cover": 1, + "a": 2, + "wide": 1, + "range": 1, + "of": 1, + "applications.": 1, + "Your": 1, + "particular": 1, + "design": 2, + "may": 1, + "different": 1, + "requirements": 1, + "please": 1, + "make": 1, + "necessary": 1, + "adjustments": 1, + "save": 1, + "your": 1, + "customized": 1, + "rules": 1, + "under": 1, + "new": 1, + "name.": 1, + "": 142, + "value=": 145, + "": 1, + "": 1, + "": 8, + "": 8, + "refer=": 7, + "": 1, + "": 1, + "": 3, + "library=": 3, + "package=": 3, + "smashed=": 3, + "": 6, + "": 3, + "1": 1, + "778": 1, + "16": 1, + "002": 1, + "": 1, + "": 1, + "": 3, + "": 4, + "element=": 4, + "pad=": 4, + "": 1, + "extent=": 1, + "": 3, + "": 2, + "": 8, + "": 2, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "xreflabel=": 1, + "xrefpart=": 1, + "Frames": 1, + "Sheet": 2, + "Layout": 1, + "": 1, + "": 1, + "font=": 4, + "DRAWING_NAME": 1, + "LAST_DATE_TIME": 1, + "SHEET": 1, + "": 1, + "columns=": 1, + "rows=": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "prefix=": 1, + "uservalue=": 1, + "FRAME": 1, + "DIN": 1, + "A4": 1, + "landscape": 1, + "with": 1, + "location": 1, + "doc.": 1, + "field": 1, + "": 1, + "": 1, + "symbol=": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "wave": 10, + "soldering": 10, + "Source": 2, + "//download.siliconexpert.com/pdfs/2005/02/24/Semi_Ap/2/VSH/Resistor/dcrcwfre.pdf": 2, + "MELF": 8, + "type": 20, + "grid": 20, + "mm": 20, + "curve=": 56, + "": 12, + "radius=": 12 + }, "ECL": { "#option": 1, "(": 32, @@ -18026,6 +19070,2322 @@ "/cell": 2, "cell": 2 }, + "Frege": { + "module": 2, + "examples.CommandLineClock": 1, + "where": 39, + "data": 3, + "Date": 5, + "native": 4, + "java.util.Date": 1, + "new": 9, + "(": 339, + ")": 345, + "-": 730, + "IO": 13, + "MutableIO": 1, + "toString": 2, + "Mutable": 1, + "s": 21, + "ST": 1, + "String": 9, + "d.toString": 1, + "action": 2, + "to": 13, + "give": 2, + "us": 1, + "the": 20, + "current": 4, + "time": 1, + "as": 33, + "do": 38, + "d": 3, + "<->": 35, + "java": 5, + "lang": 2, + "Thread": 2, + "sleep": 4, + "takes": 1, + "a": 99, + "long": 4, + "and": 14, + "returns": 2, + "nothing": 2, + "but": 2, + "may": 1, + "throw": 1, + "an": 6, + "InterruptedException": 4, + "This": 2, + "is": 24, + "without": 1, + "doubt": 1, + "public": 1, + "static": 1, + "void": 2, + "millis": 1, + "throws": 4, + "Encoded": 1, + "in": 22, + "Frege": 1, + "argument": 1, + "type": 8, + "Long": 3, + "result": 11, + "does": 2, + "defined": 1, + "frege": 1, + "Lang": 1, + "main": 11, + "args": 2, + "forever": 1, + "print": 25, + "stdout.flush": 1, + "Thread.sleep": 4, + "examples.Concurrent": 1, + "import": 7, + "System.Random": 1, + "Java.Net": 1, + "URL": 2, + "Control.Concurrent": 1, + "C": 6, + "main2": 1, + "m": 2, + "<": 84, + "newEmptyMVar": 1, + "forkIO": 11, + "m.put": 3, + "replicateM_": 3, + "c": 33, + "m.take": 1, + "println": 25, + "example1": 1, + "putChar": 2, + "example2": 2, + "getLine": 2, + "case": 6, + "of": 32, + "Right": 6, + "n": 38, + "setReminder": 3, + "Left": 5, + "_": 60, + "+": 200, + "show": 24, + "L*n": 1, + "table": 1, + "mainPhil": 2, + "[": 120, + "fork1": 3, + "fork2": 3, + "fork3": 3, + "fork4": 3, + "fork5": 3, + "]": 116, + "mapM": 3, + "MVar": 3, + "1": 2, + "5": 1, + "philosopher": 7, + "Kant": 1, + "Locke": 1, + "Wittgenstein": 1, + "Nozick": 1, + "Mises": 1, + "return": 17, + "Int": 6, + "me": 13, + "left": 4, + "right": 4, + "g": 4, + "Random.newStdGen": 1, + "let": 8, + "phil": 4, + "tT": 2, + "g1": 2, + "Random.randomR": 2, + "L": 6, + "eT": 2, + "g2": 3, + "thinkTime": 3, + "*": 5, + "eatTime": 3, + "fl": 4, + "left.take": 1, + "rFork": 2, + "poll": 1, + "Just": 2, + "fr": 3, + "right.put": 1, + "left.put": 2, + "table.notifyAll": 2, + "Nothing": 2, + "table.wait": 1, + "inter": 3, + "catch": 2, + "getURL": 4, + "xx": 2, + "url": 1, + "URL.new": 1, + "con": 3, + "url.openConnection": 1, + "con.connect": 1, + "con.getInputStream": 1, + "typ": 5, + "con.getContentType": 1, + "stderr.println": 3, + "ir": 2, + "InputStreamReader.new": 2, + "fromMaybe": 1, + "charset": 2, + "unsupportedEncoding": 3, + "br": 4, + "BufferedReader": 1, + "getLines": 1, + "InputStream": 1, + "UnsupportedEncodingException": 1, + "InputStreamReader": 1, + "x": 45, + "x.catched": 1, + "ctyp": 2, + "charset=": 1, + "m.group": 1, + "SomeException": 2, + "Throwable": 1, + "m1": 1, + "MVar.newEmpty": 3, + "m2": 1, + "m3": 2, + "r": 7, + "catchAll": 3, + ".": 41, + "m1.put": 1, + "m2.put": 1, + "m3.put": 1, + "r1": 2, + "m1.take": 1, + "r2": 3, + "m2.take": 1, + "r3": 3, + "take": 13, + "ss": 8, + "mapM_": 5, + "putStrLn": 2, + "|": 62, + "x.getClass.getName": 1, + "y": 15, + "sum": 2, + "map": 49, + "length": 20, + "package": 2, + "examples.Sudoku": 1, + "Data.TreeMap": 1, + "Tree": 4, + "keys": 2, + "Data.List": 1, + "DL": 1, + "hiding": 1, + "find": 20, + "union": 10, + "Element": 6, + "Zelle": 8, + "set": 4, + "candidates": 18, + "Position": 22, + "Feld": 3, + "Brett": 13, + "for": 25, + "assumptions": 10, + "conclusions": 2, + "Assumption": 21, + "ISNOT": 14, + "IS": 16, + "derive": 2, + "Eq": 1, + "Ord": 1, + "instance": 1, + "Show": 1, + "p": 72, + "e": 15, + "pname": 10, + "e.show": 2, + "showcs": 5, + "cs": 27, + "joined": 4, + "Assumption.show": 1, + "elements": 12, + "all": 22, + "possible": 2, + "..": 1, + "positions": 16, + "rowstarts": 4, + "row": 20, + "starting": 3, + "colstarts": 3, + "column": 2, + "boxstarts": 3, + "box": 15, + "boxmuster": 3, + "pattern": 1, + "by": 3, + "adding": 1, + "upper": 2, + "position": 9, + "results": 1, + "real": 1, + "extract": 2, + "field": 9, + "getf": 16, + "f": 19, + "fs": 22, + "fst": 9, + "otherwise": 8, + "cell": 24, + "getc": 12, + "b": 113, + "snd": 20, + "compute": 5, + "list": 7, + "that": 18, + "belong": 3, + "same": 8, + "given": 3, + "z..": 1, + "z": 12, + "quot": 1, + "col": 17, + "mod": 3, + "ri": 2, + "div": 3, + "or": 15, + "depending": 1, + "on": 4, + "ci": 3, + "index": 3, + "middle": 2, + "check": 2, + "if": 5, + "candidate": 10, + "has": 2, + "exactly": 2, + "one": 2, + "member": 1, + "i.e.": 1, + "been": 1, + "solved": 1, + "single": 9, + "Bool": 2, + "true": 16, + "false": 13, + "unsolved": 10, + "rows": 4, + "cols": 6, + "boxes": 1, + "allrows": 8, + "allcols": 5, + "allboxs": 5, + "allrcb": 5, + "zip": 7, + "repeat": 3, + "containers": 6, + "PRINTING": 1, + "printable": 1, + "coordinate": 1, + "a1": 3, + "lower": 1, + "i9": 1, + "packed": 1, + "chr": 2, + "ord": 6, + "board": 41, + "printb": 4, + "p1line": 2, + "pfld": 4, + "line": 2, + "brief": 1, + "no": 4, + "some": 2, + "zs": 1, + "initial/final": 1, + "msg": 6, + "res012": 2, + "concatMap": 1, + "a*100": 1, + "b*10": 1, + "BOARD": 1, + "ALTERATION": 1, + "ACTIONS": 1, + "message": 1, + "about": 1, + "what": 1, + "done": 1, + "turnoff1": 3, + "i": 16, + "off": 11, + "nc": 7, + "head": 19, + "newb": 7, + "filter": 26, + "notElem": 7, + "turnoff": 11, + "turnoffh": 1, + "ps": 8, + "foldM": 2, + "toh": 2, + "setto": 3, + "cname": 4, + "nf": 2, + "SOLVING": 1, + "STRATEGIES": 1, + "reduce": 3, + "sets": 2, + "contains": 1, + "numbers": 1, + "already": 1, + "finds": 1, + "logs": 1, + "NAKED": 5, + "SINGLEs": 1, + "passing.": 1, + "sss": 3, + "each": 2, + "with": 15, + "more": 2, + "than": 2, + "fields": 6, + "are": 6, + "rcb": 16, + "elem": 16, + "collect": 1, + "remove": 3, + "from": 7, + "look": 10, + "number": 4, + "appears": 1, + "container": 9, + "this": 2, + "can": 9, + "go": 1, + "other": 2, + "place": 1, + "HIDDEN": 6, + "SINGLE": 1, + "hiddenSingle": 2, + "select": 1, + "containername": 1, + "FOR": 11, + "IN": 9, + "occurs": 5, + "PAIRS": 8, + "TRIPLES": 8, + "QUADS": 2, + "nakedPair": 4, + "t": 14, + "nm": 6, + "SELECT": 3, + "pos": 5, + "tuple": 2, + "name": 2, + "//": 8, + "u": 6, + "fold": 7, + "non": 2, + "outof": 6, + "tuples": 2, + "hit": 7, + "subset": 3, + "any": 3, + "hiddenPair": 4, + "minus": 2, + "uniq": 4, + "sort": 4, + "common": 4, + "bs": 7, + "undefined": 1, + "cannot": 1, + "happen": 1, + "because": 1, + "either": 1, + "empty": 4, + "not": 5, + "intersectionlist": 2, + "intersections": 2, + "reason": 8, + "reson": 1, + "cpos": 7, + "WHERE": 2, + "tail": 2, + "intersection": 1, + "we": 5, + "occurences": 1, + "XY": 2, + "Wing": 2, + "there": 6, + "exists": 6, + "A": 7, + "X": 5, + "Y": 4, + "B": 5, + "Z": 6, + "shares": 2, + "reasoning": 1, + "will": 4, + "be": 9, + "since": 1, + "indeed": 1, + "thus": 1, + "see": 1, + "xyWing": 2, + "rcba": 4, + "share": 1, + "b1": 11, + "b2": 10, + "&&": 9, + "||": 2, + "then": 1, + "else": 1, + "c1": 4, + "c2": 3, + "N": 5, + "Fish": 1, + "Swordfish": 1, + "Jellyfish": 1, + "When": 2, + "particular": 1, + "digit": 1, + "located": 2, + "only": 1, + "columns": 2, + "eliminate": 1, + "those": 2, + "which": 2, + "fish": 7, + "fishname": 5, + "rset": 4, + "certain": 1, + "rflds": 2, + "rowset": 1, + "colss": 3, + "must": 4, + "appear": 1, + "at": 3, + "least": 3, + "cstart": 2, + "immediate": 1, + "consequences": 6, + "assumption": 8, + "form": 1, + "conseq": 3, + "cp": 3, + "two": 1, + "contradict": 2, + "contradicts": 7, + "get": 3, + "aPos": 5, + "List": 1, + "turned": 1, + "when": 2, + "true/false": 1, + "toClear": 7, + "whose": 1, + "implications": 5, + "themself": 1, + "chain": 2, + "paths": 12, + "solution": 6, + "reverse": 4, + "css": 7, + "yields": 1, + "contradictory": 1, + "chainContra": 2, + "pro": 7, + "contra": 4, + "ALL": 2, + "conlusions": 1, + "uniqBy": 2, + "using": 2, + "sortBy": 2, + "comparing": 2, + "conslusion": 1, + "chains": 4, + "LET": 1, + "BE": 1, + "final": 2, + "conclusion": 4, + "THE": 1, + "FIRST": 1, + "implication": 2, + "ai": 2, + "so": 1, + "a0": 1, + "OR": 7, + "a2": 2, + "...": 2, + "IMPLIES": 1, + "For": 2, + "cells": 1, + "pi": 2, + "have": 1, + "construct": 2, + "p0": 1, + "p1": 1, + "c0": 1, + "cellRegionChain": 2, + "os": 3, + "cellas": 2, + "regionas": 2, + "iss": 3, + "ass": 2, + "first": 2, + "candidates@": 1, + "region": 2, + "oss": 2, + "Liste": 1, + "aller": 1, + "Annahmen": 1, + "ein": 1, + "bestimmtes": 1, + "acstree": 3, + "Tree.fromList": 1, + "bypass": 1, + "maybe": 1, + "tree": 1, + "lookup": 2, + "error": 1, + "performance": 1, + "resons": 1, + "confine": 1, + "ourselves": 1, + "20": 1, + "per": 1, + "mkPaths": 3, + "acst": 3, + "impl": 2, + "{": 1, + "a3": 1, + "ordered": 1, + "impls": 2, + "ns": 2, + "concat": 1, + "takeUntil": 1, + "null": 1, + "iterate": 1, + "expandchain": 3, + "avoid": 1, + "loops": 1, + "uni": 3, + "SOLVE": 1, + "SUDOKU": 1, + "Apply": 1, + "available": 1, + "strategies": 1, + "until": 1, + "changes": 1, + "anymore": 1, + "Strategy": 1, + "functions": 2, + "supposed": 1, + "applied": 1, + "changed": 1, + "board.": 1, + "strategy": 2, + "anything": 1, + "alter": 1, + "it": 2, + "next": 1, + "tried.": 1, + "solve": 19, + "res@": 16, + "apply": 17, + "res": 16, + "smallest": 1, + "comment": 16, + "SINGLES": 1, + "locked": 1, + "2": 3, + "QUADRUPELS": 6, + "3": 3, + "4": 3, + "WINGS": 1, + "FISH": 3, + "pcomment": 2, + "9": 5, + "forcing": 1, + "allow": 1, + "infer": 1, + "both": 1, + "brd": 2, + "com": 5, + "stderr": 3, + "<<": 4, + "log": 1, + "turn": 1, + "string": 3, + "into": 1, + "mkrow": 2, + "mkrow1": 2, + "xs": 4, + "make": 1, + "sure": 1, + "unpacked": 2, + "<=>": 1, + "0": 2, + "ignored": 1, + "h": 1, + "help": 1, + "usage": 1, + "Sudoku": 2, + "file": 4, + "81": 3, + "char": 1, + "consisting": 1, + "digits": 2, + "One": 1, + "such": 1, + "going": 1, + "http": 3, + "www": 1, + "sudokuoftheday": 1, + "pages": 1, + "o": 1, + "php": 1, + "click": 1, + "puzzle": 1, + "open": 1, + "tab": 1, + "Copy": 1, + "address": 1, + "your": 1, + "browser": 1, + "There": 1, + "also": 1, + "hard": 1, + "sudokus": 1, + "examples": 1, + "top95": 1, + "txt": 1, + "W": 1, + "felder": 2, + "decode": 4, + "files": 2, + "forM_": 1, + "sudoku": 2, + "openReader": 1, + "lines": 2, + "BufferedReader.getLines": 1, + "process": 5, + "candi": 2, + "consider": 3, + "acht": 4, + "neun": 2, + "examples.SwingExamples": 1, + "Java.Awt": 1, + "ActionListener": 2, + "Java.Swing": 1, + "rs": 2, + "Runnable.new": 1, + "helloWorldGUI": 2, + "buttonDemoGUI": 2, + "celsiusConverterGUI": 2, + "invokeLater": 1, + "tempTextField": 2, + "JTextField.new": 1, + "celsiusLabel": 1, + "JLabel.new": 3, + "convertButton": 1, + "JButton.new": 3, + "fahrenheitLabel": 1, + "frame": 3, + "JFrame.new": 3, + "frame.setDefaultCloseOperation": 3, + "JFrame.dispose_on_close": 3, + "frame.setTitle": 1, + "celsiusLabel.setText": 1, + "convertButton.setText": 1, + "convertButtonActionPerformed": 2, + "celsius": 3, + "getText": 1, + "double": 1, + "fahrenheitLabel.setText": 3, + "c*1.8": 1, + ".long": 1, + "ActionListener.new": 2, + "convertButton.addActionListener": 1, + "contentPane": 2, + "frame.getContentPane": 2, + "layout": 2, + "GroupLayout.new": 1, + "contentPane.setLayout": 1, + "TODO": 1, + "continue": 1, + "//docs.oracle.com/javase/tutorial/displayCode.html": 1, + "code": 1, + "//docs.oracle.com/javase/tutorial/uiswing/examples/learn/CelsiusConverterProject/src/learn/CelsiusConverterGUI.java": 1, + "frame.pack": 3, + "frame.setVisible": 3, + "label": 2, + "cp.add": 1, + "newContentPane": 2, + "JPanel.new": 1, + "JButton": 4, + "b1.setVerticalTextPosition": 1, + "SwingConstants.center": 2, + "b1.setHorizontalTextPosition": 1, + "SwingConstants.leading": 2, + "b2.setVerticalTextPosition": 1, + "b2.setHorizontalTextPosition": 1, + "b3": 7, + "Enable": 1, + "button": 1, + "setVerticalTextPosition": 1, + "SwingConstants": 2, + "center": 1, + "setHorizontalTextPosition": 1, + "leading": 1, + "setEnabled": 7, + "action1": 2, + "action3": 2, + "b1.addActionListener": 1, + "b3.addActionListener": 1, + "newContentPane.add": 3, + "newContentPane.setOpaque": 1, + "frame.setContentPane": 1 + }, + "Game Maker Language": { + "//draws": 1, + "the": 62, + "sprite": 12, + "draw": 3, + "true": 73, + ";": 1282, + "if": 397, + "(": 1501, + "facing": 17, + "RIGHT": 10, + ")": 1502, + "image_xscale": 17, + "-": 212, + "else": 151, + "blinkToggle": 1, + "{": 300, + "state": 50, + "CLIMBING": 5, + "or": 78, + "sprite_index": 14, + "sPExit": 1, + "sDamselExit": 1, + "sTunnelExit": 1, + "and": 155, + "global.hasJetpack": 4, + "not": 63, + "whipping": 5, + "draw_sprite_ext": 10, + "x": 76, + "y": 85, + "image_yscale": 14, + "image_angle": 14, + "image_blend": 2, + "image_alpha": 10, + "//draw_sprite": 1, + "draw_sprite": 9, + "sJetpackBack": 1, + "false": 85, + "}": 307, + "sJetpackRight": 1, + "sJetpackLeft": 1, + "+": 206, + "redColor": 2, + "make_color_rgb": 1, + "holdArrow": 4, + "ARROW_NORM": 2, + "sArrowRight": 1, + "ARROW_BOMB": 2, + "holdArrowToggle": 2, + "sBombArrowRight": 2, + "LEFT": 7, + "sArrowLeft": 1, + "sBombArrowLeft": 2, + "hangCountMax": 2, + "//////////////////////////////////////": 2, + "kLeft": 12, + "checkLeft": 1, + "kLeftPushedSteps": 3, + "kLeftPressed": 2, + "checkLeftPressed": 1, + "kLeftReleased": 3, + "checkLeftReleased": 1, + "kRight": 12, + "checkRight": 1, + "kRightPushedSteps": 3, + "kRightPressed": 2, + "checkRightPressed": 1, + "kRightReleased": 3, + "checkRightReleased": 1, + "kUp": 5, + "checkUp": 1, + "kDown": 5, + "checkDown": 1, + "//key": 1, + "canRun": 1, + "kRun": 2, + "kJump": 6, + "checkJump": 1, + "kJumpPressed": 11, + "checkJumpPressed": 1, + "kJumpReleased": 5, + "checkJumpReleased": 1, + "cantJump": 3, + "global.isTunnelMan": 1, + "sTunnelAttackL": 1, + "holdItem": 1, + "kAttack": 2, + "checkAttack": 2, + "kAttackPressed": 2, + "checkAttackPressed": 1, + "kAttackReleased": 2, + "checkAttackReleased": 1, + "kItemPressed": 2, + "checkItemPressed": 1, + "xPrev": 1, + "yPrev": 1, + "stunned": 3, + "dead": 3, + "//////////////////////////////////////////": 2, + "colSolidLeft": 4, + "colSolidRight": 3, + "colLeft": 6, + "colRight": 6, + "colTop": 4, + "colBot": 11, + "colLadder": 3, + "colPlatBot": 6, + "colPlat": 5, + "colWaterTop": 3, + "colIceBot": 2, + "runKey": 4, + "isCollisionMoveableSolidLeft": 1, + "isCollisionMoveableSolidRight": 1, + "isCollisionLeft": 2, + "isCollisionRight": 2, + "isCollisionTop": 1, + "isCollisionBottom": 1, + "isCollisionLadder": 1, + "isCollisionPlatformBottom": 1, + "isCollisionPlatform": 1, + "isCollisionWaterTop": 1, + "collision_point": 30, + "oIce": 1, + "checkRun": 1, + "runHeld": 3, + "HANGING": 10, + "approximatelyZero": 4, + "xVel": 24, + "xAcc": 12, + "platformCharacterIs": 23, + "ON_GROUND": 18, + "DUCKING": 4, + "pushTimer": 3, + "//if": 5, + "SS_IsSoundPlaying": 2, + "global.sndPush": 4, + "playSound": 3, + "runAcc": 2, + "abs": 9, + "alarm": 13, + "[": 99, + "]": 103, + "<": 39, + "floor": 11, + "/": 5, + "/xVel": 1, + "instance_exists": 8, + "oCape": 2, + "oCape.open": 6, + "kJumped": 7, + "ladderTimer": 4, + "ladder": 5, + "oLadder": 4, + "ladder.x": 3, + "oLadderTop": 2, + "yAcc": 26, + "climbAcc": 2, + "FALLING": 8, + "STANDING": 2, + "departLadderXVel": 2, + "departLadderYVel": 1, + "JUMPING": 6, + "jumpButtonReleased": 7, + "jumpTime": 8, + "IN_AIR": 5, + "gravityIntensity": 2, + "yVel": 20, + "RUNNING": 3, + "jumps": 3, + "//playSound": 1, + "global.sndLand": 1, + "grav": 22, + "global.hasGloves": 3, + "hangCount": 14, + "*": 18, + "yVel*0.3": 1, + "oWeb": 2, + "obj": 14, + "instance_place": 3, + "obj.life": 1, + "initialJumpAcc": 6, + "xVel/2": 3, + "gravNorm": 7, + "global.hasCape": 1, + "jetpackFuel": 2, + "fallTimer": 2, + "global.hasJordans": 1, + "yAccLimit": 2, + "global.hasSpringShoes": 1, + "global.sndJump": 1, + "jumpTimeTotal": 2, + "//let": 1, + "character": 20, + "continue": 4, + "to": 62, + "jump": 1, + "jumpTime/jumpTimeTotal": 1, + "looking": 2, + "UP": 1, + "LOOKING_UP": 4, + "oSolid": 14, + "move_snap": 6, + "oTree": 4, + "oArrow": 5, + "instance_nearest": 1, + "obj.stuck": 1, + "//the": 2, + "can": 1, + "t": 23, + "want": 1, + "use": 4, + "because": 2, + "is": 9, + "too": 2, + "high": 1, + "yPrevHigh": 1, + "//": 11, + "we": 5, + "ll": 1, + "move": 2, + "correct": 1, + "distance": 1, + "but": 2, + "need": 1, + "shorten": 1, + "out": 4, + "a": 55, + "little": 1, + "ratio": 1, + "xVelInteger": 2, + "/dist*0.9": 1, + "//can": 1, + "be": 4, + "changed": 1, + "moveTo": 2, + "round": 6, + "xVelInteger*ratio": 1, + "yVelInteger*ratio": 1, + "slopeChangeInY": 1, + "maxDownSlope": 1, + "floating": 1, + "just": 1, + "above": 1, + "slope": 1, + "so": 2, + "down": 1, + "upYPrev": 1, + "for": 26, + "<=upYPrev+maxDownSlope;y+=1)>": 1, + "hit": 1, + "solid": 1, + "below": 1, + "upYPrev=": 1, + "I": 1, + "know": 1, + "that": 2, + "this": 2, + "doesn": 1, + "seem": 1, + "make": 1, + "sense": 1, + "of": 25, + "name": 9, + "variable": 1, + "it": 6, + "all": 3, + "works": 1, + "correctly": 1, + "after": 1, + "break": 58, + "loop": 1, + "y=": 1, + "figures": 1, + "what": 1, + "index": 11, + "should": 25, + "characterSprite": 1, + "sets": 1, + "previous": 2, + "previously": 1, + "statePrevPrev": 1, + "statePrev": 2, + "calculates": 1, + "image_speed": 9, + "based": 1, + "on": 4, + "s": 6, + "velocity": 1, + "runAnimSpeed": 1, + "0": 21, + "1": 32, + "sqrt": 1, + "sqr": 2, + "climbAnimSpeed": 1, + "<=>": 3, + "4": 2, + "setCollisionBounds": 3, + "8": 9, + "5": 5, + "DUCKTOHANG": 1, + "image_index": 1, + "limit": 5, + "at": 23, + "animation": 1, + "always": 1, + "looks": 1, + "good": 1, + "var": 79, + "i": 95, + "playerObject": 1, + "playerID": 1, + "player": 36, + "otherPlayerID": 1, + "otherPlayer": 1, + "sameVersion": 1, + "buffer": 1, + "plugins": 4, + "pluginsRequired": 2, + "usePlugins": 1, + "tcp_eof": 3, + "global.serverSocket": 10, + "gotServerHello": 2, + "show_message": 7, + "instance_destroy": 7, + "exit": 10, + "room": 1, + "DownloadRoom": 1, + "keyboard_check": 1, + "vk_escape": 1, + "downloadingMap": 2, + "while": 15, + "tcp_receive": 3, + "min": 4, + "downloadMapBytes": 2, + "buffer_size": 2, + "downloadMapBuffer": 6, + "write_buffer": 2, + "write_buffer_to_file": 1, + "downloadMapName": 3, + "buffer_destroy": 8, + "roomchange": 2, + "do": 1, + "switch": 9, + "read_ubyte": 10, + "case": 50, + "HELLO": 1, + "global.joinedServerName": 2, + "receivestring": 4, + "advertisedMapMd5": 1, + "receiveCompleteMessage": 1, + "global.tempBuffer": 3, + "string_pos": 20, + "Server": 3, + "sent": 7, + "illegal": 2, + "map": 47, + "This": 2, + "server": 10, + "requires": 1, + "following": 2, + "play": 2, + "#": 3, + "suggests": 1, + "optional": 1, + "Error": 2, + "ocurred": 1, + "loading": 1, + "plugins.": 1, + "Maps/": 2, + ".png": 2, + "The": 6, + "version": 4, + "Enter": 1, + "Password": 1, + "Incorrect": 1, + "Password.": 1, + "Incompatible": 1, + "protocol": 3, + "version.": 1, + "Name": 1, + "Exploit": 1, + "Invalid": 2, + "plugin": 6, + "packet": 3, + "ID": 2, + "There": 1, + "are": 1, + "many": 1, + "connections": 1, + "from": 5, + "your": 1, + "IP": 1, + "You": 1, + "have": 2, + "been": 1, + "kicked": 1, + "server.": 1, + ".": 12, + "#Server": 1, + "went": 1, + "invalid": 1, + "internal": 1, + "#Exiting.": 1, + "full.": 1, + "noone": 7, + "ERROR": 1, + "when": 1, + "reading": 1, + "no": 1, + "such": 1, + "unexpected": 1, + "data.": 1, + "until": 1, + "downloadHandle": 3, + "url": 62, + "tmpfile": 3, + "window_oldshowborder": 2, + "window_oldfullscreen": 2, + "timeLeft": 1, + "counter": 1, + "AudioControlPlaySong": 1, + "window_get_showborder": 1, + "window_get_fullscreen": 1, + "window_set_fullscreen": 2, + "window_set_showborder": 1, + "global.updaterBetaChannel": 3, + "UPDATE_SOURCE_BETA": 1, + "UPDATE_SOURCE": 1, + "temp_directory": 1, + "httpGet": 1, + "httpRequestStatus": 1, + "download": 1, + "isn": 1, + "extract": 1, + "downloaded": 1, + "file": 2, + "now.": 1, + "extractzip": 1, + "working_directory": 6, + "execute_program": 1, + "game_end": 1, + "victim": 10, + "killer": 11, + "assistant": 16, + "damageSource": 18, + "argument0": 28, + "argument1": 10, + "argument2": 3, + "argument3": 1, + "//*************************************": 6, + "//*": 3, + "Scoring": 1, + "Kill": 1, + "log": 1, + "recordKillInLog": 1, + "victim.stats": 1, + "DEATHS": 1, + "WEAPON_KNIFE": 1, + "||": 16, + "WEAPON_BACKSTAB": 1, + "killer.stats": 8, + "STABS": 2, + "killer.roundStats": 8, + "POINTS": 10, + "victim.object.currentWeapon.object_index": 1, + "Medigun": 2, + "victim.object.currentWeapon.uberReady": 1, + "BONUS": 2, + "KILLS": 2, + "victim.object.intel": 1, + "DEFENSES": 2, + "recordEventInLog": 1, + "killer.team": 1, + "killer.name": 2, + "global.myself": 4, + "assistant.stats": 2, + "ASSISTS": 2, + "assistant.roundStats": 2, + ".5": 2, + "//SPEC": 1, + "instance_create": 20, + "victim.object.x": 3, + "victim.object.y": 3, + "Spectator": 1, + "Gibbing": 2, + "xoffset": 5, + "yoffset": 5, + "xsize": 3, + "ysize": 3, + "view_xview": 3, + "view_yview": 3, + "view_wview": 2, + "view_hview": 2, + "randomize": 1, + "with": 47, + "victim.object": 2, + "WEAPON_ROCKETLAUNCHER": 1, + "WEAPON_MINEGUN": 1, + "FRAG_BOX": 2, + "WEAPON_REFLECTED_STICKY": 1, + "WEAPON_REFLECTED_ROCKET": 1, + "FINISHED_OFF_GIB": 2, + "GENERATOR_EXPLOSION": 2, + "player.class": 15, + "CLASS_QUOTE": 3, + "global.gibLevel": 14, + "distance_to_point": 3, + "xsize/2": 2, + "ysize/2": 2, + "hasReward": 4, + "repeat": 7, + "createGib": 14, + "PumpkinGib": 1, + "hspeed": 14, + "vspeed": 13, + "random": 21, + "choose": 8, + "Gib": 1, + "player.team": 8, + "TEAM_BLUE": 6, + "BlueClump": 1, + "TEAM_RED": 8, + "RedClump": 1, + "blood": 2, + "BloodDrop": 1, + "blood.hspeed": 1, + "blood.vspeed": 1, + "blood.sprite_index": 1, + "PumpkinJuiceS": 1, + "//All": 1, + "Classes": 1, + "gib": 1, + "head": 1, + "hands": 2, + "feet": 1, + "Headgib": 1, + "//Medic": 1, + "has": 2, + "specially": 1, + "colored": 1, + "CLASS_MEDIC": 2, + "Hand": 3, + "Feet": 1, + "//Class": 1, + "specific": 1, + "gibs": 1, + "CLASS_PYRO": 2, + "Accesory": 5, + "CLASS_SOLDIER": 2, + "CLASS_ENGINEER": 3, + "CLASS_SNIPER": 3, + "playsound": 2, + "deadbody": 2, + "DeathSnd1": 1, + "DeathSnd2": 1, + "DeadGuy": 1, + "deadbody.sprite_index": 2, + "haxxyStatue": 1, + "deadbody.image_index": 2, + "CHARACTER_ANIMATION_DEAD": 1, + "deadbody.hspeed": 1, + "deadbody.vspeed": 1, + "deadbody.image_xscale": 1, + "global.gg_birthday": 1, + "myHat": 2, + "PartyHat": 1, + "myHat.image_index": 2, + "victim.team": 2, + "global.xmas": 1, + "XmasHat": 1, + "Deathcam": 1, + "global.killCam": 3, + "KILL_BOX": 1, + "FINISHED_OFF": 5, + "DeathCam": 1, + "DeathCam.killedby": 1, + "DeathCam.name": 1, + "DeathCam.oldxview": 1, + "DeathCam.oldyview": 1, + "DeathCam.lastDamageSource": 1, + "DeathCam.team": 1, + "global.myself.team": 3, + "xr": 19, + "yr": 19, + "cloakAlpha": 1, + "team": 13, + "canCloak": 1, + "cloakAlpha/2": 1, + "invisible": 1, + "stabbing": 2, + "power": 1, + "currentWeapon.stab.alpha": 1, + "&&": 6, + "global.showHealthBar": 3, + "draw_set_alpha": 3, + "draw_healthbar": 1, + "hp*100/maxHp": 1, + "c_black": 1, + "c_red": 3, + "c_green": 1, + "mouse_x": 1, + "mouse_y": 1, + "<25)>": 1, + "cloak": 2, + "global": 8, + "myself": 2, + "draw_set_halign": 1, + "fa_center": 1, + "draw_set_valign": 1, + "fa_bottom": 1, + "team=": 1, + "draw_set_color": 2, + "c_blue": 2, + "draw_text": 4, + "35": 1, + "showTeammateStats": 1, + "weapons": 3, + "50": 3, + "Superburst": 1, + "string": 13, + "currentWeapon": 2, + "uberCharge": 1, + "20": 1, + "Shotgun": 1, + "Nuts": 1, + "N": 1, + "Bolts": 1, + "nutsNBolts": 1, + "Minegun": 1, + "Lobbed": 1, + "Mines": 1, + "lobbed": 1, + "ubercolour": 6, + "overlaySprite": 6, + "zoomed": 1, + "SniperCrouchRedS": 1, + "SniperCrouchBlueS": 1, + "sniperCrouchOverlay": 1, + "overlay": 1, + "omnomnomnom": 2, + "draw_sprite_ext_overlay": 7, + "omnomnomnomSprite": 2, + "omnomnomnomOverlay": 2, + "omnomnomnomindex": 4, + "c_white": 13, + "ubered": 7, + "7": 4, + "taunting": 2, + "tauntsprite": 2, + "tauntOverlay": 2, + "tauntindex": 2, + "humiliated": 1, + "humiliationPoses": 1, + "animationImage": 9, + "humiliationOffset": 1, + "animationOffset": 6, + "burnDuration": 2, + "burnIntensity": 2, + "numFlames": 1, + "maxIntensity": 1, + "FlameS": 1, + "flameArray_x": 1, + "flameArray_y": 1, + "maxDuration": 1, + "demon": 4, + "demonX": 5, + "median": 2, + "demonY": 4, + "demonOffset": 4, + "demonDir": 2, + "dir": 3, + "demonFrame": 5, + "sprite_get_number": 1, + "*player.team": 2, + "dir*1": 2, + "#define": 26, + "__http_init": 3, + "global.__HttpClient": 4, + "object_add": 1, + "object_set_persistent": 1, + "__http_split": 3, + "text": 19, + "delimeter": 7, + "list": 36, + "count": 4, + "ds_list_create": 5, + "ds_list_add": 23, + "string_copy": 32, + "string_length": 25, + "return": 56, + "__http_parse_url": 4, + "ds_map_create": 4, + "ds_map_add": 15, + "colonPos": 22, + "string_char_at": 13, + "slashPos": 13, + "real": 14, + "queryPos": 12, + "ds_map_destroy": 6, + "__http_resolve_url": 2, + "baseUrl": 3, + "refUrl": 18, + "urlParts": 15, + "refUrlParts": 5, + "canParseRefUrl": 3, + "result": 11, + "ds_map_find_value": 22, + "__http_resolve_path": 3, + "ds_map_replace": 3, + "ds_map_exists": 11, + "ds_map_delete": 1, + "path": 10, + "query": 4, + "relUrl": 1, + "__http_construct_url": 2, + "basePath": 4, + "refPath": 7, + "parts": 29, + "refParts": 5, + "lastPart": 3, + "ds_list_find_value": 9, + "ds_list_size": 11, + "ds_list_delete": 5, + "ds_list_destroy": 4, + "part": 6, + "ds_list_replace": 3, + "__http_parse_hex": 2, + "hexString": 4, + "hexValues": 3, + "digit": 4, + "__http_prepare_request": 4, + "client": 33, + "headers": 11, + "parsed": 18, + "show_error": 2, + "destroyed": 3, + "CR": 10, + "chr": 3, + "LF": 5, + "CRLF": 17, + "socket": 40, + "tcp_connect": 1, + "errored": 19, + "error": 18, + "linebuf": 33, + "line": 19, + "statusCode": 6, + "reasonPhrase": 2, + "responseBody": 19, + "buffer_create": 7, + "responseBodySize": 5, + "responseBodyProgress": 5, + "responseHeaders": 9, + "requestUrl": 2, + "requestHeaders": 2, + "write_string": 9, + "key": 17, + "ds_map_find_first": 1, + "is_string": 2, + "ds_map_find_next": 1, + "socket_send": 1, + "__http_parse_header": 3, + "ord": 16, + "headerValue": 9, + "string_lower": 3, + "headerName": 4, + "__http_client_step": 2, + "socket_has_error": 1, + "socket_error": 1, + "__http_client_destroy": 20, + "available": 7, + "tcp_receive_available": 1, + "bytesRead": 6, + "c": 20, + "read_string": 9, + "Reached": 2, + "end": 11, + "HTTP": 1, + "defines": 1, + "sequence": 2, + "as": 1, + "marker": 1, + "elements": 1, + "except": 2, + "entity": 1, + "body": 2, + "see": 1, + "appendix": 1, + "19": 1, + "3": 1, + "tolerant": 1, + "applications": 1, + "Strip": 1, + "trailing": 1, + "First": 1, + "status": 2, + "code": 2, + "first": 3, + "Response": 1, + "message": 1, + "Status": 1, + "Line": 1, + "consisting": 1, + "followed": 1, + "by": 5, + "numeric": 1, + "its": 1, + "associated": 1, + "textual": 1, + "phrase": 1, + "each": 18, + "element": 8, + "separated": 1, + "SP": 1, + "characters": 3, + "No": 3, + "allowed": 1, + "in": 21, + "final": 1, + "httpVer": 2, + "spacePos": 11, + "space": 4, + "response": 5, + "second": 2, + "Other": 1, + "Blank": 1, + "write": 1, + "remainder": 1, + "write_buffer_part": 3, + "Header": 1, + "Receiving": 1, + "transfer": 6, + "encoding": 2, + "chunked": 4, + "Chunked": 1, + "let": 1, + "decode": 36, + "actualResponseBody": 8, + "actualResponseSize": 1, + "actualResponseBodySize": 3, + "Parse": 1, + "chunks": 1, + "chunk": 12, + "size": 7, + "extension": 3, + "data": 4, + "HEX": 1, + "buffer_bytes_left": 6, + "chunkSize": 11, + "Read": 1, + "byte": 2, + "We": 1, + "found": 21, + "semicolon": 1, + "beginning": 1, + "skip": 1, + "stuff": 2, + "header": 2, + "Doesn": 1, + "did": 1, + "empty": 13, + "something": 1, + "up": 6, + "Parsing": 1, + "failed": 56, + "hex": 2, + "was": 1, + "hexadecimal": 1, + "Is": 1, + "bigger": 2, + "than": 1, + "remaining": 1, + "2": 2, + "responseHaders": 1, + "location": 4, + "resolved": 5, + "socket_destroy": 4, + "http_new_get": 1, + "variable_global_exists": 2, + "http_new_get_ex": 1, + "http_step": 1, + "client.errored": 3, + "client.state": 3, + "http_status_code": 1, + "client.statusCode": 1, + "http_reason_phrase": 1, + "client.error": 1, + "client.reasonPhrase": 1, + "http_response_body": 1, + "client.responseBody": 1, + "http_response_body_size": 1, + "client.responseBodySize": 1, + "http_response_body_progress": 1, + "client.responseBodyProgress": 1, + "http_response_headers": 1, + "client.responseHeaders": 1, + "http_destroy": 1, + "RoomChangeObserver": 1, + "set_little_endian_global": 1, + "file_exists": 5, + "file_delete": 3, + "backupFilename": 5, + "file_find_first": 1, + "file_find_next": 1, + "file_find_close": 1, + "customMapRotationFile": 7, + "restart": 4, + "//import": 1, + "wav": 1, + "files": 1, + "music": 1, + "global.MenuMusic": 3, + "sound_add": 3, + "global.IngameMusic": 3, + "global.FaucetMusic": 3, + "sound_volume": 3, + "global.sendBuffer": 19, + "global.HudCheck": 1, + "global.map_rotation": 19, + "global.CustomMapCollisionSprite": 1, + "window_set_region_scale": 1, + "ini_open": 2, + "global.playerName": 7, + "ini_read_string": 12, + "string_count": 2, + "MAX_PLAYERNAME_LENGTH": 2, + "global.fullscreen": 3, + "ini_read_real": 65, + "global.useLobbyServer": 2, + "global.hostingPort": 2, + "global.music": 2, + "MUSIC_BOTH": 1, + "global.playerLimit": 4, + "//thy": 1, + "playerlimit": 1, + "shalt": 1, + "exceed": 1, + "global.dedicatedMode": 7, + "ini_write_real": 60, + "global.multiClientLimit": 2, + "global.particles": 2, + "PARTICLES_NORMAL": 1, + "global.monitorSync": 3, + "set_synchronization": 2, + "global.medicRadar": 2, + "global.showHealer": 2, + "global.showHealing": 2, + "global.showTeammateStats": 2, + "global.serverPluginsPrompt": 2, + "global.restartPrompt": 2, + "//user": 1, + "HUD": 1, + "settings": 1, + "global.timerPos": 2, + "global.killLogPos": 2, + "global.kothHudPos": 2, + "global.clientPassword": 1, + "global.shuffleRotation": 2, + "global.timeLimitMins": 2, + "max": 2, + "global.serverPassword": 2, + "global.mapRotationFile": 1, + "global.serverName": 2, + "global.welcomeMessage": 2, + "global.caplimit": 3, + "global.caplimitBkup": 1, + "global.autobalance": 2, + "global.Server_RespawntimeSec": 4, + "global.rewardKey": 1, + "unhex": 1, + "global.rewardId": 1, + "global.mapdownloadLimitBps": 2, + "isBetaVersion": 1, + "global.attemptPortForward": 2, + "global.serverPluginList": 3, + "global.serverPluginsRequired": 2, + "CrosshairFilename": 5, + "CrosshairRemoveBG": 4, + "global.queueJumping": 2, + "global.backgroundHash": 2, + "global.backgroundTitle": 2, + "global.backgroundURL": 2, + "global.backgroundShowVersion": 2, + "readClasslimitsFromIni": 1, + "global.currentMapArea": 1, + "global.totalMapAreas": 1, + "global.setupTimer": 1, + "global.serverPluginsInUse": 1, + "global.pluginPacketBuffers": 1, + "global.pluginPacketPlayers": 1, + "ini_write_string": 10, + "ini_key_delete": 1, + "global.classlimits": 10, + "CLASS_SCOUT": 1, + "CLASS_HEAVY": 2, + "CLASS_DEMOMAN": 1, + "CLASS_SPY": 1, + "//screw": 1, + "will": 1, + "start": 1, + "//map_truefort": 1, + "maps": 37, + "//map_2dfort": 1, + "//map_conflict": 1, + "//map_classicwell": 1, + "//map_waterway": 1, + "//map_orange": 1, + "//map_dirtbowl": 1, + "//map_egypt": 1, + "//arena_montane": 1, + "//arena_lumberyard": 1, + "//gen_destroy": 1, + "//koth_valley": 1, + "//koth_corinth": 1, + "//koth_harvest": 1, + "//dkoth_atalia": 1, + "//dkoth_sixties": 1, + "//Server": 1, + "respawn": 1, + "time": 1, + "calculator.": 1, + "Converts": 1, + "frame.": 1, + "read": 1, + "multiply": 1, + "hehe": 1, + "global.Server_Respawntime": 3, + "global.mapchanging": 1, + "ini_close": 2, + "global.protocolUuid": 2, + "parseUuid": 2, + "PROTOCOL_UUID": 1, + "global.gg2lobbyId": 2, + "GG2_LOBBY_UUID": 1, + "initRewards": 1, + "IPRaw": 3, + "portRaw": 3, + "doubleCheck": 8, + "global.launchMap": 5, + "parameter_count": 1, + "parameter_string": 8, + "global.serverPort": 1, + "global.serverIP": 1, + "global.isHost": 1, + "Client": 1, + "global.customMapdesginated": 2, + "fileHandle": 6, + "mapname": 9, + "file_text_open_read": 1, + "file_text_eof": 1, + "file_text_read_string": 1, + "starts": 1, + "tab": 2, + "string_delete": 1, + "delete": 1, + "comment": 1, + "starting": 1, + "file_text_readln": 1, + "file_text_close": 1, + "load": 1, + "ini": 1, + "Maps": 9, + "section": 1, + "//Set": 1, + "rotation": 1, + "sort_list": 7, + "*maps": 1, + "ds_list_sort": 1, + "mod": 1, + "global.gg2Font": 2, + "font_add_sprite": 2, + "gg2FontS": 1, + "global.countFont": 1, + "countFontS": 1, + "draw_set_font": 1, + "cursor_sprite": 1, + "CrosshairS": 5, + "directory_exists": 2, + "directory_create": 2, + "AudioControl": 1, + "SSControl": 1, + "message_background": 1, + "popupBackgroundB": 1, + "message_button": 1, + "popupButtonS": 1, + "message_text_font": 1, + "message_button_font": 1, + "message_input_font": 1, + "//Key": 1, + "Mapping": 1, + "global.jump": 1, + "global.down": 1, + "global.left": 1, + "global.right": 1, + "global.attack": 1, + "MOUSE_LEFT": 1, + "global.special": 1, + "MOUSE_RIGHT": 1, + "global.taunt": 1, + "global.chat1": 1, + "global.chat2": 1, + "global.chat3": 1, + "global.medic": 1, + "global.drop": 1, + "global.changeTeam": 1, + "global.changeClass": 1, + "global.showScores": 1, + "vk_shift": 1, + "calculateMonthAndDay": 1, + "loadplugins": 1, + "registry_set_root": 1, + "HKLM": 1, + "global.NTKernelVersion": 1, + "registry_read_string_ext": 1, + "CurrentVersion": 1, + "SIC": 1, + "sprite_replace": 1, + "sprite_set_offset": 1, + "sprite_get_width": 1, + "/2": 2, + "sprite_get_height": 1, + "AudioControlToggleMute": 1, + "room_goto_fix": 2, + "Menu": 2, + "__jso_gmt_tuple": 1, + "//Position": 1, + "address": 1, + "table": 1, + "pos": 2, + "addr_table": 2, + "*argument_count": 1, + "//Build": 1, + "tuple": 1, + "ca": 1, + "isstr": 1, + "datastr": 1, + "argument_count": 1, + "//Check": 1, + "argument": 10, + "Unexpected": 18, + "position": 16, + "f": 5, + "JSON": 5, + "string.": 5, + "Cannot": 5, + "parse": 3, + "boolean": 3, + "value": 13, + "expecting": 9, + "digit.": 9, + "e": 4, + "E": 4, + "dot": 1, + "an": 24, + "integer": 6, + "Expected": 6, + "least": 6, + "arguments": 26, + "got": 6, + "find": 10, + "lookup.": 4, + "indices": 1, + "nested": 27, + "lists": 6, + "Index": 1, + "overflow": 4, + "Recursive": 1, + "abcdef": 1, + "number": 7, + "num": 1, + "assert_true": 1, + "_assert_error_popup": 2, + "string_repeat": 2, + "_assert_newline": 2, + "assert_false": 1, + "assert_equal": 1, + "//Safe": 1, + "equality": 1, + "check": 1, + "won": 1, + "support": 1, + "instead": 1, + "_assert_debug_value": 1, + "//String": 1, + "os_browser": 1, + "browser_not_a_browser": 1, + "string_replace_all": 1, + "//Numeric": 1, + "GMTuple": 1, + "jso_encode_string": 1, + "encode": 8, + "escape": 2, + "jso_encode_map": 4, + "one": 42, + "key1": 3, + "key2": 3, + "multi": 7, + "jso_encode_list": 3, + "three": 36, + "_jso_decode_string": 5, + "small": 1, + "quick": 2, + "brown": 2, + "fox": 2, + "over": 2, + "lazy": 2, + "dog.": 2, + "simple": 1, + "Waahoo": 1, + "negg": 1, + "mixed": 1, + "_jso_decode_boolean": 2, + "_jso_decode_real": 11, + "standard": 1, + "zero": 4, + "signed": 2, + "decimal": 1, + "digits": 1, + "positive": 7, + "negative": 7, + "exponent": 4, + "_jso_decode_integer": 3, + "_jso_decode_map": 14, + "didn": 14, + "include": 14, + "right": 14, + "prefix": 14, + "#1": 14, + "#2": 14, + "entry": 29, + "pi": 2, + "bool": 2, + "waahoo": 10, + "woohah": 8, + "mix": 4, + "_jso_decode_list": 14, + "woo": 2, + "Empty": 4, + "equal": 20, + "other.": 12, + "junk": 2, + "info": 1, + "taxi": 1, + "An": 4, + "filled": 4, + "map.": 2, + "A": 24, + "B": 18, + "C": 8, + "same": 6, + "content": 4, + "entered": 4, + "different": 12, + "orders": 4, + "D": 1, + "keys": 2, + "values": 4, + "six": 1, + "corresponding": 4, + "types": 4, + "other": 4, + "crash.": 4, + "list.": 2, + "Lists": 4, + "two": 16, + "entries": 2, + "also": 2, + "jso_map_check": 9, + "existing": 9, + "single": 11, + "jso_map_lookup": 3, + "wrong": 10, + "trap": 2, + "jso_map_lookup_type": 3, + "type": 8, + "four": 21, + "inexistent": 11, + "multiple": 20, + "jso_list_check": 8, + "jso_list_lookup": 3, + "jso_list_lookup_type": 3, + "inner": 1, + "indexing": 1, + "bad": 1, + "jso_cleanup_map": 1, + "one_map": 1, + "hashList": 5, + "pluginname": 9, + "pluginhash": 4, + "realhash": 1, + "handle": 1, + "filesize": 1, + "progress": 1, + "tempfile": 1, + "tempdir": 1, + "lastContact": 2, + "isCached": 2, + "isDebug": 2, + "split": 1, + "checkpluginname": 1, + "ds_list_find_index": 1, + ".zip": 3, + "ServerPluginsCache": 6, + "@": 5, + ".zip.tmp": 1, + ".tmp": 2, + "ServerPluginsDebug": 1, + "Warning": 2, + "being": 2, + "loaded": 2, + "ServerPluginsDebug.": 2, + "Make": 2, + "sure": 2, + "clients": 1, + "they": 1, + "may": 2, + "unable": 2, + "connect.": 2, + "you": 1, + "Downloading": 1, + "last_plugin.log": 2, + "plugin.gml": 1, + "playerId": 11, + "commandLimitRemaining": 4, + "variable_local_exists": 4, + "commandReceiveState": 1, + "commandReceiveExpectedBytes": 1, + "commandReceiveCommand": 1, + "player.socket": 12, + "player.commandReceiveExpectedBytes": 7, + "player.commandReceiveState": 7, + "player.commandReceiveCommand": 4, + "commandBytes": 2, + "commandBytesInvalidCommand": 1, + "commandBytesPrefixLength1": 1, + "commandBytesPrefixLength2": 1, + "default": 1, + "read_ushort": 2, + "PLAYER_LEAVE": 1, + "PLAYER_CHANGECLASS": 1, + "class": 8, + "getCharacterObject": 2, + "player.object": 12, + "SpawnRoom": 2, + "lastDamageDealer": 8, + "sendEventPlayerDeath": 4, + "BID_FAREWELL": 4, + "doEventPlayerDeath": 4, + "secondToLastDamageDealer": 2, + "lastDamageDealer.object": 2, + "lastDamageDealer.object.healer": 4, + "player.alarm": 4, + "<=0)>": 1, + "checkClasslimits": 2, + "ServerPlayerChangeclass": 2, + "sendBuffer": 1, + "PLAYER_CHANGETEAM": 1, + "newTeam": 7, + "balance": 5, + "redSuperiority": 6, + "calculate": 1, + "which": 1, + "Player": 1, + "TEAM_SPECTATOR": 1, + "newClass": 4, + "ServerPlayerChangeteam": 1, + "ServerBalanceTeams": 1, + "CHAT_BUBBLE": 2, + "bubbleImage": 5, + "global.aFirst": 1, + "write_ubyte": 20, + "setChatBubble": 1, + "BUILD_SENTRY": 2, + "collision_circle": 1, + "player.object.x": 3, + "player.object.y": 3, + "Sentry": 1, + "player.object.nutsNBolts": 1, + "player.sentry": 2, + "player.object.onCabinet": 1, + "write_ushort": 2, + "global.serializeBuffer": 3, + "player.object.x*5": 1, + "player.object.y*5": 1, + "write_byte": 1, + "player.object.image_xscale": 2, + "buildSentry": 1, + "DESTROY_SENTRY": 1, + "DROP_INTEL": 1, + "player.object.intel": 1, + "sendEventDropIntel": 1, + "doEventDropIntel": 1, + "OMNOMNOMNOM": 2, + "player.humiliated": 1, + "player.object.taunting": 1, + "player.object.omnomnomnom": 1, + "player.object.canEat": 1, + "omnomnomnomend": 2, + "xscale": 1, + "TOGGLE_ZOOM": 2, + "toggleZoom": 1, + "PLAYER_CHANGENAME": 2, + "nameLength": 4, + "socket_receivebuffer_size": 3, + "KICK": 2, + "KICK_NAME": 1, + "current_time": 2, + "lastNamechange": 2, + "INPUTSTATE": 1, + "keyState": 1, + "netAimDirection": 1, + "aimDirection": 1, + "netAimDirection*360/65536": 1, + "event_user": 1, + "REWARD_REQUEST": 1, + "player.rewardId": 1, + "player.challenge": 2, + "rewardCreateChallenge": 1, + "REWARD_CHALLENGE_CODE": 1, + "write_binstring": 1, + "REWARD_CHALLENGE_RESPONSE": 1, + "answer": 3, + "authbuffer": 1, + "read_binstring": 1, + "rewardAuthStart": 1, + "challenge": 1, + "rewardId": 1, + "PLUGIN_PACKET": 1, + "packetID": 3, + "buf": 5, + "success": 3, + "_PluginPacketPush": 1, + "KICK_BAD_PLUGIN_PACKET": 1, + "CLIENT_SETTINGS": 2, + "mirror": 4, + "player.queueJump": 1, + "global.levelType": 22, + "//global.currLevel": 1, + "global.currLevel": 22, + "global.hadDarkLevel": 4, + "global.startRoomX": 1, + "global.startRoomY": 1, + "global.endRoomX": 1, + "global.endRoomY": 1, + "oGame.levelGen": 2, + "j": 14, + "global.roomPath": 1, + "k": 5, + "global.lake": 3, + "isLevel": 1, + "999": 2, + "levelType": 2, + "16": 14, + "656": 3, + "oDark": 2, + "invincible": 2, + "sDark": 1, + "oTemple": 2, + "cityOfGold": 1, + "sTemple": 2, + "lake": 1, + "i*16": 8, + "j*16": 6, + "oLush": 2, + "obj.sprite_index": 4, + "sLush": 2, + "obj.invincible": 3, + "oBrick": 1, + "sBrick": 1, + "global.cityOfGold": 2, + "*16": 2, + "//instance_create": 2, + "oSpikes": 1, + "background_index": 1, + "bgTemple": 1, + "global.temp1": 1, + "global.gameStart": 3, + "scrLevelGen": 1, + "global.cemetary": 3, + "rand": 10, + "global.probCemetary": 1, + "oRoom": 1, + "scrRoomGen": 1, + "global.blackMarket": 3, + "scrRoomGenMarket": 1, + "scrRoomGen2": 1, + "global.yetiLair": 2, + "scrRoomGenYeti": 1, + "scrRoomGen3": 1, + "scrRoomGen4": 1, + "scrRoomGen5": 1, + "global.darkLevel": 4, + "global.noDarkLevel": 1, + "global.probDarkLevel": 1, + "oPlayer1.x": 2, + "oPlayer1.y": 2, + "oFlare": 1, + "global.genUdjatEye": 4, + "global.madeUdjatEye": 1, + "global.genMarketEntrance": 4, + "global.madeMarketEntrance": 1, + "////////////////////////////": 2, + "global.temp2": 1, + "isRoom": 3, + "scrEntityGen": 1, + "oEntrance": 1, + "global.customLevel": 1, + "oEntrance.x": 1, + "oEntrance.y": 1, + "global.snakePit": 1, + "global.alienCraft": 1, + "global.sacrificePit": 1, + "oPlayer1": 1, + "scrSetupWalls": 3, + "global.graphicsHigh": 1, + "tile_add": 4, + "bgExtrasLush": 1, + "*rand": 12, + "bgExtrasIce": 1, + "bgExtrasTemple": 1, + "bgExtras": 1, + "global.murderer": 1, + "global.thiefLevel": 1, + "isRealLevel": 1, + "oExit": 1, + "oShopkeeper": 1, + "obj.status": 1, + "oTreasure": 1, + "oWater": 1, + "sWaterTop": 1, + "sLavaTop": 1, + "scrCheckWaterTop": 1, + "global.temp3": 1 + }, "GAS": { ".cstring": 1, "LC0": 2, @@ -18567,6 +21927,179 @@ "gl_FragColor.rgba": 1, "sampled.rgb": 1 }, + "Gnuplot": { + "set": 98, + "label": 14, + "at": 14, + "-": 102, + "left": 15, + "norotate": 18, + "back": 23, + "textcolor": 13, + "rgb": 8, + "nopoint": 14, + "offset": 25, + "character": 22, + "lt": 15, + "style": 7, + "line": 4, + "linetype": 11, + "linecolor": 4, + "linewidth": 11, + "pointtype": 4, + "pointsize": 4, + "default": 4, + "pointinterval": 4, + "noxtics": 2, + "noytics": 2, + "title": 13, + "xlabel": 6, + "xrange": 3, + "[": 18, + "]": 18, + "noreverse": 13, + "nowriteback": 12, + "yrange": 4, + "bmargin": 1, + "unset": 2, + "colorbox": 3, + "plot": 3, + "cos": 9, + "(": 52, + "x": 7, + ")": 52, + "ls": 4, + ".2": 1, + ".4": 1, + ".6": 1, + ".8": 1, + "lc": 3, + "boxwidth": 1, + "absolute": 1, + "fill": 1, + "solid": 1, + "border": 3, + "key": 1, + "inside": 1, + "right": 1, + "top": 1, + "vertical": 2, + "Right": 1, + "noenhanced": 1, + "autotitles": 1, + "nobox": 1, + "histogram": 1, + "clustered": 1, + "gap": 1, + "datafile": 1, + "missing": 1, + "data": 1, + "histograms": 1, + "xtics": 3, + "in": 1, + "scale": 1, + "nomirror": 1, + "rotate": 3, + "by": 3, + "autojustify": 1, + "norangelimit": 3, + "font": 8, + "i": 1, + "using": 2, + "xtic": 1, + "ti": 4, + "col": 4, + "u": 25, + "SHEBANG#!gnuplot": 1, + "reset": 1, + "terminal": 1, + "png": 1, + "output": 1, + "ylabel": 5, + "#set": 2, + "xr": 1, + "yr": 1, + "pt": 2, + "notitle": 15, + "dummy": 3, + "v": 31, + "arrow": 7, + "from": 7, + "to": 7, + "head": 7, + "nofilled": 7, + "parametric": 3, + "view": 3, + "samples": 3, + "isosamples": 3, + "hidden3d": 2, + "trianglepattern": 2, + "undefined": 2, + "altdiagonal": 2, + "bentover": 2, + "ztics": 2, + "zlabel": 4, + "zrange": 2, + "sinc": 13, + "sin": 3, + "sqrt": 4, + "u**2": 4, + "+": 6, + "v**2": 4, + "/": 2, + "GPFUN_sinc": 2, + "xx": 2, + "dx": 2, + "x0": 4, + "x1": 4, + "x2": 4, + "x3": 4, + "x4": 4, + "x5": 4, + "x6": 4, + "x7": 4, + "x8": 4, + "x9": 4, + "splot": 3, + "<": 10, + "xmin": 3, + "xmax": 1, + "n": 1, + "zbase": 2, + ".5": 2, + "*n": 1, + "floor": 3, + "u/3": 1, + "*dx": 1, + "%": 2, + "u/3.*dx": 1, + "/0": 1, + "angles": 1, + "degrees": 1, + "mapping": 1, + "spherical": 1, + "noztics": 1, + "urange": 1, + "vrange": 1, + "cblabel": 1, + "cbrange": 1, + "user": 1, + "origin": 1, + "screen": 2, + "size": 1, + "front": 1, + "bdefault": 1, + "*cos": 1, + "*sin": 1, + "with": 3, + "lines": 2, + "labels": 1, + "point": 1, + "lw": 1, + ".1": 1, + "tc": 1, + "pal": 1 + }, "Gosu": { "<%!-->": 1, "defined": 1, @@ -18702,6 +22235,676 @@ "PersonCSVTemplate.renderToString": 1, "PersonCSVTemplate.render": 1 }, + "Grammatical Framework": { + "-": 594, + "(": 256, + "c": 73, + ")": 256, + "Aarne": 13, + "Ranta": 13, + "under": 33, + "LGPL": 33, + "abstract": 1, + "Foods": 34, + "{": 579, + "flags": 32, + "startcat": 1, + "Comment": 31, + ";": 1399, + "cat": 1, + "Item": 31, + "Kind": 33, + "Quality": 34, + "fun": 1, + "Pred": 30, + "This": 29, + "That": 29, + "These": 28, + "Those": 28, + "Mod": 29, + "Wine": 29, + "Cheese": 29, + "Fish": 29, + "Pizza": 28, + "Very": 29, + "Fresh": 29, + "Warm": 29, + "Italian": 29, + "Expensive": 29, + "Delicious": 29, + "Boring": 29, + "}": 580, + "Laurette": 2, + "Pretorius": 2, + "Sr": 2, + "&": 2, + "Jr": 2, + "and": 4, + "Ansu": 2, + "Berg": 2, + "concrete": 33, + "FoodsAfr": 1, + "of": 89, + "open": 23, + "Prelude": 11, + "Predef": 3, + "in": 32, + "coding": 29, + "utf8": 29, + "lincat": 28, + "s": 365, + "Str": 394, + "Number": 207, + "n": 206, + "AdjAP": 10, + "lin": 28, + "item": 36, + "quality": 90, + "item.s": 24, + "+": 480, + "quality.s": 50, + "Predic": 3, + "kind": 115, + "kind.s": 46, + "Sg": 184, + "Pl": 182, + "table": 148, + "Attr": 9, + "declNoun_e": 2, + "declNoun_aa": 2, + "declNoun_ss": 2, + "declNoun_s": 2, + "veryAdj": 2, + "regAdj": 61, + "smartAdj_e": 4, + "param": 22, + "|": 122, + "oper": 29, + "Noun": 9, + "operations": 2, + "wyn": 1, + "kaas": 1, + "vis": 1, + "pizza": 1, + "x": 74, + "let": 8, + "v": 6, + "tk": 1, + "last": 3, + "Adjective": 9, + "mkAdj": 27, + "y": 3, + "declAdj_e": 2, + "declAdj_g": 2, + "w": 15, + "init": 4, + "declAdj_oog": 2, + "i": 2, + "a": 57, + "x.s": 8, + "case": 44, + "_": 68, + "FoodsAmh": 1, + "Krasimir": 1, + "Angelov": 1, + "FoodsBul": 1, + "Gender": 94, + "Masc": 67, + "Fem": 65, + "Neutr": 21, + "Agr": 3, + "ASg": 23, + "APl": 11, + "g": 132, + "qual": 8, + "item.a": 2, + "qual.s": 8, + "kind.g": 38, + "#": 14, + "path": 14, + ".": 13, + "present": 7, + "Jordi": 2, + "Saludes": 2, + "FoodsCat": 1, + "FoodsI": 6, + "with": 5, + "Syntax": 7, + "SyntaxCat": 2, + "LexFoods": 12, + "LexFoodsCat": 2, + "FoodsChi": 1, + "p": 11, + "quality.p": 2, + "kind.c": 11, + "geKind": 5, + "longQuality": 8, + "mkKind": 2, + "Katerina": 2, + "Bohmova": 2, + "FoodsCze": 1, + "ResCze": 2, + "NounPhrase": 3, + "copula": 33, + "item.n": 29, + "item.g": 12, + "det": 86, + "noun": 51, + "regnfAdj": 2, + "Femke": 1, + "Johansson": 1, + "FoodsDut": 1, + "AForm": 4, + "APred": 8, + "AAttr": 3, + "regNoun": 38, + "f": 16, + "a.s": 8, + "regadj": 6, + "adj": 38, + "noun.s": 7, + "man": 10, + "men": 10, + "wijn": 3, + "koud": 3, + "duur": 2, + "dure": 2, + "FoodsEng": 1, + "language": 2, + "en_US": 1, + "car": 6, + "cold": 4, + "Julia": 1, + "Hammar": 1, + "FoodsEpo": 1, + "SS": 6, + "ss": 13, + "d": 6, + "cn": 11, + "cn.s": 8, + "vino": 3, + "nova": 3, + "FoodsFin": 1, + "SyntaxFin": 2, + "LexFoodsFin": 2, + "../foods": 1, + "FoodsFre": 1, + "SyntaxFre": 1, + "ParadigmsFre": 1, + "Utt": 4, + "NP": 4, + "CN": 4, + "AP": 4, + "mkUtt": 4, + "mkCl": 4, + "mkNP": 16, + "this_QuantSg": 2, + "that_QuantSg": 2, + "these_QuantPl": 2, + "those_QuantPl": 2, + "mkCN": 20, + "mkAP": 28, + "very_AdA": 4, + "mkN": 46, + "masculine": 4, + "feminine": 2, + "mkA": 47, + "FoodsGer": 1, + "SyntaxGer": 2, + "LexFoodsGer": 2, + "alltenses": 3, + "Dana": 1, + "Dannells": 1, + "Licensed": 1, + "FoodsHeb": 2, + "Species": 8, + "mod": 7, + "Modified": 5, + "sp": 11, + "Indef": 6, + "Def": 21, + "T": 2, + "regAdj2": 3, + "F": 2, + "Type": 9, + "Adj": 4, + "m": 9, + "cn.mod": 2, + "cn.g": 10, + "gvina": 6, + "hagvina": 3, + "gvinot": 6, + "hagvinot": 3, + "defH": 7, + "replaceLastLetter": 7, + "adjective": 22, + "tov": 6, + "tova": 3, + "tovim": 3, + "tovot": 3, + "to": 6, + "c@": 3, + "italki": 3, + "italk": 4, + "Vikash": 1, + "Rauniyar": 1, + "FoodsHin": 2, + "regN": 15, + "lark": 8, + "ms": 4, + "mp": 4, + "acch": 6, + "incomplete": 1, + "this_Det": 2, + "that_Det": 2, + "these_Det": 2, + "those_Det": 2, + "wine_N": 7, + "pizza_N": 7, + "cheese_N": 7, + "fish_N": 8, + "fresh_A": 7, + "warm_A": 8, + "italian_A": 7, + "expensive_A": 7, + "delicious_A": 7, + "boring_A": 7, + "prelude": 2, + "Martha": 1, + "Dis": 1, + "Brandt": 1, + "FoodsIce": 1, + "Defin": 9, + "Ind": 14, + "the": 7, + "word": 3, + "is": 6, + "more": 1, + "commonly": 1, + "used": 2, + "Iceland": 1, + "but": 1, + "Icelandic": 1, + "for": 6, + "it": 2, + "defOrInd": 2, + "order": 1, + "given": 1, + "forms": 2, + "mSg": 1, + "fSg": 1, + "nSg": 1, + "mPl": 1, + "fPl": 1, + "nPl": 1, + "mSgDef": 1, + "f/nSgDef": 1, + "_PlDef": 1, + "masc": 3, + "fem": 2, + "neutr": 2, + "x1": 3, + "x9": 1, + "ferskur": 5, + "fersk": 11, + "ferskt": 2, + "ferskir": 2, + "ferskar": 2, + "fersk_pl": 2, + "ferski": 2, + "ferska": 2, + "fersku": 2, + "t": 28, + "": 1, + "<": 10, + "Predef.tk": 2, + "FoodsIta": 1, + "SyntaxIta": 2, + "LexFoodsIta": 2, + "../lib/src/prelude": 1, + "Zofia": 1, + "Stankiewicz": 1, + "FoodsJpn": 1, + "Style": 3, + "AdjUse": 4, + "AdjType": 4, + "quality.t": 3, + "IAdj": 4, + "Plain": 3, + "Polite": 4, + "NaAdj": 4, + "na": 1, + "adjectives": 2, + "have": 2, + "different": 1, + "as": 2, + "attributes": 1, + "predicates": 2, + "phrase": 1, + "types": 1, + "can": 1, + "form": 4, + "without": 1, + "cannot": 1, + "sakana": 6, + "chosenna": 2, + "chosen": 2, + "akai": 2, + "Inese": 1, + "Bernsone": 1, + "FoodsLav": 1, + "Q": 5, + "Q1": 5, + "q": 10, + "spec": 2, + "Q2": 3, + "specAdj": 2, + "skaists": 5, + "skaista": 2, + "skaisti": 2, + "skaistas": 2, + "skaistais": 2, + "skaistaa": 2, + "skaistie": 2, + "skaistaas": 2, + "skaist": 8, + "John": 1, + "J.": 1, + "Camilleri": 1, + "FoodsMlt": 1, + "uniAdj": 2, + "Create": 6, + "an": 2, + "full": 1, + "function": 1, + "Params": 4, + "Sing": 4, + "Plural": 2, + "iswed": 2, + "sewda": 2, + "suwed": 3, + "regular": 2, + "Param": 2, + "frisk": 4, + "eg": 1, + "tal": 1, + "buzz": 1, + "uni": 4, + "Singular": 1, + "inherent": 1, + "ktieb": 2, + "kotba": 2, + "Copula": 1, + "linking": 1, + "verb": 1, + "article": 3, + "taking": 1, + "into": 1, + "account": 1, + "first": 1, + "letter": 1, + "next": 1, + "pre": 1, + "cons@": 1, + "cons": 1, + "determinant": 1, + "Sg/Pl": 1, + "string": 1, + "default": 1, + "gender": 2, + "number": 2, + "/GF/lib/src/prelude": 1, + "Nyamsuren": 1, + "Erdenebadrakh": 1, + "FoodsMon": 1, + "prefixSS": 1, + "Dinesh": 1, + "Simkhada": 1, + "FoodsNep": 1, + "adjPl": 2, + "bor": 2, + "FoodsOri": 1, + "FoodsPes": 1, + "optimize": 1, + "noexpand": 1, + "Add": 8, + "prep": 11, + "Indep": 4, + "kind.prep": 1, + "quality.prep": 1, + "at": 3, + "a.prep": 1, + "must": 1, + "be": 1, + "written": 1, + "x4": 2, + "pytzA": 3, + "pytzAy": 1, + "pytzAhA": 3, + "pr": 4, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "mrd": 8, + "tAzh": 8, + "tAzhy": 2, + "Rami": 1, + "Shashati": 1, + "FoodsPor": 1, + "mkAdjReg": 7, + "QualityT": 5, + "bonito": 2, + "bonita": 2, + "bonitos": 2, + "bonitas": 2, + "pattern": 1, + "adjSozinho": 2, + "sozinho": 3, + "sozinh": 4, + "independent": 1, + "adjUtil": 2, + "util": 3, + "uteis": 3, + "smart": 1, + "paradigm": 1, + "adjcetives": 1, + "ItemT": 2, + "KindT": 4, + "num": 6, + "noun.g": 3, + "animal": 2, + "animais": 2, + "gen": 4, + "carro": 3, + "Ramona": 1, + "Enache": 1, + "FoodsRon": 1, + "NGender": 6, + "NMasc": 2, + "NFem": 3, + "NNeut": 2, + "mkTab": 5, + "mkNoun": 5, + "getAgrGender": 3, + "acesta": 2, + "aceasta": 2, + "gg": 3, + "det.s": 1, + "peste": 2, + "pesti": 2, + "scump": 2, + "scumpa": 2, + "scumpi": 2, + "scumpe": 2, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "ng": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "FoodsSpa": 1, + "SyntaxSpa": 1, + "StructuralSpa": 1, + "ParadigmsSpa": 1, + "FoodsSwe": 1, + "SyntaxSwe": 2, + "LexFoodsSwe": 2, + "**": 1, + "sv_SE": 1, + "FoodsTha": 1, + "SyntaxTha": 1, + "LexiconTha": 1, + "ParadigmsTha": 1, + "R": 4, + "ResTha": 1, + "R.thword": 4, + "FoodsTsn": 1, + "NounClass": 28, + "r": 9, + "b": 9, + "Bool": 5, + "p_form": 18, + "TType": 16, + "mkPredDescrCop": 2, + "item.c": 1, + "quality.p_form": 1, + "kind.w": 4, + "mkDemPron1": 3, + "kind.q": 4, + "mkDemPron2": 3, + "mkMod": 2, + "Lexicon": 1, + "mkNounNC14_6": 2, + "mkNounNC9_10": 4, + "smartVery": 2, + "mkVarAdj": 2, + "mkOrdAdj": 4, + "mkPerAdj": 2, + "mkVerbRel": 2, + "NC9_10": 14, + "NC14_6": 14, + "P": 4, + "V": 4, + "ModV": 4, + "y.b": 1, + "True": 3, + "y.w": 2, + "y.r": 2, + "y.c": 14, + "y.q": 4, + "smartQualRelPart": 5, + "x.t": 10, + "smartDescrCop": 5, + "False": 3, + "mkVeryAdj": 2, + "x.p_form": 2, + "mkVeryVerb": 3, + "mkQualRelPart_PName": 2, + "mkQualRelPart": 2, + "mkDescrCop_PName": 2, + "mkDescrCop": 2, + "FoodsTur": 1, + "Case": 10, + "softness": 4, + "Softness": 5, + "h": 4, + "Harmony": 5, + "Reason": 1, + "excluding": 1, + "plural": 3, + "In": 1, + "Turkish": 1, + "if": 1, + "subject": 1, + "not": 2, + "human": 2, + "being": 1, + "then": 1, + "singular": 1, + "regardless": 1, + "subject.": 1, + "Since": 1, + "all": 1, + "possible": 1, + "subjects": 1, + "are": 1, + "non": 1, + "do": 1, + "need": 1, + "form.": 1, + "quality.softness": 1, + "quality.h": 1, + "quality.c": 1, + "Nom": 9, + "Gen": 5, + "a.c": 1, + "a.softness": 1, + "a.h": 1, + "I_Har": 4, + "Ih_Har": 4, + "U_Har": 4, + "Uh_Har": 4, + "Ih": 1, + "Uh": 1, + "Soft": 3, + "Hard": 3, + "overload": 1, + "mkn": 1, + "peynir": 2, + "peynirler": 2, + "[": 2, + "]": 2, + "sarap": 2, + "saraplar": 2, + "sarabi": 2, + "saraplari": 2, + "italyan": 4, + "ca": 2, + "getSoftness": 2, + "getHarmony": 2, + "See": 1, + "comment": 1, + "lines": 1, + "excluded": 1, + "copula.": 1, + "base": 4, + "*": 1, + "Shafqat": 1, + "Virk": 1, + "FoodsUrd": 1, + "coupla": 2, + "interface": 1, + "N": 4, + "A": 6, + "instance": 5, + "ParadigmsCat": 1, + "M": 1, + "MorphoCat": 1, + "M.Masc": 2, + "ParadigmsFin": 1, + "ParadigmsGer": 1, + "ParadigmsIta": 1, + "ParadigmsSwe": 1, + "resource": 1, + "ne": 2, + "muz": 2, + "muzi": 2, + "msg": 3, + "fsg": 3, + "nsg": 3, + "mpl": 3, + "fpl": 3, + "npl": 3, + "mlad": 7, + "vynikajici": 7 + }, "Groovy": { "task": 1, "echoDirListViaAntBuilder": 1, @@ -26087,6 +30290,57 @@ "type": 1, "url": 1 }, + "JSONiq": { + "(": 14, + "Query": 2, + "for": 4, + "returning": 1, + "one": 1, + "database": 2, + "entry": 1, + ")": 14, + "import": 5, + "module": 5, + "namespace": 5, + "req": 6, + ";": 9, + "catalog": 4, + "variable": 4, + "id": 3, + "param": 4, + "-": 11, + "values": 4, + "[": 5, + "]": 5, + "part": 2, + "get": 2, + "data": 4, + "by": 2, + "key": 1, + "searching": 1, + "the": 1, + "keywords": 1, + "index": 3, + "phrase": 2, + "limit": 2, + "integer": 1, + "result": 1, + "at": 1, + "idx": 2, + "in": 1, + "search": 1, + "where": 1, + "le": 1, + "let": 1, + "result.s": 1, + "result.p": 1, + "return": 1, + "{": 2, + "|": 2, + "score": 1, + "result.r": 1, + "}": 2 + }, "JSONLD": { "{": 7, "}": 7, @@ -28031,27 +32285,27 @@ "in_8_list": 1 }, "M": { - "%": 203, + "%": 207, "zewdAPI": 52, - ";": 1275, + ";": 1309, "Enterprise": 5, "Web": 5, "Developer": 5, "run": 2, - "-": 1604, + "-": 1605, "time": 9, "functions": 4, - "and": 56, + "and": 59, "user": 27, "APIs": 1, "Product": 2, - "(": 2142, + "(": 2144, "Build": 6, - ")": 2150, + ")": 2152, "Date": 2, "Fri": 1, "Nov": 1, - "|": 170, + "|": 171, "for": 77, "GT.M": 30, "m_apache": 3, @@ -28072,52 +32326,52 @@ "rtweed@mgateway.com": 4, "This": 26, "program": 19, - "is": 81, + "is": 88, "free": 15, "software": 12, - "you": 16, - "can": 15, + "you": 17, + "can": 20, "redistribute": 11, - "it": 44, + "it": 45, "and/or": 11, "modify": 11, "under": 14, - "the": 217, + "the": 223, "terms": 11, - "of": 80, + "of": 84, "GNU": 33, "Affero": 33, "General": 33, "Public": 33, "License": 48, - "as": 22, + "as": 23, "published": 11, - "by": 33, + "by": 35, "Free": 11, "Software": 11, "Foundation": 11, "either": 13, "version": 16, - "or": 46, + "or": 50, "at": 21, "your": 16, "option": 12, - "any": 15, + "any": 16, "later": 11, "version.": 11, "distributed": 13, - "in": 78, + "in": 80, "hope": 11, - "that": 17, + "that": 19, "will": 23, - "be": 32, + "be": 35, "useful": 11, - "but": 17, + "but": 19, "WITHOUT": 12, "ANY": 12, "WARRANTY": 11, "without": 11, - "even": 11, + "even": 12, "implied": 11, "warranty": 11, "MERCHANTABILITY": 11, @@ -28131,21 +32385,21 @@ "details.": 12, "You": 13, "should": 16, - "have": 17, + "have": 21, "received": 11, - "a": 112, + "a": 130, "copy": 13, "along": 11, - "with": 43, - "this": 38, + "with": 45, + "this": 39, "program.": 9, "If": 14, - "not": 37, - "see": 25, + "not": 39, + "see": 26, "": 11, - ".": 814, - "QUIT": 249, - "_": 126, + ".": 815, + "QUIT": 251, + "_": 127, "getVersion": 1, "zewdCompiler": 6, "date": 1, @@ -28219,7 +32473,7 @@ "text": 6, "replaceAll": 11, "writeLine": 2, - "line": 9, + "line": 14, "CacheTempBuffer": 2, "j": 67, "increment": 11, @@ -28237,7 +32491,7 @@ "value": 72, "getSessionValue": 3, "tr": 13, - "+": 188, + "+": 189, "f": 93, "o": 51, "q": 244, @@ -28253,7 +32507,7 @@ "type": 2, "avoid": 1, "Cache": 3, - "bug": 1, + "bug": 2, "getPhraseIndex": 1, "zewdCompiler5": 1, "licensed": 1, @@ -28268,7 +32522,7 @@ "wldSessid": 1, "zzname": 1, "zv": 6, - "[": 53, + "[": 54, "extcErr": 1, "mess": 3, "namespace": 1, @@ -28376,7 +32630,7 @@ "char": 9, "len": 8, "create": 6, - "characters": 4, + "characters": 8, "str": 15, "convertDateToSeconds": 1, "hdate": 7, @@ -28421,12 +32675,12 @@ "format": 2, "Offset": 1, "relative": 1, - "to": 73, + "to": 74, "GMT": 1, "eg": 3, "hh": 4, "ss": 4, - "<": 19, + "<": 20, "_hh": 1, "time#3600": 1, "_mm": 1, @@ -28437,7 +32691,7 @@ "openNewFile": 2, "openFile": 2, "openDOM": 2, - "&": 27, + "&": 28, "#39": 1, "<\",\"<\")>": 1, "string=": 1, @@ -28446,7 +32700,7 @@ "HTML": 1, "quot": 2, "stop": 20, - "no": 53, + "no": 54, "no2": 1, "p1_c_p2": 1, "getIP": 2, @@ -28475,7 +32729,7 @@ "linkToParentSession": 2, "zewdCompiler20": 1, "exportToGTM": 1, - "routine": 4, + "routine": 6, "zewdDemo": 1, "Tutorial": 1, "Wed": 1, @@ -28524,10 +32778,10 @@ ".value": 1, "testField2": 1, "field3": 1, - "must": 7, + "must": 8, "null": 6, "dateTime": 1, - "start": 24, + "start": 26, "student": 14, "zwrite": 1, "write": 59, @@ -28553,12 +32807,91 @@ "todrop": 2, "Populate": 1, "values": 4, - "on": 15, + "on": 17, "first": 10, "use": 5, "only.": 1, "zextract": 3, "zlength": 3, + "Comment": 1, + "comment": 4, + "block": 1, + "comments": 5, + "always": 2, + "semicolon": 1, + "next": 1, + "while": 4, + "legal": 1, + "blank": 1, + "whitespace": 2, + "alone": 1, + "valid": 2, + "**": 4, + "Comments": 1, + "graphic": 3, + "character": 5, + "such": 1, + "@#": 1, + "*": 6, + "{": 5, + "}": 5, + "]": 15, + "/": 3, + "space": 1, + "considered": 1, + "though": 1, + "t": 12, + "it.": 2, + "ASCII": 2, + "whose": 1, + "numeric": 8, + "code": 29, + "above": 3, + "below": 1, + "are": 14, + "NOT": 2, + "allowed": 18, + "routine.": 1, + "multiple": 1, + "semicolons": 1, + "okay": 1, + "has": 7, + "tag": 2, + "after": 3, + "does": 1, + "command": 11, + "Tag1": 1, + "Tags": 2, + "an": 14, + "uppercase": 2, + "lowercase": 1, + "alphabetic": 2, + "series": 2, + "HELO": 1, + "most": 1, + "common": 1, + "label": 5, + "LABEL": 1, + "followed": 1, + "directly": 1, + "open": 1, + "parenthesis": 2, + "formal": 1, + "list": 1, + "variables": 3, + "close": 1, + "ANOTHER": 1, + "X": 19, + "Normally": 1, + "subroutine": 1, + "would": 2, + "ended": 1, + "we": 1, + "taking": 1, + "advantage": 1, + "rule": 1, + "END": 1, + "implicit": 1, "Digest": 2, "Extension": 9, "Piotr": 7, @@ -28589,7 +32922,6 @@ "digest.init": 3, "usually": 1, "when": 11, - "an": 11, "invalid": 4, "algorithm": 1, "was": 5, @@ -28604,9 +32936,7 @@ "contact": 2, "me": 2, "questions": 2, - "comments": 4, "returns": 7, - "ASCII": 1, "HEX": 1, "all": 8, "one": 5, @@ -28658,7 +32988,6 @@ "illustrate": 1, "dynamic": 1, "scope": 1, - "variables": 2, "triangle1": 1, "sum": 15, "main2": 1, @@ -28666,12 +32995,10 @@ "triangle2": 1, "compute": 2, "Fibonacci": 1, - "series": 1, "b": 64, "term": 10, "start1": 2, "entry": 5, - "label": 4, "start2": 1, "function": 6, "computes": 1, @@ -28783,7 +33110,6 @@ "modulo": 1, "division.": 1, "//en.wikipedia.org/wiki/MD5": 1, - "t": 11, "#64": 1, "msg_": 1, "_m_": 1, @@ -28825,9 +33151,7 @@ "keyId": 108, "been": 4, "tested": 1, - "valid": 1, "these": 1, - "are": 11, "called": 8, "To": 2, "Initialise": 2, @@ -28889,7 +33213,6 @@ "getAttributeId": 2, "domain": 1, "Not": 1, - "allowed": 17, "same": 2, "remove": 6, "existing": 2, @@ -28980,7 +33303,6 @@ "runSelect": 3, "count": 18, "select": 3, - "*": 5, "where": 6, "limit": 14, "asc": 1, @@ -29028,7 +33350,6 @@ ".itemStack": 1, "***": 2, "listCopy": 3, - "numeric": 6, "N.N": 12, "N.N1": 4, "externalSelect": 2, @@ -29239,7 +33560,6 @@ "protect": 11, "erropt": 6, "isstring": 5, - "code": 28, "pcre.config": 1, ".name": 1, ".erropt": 3, @@ -29263,7 +33583,6 @@ "LANG": 4, "LC_*": 1, "output": 49, - "command": 9, "Debian": 2, "tip": 1, "dpkg": 1, @@ -29337,7 +33656,6 @@ "begin_": 1, "_end": 1, "store": 6, - "above": 2, "stores": 1, "captured": 6, "key=": 2, @@ -29413,8 +33731,6 @@ "matched": 1, "back": 4, "th": 3, - "{": 4, - "}": 4, "replaced": 1, "substitution": 2, "begins": 1, @@ -29447,7 +33763,6 @@ "@ref": 2, "E": 12, "COMPILE": 2, - "has": 6, "meaning": 1, "zs": 2, "re": 2, @@ -29527,7 +33842,6 @@ "Run": 1, ".offset": 1, "used.": 2, - "always": 1, "strings": 1, "submitted": 1, "exact": 1, @@ -29536,8 +33850,6 @@ "way": 1, "i*2": 3, "what": 2, - "while": 3, - "/": 2, "/mg": 2, "aaa": 1, "nbb": 1, @@ -29560,7 +33872,6 @@ "listing": 1, "CHAR": 1, "different": 3, - "character": 2, "modes": 1, "In": 1, "probably": 1, @@ -29636,7 +33947,6 @@ "runs": 2, "especially": 1, "there": 2, - "would": 1, "paths": 2, "tree": 1, "checked.": 1, @@ -29741,7 +34051,6 @@ "false": 5, "post2": 1, "special": 2, - "after": 2, "post": 1, "condition": 1, "PRCAAPR": 1, @@ -29758,7 +34067,6 @@ "Accounts": 1, "Receivable": 1, "**198": 1, - "**": 2, "Mar": 1, "Per": 1, "VHA": 1, @@ -29768,7 +34076,6 @@ "PRCATY": 2, "NEW": 3, "DIC": 6, - "X": 18, "Y": 26, "DEBT": 10, "PRCADB": 5, @@ -29811,7 +34118,6 @@ "_PRCATY_": 1, "COMP1": 2, "RCY": 5, - "]": 14, "COMP2": 2, "_STAT_": 1, "_STAT": 1, @@ -30045,7 +34351,6 @@ "WVBEGDT1": 1, "NOTIFICATION": 1, "IS": 3, - "NOT": 1, "QUEUED.": 1, "WVB": 4, "OR": 2, @@ -30159,7 +34464,6 @@ "TODO": 1, "Caller": 1, "indentation": 1, - "comment": 1, "tab": 1, "space.": 1, "M/Wire": 4, @@ -30205,7 +34509,6 @@ "simply": 1, "Stop": 1, "RESJOB": 1, - "it.": 1, "mwireVersion": 4, "mwireDate": 2, "July": 1, @@ -30365,6 +34668,133 @@ "Markdown": { "Tender": 1 }, + "Mask": { + "header": 1, + "{": 10, + "img": 1, + ".logo": 1, + "src": 1, + "alt": 1, + "logo": 1, + ";": 3, + "h4": 1, + "if": 1, + "(": 3, + "currentUser": 1, + ")": 3, + ".account": 1, + "a": 1, + "href": 1, + "}": 10, + ".view": 1, + "ul": 1, + "for": 1, + "user": 1, + "index": 1, + "of": 1, + "users": 1, + "li.user": 1, + "data": 1, + "-": 3, + "id": 1, + ".name": 1, + ".count": 1, + ".date": 1, + "countdownComponent": 1, + "input": 1, + "type": 1, + "text": 1, + "dualbind": 1, + "value": 1, + "button": 1, + "x": 2, + "signal": 1, + "h5": 1, + "animation": 1, + "slot": 1, + "@model": 1, + "@next": 1, + "footer": 1, + "bazCompo": 1 + }, + "Mathematica": { + "Get": 1, + "[": 74, + "]": 73, + "Paclet": 1, + "Name": 1, + "-": 8, + "Version": 1, + "MathematicaVersion": 1, + "Description": 1, + "Creator": 1, + "Extensions": 1, + "{": 2, + "Language": 1, + "MainPage": 1, + "}": 2, + "BeginPackage": 1, + ";": 41, + "PossiblyTrueQ": 3, + "usage": 22, + "PossiblyFalseQ": 2, + "PossiblyNonzeroQ": 3, + "Begin": 2, + "expr_": 4, + "Not": 6, + "TrueQ": 4, + "expr": 4, + "End": 2, + "AnyQ": 3, + "AnyElementQ": 4, + "AllQ": 2, + "AllElementQ": 2, + "AnyNonzeroQ": 2, + "AnyPossiblyNonzeroQ": 2, + "RealQ": 3, + "PositiveQ": 3, + "NonnegativeQ": 3, + "PositiveIntegerQ": 3, + "NonnegativeIntegerQ": 4, + "IntegerListQ": 5, + "PositiveIntegerListQ": 3, + "NonnegativeIntegerListQ": 3, + "IntegerOrListQ": 2, + "PositiveIntegerOrListQ": 2, + "NonnegativeIntegerOrListQ": 2, + "SymbolQ": 2, + "SymbolOrNumberQ": 2, + "cond_": 4, + "L_": 5, + "Fold": 3, + "Or": 1, + "False": 4, + "cond": 4, + "/@": 3, + "L": 4, + "Flatten": 1, + "And": 4, + "True": 2, + "SHEBANG#!#!=": 1, + "n_": 5, + "Im": 1, + "n": 8, + "Positive": 2, + "IntegerQ": 3, + "&&": 4, + "input_": 6, + "ListQ": 1, + "input": 11, + "MemberQ": 3, + "IntegerQ/@input": 1, + "||": 4, + "a_": 2, + "Head": 2, + "a": 3, + "Symbol": 2, + "NumericQ": 1, + "EndPackage": 1 + }, "Matlab": { "function": 34, "[": 311, @@ -35469,6 +39899,756 @@ "indexPathWithIndexes": 1, "indexAtPosition": 2 }, + "Objective-C++": { + "#include": 26, + "": 1, + "": 1, + "#if": 10, + "(": 612, + "defined": 1, + "OBJC_API_VERSION": 2, + ")": 610, + "&&": 12, + "static": 16, + "inline": 3, + "IMP": 4, + "method_setImplementation": 2, + "Method": 2, + "m": 3, + "i": 29, + "{": 151, + "oi": 2, + "-": 175, + "method_imp": 2, + ";": 494, + "return": 149, + "}": 148, + "#endif": 19, + "namespace": 1, + "WebCore": 1, + "ENABLE": 10, + "DRAG_SUPPORT": 7, + "const": 16, + "double": 1, + "EventHandler": 30, + "TextDragDelay": 1, + "RetainPtr": 4, + "": 4, + "&": 21, + "currentNSEventSlot": 6, + "DEFINE_STATIC_LOCAL": 1, + "event": 30, + "NSEvent": 21, + "*EventHandler": 2, + "currentNSEvent": 13, + ".get": 1, + "class": 14, + "CurrentEventScope": 14, + "WTF_MAKE_NONCOPYABLE": 1, + "public": 1, + "*": 34, + "private": 1, + "m_savedCurrentEvent": 3, + "#ifndef": 3, + "NDEBUG": 2, + "m_event": 3, + "*event": 11, + "ASSERT": 13, + "bool": 26, + "wheelEvent": 5, + "Page*": 7, + "page": 33, + "m_frame": 24, + "if": 104, + "false": 40, + "scope": 6, + "PlatformWheelEvent": 2, + "chrome": 8, + "platformPageClient": 4, + "handleWheelEvent": 2, + "wheelEvent.isAccepted": 1, + "PassRefPtr": 2, + "": 1, + "currentKeyboardEvent": 1, + "[": 268, + "NSApp": 5, + "currentEvent": 2, + "]": 266, + "switch": 4, + "type": 10, + "case": 25, + "NSKeyDown": 4, + "PlatformKeyboardEvent": 6, + "platformEvent": 2, + "platformEvent.disambiguateKeyDownEvent": 1, + "RawKeyDown": 1, + "KeyboardEvent": 2, + "create": 3, + "document": 6, + "defaultView": 2, + "NSKeyUp": 3, + "default": 3, + "keyEvent": 2, + "BEGIN_BLOCK_OBJC_EXCEPTIONS": 13, + "||": 18, + "END_BLOCK_OBJC_EXCEPTIONS": 13, + "void": 18, + "focusDocumentView": 1, + "FrameView*": 7, + "frameView": 4, + "view": 28, + "NSView": 14, + "*documentView": 1, + "documentView": 2, + "focusNSView": 1, + "focusController": 1, + "setFocusedFrame": 1, + "passWidgetMouseDownEventToWidget": 3, + "MouseEventWithHitTestResults": 7, + "RenderObject*": 2, + "target": 6, + "targetNode": 3, + "renderer": 7, + "isWidget": 2, + "passMouseDownEventToWidget": 3, + "toRenderWidget": 3, + "widget": 18, + "RenderWidget*": 1, + "renderWidget": 2, + "lastEventIsMouseUp": 2, + "*currentEventAfterHandlingMouseDown": 1, + "currentEventAfterHandlingMouseDown": 3, + "NSLeftMouseUp": 3, + "timestamp": 8, + "Widget*": 3, + "pWidget": 2, + "RefPtr": 1, + "": 1, + "LOG_ERROR": 1, + "true": 29, + "platformWidget": 6, + "*nodeView": 1, + "nodeView": 9, + "superview": 5, + "*view": 4, + "hitTest": 2, + "convertPoint": 2, + "locationInWindow": 4, + "fromView": 3, + "nil": 25, + "client": 3, + "firstResponder": 1, + "clickCount": 8, + "<=>": 1, + "1": 1, + "acceptsFirstResponder": 1, + "needsPanelToBecomeKey": 1, + "makeFirstResponder": 1, + "wasDeferringLoading": 3, + "defersLoading": 1, + "setDefersLoading": 2, + "m_sendingEventToSubview": 24, + "*outerView": 1, + "getOuterView": 1, + "beforeMouseDown": 1, + "outerView": 2, + "widget.get": 2, + "mouseDown": 2, + "afterMouseDown": 1, + "m_mouseDownView": 5, + "m_mouseDownWasInSubframe": 7, + "m_mousePressed": 2, + "findViewInSubviews": 3, + "*superview": 1, + "*target": 1, + "NSEnumerator": 1, + "*e": 1, + "subviews": 1, + "objectEnumerator": 1, + "*subview": 1, + "while": 4, + "subview": 3, + "e": 1, + "nextObject": 1, + "mouseDownViewIfStillGood": 3, + "*mouseDownView": 1, + "mouseDownView": 3, + "topFrameView": 3, + "*topView": 1, + "topView": 2, + "eventLoopHandleMouseDragged": 1, + "mouseDragged": 2, + "//": 7, + "eventLoopHandleMouseUp": 1, + "mouseUp": 2, + "passSubframeEventToSubframe": 4, + "Frame*": 5, + "subframe": 13, + "HitTestResult*": 2, + "hoveredNode": 5, + "NSLeftMouseDragged": 1, + "NSOtherMouseDragged": 1, + "NSRightMouseDragged": 1, + "dragController": 1, + "didInitiateDrag": 1, + "NSMouseMoved": 2, + "eventHandler": 6, + "handleMouseMoveEvent": 3, + "currentPlatformMouseEvent": 8, + "NSLeftMouseDown": 3, + "Node*": 1, + "node": 3, + "isFrameView": 2, + "handleMouseReleaseEvent": 3, + "originalNSScrollViewScrollWheel": 4, + "_nsScrollViewScrollWheelShouldRetainSelf": 3, + "selfRetainingNSScrollViewScrollWheel": 3, + "NSScrollView": 2, + "SEL": 2, + "nsScrollViewScrollWheelShouldRetainSelf": 2, + "isMainThread": 3, + "setNSScrollViewScrollWheelShouldRetainSelf": 3, + "shouldRetain": 2, + "method": 2, + "class_getInstanceMethod": 1, + "objc_getRequiredClass": 1, + "@selector": 4, + "scrollWheel": 2, + "reinterpret_cast": 1, + "": 1, + "*self": 1, + "selector": 2, + "shouldRetainSelf": 3, + "self": 70, + "retain": 1, + "release": 1, + "passWheelEventToWidget": 1, + "NSView*": 1, + "static_cast": 1, + "": 1, + "frame": 3, + "NSScrollWheel": 1, + "v": 6, + "loader": 1, + "resetMultipleFormSubmissionProtection": 1, + "handleMousePressEvent": 2, + "int": 36, + "%": 2, + "handleMouseDoubleClickEvent": 1, + "else": 11, + "sendFakeEventsAfterWidgetTracking": 1, + "*initiatingEvent": 1, + "eventType": 5, + "initiatingEvent": 22, + "*fakeEvent": 1, + "fakeEvent": 6, + "mouseEventWithType": 2, + "location": 3, + "modifierFlags": 6, + "windowNumber": 6, + "context": 6, + "eventNumber": 3, + "pressure": 3, + "postEvent": 3, + "atStart": 3, + "YES": 6, + "keyEventWithType": 1, + "characters": 3, + "charactersIgnoringModifiers": 2, + "isARepeat": 2, + "keyCode": 2, + "window": 1, + "convertScreenToBase": 1, + "mouseLocation": 1, + "mouseMoved": 2, + "frameHasPlatformWidget": 4, + "passMousePressEventToSubframe": 1, + "mev": 6, + "mev.event": 3, + "passMouseMoveEventToSubframe": 1, + "m_mouseDownMayStartDrag": 1, + "passMouseReleaseEventToSubframe": 1, + "PlatformMouseEvent": 5, + "*windowView": 1, + "windowView": 2, + "CONTEXT_MENUS": 2, + "sendContextMenuEvent": 2, + "eventMayStartDrag": 2, + "eventActivatedView": 1, + "m_activationEventNumber": 1, + "event.eventNumber": 1, + "": 1, + "createDraggingClipboard": 1, + "NSPasteboard": 2, + "*pasteboard": 1, + "pasteboardWithName": 1, + "NSDragPboard": 1, + "pasteboard": 2, + "declareTypes": 1, + "NSArray": 3, + "array": 2, + "owner": 15, + "ClipboardMac": 1, + "Clipboard": 1, + "DragAndDrop": 1, + "ClipboardWritable": 1, + "tabsToAllFormControls": 1, + "KeyboardEvent*": 1, + "KeyboardUIMode": 1, + "keyboardUIMode": 5, + "handlingOptionTab": 4, + "isKeyboardOptionTab": 1, + "KeyboardAccessTabsToLinks": 2, + "KeyboardAccessFull": 1, + "needsKeyboardEventDisambiguationQuirks": 2, + "Document*": 1, + "applicationIsSafari": 1, + "url": 2, + ".protocolIs": 2, + "Settings*": 1, + "settings": 5, + "DASHBOARD_SUPPORT": 1, + "usesDashboardBackwardCompatibilityMode": 1, + "unsigned": 2, + "accessKeyModifiers": 1, + "AXObjectCache": 1, + "accessibilityEnhancedUserInterfaceEnabled": 1, + "CtrlKey": 2, + "|": 3, + "AltKey": 1, + "#import": 3, + "": 1, + "": 1, + "#ifdef": 6, + "OODEBUG": 1, + "#define": 1, + "OODEBUG_SQL": 4, + "OOOODatabase": 1, + "OODB": 1, + "NSString": 25, + "*kOOObject": 1, + "@": 28, + "*kOOInsert": 1, + "*kOOUpdate": 1, + "*kOOExecSQL": 1, + "#pragma": 5, + "mark": 5, + "OORecord": 3, + "abstract": 1, + "superclass": 1, + "for": 14, + "records": 1, + "@implementation": 7, + "+": 55, + "id": 19, + "record": 18, + "OO_AUTORETURNS": 2, + "OO_AUTORELEASE": 3, + "alloc": 11, + "init": 4, + "insert": 7, + "*record": 4, + "insertWithParent": 1, + "parent": 10, + "OODatabase": 26, + "sharedInstance": 37, + "copyJoinKeysFrom": 1, + "to": 6, + "delete": 4, + "update": 4, + "indate": 4, + "upsert": 4, + "commit": 6, + "rollback": 5, + "setNilValueForKey": 1, + "key": 2, + "OOReference": 2, + "": 1, + "zeroForNull": 4, + "NSNumber": 4, + "numberWithInt": 1, + "setValue": 1, + "forKey": 1, + "OOArray": 16, + "": 14, + "select": 21, + "intoClass": 11, + "joinFrom": 10, + "cOOString": 15, + "sql": 21, + "selectRecordsRelatedTo": 1, + "importFrom": 1, + "OOFile": 4, + "file": 2, + "delimiter": 4, + "delim": 4, + "rows": 2, + "OOMetaData": 21, + "import": 1, + "file.string": 1, + "insertArray": 3, + "BOOL": 11, + "exportTo": 1, + "file.save": 1, + "export": 1, + "bindToView": 1, + "OOView": 2, + "delegate": 4, + "bindRecord": 1, + "toView": 1, + "updateFromView": 1, + "updateRecord": 1, + "description": 6, + "*metaData": 14, + "metaDataForClass": 3, + "hack": 1, + "required": 2, + "where": 1, + "contains": 1, + "a": 9, + "field": 1, + "avoid": 1, + "recursion": 1, + "OOStringArray": 6, + "ivars": 5, + "<<": 2, + "metaData": 26, + "encode": 3, + "dictionaryWithValuesForKeys": 3, + "@end": 14, + "OOAdaptor": 6, + "all": 3, + "methods": 1, + "by": 1, + "objsql": 1, + "access": 2, + "database": 12, + "@interface": 6, + "NSObject": 1, + "sqlite3": 1, + "*db": 1, + "sqlite3_stmt": 1, + "*stmt": 1, + "struct": 5, + "_str_link": 5, + "*next": 2, + "char": 9, + "str": 7, + "*strs": 1, + "OO_UNSAFE": 1, + "*owner": 3, + "initPath": 5, + "path": 9, + "prepare": 4, + "bindCols": 5, + "cOOStringArray": 3, + "columns": 7, + "values": 29, + "cOOValueDictionary": 2, + "startingAt": 5, + "pno": 13, + "bindNulls": 8, + "bindResultsIntoInstancesOfClass": 4, + "Class": 9, + "recordClass": 16, + "sqlite_int64": 2, + "lastInsertRowID": 2, + "NSData": 3, + "OOExtras": 9, + "initWithDescription": 1, + "is": 2, + "the": 5, + "low": 1, + "level": 1, + "interface": 1, + "particular": 2, + "": 1, + "sharedInstanceForPath": 2, + "OODocument": 1, + ".path": 1, + "OONil": 1, + "OO_RELEASE": 6, + "exec": 10, + "fmt": 9, + "...": 3, + "va_list": 3, + "argp": 12, + "va_start": 3, + "*sql": 5, + "initWithFormat": 3, + "arguments": 3, + "va_end": 3, + "objects": 4, + "deleteArray": 2, + "object": 13, + "commitTransaction": 3, + "super": 3, + "adaptor": 1, + "registerSubclassesOf": 1, + "recordSuperClass": 2, + "numClasses": 5, + "objc_getClassList": 2, + "NULL": 4, + "*classes": 2, + "malloc": 2, + "sizeof": 2, + "": 1, + "viewClasses": 4, + "classNames": 4, + "scan": 1, + "registered": 2, + "classes": 12, + "relevant": 1, + "subclasses": 1, + "c": 14, + "<": 5, + "superClass": 5, + "class_getName": 4, + "class_getSuperclass": 1, + "respondsToSelector": 2, + "ooTableSql": 1, + "tableMetaDataForClass": 8, + "break": 6, + "delay": 1, + "creation": 1, + "views": 1, + "until": 1, + "after": 1, + "tables": 1, + "": 1, + "in": 9, + "order": 1, + "free": 3, + "Register": 1, + "list": 1, + "of": 2, + "before": 1, + "using": 2, + "them": 2, + "so": 2, + "can": 1, + "determine": 1, + "relationships": 1, + "between": 1, + "registerTableClassesNamed": 1, + "tableClass": 2, + "NSBundle": 1, + "mainBundle": 1, + "classNamed": 1, + "Send": 1, + "any": 2, + "SQL": 1, + "Sql": 1, + "format": 1, + "string": 1, + "escape": 1, + "Any": 1, + "results": 3, + "returned": 1, + "are": 1, + "placed": 1, + "as": 1, + "an": 1, + "dictionary": 1, + "results.": 1, + "*/": 1, + "errcode": 12, + "OOString": 6, + "stringForSql": 2, + "*aColumnName": 1, + "**results": 1, + "allKeys": 1, + "objectAtIndex": 1, + "OOValueDictionary": 5, + "joinValues": 4, + "sharedColumns": 5, + "*parentMetaData": 1, + "parentMetaData": 2, + "naturalJoinTo": 1, + "joinableColumns": 1, + "whereClauseFor": 2, + "qualifyNulls": 2, + "NO": 3, + "ooOrderBy": 2, + "OOFormat": 5, + "NSLog": 4, + "*joinValues": 1, + "*adaptor": 7, + "": 1, + "tablesRelatedByNaturalJoinFrom": 1, + "tablesWithNaturalJoin": 5, + "**tablesWithNaturalJoin": 1, + "*childMetaData": 1, + "tableMetaDataByClassName": 3, + "prepareSql": 1, + "toTable": 1, + "childMetaData": 1, + "OODictionary": 2, + "": 1, + "tmpResults": 1, + "kOOExecSQL": 1, + "*exec": 2, + "OOWarn": 9, + "errmsg": 5, + "continue": 3, + "OORef": 2, + "": 1, + "*values": 3, + "kOOObject": 3, + "isInsert": 4, + "kOOInsert": 1, + "isUpdate": 5, + "kOOUpdate": 2, + "newValues": 3, + "changedCols": 4, + "*name": 4, + "*newValues": 1, + "name": 9, + "isEqual": 1, + "tableName": 4, + "columns/": 1, + "nchanged": 4, + "*object": 1, + "lastSQL": 4, + "**changedCols": 1, + "quote": 2, + "commaQuote": 2, + "": 1, + "commited": 2, + "updateCount": 2, + "transaction": 2, + "updated": 2, + "NSMutableDictionary": 1, + "*d": 1, + "*transaction": 1, + "d": 2, + "": 1, + "OO_ARC": 1, + "boxed": 1, + "valueForKey": 1, + "pointerValue": 1, + "setValuesForKeysWithDictionary": 2, + "decode": 2, + "count": 1, + "className": 3, + "createTableSQL": 2, + "*idx": 1, + "indexes": 1, + "idx": 2, + "implements": 1, + ".directory": 1, + ".mkdir": 1, + "sqlite3_open": 1, + "db": 8, + "SQLITE_OK": 6, + "*path": 1, + "sqlite3_prepare_v2": 1, + "stmt": 20, + "sqlite3_errmsg": 3, + "bindValue": 2, + "value": 26, + "asParameter": 2, + "OODEBUG_BIND": 1, + "OONull": 3, + "sqlite3_bind_null": 1, + "OOSQL_THREAD_SAFE_BUT_USES_MORE_MEMORY": 1, + "isKindOfClass": 3, + "sqlite3_bind_text": 2, + "UTF8String": 1, + "SQLITE_STATIC": 3, + "#else": 1, + "len": 4, + "lengthOfBytesUsingEncoding": 1, + "NSUTF8StringEncoding": 3, + "*str": 2, + "next": 3, + "strs": 6, + "getCString": 1, + "maxLength": 1, + "encoding": 2, + "sqlite3_bind_blob": 1, + "bytes": 5, + "length": 4, + "*type": 1, + "objCType": 1, + "sqlite3_bind_int": 1, + "intValue": 3, + "sqlite3_bind_int64": 1, + "longLongValue": 1, + "sqlite3_bind_double": 1, + "doubleValue": 1, + "*columns": 1, + "valuesForNextRow": 2, + "ncols": 2, + "sqlite3_column_count": 1, + "sqlite3_column_name": 1, + "sqlite3_column_type": 2, + "SQLITE_NULL": 1, + "SQLITE_INTEGER": 1, + "initWithLongLong": 1, + "sqlite3_column_int64": 1, + "SQLITE_FLOAT": 1, + "initWithDouble": 1, + "sqlite3_column_double": 1, + "SQLITE_TEXT": 1, + "*bytes": 2, + "sqlite3_column_text": 1, + "NSMutableString": 1, + "initWithBytes": 2, + "sqlite3_column_bytes": 2, + "SQLITE_BLOB": 1, + "sqlite3_column_blob": 1, + "out": 4, + "awakeFromDB": 4, + "instancesRespondToSelector": 1, + "sqlite3_step": 1, + "SQLITE_ROW": 1, + "SQLITE_DONE": 1, + "out.alloc": 1, + "sqlite3_changes": 1, + "sqlite3_finalize": 1, + "sqlite3_last_insert_rowid": 1, + "dealloc": 1, + "sqlite3_close": 1, + "OO_DEALLOC": 1, + "instances": 1, + "represent": 1, + "table": 1, + "and": 2, + "it": 2, + "s": 2, + "l": 1, + "C": 1, + "S": 1, + "I": 1, + "L": 1, + "q": 1, + "Q": 1, + "f": 1, + "_": 2, + "tag": 1, + "A": 2, + "<'>": 1, + "iptr": 4, + "*optr": 1, + "unhex": 2, + "*iptr": 1, + "*16": 1, + "hex": 1, + "initWithBytesNoCopy": 1, + "optr": 1, + "freeWhenDone": 1, + "stringValue": 4, + "charValue": 1, + "shortValue": 1, + "OOReplace": 2, + "reformat": 4, + "NSDictionary": 2, + "__IPHONE_OS_VERSION_MIN_REQUIRED": 1, + "UISwitch": 2, + "text": 1, + "self.on": 1 + }, "OCaml": { "{": 11, "shared": 1, @@ -39777,6 +44957,225 @@ "AddressBook": 1, "person": 1 }, + "PureScript": { + "module": 4, + "Control.Arrow": 1, + "where": 20, + "import": 32, + "Data.Tuple": 3, + "class": 4, + "Arrow": 5, + "a": 46, + "arr": 10, + "forall": 26, + "b": 49, + "c.": 3, + "(": 111, + "-": 88, + "c": 17, + ")": 115, + "first": 4, + "d.": 2, + "Tuple": 21, + "d": 6, + "instance": 12, + "arrowFunction": 1, + "f": 28, + "second": 3, + "Category": 3, + "swap": 4, + "b.": 1, + "x": 26, + "y": 2, + "infixr": 3, + "***": 2, + "&&": 3, + "&": 3, + ".": 2, + "g": 4, + "ArrowZero": 1, + "zeroArrow": 1, + "<+>": 2, + "ArrowPlus": 1, + "Data.Foreign": 2, + "Foreign": 12, + "..": 1, + "ForeignParser": 29, + "parseForeign": 6, + "parseJSON": 3, + "ReadForeign": 11, + "read": 10, + "prop": 3, + "Prelude": 3, + "Data.Array": 3, + "Data.Either": 1, + "Data.Maybe": 3, + "Data.Traversable": 2, + "foreign": 6, + "data": 3, + "*": 1, + "fromString": 2, + "String": 13, + "Either": 6, + "readPrimType": 5, + "a.": 6, + "readMaybeImpl": 2, + "Maybe": 5, + "readPropImpl": 2, + "showForeignImpl": 2, + "showForeign": 1, + "Prelude.Show": 1, + "show": 5, + "p": 11, + "json": 2, + "monadForeignParser": 1, + "Prelude.Monad": 1, + "return": 6, + "_": 7, + "Right": 9, + "case": 9, + "of": 9, + "Left": 8, + "err": 8, + "applicativeForeignParser": 1, + "Prelude.Applicative": 1, + "pure": 1, + "<*>": 2, + "<$>": 8, + "functorForeignParser": 1, + "Prelude.Functor": 1, + "readString": 1, + "readNumber": 1, + "Number": 1, + "readBoolean": 1, + "Boolean": 1, + "readArray": 1, + "[": 5, + "]": 5, + "let": 4, + "arrayItem": 2, + "i": 2, + "result": 4, + "+": 30, + "in": 2, + "xs": 3, + "traverse": 2, + "zip": 1, + "range": 1, + "length": 3, + "readMaybe": 1, + "<<": 4, + "<": 13, + "Just": 7, + "Nothing": 7, + "Data.Map": 1, + "Map": 26, + "empty": 6, + "singleton": 5, + "insert": 10, + "lookup": 8, + "delete": 9, + "alter": 8, + "toList": 10, + "fromList": 3, + "union": 3, + "map": 8, + "qualified": 1, + "as": 1, + "P": 1, + "concat": 3, + "Data.Foldable": 2, + "foldl": 4, + "k": 108, + "v": 57, + "Leaf": 15, + "|": 9, + "Branch": 27, + "{": 25, + "key": 13, + "value": 8, + "left": 15, + "right": 14, + "}": 26, + "eqMap": 1, + "P.Eq": 11, + "m1": 6, + "m2": 6, + "P.": 11, + "/": 1, + "P.not": 1, + "showMap": 1, + "P.Show": 3, + "m": 6, + "P.show": 1, + "v.": 11, + "P.Ord": 9, + "b@": 6, + "k1": 16, + "b.left": 9, + "b.right": 8, + "findMinKey": 5, + "glue": 4, + "minKey": 3, + "root": 2, + "b.key": 1, + "b.value": 2, + "v1": 3, + "v2.": 1, + "v2": 2, + "ReactiveJQueryTest": 1, + "flip": 2, + "Control.Monad": 1, + "Control.Monad.Eff": 1, + "Control.Monad.JQuery": 1, + "Control.Reactive": 1, + "Control.Reactive.JQuery": 1, + "head": 2, + "Data.Monoid": 1, + "Debug.Trace": 1, + "Global": 1, + "parseInt": 1, + "main": 1, + "do": 4, + "personDemo": 2, + "todoListDemo": 1, + "greet": 1, + "firstName": 2, + "lastName": 2, + "Create": 3, + "new": 1, + "reactive": 1, + "variables": 1, + "to": 3, + "hold": 1, + "the": 3, + "user": 1, + "readRArray": 1, + "insertRArray": 1, + "text": 5, + "completed": 2, + "paragraph": 2, + "display": 2, + "next": 1, + "task": 4, + "nextTaskLabel": 3, + "create": 2, + "append": 2, + "nextTask": 2, + "toComputedArray": 2, + "toComputed": 2, + "bindTextOneWay": 2, + "counter": 3, + "counterLabel": 3, + "rs": 2, + "cs": 2, + "<->": 1, + "if": 1, + "then": 1, + "else": 1, + "entry": 1, + "entry.completed": 1 + }, "Python": { "from": 34, "__future__": 2, @@ -41220,12 +46619,155 @@ "purpose.": 1 }, "Rebol": { - "REBOL": 1, - "[": 3, - "]": 3, - "hello": 2, - "func": 1, - "print": 1 + "REBOL": 5, + "[": 54, + "System": 1, + "Title": 2, + "Rights": 1, + "{": 8, + "Copyright": 1, + "Technologies": 2, + "is": 4, + "a": 2, + "trademark": 1, + "of": 1, + "}": 8, + "License": 2, + "Licensed": 1, + "under": 1, + "the": 3, + "Apache": 1, + "Version": 1, + "See": 1, + "http": 1, + "//www.apache.org/licenses/LICENSE": 1, + "-": 26, + "Purpose": 1, + "These": 1, + "are": 2, + "used": 3, + "to": 2, + "define": 1, + "natives": 1, + "and": 2, + "actions.": 1, + "Bind": 1, + "attributes": 1, + "for": 4, + "this": 1, + "block": 5, + "BIND_SET": 1, + "SHALLOW": 1, + "]": 61, + ";": 19, + "Special": 1, + "as": 1, + "spec": 3, + "datatype": 2, + "test": 1, + "functions": 1, + "(": 30, + "e.g.": 1, + "time": 2, + ")": 33, + "value": 1, + "any": 1, + "type": 1, + "The": 1, + "native": 5, + "function": 3, + "must": 1, + "be": 1, + "defined": 1, + "first.": 1, + "This": 1, + "special": 1, + "boot": 1, + "created": 1, + "manually": 1, + "within": 1, + "C": 1, + "code.": 1, + "Creates": 2, + "internal": 2, + "usage": 2, + "only": 2, + ".": 4, + "no": 3, + "check": 2, + "required": 2, + "we": 2, + "know": 2, + "it": 2, + "correct": 2, + "action": 2, + "Rebol": 4, + "re": 20, + "func": 5, + "s": 5, + "/i": 1, + "rejoin": 1, + "compose": 1, + "either": 1, + "i": 1, + "little": 1, + "helper": 1, + "standard": 1, + "grammar": 1, + "regex": 2, + "date": 6, + "naive": 1, + "string": 1, + "|": 22, + "S": 3, + "*": 7, + "<(?:[^^\\>": 1, + "d": 3, + "+": 6, + "/": 5, + "@": 1, + "%": 2, + "A": 3, + "F": 1, + "url": 1, + "PR_LITERAL": 10, + "string_url": 1, + "email": 1, + "string_email": 1, + "binary": 1, + "binary_base_two": 1, + "binary_base_sixty_four": 1, + "binary_base_sixteen": 1, + "re/i": 2, + "issue": 1, + "string_issue": 1, + "values": 1, + "value_date": 1, + "value_time": 1, + "tuple": 1, + "value_tuple": 1, + "pair": 1, + "value_pair": 1, + "number": 2, + "PR": 1, + "Za": 2, + "z0": 2, + "<[=>": 1, + "rebol": 1, + "red": 1, + "/system": 1, + "world": 1, + "topaz": 1, + "true": 1, + "false": 1, + "yes": 1, + "on": 1, + "off": 1, + "none": 1, + "#": 1, + "hello": 8, + "print": 4, + "author": 1 }, "RMarkdown": { "Some": 1, @@ -44077,6 +49619,585 @@ "foodforthought.jpg": 1, "name##*fo": 1 }, + "ShellSession": { + "echo": 2, + "FOOBAR": 2, + "Hello": 2, + "World": 2, + "gem": 4, + "install": 4, + "nokogiri": 6, + "...": 4, + "Building": 2, + "native": 2, + "extensions.": 2, + "This": 4, + "could": 2, + "take": 2, + "a": 4, + "while...": 2, + "checking": 1, + "for": 4, + "libxml/parser.h...": 1, + "***": 2, + "extconf.rb": 1, + "failed": 1, + "Could": 2, + "not": 2, + "create": 1, + "Makefile": 1, + "due": 1, + "to": 3, + "some": 1, + "reason": 2, + "probably": 1, + "lack": 1, + "of": 2, + "necessary": 1, + "libraries": 1, + "and/or": 1, + "headers.": 1, + "Check": 1, + "the": 2, + "mkmf.log": 1, + "file": 1, + "more": 1, + "details.": 1, + "You": 1, + "may": 1, + "need": 1, + "configuration": 1, + "options.": 1, + "brew": 2, + "tap": 2, + "homebrew/dupes": 1, + "Cloning": 1, + "into": 1, + "remote": 3, + "Counting": 1, + "objects": 3, + "done.": 4, + "Compressing": 1, + "%": 5, + "(": 6, + "/591": 1, + ")": 6, + "Total": 1, + "delta": 2, + "reused": 1, + "Receiving": 1, + "/1034": 1, + "KiB": 1, + "|": 1, + "bytes/s": 1, + "Resolving": 1, + "deltas": 1, + "/560": 1, + "Checking": 1, + "connectivity...": 1, + "done": 1, + "Warning": 1, + "homebrew/dupes/lsof": 1, + "over": 1, + "mxcl/master/lsof": 1, + "Tapped": 1, + "formula": 4, + "apple": 1, + "-": 12, + "gcc42": 1, + "Downloading": 1, + "http": 2, + "//r.research.att.com/tools/gcc": 1, + "darwin11.pkg": 1, + "########################################################################": 1, + "Caveats": 1, + "NOTE": 1, + "provides": 1, + "components": 1, + "that": 1, + "were": 1, + "removed": 1, + "from": 3, + "XCode": 2, + "in": 2, + "release.": 1, + "There": 1, + "is": 2, + "no": 1, + "this": 1, + "if": 1, + "you": 1, + "are": 1, + "using": 1, + "version": 1, + "prior": 1, + "contains": 1, + "compilers": 2, + "built": 2, + "Apple": 1, + "s": 1, + "GCC": 1, + "sources": 1, + "build": 1, + "available": 1, + "//opensource.apple.com/tarballs/gcc": 1, + "All": 1, + "have": 1, + "suffix.": 1, + "A": 1, + "GFortran": 1, + "compiler": 1, + "also": 1, + "included.": 1, + "Summary": 1, + "/usr/local/Cellar/apple": 1, + "gcc42/4.2.1": 1, + "files": 1, + "M": 1, + "seconds": 1, + "v": 1, + "Fetching": 1, + "Successfully": 1, + "installed": 2, + "Installing": 2, + "ri": 1, + "documentation": 2, + "RDoc": 1 + }, + "Shen": { + "*": 47, + "graph.shen": 1, + "-": 747, + "a": 30, + "library": 3, + "for": 12, + "graph": 52, + "definition": 1, + "and": 16, + "manipulation": 1, + "Copyright": 2, + "(": 267, + "C": 6, + ")": 250, + "Eric": 2, + "Schulte": 2, + "***": 5, + "License": 2, + "Redistribution": 2, + "use": 2, + "in": 13, + "source": 4, + "binary": 4, + "forms": 2, + "with": 8, + "or": 2, + "without": 2, + "modification": 2, + "are": 7, + "permitted": 2, + "provided": 4, + "that": 3, + "the": 29, + "following": 6, + "conditions": 6, + "met": 2, + "Redistributions": 4, + "of": 20, + "code": 2, + "must": 4, + "retain": 2, + "above": 4, + "copyright": 4, + "notice": 4, + "this": 4, + "list": 32, + "disclaimer.": 2, + "form": 2, + "reproduce": 2, + "disclaimer": 2, + "documentation": 2, + "and/or": 2, + "other": 2, + "materials": 2, + "distribution.": 2, + "THIS": 4, + "SOFTWARE": 4, + "IS": 2, + "PROVIDED": 2, + "BY": 2, + "THE": 10, + "COPYRIGHT": 4, + "HOLDERS": 2, + "AND": 8, + "CONTRIBUTORS": 4, + "ANY": 8, + "EXPRESS": 2, + "OR": 16, + "IMPLIED": 4, + "WARRANTIES": 4, + "INCLUDING": 6, + "BUT": 4, + "NOT": 4, + "LIMITED": 4, + "TO": 4, + "OF": 16, + "MERCHANTABILITY": 2, + "FITNESS": 2, + "FOR": 4, + "A": 32, + "PARTICULAR": 2, + "PURPOSE": 2, + "ARE": 2, + "DISCLAIMED.": 2, + "IN": 6, + "NO": 2, + "EVENT": 2, + "SHALL": 2, + "HOLDER": 2, + "BE": 2, + "LIABLE": 2, + "DIRECT": 2, + "INDIRECT": 2, + "INCIDENTAL": 2, + "SPECIAL": 2, + "EXEMPLARY": 2, + "CONSEQUENTIAL": 2, + "DAMAGES": 2, + "PROCUREMENT": 2, + "SUBSTITUTE": 2, + "GOODS": 2, + "SERVICES": 2, + ";": 12, + "LOSS": 2, + "USE": 4, + "DATA": 2, + "PROFITS": 2, + "BUSINESS": 2, + "INTERRUPTION": 2, + "HOWEVER": 2, + "CAUSED": 2, + "ON": 2, + "THEORY": 2, + "LIABILITY": 4, + "WHETHER": 2, + "CONTRACT": 2, + "STRICT": 2, + "TORT": 2, + "NEGLIGENCE": 2, + "OTHERWISE": 2, + "ARISING": 2, + "WAY": 2, + "OUT": 2, + "EVEN": 2, + "IF": 2, + "ADVISED": 2, + "POSSIBILITY": 2, + "SUCH": 2, + "DAMAGE.": 2, + "Commentary": 2, + "Graphs": 1, + "represented": 1, + "as": 2, + "two": 1, + "dictionaries": 1, + "one": 2, + "vertices": 17, + "edges.": 1, + "It": 1, + "is": 5, + "important": 1, + "to": 16, + "note": 1, + "dictionary": 3, + "implementation": 1, + "used": 2, + "able": 1, + "accept": 1, + "arbitrary": 1, + "data": 17, + "structures": 1, + "keys.": 1, + "This": 1, + "structure": 2, + "technically": 1, + "encodes": 1, + "hypergraphs": 1, + "generalization": 1, + "graphs": 1, + "which": 1, + "each": 1, + "edge": 32, + "may": 1, + "contain": 2, + "any": 1, + "number": 12, + ".": 1, + "Examples": 1, + "regular": 1, + "G": 25, + "hypergraph": 1, + "H": 3, + "corresponding": 1, + "given": 4, + "below.": 1, + "": 3, + "Vertices": 11, + "Edges": 9, + "+": 33, + "Graph": 65, + "hash": 8, + "|": 103, + "key": 9, + "value": 17, + "b": 13, + "c": 11, + "g": 19, + "[": 93, + "]": 91, + "d": 12, + "e": 14, + "f": 10, + "Hypergraph": 1, + "h": 3, + "i": 3, + "j": 2, + "associated": 1, + "edge/vertex": 1, + "@p": 17, + "V": 48, + "#": 4, + "E": 20, + "edges": 17, + "M": 4, + "vertex": 29, + "associations": 1, + "size": 2, + "all": 3, + "stored": 1, + "dict": 39, + "sizeof": 4, + "int": 1, + "indices": 1, + "into": 1, + "&": 1, + "Edge": 11, + "dicts": 3, + "entry": 2, + "storage": 2, + "Vertex": 3, + "Code": 1, + "require": 2, + "sequence": 2, + "datatype": 1, + "dictoinary": 1, + "vector": 4, + "symbol": 1, + "package": 2, + "add": 25, + "has": 5, + "neighbors": 8, + "connected": 21, + "components": 8, + "partition": 7, + "bipartite": 3, + "included": 2, + "from": 3, + "take": 2, + "drop": 2, + "while": 2, + "range": 1, + "flatten": 1, + "filter": 2, + "complement": 1, + "seperate": 1, + "zip": 1, + "indexed": 1, + "reduce": 3, + "mapcon": 3, + "unique": 3, + "frequencies": 1, + "shuffle": 1, + "pick": 1, + "remove": 2, + "first": 2, + "interpose": 1, + "subset": 3, + "cartesian": 1, + "product": 1, + "<-dict>": 5, + "contents": 1, + "keys": 3, + "vals": 1, + "make": 10, + "define": 34, + "X": 4, + "<-address>": 5, + "0": 1, + "create": 1, + "specified": 1, + "sizes": 2, + "}": 22, + "Vertsize": 2, + "Edgesize": 2, + "let": 9, + "absvector": 1, + "do": 8, + "address": 5, + "defmacro": 3, + "macro": 3, + "return": 4, + "taking": 1, + "optional": 1, + "N": 7, + "vert": 12, + "1": 1, + "2": 3, + "{": 15, + "get": 3, + "Value": 3, + "if": 8, + "tuple": 3, + "fst": 3, + "error": 7, + "string": 3, + "resolve": 6, + "Vector": 2, + "Index": 2, + "Place": 6, + "nth": 1, + "<-vector>": 2, + "Vert": 5, + "Val": 5, + "trap": 4, + "snd": 2, + "map": 5, + "lambda": 1, + "w": 4, + "B": 2, + "Data": 2, + "w/o": 5, + "D": 4, + "update": 5, + "an": 3, + "s": 1, + "Vs": 4, + "Store": 6, + "<": 4, + "limit": 2, + "VertLst": 2, + "/.": 4, + "Contents": 5, + "adjoin": 2, + "length": 5, + "EdgeID": 3, + "EdgeLst": 2, + "p": 1, + "boolean": 4, + "Return": 1, + "Already": 5, + "New": 5, + "Reachable": 2, + "difference": 3, + "append": 1, + "including": 1, + "itself": 1, + "fully": 1, + "Acc": 2, + "true": 1, + "_": 1, + "VS": 4, + "Component": 6, + "ES": 3, + "Con": 8, + "verts": 4, + "cons": 1, + "place": 3, + "partitions": 1, + "element": 2, + "simple": 3, + "CS": 3, + "Neighbors": 3, + "empty": 1, + "intersection": 1, + "check": 1, + "tests": 1, + "set": 1, + "chris": 6, + "patton": 2, + "eric": 1, + "nobody": 2, + "fail": 1, + "when": 1, + "wrapper": 1, + "function": 1, + "html.shen": 1, + "html": 2, + "generation": 1, + "functions": 1, + "shen": 1, + "The": 1, + "standard": 1, + "lisp": 1, + "conversion": 1, + "tool": 1, + "suite.": 1, + "Follows": 1, + "some": 1, + "convertions": 1, + "Clojure": 1, + "tasks": 1, + "stuff": 1, + "todo1": 1, + "today": 1, + "attributes": 1, + "AS": 1, + "load": 1, + "JSON": 1, + "Lexer": 1, + "Read": 1, + "stream": 1, + "characters": 4, + "Whitespace": 4, + "not": 1, + "strings": 2, + "should": 2, + "be": 2, + "discarded.": 1, + "preserved": 1, + "Strings": 1, + "can": 1, + "escaped": 1, + "double": 1, + "quotes.": 1, + "e.g.": 2, + "whitespacep": 2, + "ASCII": 2, + "Space.": 1, + "All": 1, + "others": 1, + "whitespace": 7, + "table.": 1, + "Char": 4, + "member": 1, + "replace": 3, + "@s": 4, + "Suffix": 4, + "where": 2, + "Prefix": 2, + "fetch": 1, + "until": 1, + "unescaped": 1, + "doublequote": 1, + "c#34": 5, + "WhitespaceChar": 2, + "Chars": 4, + "strip": 2, + "chars": 2, + "tokenise": 1, + "JSONString": 2, + "CharList": 2, + "explode": 1 + }, "Slash": { "<%>": 1, "class": 11, @@ -44151,6 +50272,343 @@ "ast.eval": 1, "Env.new": 1 }, + "SourcePawn": { + "//#define": 1, + "DEBUG": 2, + "#if": 1, + "defined": 1, + "#define": 7, + "assert": 2, + "(": 233, + "%": 18, + ")": 234, + "if": 44, + "ThrowError": 2, + ";": 213, + "assert_msg": 2, + "#else": 1, + "#endif": 1, + "#pragma": 1, + "semicolon": 1, + "#include": 3, + "": 1, + "": 1, + "": 1, + "public": 21, + "Plugin": 1, + "myinfo": 1, + "{": 73, + "name": 7, + "author": 1, + "description": 1, + "version": 1, + "SOURCEMOD_VERSION": 1, + "url": 1, + "}": 71, + "new": 62, + "Handle": 51, + "g_Cvar_Winlimit": 5, + "INVALID_HANDLE": 56, + "g_Cvar_Maxrounds": 5, + "g_Cvar_Fraglimit": 6, + "g_Cvar_Bonusroundtime": 6, + "g_Cvar_StartTime": 3, + "g_Cvar_StartRounds": 5, + "g_Cvar_StartFrags": 3, + "g_Cvar_ExtendTimeStep": 2, + "g_Cvar_ExtendRoundStep": 2, + "g_Cvar_ExtendFragStep": 2, + "g_Cvar_ExcludeMaps": 3, + "g_Cvar_IncludeMaps": 2, + "g_Cvar_NoVoteMode": 2, + "g_Cvar_Extend": 2, + "g_Cvar_DontChange": 2, + "g_Cvar_EndOfMapVote": 8, + "g_Cvar_VoteDuration": 3, + "g_Cvar_RunOff": 2, + "g_Cvar_RunOffPercent": 2, + "g_VoteTimer": 7, + "g_RetryTimer": 4, + "g_MapList": 8, + "g_NominateList": 7, + "g_NominateOwners": 7, + "g_OldMapList": 7, + "g_NextMapList": 2, + "g_VoteMenu": 1, + "g_Extends": 2, + "g_TotalRounds": 7, + "bool": 10, + "g_HasVoteStarted": 7, + "g_WaitingForVote": 4, + "g_MapVoteCompleted": 9, + "g_ChangeMapAtRoundEnd": 6, + "g_ChangeMapInProgress": 4, + "g_mapFileSerial": 3, + "-": 12, + "g_NominateCount": 3, + "MapChange": 4, + "g_ChangeTime": 1, + "g_NominationsResetForward": 3, + "g_MapVoteStartedForward": 2, + "MAXTEAMS": 4, + "g_winCount": 4, + "[": 19, + "]": 19, + "VOTE_EXTEND": 1, + "VOTE_DONTCHANGE": 1, + "OnPluginStart": 1, + "LoadTranslations": 2, + "arraySize": 5, + "ByteCountToCells": 1, + "PLATFORM_MAX_PATH": 6, + "CreateArray": 5, + "CreateConVar": 15, + "_": 18, + "true": 26, + "RegAdminCmd": 2, + "Command_Mapvote": 2, + "ADMFLAG_CHANGEMAP": 2, + "Command_SetNextmap": 2, + "FindConVar": 4, + "||": 15, + "decl": 5, + "String": 11, + "folder": 5, + "GetGameFolderName": 1, + "sizeof": 6, + "strcmp": 3, + "HookEvent": 6, + "Event_TeamPlayWinPanel": 3, + "Event_TFRestartRound": 2, + "else": 5, + "Event_RoundEnd": 3, + "Event_PlayerDeath": 2, + "AutoExecConfig": 1, + "//Change": 1, + "the": 5, + "mp_bonusroundtime": 1, + "max": 1, + "so": 1, + "that": 2, + "we": 2, + "have": 2, + "time": 9, + "to": 4, + "display": 2, + "vote": 6, + "//If": 1, + "you": 1, + "a": 1, + "during": 2, + "bonus": 2, + "good": 1, + "defaults": 1, + "are": 1, + "duration": 1, + "and": 1, + "mp_bonustime": 1, + "SetConVarBounds": 1, + "ConVarBound_Upper": 1, + "CreateGlobalForward": 2, + "ET_Ignore": 2, + "Param_String": 1, + "Param_Cell": 1, + "APLRes": 1, + "AskPluginLoad2": 1, + "myself": 1, + "late": 1, + "error": 1, + "err_max": 1, + "RegPluginLibrary": 1, + "CreateNative": 9, + "Native_NominateMap": 1, + "Native_RemoveNominationByMap": 1, + "Native_RemoveNominationByOwner": 1, + "Native_InitiateVote": 1, + "Native_CanVoteStart": 2, + "Native_CheckVoteDone": 2, + "Native_GetExcludeMapList": 2, + "Native_GetNominatedMapList": 2, + "Native_EndOfMapVoteEnabled": 2, + "return": 23, + "APLRes_Success": 1, + "OnConfigsExecuted": 1, + "ReadMapList": 1, + "MAPLIST_FLAG_CLEARARRAY": 1, + "|": 1, + "MAPLIST_FLAG_MAPSFOLDER": 1, + "LogError": 2, + "CreateNextVote": 1, + "SetupTimeleftTimer": 3, + "false": 8, + "ClearArray": 2, + "for": 9, + "i": 13, + "<": 5, + "+": 12, + "&&": 5, + "GetConVarInt": 10, + "GetConVarFloat": 2, + "<=>": 1, + "Warning": 1, + "Bonus": 1, + "Round": 1, + "Time": 2, + "shorter": 1, + "than": 1, + "Vote": 4, + "Votes": 1, + "round": 1, + "may": 1, + "not": 1, + "complete": 1, + "OnMapEnd": 1, + "map": 27, + "GetCurrentMap": 1, + "PushArrayString": 3, + "GetArraySize": 8, + "RemoveFromArray": 3, + "OnClientDisconnect": 1, + "client": 9, + "index": 8, + "FindValueInArray": 1, + "oldmap": 4, + "GetArrayString": 3, + "Call_StartForward": 1, + "Call_PushString": 1, + "Call_PushCell": 1, + "GetArrayCell": 2, + "Call_Finish": 1, + "Action": 3, + "args": 3, + "ReplyToCommand": 2, + "Plugin_Handled": 4, + "GetCmdArg": 1, + "IsMapValid": 1, + "ShowActivity": 1, + "LogAction": 1, + "SetNextMap": 1, + "OnMapTimeLeftChanged": 1, + "GetMapTimeLeft": 1, + "startTime": 4, + "*": 1, + "GetConVarBool": 6, + "InitiateVote": 8, + "MapChange_MapEnd": 6, + "KillTimer": 1, + "//g_VoteTimer": 1, + "CreateTimer": 3, + "float": 2, + "Timer_StartMapVote": 3, + "TIMER_FLAG_NO_MAPCHANGE": 4, + "data": 8, + "CreateDataTimer": 1, + "WritePackCell": 2, + "ResetPack": 1, + "timer": 2, + "Plugin_Stop": 2, + "mapChange": 2, + "ReadPackCell": 2, + "hndl": 2, + "event": 11, + "const": 4, + "dontBroadcast": 4, + "Timer_ChangeMap": 2, + "bluescore": 2, + "GetEventInt": 7, + "redscore": 2, + "StrEqual": 1, + "CheckMaxRounds": 3, + "switch": 1, + "case": 2, + "CheckWinLimit": 4, + "//We": 1, + "need": 2, + "do": 1, + "nothing": 1, + "on": 1, + "winning_team": 1, + "this": 1, + "indicates": 1, + "stalemate.": 1, + "default": 1, + "winner": 9, + "//": 3, + "Nuclear": 1, + "Dawn": 1, + "SetFailState": 1, + "winner_score": 2, + "winlimit": 3, + "roundcount": 2, + "maxrounds": 3, + "fragger": 3, + "GetClientOfUserId": 1, + "GetClientFrags": 1, + "when": 2, + "inputlist": 1, + "IsVoteInProgress": 1, + "Can": 1, + "t": 7, + "be": 1, + "excluded": 1, + "from": 1, + "as": 2, + "they": 1, + "weren": 1, + "nominationsToAdd": 1, + "Change": 2, + "Extend": 2, + "Map": 5, + "Voting": 7, + "next": 5, + "has": 5, + "started.": 1, + "SM": 5, + "Nextmap": 5, + "Started": 1, + "Current": 2, + "Extended": 1, + "finished.": 3, + "The": 1, + "current": 1, + "been": 1, + "extended.": 1, + "Stays": 1, + "was": 3, + "Finished": 1, + "s.": 1, + "Runoff": 2, + "Starting": 2, + "indecisive": 1, + "beginning": 1, + "runoff": 1, + "T": 3, + "Dont": 1, + "because": 1, + "outside": 1, + "request": 1, + "inputarray": 1, + "plugin": 5, + "numParams": 5, + "CanVoteStart": 1, + "array": 3, + "GetNativeCell": 3, + "size": 2, + "maparray": 3, + "ownerarray": 3, + "If": 1, + "optional": 1, + "parameter": 1, + "an": 1, + "owner": 1, + "list": 1, + "passed": 1, + "then": 1, + "fill": 1, + "out": 1, + "well": 1, + "PushArrayCell": 1 + }, "Squirrel": { "//example": 1, "from": 1, @@ -44795,6 +51253,551 @@ "table": 14, "clear": 1 }, + "Stata": { + "local": 6, + "inname": 1, + "outname": 1, + "program": 2, + "hello": 1, + "vers": 1, + "display": 1, + "end": 4, + "{": 441, + "*": 25, + "version": 2, + "mar2014": 1, + "}": 440, + "...": 30, + "Hello": 1, + "world": 1, + "p_end": 47, + "MAXDIM": 1, + "smcl": 1, + "Matthew": 2, + "White": 2, + "jan2014": 1, + "title": 7, + "Title": 1, + "phang": 4, + "cmd": 111, + "odkmeta": 17, + "hline": 1, + "Create": 4, + "a": 30, + "do": 22, + "-": 42, + "file": 18, + "to": 23, + "import": 9, + "ODK": 6, + "data": 4, + "marker": 10, + "syntax": 1, + "Syntax": 1, + "p": 2, + "using": 10, + "it": 61, + "help": 27, + "filename": 3, + "opt": 25, + "csv": 9, + "(": 60, + "csvfile": 3, + ")": 61, + "Using": 7, + "histogram": 2, + "as": 29, + "template.": 8, + "notwithstanding": 1, + "is": 31, + "rarely": 1, + "preceded": 3, + "by": 7, + "an": 6, + "underscore.": 1, + "cmdab": 5, + "s": 10, + "urvey": 2, + "surveyfile": 5, + "odkmeta##surveyopts": 2, + "surveyopts": 4, + "cho": 2, + "ices": 2, + "choicesfile": 4, + "odkmeta##choicesopts": 2, + "choicesopts": 5, + "[": 6, + "options": 1, + "]": 6, + "odbc": 2, + "the": 67, + "position": 1, + "of": 36, + "last": 1, + "character": 1, + "in": 24, + "first": 2, + "column": 18, + "+": 2, + "synoptset": 5, + "tabbed": 4, + "synopthdr": 4, + "synoptline": 8, + "syntab": 6, + "Main": 3, + "heckman": 2, + "p2coldent": 3, + "name": 20, + ".csv": 2, + "that": 21, + "contains": 3, + "metadata": 5, + "from": 6, + "survey": 14, + "worksheet": 5, + "choices": 10, + "Fields": 2, + "synopt": 16, + "drop": 1, + "attrib": 2, + "headers": 8, + "not": 8, + "field": 25, + "attributes": 10, + "with": 10, + "keep": 1, + "only": 3, + "rel": 1, + "ax": 1, + "ignore": 1, + "fields": 7, + "exist": 1, + "Lists": 1, + "ca": 1, + "oth": 1, + "er": 1, + "odkmeta##other": 1, + "other": 14, + "Stata": 5, + "value": 14, + "values": 3, + "select": 6, + "or_other": 5, + ";": 15, + "default": 8, + "max": 2, + "one": 5, + "line": 4, + "write": 1, + "each": 7, + "list": 13, + "on": 7, + "single": 1, + "Options": 1, + "replace": 7, + "overwrite": 1, + "existing": 1, + "p2colreset": 4, + "and": 18, + "are": 13, + "required.": 1, + "Change": 1, + "t": 2, + "ype": 1, + "header": 15, + "type": 7, + "attribute": 10, + "la": 2, + "bel": 2, + "label": 9, + "d": 1, + "isabled": 1, + "disabled": 4, + "li": 1, + "stname": 1, + "list_name": 6, + "maximum": 3, + "plus": 2, + "min": 2, + "minimum": 2, + "minus": 1, + "#": 6, + "constant": 2, + "for": 13, + "all": 3, + "labels": 8, + "description": 1, + "Description": 1, + "pstd": 20, + "creates": 1, + "worksheets": 1, + "XLSForm.": 1, + "The": 9, + "saved": 1, + "completes": 2, + "following": 1, + "tasks": 3, + "order": 1, + "anova": 1, + "phang2": 23, + "o": 12, + "Import": 2, + "lists": 2, + "Add": 1, + "char": 4, + "characteristics": 4, + "Split": 1, + "select_multiple": 6, + "variables": 8, + "Drop": 1, + "note": 1, + "format": 1, + "Format": 1, + "date": 1, + "time": 1, + "datetime": 1, + "Attach": 2, + "variable": 14, + "notes": 1, + "merge": 3, + "Merge": 1, + "repeat": 6, + "groups": 4, + "After": 1, + "have": 2, + "been": 1, + "split": 4, + "can": 1, + "be": 12, + "removed": 1, + "without": 2, + "affecting": 1, + "tasks.": 1, + "User": 1, + "written": 2, + "supplements": 1, + "may": 2, + "make": 1, + "use": 3, + "any": 3, + "which": 6, + "imported": 4, + "characteristics.": 1, + "remarks": 1, + "Remarks": 1, + "uses": 3, + "helpb": 7, + "insheet": 4, + "data.": 1, + "long": 7, + "strings": 1, + "digits": 1, + "such": 2, + "simserial": 1, + "will": 9, + "numeric": 4, + "even": 1, + "if": 10, + "they": 2, + "more": 1, + "than": 3, + "digits.": 1, + "As": 1, + "result": 6, + "lose": 1, + "precision": 1, + ".": 22, + "makes": 1, + "limited": 1, + "mata": 1, + "Mata": 1, + "manage": 1, + "contain": 1, + "difficult": 1, + "characters.": 2, + "starts": 1, + "definitions": 1, + "several": 1, + "macros": 1, + "these": 4, + "constants": 1, + "uses.": 1, + "For": 4, + "instance": 1, + "macro": 1, + "datemask": 1, + "varname": 1, + "constraints": 1, + "names": 16, + "Further": 1, + "files": 1, + "often": 1, + "much": 1, + "longer": 1, + "length": 3, + "limit": 1, + "These": 2, + "differences": 1, + "convention": 1, + "lead": 1, + "three": 1, + "kinds": 1, + "problematic": 1, + "Long": 3, + "involve": 1, + "invalid": 1, + "combination": 1, + "characters": 3, + "example": 2, + "begins": 1, + "colon": 1, + "followed": 1, + "number.": 1, + "convert": 2, + "instead": 1, + "naming": 1, + "v": 6, + "concatenated": 1, + "positive": 1, + "integer": 1, + "v1": 1, + "unique": 1, + "but": 4, + "when": 1, + "converted": 3, + "truncated": 1, + "become": 3, + "duplicates.": 1, + "again": 1, + "names.": 6, + "form": 1, + "duplicates": 1, + "cannot": 2, + "chooses": 1, + "different": 1, + "Because": 1, + "problem": 2, + "recommended": 1, + "you": 1, + "If": 2, + "its": 3, + "characteristic": 2, + "odkmeta##Odk_bad_name": 1, + "Odk_bad_name": 3, + "otherwise": 1, + "Most": 1, + "depend": 1, + "There": 1, + "two": 2, + "exceptions": 1, + "variables.": 1, + "error": 4, + "has": 6, + "or": 7, + "splitting": 2, + "would": 1, + "duplicate": 4, + "reshape": 2, + "groups.": 1, + "there": 2, + "merging": 2, + "code": 1, + "datasets.": 1, + "Where": 1, + "renaming": 2, + "left": 1, + "user.": 1, + "section": 2, + "designated": 2, + "area": 2, + "renaming.": 3, + "In": 3, + "reshaping": 1, + "group": 4, + "own": 2, + "Many": 1, + "forms": 2, + "require": 1, + "others": 1, + "few": 1, + "need": 1, + "renamed": 1, + "should": 1, + "go": 1, + "areas.": 1, + "However": 1, + "some": 1, + "usually": 1, + "because": 1, + "many": 2, + "nested": 2, + "above": 1, + "this": 1, + "case": 1, + "work": 1, + "best": 1, + "Odk_group": 1, + "Odk_name": 1, + "Odk_is_other": 2, + "Odk_geopoint": 2, + "r": 2, + "varlist": 2, + "Odk_list_name": 2, + "foreach": 1, + "var": 5, + "*search": 1, + "n/a": 1, + "know": 1, + "don": 1, + "worksheet.": 1, + "requires": 1, + "comma": 1, + "separated": 2, + "text": 1, + "file.": 1, + "Strings": 1, + "embedded": 2, + "commas": 1, + "double": 3, + "quotes": 3, + "must": 2, + "enclosed": 1, + "another": 1, + "quote.": 1, + "pmore": 5, + "Each": 1, + "header.": 1, + "Use": 1, + "suboptions": 1, + "specify": 1, + "alternative": 1, + "respectively.": 1, + "All": 1, + "used.": 1, + "standardized": 1, + "follows": 1, + "replaced": 9, + "select_one": 3, + "begin_group": 1, + "begin": 2, + "end_group": 1, + "begin_repeat": 1, + "end_repeat": 1, + "addition": 1, + "specified": 1, + "attaches": 1, + "pmore2": 3, + "formed": 1, + "concatenating": 1, + "elements": 1, + "Odk_repeat": 1, + "nested.": 1, + "geopoint": 2, + "component": 1, + "Latitude": 1, + "Longitude": 1, + "Altitude": 1, + "Accuracy": 1, + "blank.": 1, + "imports": 4, + "XLSForm": 1, + "list.": 1, + "one.": 1, + "specifies": 4, + "vary": 1, + "definition": 1, + "rather": 1, + "multiple": 1, + "delimit": 1, + "#delimit": 1, + "dlgtab": 1, + "Other": 1, + "already": 2, + "exists.": 1, + "examples": 1, + "Examples": 1, + "named": 1, + "import.do": 7, + "including": 1, + "survey.csv": 1, + "choices.csv": 1, + "txt": 6, + "Same": 3, + "previous": 3, + "command": 3, + "appears": 2, + "fieldname": 3, + "survey_fieldname.csv": 1, + "valuename": 2, + "choices_valuename.csv": 1, + "except": 1, + "hint": 2, + "dropattrib": 2, + "does": 1, + "_all": 1, + "acknowledgements": 1, + "Acknowledgements": 1, + "Lindsey": 1, + "Shaughnessy": 1, + "Innovations": 2, + "Poverty": 2, + "Action": 2, + "assisted": 1, + "almost": 1, + "aspects": 1, + "development.": 1, + "She": 1, + "collaborated": 1, + "structure": 1, + "was": 1, + "very": 1, + "helpful": 1, + "tester": 1, + "contributed": 1, + "information": 1, + "about": 1, + "ODK.": 1, + "author": 1, + "Author": 1, + "mwhite@poverty": 1, + "action.org": 1, + "Setup": 1, + "sysuse": 1, + "auto": 1, + "Fit": 2, + "linear": 2, + "regression": 2, + "regress": 5, + "mpg": 1, + "weight": 4, + "foreign": 2, + "better": 1, + "physics": 1, + "standpoint": 1, + "gen": 1, + "gp100m": 2, + "/mpg": 1, + "Obtain": 1, + "beta": 2, + "coefficients": 1, + "refitting": 1, + "model": 1, + "Suppress": 1, + "intercept": 1, + "term": 1, + "noconstant": 1, + "Model": 1, + "bn.foreign": 1, + "hascons": 1, + "matrix": 3, + "tanh": 1, + "u": 3, + "eu": 4, + "emu": 4, + "exp": 2, + "return": 1, + "/": 1 + }, "Stylus": { "border": 6, "-": 10, @@ -44884,6 +51887,300 @@ "wait": 1, ".fork": 1 }, + "SystemVerilog": { + "module": 3, + "endpoint_phy_wrapper": 2, + "(": 92, + "input": 12, + "clk_sys_i": 2, + "clk_ref_i": 6, + "clk_rx_i": 3, + "rst_n_i": 3, + "IWishboneMaster.master": 2, + "src": 1, + "IWishboneSlave.slave": 1, + "snk": 1, + "sys": 1, + "output": 6, + "[": 17, + "]": 17, + "td_o": 2, + "rd_i": 2, + "txn_o": 2, + "txp_o": 2, + "rxn_i": 2, + "rxp_i": 2, + ")": 92, + ";": 32, + "wire": 12, + "rx_clock": 3, + "parameter": 2, + "g_phy_type": 6, + "gtx_data": 3, + "gtx_k": 3, + "gtx_disparity": 3, + "gtx_enc_error": 3, + "grx_data": 3, + "grx_clk": 1, + "grx_k": 3, + "grx_enc_error": 3, + "grx_bitslide": 2, + "gtp_rst": 2, + "tx_clock": 3, + "generate": 1, + "if": 5, + "begin": 4, + "assign": 2, + "wr_tbi_phy": 1, + "U_Phy": 1, + ".serdes_rst_i": 1, + ".serdes_loopen_i": 1, + "b0": 5, + ".serdes_enable_i": 1, + "b1": 2, + ".serdes_tx_data_i": 1, + ".serdes_tx_k_i": 1, + ".serdes_tx_disparity_o": 1, + ".serdes_tx_enc_err_o": 1, + ".serdes_rx_data_o": 1, + ".serdes_rx_k_o": 1, + ".serdes_rx_enc_err_o": 1, + ".serdes_rx_bitslide_o": 1, + ".tbi_refclk_i": 1, + ".tbi_rbclk_i": 1, + ".tbi_td_o": 1, + ".tbi_rd_i": 1, + ".tbi_syncen_o": 1, + ".tbi_loopen_o": 1, + ".tbi_prbsen_o": 1, + ".tbi_enable_o": 1, + "end": 4, + "else": 2, + "//": 3, + "wr_gtx_phy_virtex6": 1, + "#": 3, + ".g_simulation": 2, + "U_PHY": 1, + ".clk_ref_i": 2, + ".tx_clk_o": 1, + ".tx_data_i": 1, + ".tx_k_i": 1, + ".tx_disparity_o": 1, + ".tx_enc_err_o": 1, + ".rx_rbclk_o": 1, + ".rx_data_o": 1, + ".rx_k_o": 1, + ".rx_enc_err_o": 1, + ".rx_bitslide_o": 1, + ".rst_i": 1, + ".loopen_i": 1, + ".pad_txn0_o": 1, + ".pad_txp0_o": 1, + ".pad_rxn0_i": 1, + ".pad_rxp0_i": 1, + "endgenerate": 1, + "wr_endpoint": 1, + ".g_pcs_16bit": 1, + ".g_rx_buffer_size": 1, + ".g_with_rx_buffer": 1, + ".g_with_timestamper": 1, + ".g_with_dmtd": 1, + ".g_with_dpi_classifier": 1, + ".g_with_vlans": 1, + ".g_with_rtu": 1, + "DUT": 1, + ".clk_sys_i": 1, + ".clk_dmtd_i": 1, + ".rst_n_i": 1, + ".pps_csync_p1_i": 1, + ".src_dat_o": 1, + "snk.dat_i": 1, + ".src_adr_o": 1, + "snk.adr": 1, + ".src_sel_o": 1, + "snk.sel": 1, + ".src_cyc_o": 1, + "snk.cyc": 1, + ".src_stb_o": 1, + "snk.stb": 1, + ".src_we_o": 1, + "snk.we": 1, + ".src_stall_i": 1, + "snk.stall": 1, + ".src_ack_i": 1, + "snk.ack": 1, + ".src_err_i": 1, + ".rtu_full_i": 1, + ".rtu_rq_strobe_p1_o": 1, + ".rtu_rq_smac_o": 1, + ".rtu_rq_dmac_o": 1, + ".rtu_rq_vid_o": 1, + ".rtu_rq_has_vid_o": 1, + ".rtu_rq_prio_o": 1, + ".rtu_rq_has_prio_o": 1, + ".wb_cyc_i": 1, + "sys.cyc": 1, + ".wb_stb_i": 1, + "sys.stb": 1, + ".wb_we_i": 1, + "sys.we": 1, + ".wb_sel_i": 1, + "sys.sel": 1, + ".wb_adr_i": 1, + "sys.adr": 1, + ".wb_dat_i": 1, + "sys.dat_o": 1, + ".wb_dat_o": 1, + "sys.dat_i": 1, + ".wb_ack_o": 1, + "sys.ack": 1, + "endmodule": 2, + "fifo": 1, + "clk_50": 1, + "clk_2": 1, + "reset_n": 1, + "data_out": 1, + "empty": 1, + "priority_encoder": 1, + "INPUT_WIDTH": 3, + "OUTPUT_WIDTH": 3, + "logic": 2, + "-": 4, + "input_data": 2, + "output_data": 3, + "int": 1, + "ii": 6, + "always_comb": 1, + "for": 2, + "<": 1, + "+": 3, + "function": 1, + "integer": 2, + "log2": 4, + "x": 6, + "endfunction": 1 + }, + "Tcl": { + "#": 7, + "package": 2, + "require": 2, + "Tcl": 2, + "namespace": 6, + "eval": 2, + "stream": 61, + "{": 148, + "export": 3, + "[": 76, + "a": 1, + "-": 5, + "z": 1, + "]": 76, + "*": 19, + "}": 148, + "ensemble": 1, + "create": 7, + "proc": 28, + "first": 24, + "restCmdPrefix": 2, + "return": 22, + "list": 18, + "lassign": 11, + "foldl": 1, + "cmdPrefix": 19, + "initialValue": 7, + "args": 13, + "set": 34, + "numStreams": 3, + "llength": 5, + "if": 14, + "FoldlSingleStream": 2, + "lindex": 5, + "elseif": 3, + "FoldlMultiStream": 2, + "else": 5, + "Usage": 4, + "foreach": 5, + "numArgs": 7, + "varName": 7, + "body": 8, + "ForeachSingleStream": 2, + "(": 11, + ")": 11, + "&&": 2, + "%": 1, + "end": 2, + "items": 5, + "lrange": 1, + "ForeachMultiStream": 2, + "fromList": 2, + "_list": 4, + "index": 4, + "expr": 4, + "+": 1, + "isEmpty": 10, + "map": 1, + "MapSingleStream": 3, + "MapMultiStream": 3, + "rest": 22, + "select": 2, + "while": 6, + "take": 2, + "num": 3, + "||": 1, + "<": 1, + "toList": 1, + "res": 10, + "lappend": 8, + "#################################": 2, + "acc": 9, + "streams": 5, + "firsts": 6, + "restStreams": 6, + "uplevel": 4, + "nextItems": 4, + "msg": 1, + "code": 1, + "error": 1, + "level": 1, + "XDG": 11, + "variable": 4, + "DEFAULTS": 8, + "DATA_HOME": 4, + "CONFIG_HOME": 4, + "CACHE_HOME": 4, + "RUNTIME_DIR": 3, + "DATA_DIRS": 4, + "CONFIG_DIRS": 4, + "SetDefaults": 3, + "ne": 2, + "file": 9, + "join": 9, + "env": 8, + "HOME": 3, + ".local": 1, + "share": 3, + ".config": 1, + ".cache": 1, + "/usr": 2, + "local": 1, + "/etc": 1, + "xdg": 1, + "XDGVarSet": 4, + "var": 11, + "info": 1, + "exists": 1, + "XDG_": 4, + "Dir": 4, + "subdir": 16, + "dir": 5, + "dict": 2, + "get": 2, + "Dirs": 3, + "rawDirs": 3, + "split": 1, + "outDirs": 3, + "XDG_RUNTIME_DIR": 1 + }, "Tea": { "<%>": 1, "template": 1, @@ -48459,7 +55756,7 @@ }, "YAML": { "gem": 1, - "-": 16, + "-": 25, "local": 1, "gen": 1, "rdoc": 2, @@ -48471,17 +55768,203 @@ "numbers": 1, "gempath": 1, "/usr/local/rubygems": 1, - "/home/gavin/.rubygems": 1 + "/home/gavin/.rubygems": 1, + "http_interactions": 1, + "request": 1, + "method": 1, + "get": 1, + "uri": 1, + "http": 1, + "//example.com/": 1, + "body": 3, + "headers": 2, + "{": 1, + "}": 1, + "response": 2, + "status": 1, + "code": 1, + "message": 1, + "OK": 1, + "Content": 2, + "Type": 1, + "text/html": 1, + ";": 1, + "charset": 1, + "utf": 1, + "Length": 1, + "This": 1, + "is": 1, + "the": 1, + "http_version": 1, + "recorded_at": 1, + "Tue": 1, + "Nov": 1, + "GMT": 1, + "recorded_with": 1, + "VCR": 1 + }, + "Zephir": { + "%": 10, + "{": 56, + "#define": 1, + "MAX_FACTOR": 3, + "}": 50, + "namespace": 3, + "Test": 2, + ";": 86, + "#include": 1, + "static": 1, + "long": 3, + "fibonacci": 4, + "(": 55, + "n": 5, + ")": 53, + "if": 39, + "<": 1, + "return": 25, + "else": 11, + "-": 25, + "+": 5, + "class": 2, + "Cblock": 1, + "public": 22, + "function": 22, + "testCblock1": 1, + "int": 3, + "a": 6, + "testCblock2": 1, + "Router": 1, + "Route": 1, + "protected": 9, + "_pattern": 3, + "_compiledPattern": 3, + "_paths": 3, + "_methods": 5, + "_hostname": 3, + "_converters": 3, + "_id": 2, + "_name": 3, + "_beforeMatch": 3, + "__construct": 1, + "pattern": 37, + "paths": 7, + "null": 11, + "httpMethods": 6, + "this": 28, + "reConfigure": 2, + "let": 51, + "compilePattern": 2, + "var": 4, + "idPattern": 6, + "memstr": 10, + "str_replace": 6, + ".": 5, + "via": 1, + "extractNamedParams": 2, + "string": 6, + "char": 1, + "ch": 27, + "tmp": 4, + "matches": 5, + "boolean": 1, + "notValid": 5, + "false": 3, + "cursor": 4, + "cursorVar": 5, + "marker": 4, + "bracketCount": 7, + "parenthesesCount": 5, + "foundPattern": 6, + "intermediate": 4, + "numberMatches": 4, + "route": 12, + "item": 7, + "variable": 5, + "regexp": 7, + "strlen": 1, + "<=>": 5, + "0": 9, + "for": 4, + "in": 4, + "1": 3, + "substr": 3, + "break": 9, + "&&": 6, + "z": 2, + "Z": 2, + "true": 2, + "<='9')>": 1, + "_": 1, + "2": 2, + "continue": 1, + "[": 14, + "]": 14, + "moduleName": 5, + "controllerName": 7, + "actionName": 4, + "parts": 9, + "routePaths": 5, + "realClassName": 1, + "namespaceName": 1, + "pcrePattern": 4, + "compiledPattern": 4, + "extracted": 4, + "typeof": 2, + "throw": 1, + "new": 1, + "Exception": 1, + "explode": 1, + "switch": 1, + "count": 1, + "case": 3, + "controller": 1, + "action": 1, + "array": 1, + "The": 1, + "contains": 1, + "invalid": 1, + "#": 1, + "array_merge": 1, + "//Update": 1, + "the": 1, + "s": 1, + "name": 5, + "*": 2, + "@return": 1, + "*/": 1, + "getName": 1, + "setName": 1, + "beforeMatch": 1, + "callback": 2, + "getBeforeMatch": 1, + "getRouteId": 1, + "getPattern": 1, + "getCompiledPattern": 1, + "getPaths": 1, + "getReversedPaths": 1, + "reversed": 4, + "path": 3, + "position": 3, + "setHttpMethods": 1, + "getHttpMethods": 1, + "setHostname": 1, + "hostname": 2, + "getHostname": 1, + "convert": 1, + "converter": 2, + "getConverters": 1 } }, "language_tokens": { "ABAP": 1500, "Agda": 376, + "Alloy": 1143, "ApacheConf": 1449, "Apex": 4408, "AppleScript": 1862, "Arduino": 20, "AsciiDoc": 103, + "AspectJ": 324, "ATS": 4558, "AutoHotkey": 3, "Awk": 544, @@ -48490,7 +55973,7 @@ "Brightscript": 579, "C": 59053, "C#": 278, - "C++": 31181, + "C++": 32475, "Ceylon": 50, "Cirru": 244, "Clojure": 510, @@ -48504,6 +55987,8 @@ "Dart": 74, "Diff": 16, "DM": 169, + "Dogescript": 30, + "Eagle": 30089, "ECL": 281, "edn": 227, "Elm": 628, @@ -48511,9 +55996,13 @@ "Erlang": 2928, "fish": 636, "Forth": 1516, + "Frege": 5564, + "Game Maker Language": 13310, "GAS": 133, "GLSL": 3766, + "Gnuplot": 1023, "Gosu": 410, + "Grammatical Framework": 10607, "Groovy": 69, "Groovy Server Pages": 91, "Haml": 4, @@ -48528,6 +56017,7 @@ "JavaScript": 76934, "JSON": 183, "JSON5": 57, + "JSONiq": 151, "JSONLD": 18, "Julia": 247, "Kotlin": 155, @@ -48541,9 +56031,11 @@ "Logos": 93, "Logtalk": 36, "Lua": 724, - "M": 23373, + "M": 23615, "Makefile": 50, "Markdown": 1, + "Mask": 74, + "Mathematica": 411, "Matlab": 11942, "Max": 714, "MediaWiki": 766, @@ -48556,6 +56048,7 @@ "NSIS": 725, "Nu": 116, "Objective-C": 26518, + "Objective-C++": 6021, "OCaml": 382, "Omgrofl": 57, "Opa": 28, @@ -48577,12 +56070,13 @@ "Processing": 74, "Prolog": 468, "Protocol Buffer": 63, + "PureScript": 1652, "Python": 5715, "R": 195, "Racket": 331, "Ragel in Ruby Host": 593, "RDoc": 279, - "Rebol": 11, + "Rebol": 533, "RMarkdown": 19, "RobotFramework": 483, "Ruby": 3862, @@ -48594,11 +56088,17 @@ "Scilab": 69, "SCSS": 39, "Shell": 3744, + "ShellSession": 233, + "Shen": 3472, "Slash": 187, + "SourcePawn": 2080, "Squirrel": 130, "Standard ML": 6405, + "Stata": 3133, "Stylus": 76, "SuperCollider": 133, + "SystemVerilog": 541, + "Tcl": 1133, "Tea": 3, "TeX": 2701, "Turing": 44, @@ -48617,16 +56117,19 @@ "XQuery": 801, "XSLT": 44, "Xtend": 399, - "YAML": 30 + "YAML": 77, + "Zephir": 1026 }, "languages": { "ABAP": 1, "Agda": 1, + "Alloy": 3, "ApacheConf": 3, "Apex": 6, "AppleScript": 7, "Arduino": 1, "AsciiDoc": 3, + "AspectJ": 2, "ATS": 10, "AutoHotkey": 1, "Awk": 1, @@ -48635,7 +56138,7 @@ "Brightscript": 1, "C": 29, "C#": 2, - "C++": 27, + "C++": 28, "Ceylon": 1, "Cirru": 9, "Clojure": 7, @@ -48649,6 +56152,8 @@ "Dart": 1, "Diff": 1, "DM": 1, + "Dogescript": 1, + "Eagle": 2, "ECL": 1, "edn": 1, "Elm": 3, @@ -48656,9 +56161,13 @@ "Erlang": 5, "fish": 3, "Forth": 7, + "Frege": 4, + "Game Maker Language": 13, "GAS": 1, "GLSL": 3, + "Gnuplot": 6, "Gosu": 4, + "Grammatical Framework": 41, "Groovy": 2, "Groovy Server Pages": 4, "Haml": 1, @@ -48673,6 +56182,7 @@ "JavaScript": 20, "JSON": 4, "JSON5": 2, + "JSONiq": 2, "JSONLD": 1, "Julia": 1, "Kotlin": 1, @@ -48686,9 +56196,11 @@ "Logos": 1, "Logtalk": 1, "Lua": 3, - "M": 28, + "M": 29, "Makefile": 2, "Markdown": 1, + "Mask": 1, + "Mathematica": 3, "Matlab": 39, "Max": 3, "MediaWiki": 1, @@ -48701,6 +56213,7 @@ "NSIS": 2, "Nu": 2, "Objective-C": 19, + "Objective-C++": 2, "OCaml": 2, "Omgrofl": 1, "Opa": 2, @@ -48722,12 +56235,13 @@ "Processing": 1, "Prolog": 3, "Protocol Buffer": 1, + "PureScript": 4, "Python": 7, "R": 3, "Racket": 2, "Ragel in Ruby Host": 3, "RDoc": 1, - "Rebol": 1, + "Rebol": 6, "RMarkdown": 1, "RobotFramework": 3, "Ruby": 17, @@ -48739,11 +56253,17 @@ "Scilab": 3, "SCSS": 1, "Shell": 37, + "ShellSession": 3, + "Shen": 3, "Slash": 1, + "SourcePawn": 1, "Squirrel": 1, "Standard ML": 4, + "Stata": 7, "Stylus": 1, "SuperCollider": 1, + "SystemVerilog": 4, + "Tcl": 2, "Tea": 1, "TeX": 2, "Turing": 1, @@ -48762,7 +56282,8 @@ "XQuery": 1, "XSLT": 1, "Xtend": 2, - "YAML": 1 + "YAML": 2, + "Zephir": 2 }, - "md5": "cfe1841f5e4b2ab14a1ad53ad64523b8" + "md5": "d63dba05d93104a7fb8207b9df7de2cd" } \ No newline at end of file diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 135f367c..0b0c5523 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -10,7 +10,7 @@ ## Vendor Conventions ## # Caches -- cache/ +- (^|/)cache/ # Dependencies - ^[Dd]ependencies/ @@ -98,6 +98,9 @@ # AngularJS - (^|/)angular([^.]*)(\.min)?\.js$ +# React +- (^|/)react(-[^.]*)?(\.min)?\.js$ + ## Python ## # django @@ -128,6 +131,7 @@ # Visual Studio IntelliSense - -vsdoc\.js$ +- \.intellisense\.js$ # jQuery validation plugin (MS bundles this with asp.net mvc) - (^|/)jquery([^.]*)\.validate(\.unobtrusive)?(\.min)?\.js$ diff --git a/samples/Alloy/file_system.als b/samples/Alloy/file_system.als new file mode 100644 index 00000000..60fd959b --- /dev/null +++ b/samples/Alloy/file_system.als @@ -0,0 +1,59 @@ +module examples/systems/file_system + +/* + * Model of a generic file system. + */ + +abstract sig Object {} + +sig Name {} + +sig File extends Object {} { some d: Dir | this in d.entries.contents } + +sig Dir extends Object { + entries: set DirEntry, + parent: lone Dir +} { + parent = this.~@contents.~@entries + all e1, e2 : entries | e1.name = e2.name => e1 = e2 + this !in this.^@parent + this != Root => Root in this.^@parent +} + +one sig Root extends Dir {} { no parent } + +lone sig Cur extends Dir {} + +sig DirEntry { + name: Name, + contents: Object +} { + one this.~entries +} + + +/** + * all directories besides root have one parent + */ +pred OneParent_buggyVersion { + all d: Dir - Root | one d.parent +} + +/** + * all directories besides root have one parent + */ +pred OneParent_correctVersion { + all d: Dir - Root | (one d.parent && one contents.d) +} + +/** + * Only files may be linked (that is, have more than one entry) + * That is, all directories are the contents of at most one directory entry + */ +pred NoDirAliases { + all o: Dir | lone o.~contents +} + +check { OneParent_buggyVersion => NoDirAliases } for 5 expect 1 + +check { OneParent_correctVersion => NoDirAliases } for 5 expect 0 diff --git a/samples/Alloy/marksweepgc.als b/samples/Alloy/marksweepgc.als new file mode 100644 index 00000000..b8081e3f --- /dev/null +++ b/samples/Alloy/marksweepgc.als @@ -0,0 +1,83 @@ +module examples/systems/marksweepgc + +/* + * Model of mark and sweep garbage collection. + */ + +// a node in the heap +sig Node {} + +sig HeapState { + left, right : Node -> lone Node, + marked : set Node, + freeList : lone Node +} + +pred clearMarks[hs, hs' : HeapState] { + // clear marked set + no hs'.marked + // left and right fields are unchanged + hs'.left = hs.left + hs'.right = hs.right +} + +/** + * simulate the recursion of the mark() function using transitive closure + */ +fun reachable[hs: HeapState, n: Node] : set Node { + n + n.^(hs.left + hs.right) +} + +pred mark[hs: HeapState, from : Node, hs': HeapState] { + hs'.marked = hs.reachable[from] + hs'.left = hs.left + hs'.right = hs.right +} + +/** + * complete hack to simulate behavior of code to set freeList + */ +pred setFreeList[hs, hs': HeapState] { + // especially hackish + hs'.freeList.*(hs'.left) in (Node - hs.marked) + all n: Node | + (n !in hs.marked) => { + no hs'.right[n] + hs'.left[n] in (hs'.freeList.*(hs'.left)) + n in hs'.freeList.*(hs'.left) + } else { + hs'.left[n] = hs.left[n] + hs'.right[n] = hs.right[n] + } + hs'.marked = hs.marked +} + +pred GC[hs: HeapState, root : Node, hs': HeapState] { + some hs1, hs2: HeapState | + hs.clearMarks[hs1] && hs1.mark[root, hs2] && hs2.setFreeList[hs'] +} + +assert Soundness1 { + all h, h' : HeapState, root : Node | + h.GC[root, h'] => + (all live : h.reachable[root] | { + h'.left[live] = h.left[live] + h'.right[live] = h.right[live] + }) +} + +assert Soundness2 { + all h, h' : HeapState, root : Node | + h.GC[root, h'] => + no h'.reachable[root] & h'.reachable[h'.freeList] +} + +assert Completeness { + all h, h' : HeapState, root : Node | + h.GC[root, h'] => + (Node - h'.reachable[root]) in h'.reachable[h'.freeList] +} + +check Soundness1 for 3 expect 0 +check Soundness2 for 3 expect 0 +check Completeness for 3 expect 0 diff --git a/samples/Alloy/views.als b/samples/Alloy/views.als new file mode 100644 index 00000000..3a5ab82b --- /dev/null +++ b/samples/Alloy/views.als @@ -0,0 +1,217 @@ +module examples/systems/views + +/* + * Model of views in object-oriented programming. + * + * Two object references, called the view and the backing, + * are related by a view mechanism when changes to the + * backing are automatically propagated to the view. Note + * that the state of a view need not be a projection of the + * state of the backing; the keySet method of Map, for + * example, produces two view relationships, and for the + * one in which the map is modified by changes to the key + * set, the value of the new map cannot be determined from + * the key set. Note that in the iterator view mechanism, + * the iterator is by this definition the backing object, + * since changes are propagated from iterator to collection + * and not vice versa. Oddly, a reference may be a view of + * more than one backing: there can be two iterators on the + * same collection, eg. A reference cannot be a view under + * more than one view type. + * + * A reference is made dirty when it is a backing for a view + * with which it is no longer related by the view invariant. + * This usually happens when a view is modified, either + * directly or via another backing. For example, changing a + * collection directly when it has an iterator invalidates + * it, as does changing the collection through one iterator + * when there are others. + * + * More work is needed if we want to model more closely the + * failure of an iterator when its collection is invalidated. + * + * As a terminological convention, when there are two + * complementary view relationships, we will give them types + * t and t'. For example, KeySetView propagates from map to + * set, and KeySetView' propagates from set to map. + * + * author: Daniel Jackson + */ + +open util/ordering[State] as so +open util/relation as rel + +sig Ref {} +sig Object {} + +-- t->b->v in views when v is view of type t of backing b +-- dirty contains refs that have been invalidated +sig State { + refs: set Ref, + obj: refs -> one Object, + views: ViewType -> refs -> refs, + dirty: set refs +-- , anyviews: Ref -> Ref -- for visualization + } +-- {anyviews = ViewType.views} + +sig Map extends Object { + keys: set Ref, + map: keys -> one Ref + }{all s: State | keys + Ref.map in s.refs} +sig MapRef extends Ref {} +fact {State.obj[MapRef] in Map} + +sig Iterator extends Object { + left, done: set Ref, + lastRef: lone done + }{all s: State | done + left + lastRef in s.refs} +sig IteratorRef extends Ref {} +fact {State.obj[IteratorRef] in Iterator} + +sig Set extends Object { + elts: set Ref + }{all s: State | elts in s.refs} +sig SetRef extends Ref {} +fact {State.obj[SetRef] in Set} + +abstract sig ViewType {} +one sig KeySetView, KeySetView', IteratorView extends ViewType {} +fact ViewTypes { + State.views[KeySetView] in MapRef -> SetRef + State.views[KeySetView'] in SetRef -> MapRef + State.views[IteratorView] in IteratorRef -> SetRef + all s: State | s.views[KeySetView] = ~(s.views[KeySetView']) + } + +/** + * mods is refs modified directly or by view mechanism + * doesn't handle possibility of modifying an object and its view at once? + * should we limit frame conds to non-dirty refs? + */ +pred modifies [pre, post: State, rs: set Ref] { + let vr = pre.views[ViewType], mods = rs.*vr { + all r: pre.refs - mods | pre.obj[r] = post.obj[r] + all b: mods, v: pre.refs, t: ViewType | + b->v in pre.views[t] => viewFrame [t, pre.obj[v], post.obj[v], post.obj[b]] + post.dirty = pre.dirty + + {b: pre.refs | some v: Ref, t: ViewType | + b->v in pre.views[t] && !viewFrame [t, pre.obj[v], post.obj[v], post.obj[b]] + } + } + } + +pred allocates [pre, post: State, rs: set Ref] { + no rs & pre.refs + post.refs = pre.refs + rs + } + +/** + * models frame condition that limits change to view object from v to v' when backing object changes to b' + */ +pred viewFrame [t: ViewType, v, v', b': Object] { + t in KeySetView => v'.elts = dom [b'.map] + t in KeySetView' => b'.elts = dom [v'.map] + t in KeySetView' => (b'.elts) <: (v.map) = (b'.elts) <: (v'.map) + t in IteratorView => v'.elts = b'.left + b'.done + } + +pred MapRef.keySet [pre, post: State, setRefs: SetRef] { + post.obj[setRefs].elts = dom [pre.obj[this].map] + modifies [pre, post, none] + allocates [pre, post, setRefs] + post.views = pre.views + KeySetView->this->setRefs + KeySetView'->setRefs->this + } + +pred MapRef.put [pre, post: State, k, v: Ref] { + post.obj[this].map = pre.obj[this].map ++ k->v + modifies [pre, post, this] + allocates [pre, post, none] + post.views = pre.views + } + +pred SetRef.iterator [pre, post: State, iterRef: IteratorRef] { + let i = post.obj[iterRef] { + i.left = pre.obj[this].elts + no i.done + i.lastRef + } + modifies [pre,post,none] + allocates [pre, post, iterRef] + post.views = pre.views + IteratorView->iterRef->this + } + +pred IteratorRef.remove [pre, post: State] { + let i = pre.obj[this], i' = post.obj[this] { + i'.left = i.left + i'.done = i.done - i.lastRef + no i'.lastRef + } + modifies [pre,post,this] + allocates [pre, post, none] + pre.views = post.views + } + +pred IteratorRef.next [pre, post: State, ref: Ref] { + let i = pre.obj[this], i' = post.obj[this] { + ref in i.left + i'.left = i.left - ref + i'.done = i.done + ref + i'.lastRef = ref + } + modifies [pre, post, this] + allocates [pre, post, none] + pre.views = post.views + } + +pred IteratorRef.hasNext [s: State] { + some s.obj[this].left + } + +assert zippishOK { + all + ks, vs: SetRef, + m: MapRef, + ki, vi: IteratorRef, + k, v: Ref | + let s0=so/first, + s1=so/next[s0], + s2=so/next[s1], + s3=so/next[s2], + s4=so/next[s3], + s5=so/next[s4], + s6=so/next[s5], + s7=so/next[s6] | + ({ + precondition [s0, ks, vs, m] + no s0.dirty + ks.iterator [s0, s1, ki] + vs.iterator [s1, s2, vi] + ki.hasNext [s2] + vi.hasNext [s2] + ki.this/next [s2, s3, k] + vi.this/next [s3, s4, v] + m.put [s4, s5, k, v] + ki.remove [s5, s6] + vi.remove [s6, s7] + } => no State.dirty) + } + +pred precondition [pre: State, ks, vs, m: Ref] { + // all these conditions and other errors discovered in scope of 6 but 8,3 + // in initial state, must have view invariants hold + (all t: ViewType, b, v: pre.refs | + b->v in pre.views[t] => viewFrame [t, pre.obj[v], pre.obj[v], pre.obj[b]]) + // sets are not aliases +-- ks != vs + // sets are not views of map +-- no (ks+vs)->m & ViewType.pre.views + // no iterator currently on either set +-- no Ref->(ks+vs) & ViewType.pre.views + } + +check zippishOK for 6 but 8 State, 3 ViewType expect 1 + +/** + * experiment with controlling heap size + */ +fact {all s: State | #s.obj < 5} diff --git a/samples/AspectJ/CacheAspect.aj b/samples/AspectJ/CacheAspect.aj new file mode 100644 index 00000000..bfab7bc4 --- /dev/null +++ b/samples/AspectJ/CacheAspect.aj @@ -0,0 +1,41 @@ +package com.blogspot.miguelinlas3.aspectj.cache; + +import java.util.Map; +import java.util.WeakHashMap; + +import org.aspectj.lang.JoinPoint; + +import com.blogspot.miguelinlas3.aspectj.cache.marker.Cachable; + +/** + * This simple aspect simulates the behaviour of a very simple cache + * + * @author migue + * + */ +public aspect CacheAspect { + + public pointcut cache(Cachable cachable): execution(@Cachable * * (..)) && @annotation(cachable); + + Object around(Cachable cachable): cache(cachable){ + + String evaluatedKey = this.evaluateKey(cachable.scriptKey(), thisJoinPoint); + + if(cache.containsKey(evaluatedKey)){ + System.out.println("Cache hit for key " + evaluatedKey); + return this.cache.get(evaluatedKey); + } + + System.out.println("Cache miss for key " + evaluatedKey); + Object value = proceed(cachable); + cache.put(evaluatedKey, value); + return value; + } + + protected String evaluateKey(String key, JoinPoint joinPoint) { + // TODO add some smart staff to allow simple scripting in @Cachable annotation + return key; + } + + protected Map cache = new WeakHashMap(); +} diff --git a/samples/AspectJ/OptimizeRecursionCache.aj b/samples/AspectJ/OptimizeRecursionCache.aj new file mode 100644 index 00000000..ed1e8695 --- /dev/null +++ b/samples/AspectJ/OptimizeRecursionCache.aj @@ -0,0 +1,50 @@ +package aspects.caching; + +import java.util.Map; + +/** + * Cache aspect for optimize recursive functions. + * + * @author Migueli + * @date 05/11/2013 + * @version 1.0 + * + */ +public abstract aspect OptimizeRecursionCache { + + @SuppressWarnings("rawtypes") + private Map _cache; + + public OptimizeRecursionCache() { + _cache = getCache(); + } + + @SuppressWarnings("rawtypes") + abstract public Map getCache(); + + abstract public pointcut operation(Object o); + + pointcut topLevelOperation(Object o): operation(o) && !cflowbelow(operation(Object)); + + before(Object o) : topLevelOperation(o) { + System.out.println("Seeking value for " + o); + } + + Object around(Object o) : operation(o) { + Object cachedValue = _cache.get(o); + if (cachedValue != null) { + System.out.println("Found cached value for " + o + ": " + cachedValue); + return cachedValue; + } + return proceed(o); + } + + @SuppressWarnings("unchecked") + after(Object o) returning(Object result) : topLevelOperation(o) { + _cache.put(o, result); + } + + after(Object o) returning(Object result) : topLevelOperation(o) { + System.out.println("cache size: " + _cache.size()); + } +} diff --git a/samples/C++/Math.inl b/samples/C++/Math.inl new file mode 100644 index 00000000..194370a3 --- /dev/null +++ b/samples/C++/Math.inl @@ -0,0 +1,530 @@ +/* +=========================================================================== +The Open Game Libraries. +Copyright (C) 2007-2010 Lusito Software + +Author: Santo Pfingsten (TTK-Bandit) +Purpose: Math namespace +----------------------------------------- + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. +=========================================================================== +*/ + +#ifndef __OG_MATH_INL__ +#define __OG_MATH_INL__ + +namespace og { + +/* +============================================================================== + + Math + +============================================================================== +*/ + +/* +================ +Math::Abs +================ +*/ +OG_INLINE int Math::Abs( int i ) { +#if 1 + if ( i & 0x80000000 ) + return 0x80000000 - (i & MASK_SIGNED); + return i; +#else + int y = x >> 31; + return ( ( x ^ y ) - y ); +#endif +} + +/* +================ +Math::Fabs +================ +*/ +OG_INLINE float Math::Fabs( float f ) { +#if 1 + uInt *pf = reinterpret_cast(&f); + *(pf) &= MASK_SIGNED; + return f; +#else + return fabsf( f ); +#endif +} + +/* +================ +Math::Round +================ +*/ +OG_INLINE float Math::Round( float f ) { + return floorf( f + 0.5f ); +} + +/* +================ +Math::Floor +================ +*/ +OG_INLINE float Math::Floor( float f ) { + return floorf( f ); +} + +/* +================ +Math::Ceil +================ +*/ +OG_INLINE float Math::Ceil( float f ) { + return ceilf( f ); +} + +/* +================ +Math::Ftoi + +ok since this is SSE, why should the other ftoi be the faster one ? +and: we might need to add a check for SSE extensions.. +because sse isn't *really* faster (I actually read that GCC does not handle +SSE extensions perfectly. I'll find the link and send it to you when you're online) +================ +*/ +OG_INLINE int Math::Ftoi( float f ) { + //! @todo needs testing + // note: sse function cvttss2si +#if OG_ASM_MSVC + int i; +#if defined(OG_FTOI_USE_SSE) + if( SysInfo::cpu.general.SSE ) { + __asm cvttss2si eax, f + __asm mov i, eax + return i; + } else +#endif + { + __asm fld f + __asm fistp i + //__asm mov eax, i // do we need this ? O_o + } + return i; +#elif OG_ASM_GNU + int i; +#if defined(OG_FTOI_USE_SSE) + if( SysInfo::cpu.general.SSE ) { + __asm__ __volatile__( "cvttss2si %1 \n\t" + : "=m" (i) + : "m" (f) + ); + } else +#endif + { + __asm__ __volatile__( "flds %1 \n\t" + "fistpl %0 \n\t" + : "=m" (i) + : "m" (f) + ); + } + return i; +#else + // we use c++ cast instead of c cast (not sure why id did that) + return static_cast(f); +#endif +} + +/* +================ +Math::FtoiFast +================ +*/ +OG_INLINE int Math::FtoiFast( float f ) { +#if OG_ASM_MSVC + int i; + __asm fld f + __asm fistp i + //__asm mov eax, i // do we need this ? O_o + return i; +#elif OG_ASM_GNU + int i; + __asm__ __volatile__( "flds %1 \n\t" + "fistpl %0 \n\t" + : "=m" (i) + : "m" (f) + ); + return i; +#else + // we use c++ cast instead of c cast (not sure why id did that) + return static_cast(f); +#endif +} + +/* +================ +Math::Ftol +================ +*/ +OG_INLINE long Math::Ftol( float f ) { +#if OG_ASM_MSVC + long i; + __asm fld f + __asm fistp i + //__asm mov eax, i // do we need this ? O_o + return i; +#elif OG_ASM_GNU + long i; + __asm__ __volatile__( "flds %1 \n\t" + "fistpl %0 \n\t" + : "=m" (i) + : "m" (f) + ); + return i; +#else + // we use c++ cast instead of c cast (not sure why id did that) + return static_cast(f); +#endif +} + +/* +================ +Math::Sign +================ +*/ +OG_INLINE float Math::Sign( float f ) { + if ( f > 0.0f ) + return 1.0f; + if ( f < 0.0f ) + return -1.0f; + return 0.0f; +} + +/* +================ +Math::Fmod +================ +*/ +OG_INLINE float Math::Fmod( float numerator, float denominator ) { + return fmodf( numerator, denominator ); +} + +/* +================ +Math::Modf +================ +*/ +OG_INLINE float Math::Modf( float f, float& i ) { + return modff( f, &i ); +} +OG_INLINE float Math::Modf( float f ) { + float i; + return modff( f, &i ); +} + +/* +================ +Math::Sqrt +================ +*/ +OG_INLINE float Math::Sqrt( float f ) { + return sqrtf( f ); +} + +/* +================ +Math::InvSqrt + +Cannot be 0.0f +================ +*/ +OG_INLINE float Math::InvSqrt( float f ) { + OG_ASSERT( f != 0.0f ); + return 1.0f / sqrtf( f ); +} + +/* +================ +Math::RSqrt + +Can be 0.0f +================ +*/ +OG_INLINE float Math::RSqrt( float f ) { + float g = 0.5f * f; + int i = *reinterpret_cast(&f); + + // do a guess + i = 0x5f375a86 - ( i>>1 ); + f = *reinterpret_cast(&i); + + // Newtons calculation + f = f * ( 1.5f - g * f * f ); + return f; +} + +/* +================ +Math::Log/Log2/Log10 + +Log of 0 is bad. +I've also heard you're not really +supposed to do log of negatives, yet +they work fine. +================ +*/ +OG_INLINE float Math::Log( float f ) { + OG_ASSERT( f != 0.0f ); + return logf( f ); +} +OG_INLINE float Math::Log2( float f ) { + OG_ASSERT( f != 0.0f ); + return INV_LN_2 * logf( f ); +} +OG_INLINE float Math::Log10( float f ) { + OG_ASSERT( f != 0.0f ); + return INV_LN_10 * logf( f ); +} + +/* +================ +Math::Pow +================ +*/ +OG_INLINE float Math::Pow( float base, float exp ) { + return powf( base, exp ); +} + +/* +================ +Math::Exp +================ +*/ +OG_INLINE float Math::Exp( float f ) { + return expf( f ); +} + +/* +================ +Math::IsPowerOfTwo +================ +*/ +OG_INLINE bool Math::IsPowerOfTwo( int x ) { + // This is the faster of the two known methods + // with the x > 0 check moved to the beginning + return x > 0 && ( x & ( x - 1 ) ) == 0; +} + +/* +================ +Math::HigherPowerOfTwo +================ +*/ +OG_INLINE int Math::HigherPowerOfTwo( int x ) { + x--; + x |= x >> 1; + x |= x >> 2; + x |= x >> 4; + x |= x >> 8; + x |= x >> 16; + return x + 1; +} + +/* +================ +Math::LowerPowerOfTwo +================ +*/ +OG_INLINE int Math::LowerPowerOfTwo( int x ) { + return HigherPowerOfTwo( x ) >> 1; +} + +/* +================ +Math::FloorPowerOfTwo +================ +*/ +OG_INLINE int Math::FloorPowerOfTwo( int x ) { + return IsPowerOfTwo( x ) ? x : LowerPowerOfTwo( x ); +} + +/* +================ +Math::CeilPowerOfTwo +================ +*/ +OG_INLINE int Math::CeilPowerOfTwo( int x ) { + return IsPowerOfTwo( x ) ? x : HigherPowerOfTwo( x ); +} + +/* +================ +Math::ClosestPowerOfTwo +================ +*/ +OG_INLINE int Math::ClosestPowerOfTwo( int x ) { + if ( IsPowerOfTwo( x ) ) + return x; + int high = HigherPowerOfTwo( x ); + int low = high >> 1; + return ((high-x) < (x-low)) ? high : low; +} + +/* +================ +Math::Digits +================ +*/ +OG_INLINE int Math::Digits( int x ) { + int digits = 1; + int step = 10; + while (step <= x) { + digits++; + step *= 10; + } + return digits; +} + +/* +================ +Math::Sin/ASin +================ +*/ +OG_INLINE float Math::Sin( float f ) { + return sinf( f ); +} +OG_INLINE float Math::ASin( float f ) { + if ( f <= -1.0f ) + return -HALF_PI; + if ( f >= 1.0f ) + return HALF_PI; + return asinf( f ); +} + +/* +================ +Math::Cos/ACos +================ +*/ +OG_INLINE float Math::Cos( float f ) { + return cosf( f ); +} +OG_INLINE float Math::ACos( float f ) { + if ( f <= -1.0f ) + return PI; + if ( f >= 1.0f ) + return 0.0f; + return acosf( f ); +} + +/* +================ +Math::Tan/ATan +================ +*/ +OG_INLINE float Math::Tan( float f ) { + return tanf( f ); +} +OG_INLINE float Math::ATan( float f ) { + return atanf( f ); +} +OG_INLINE float Math::ATan( float f1, float f2 ) { + return atan2f( f1, f2 ); +} + +/* +================ +Math::SinCos +================ +*/ +OG_INLINE void Math::SinCos( float f, float &s, float &c ) { +#if OG_ASM_MSVC + // sometimes assembler is just waaayy faster + _asm { + fld f + fsincos + mov ecx, c + mov edx, s + fstp dword ptr [ecx] + fstp dword ptr [edx] + } +#elif OG_ASM_GNU + asm ("fsincos" : "=t" (c), "=u" (s) : "0" (f)); +#else + s = Sin(f); + c = Sqrt( 1.0f - s * s ); // faster than calling Cos(f) +#endif +} + +/* +================ +Math::Deg2Rad +================ +*/ +OG_INLINE float Math::Deg2Rad( float f ) { + return f * DEG_TO_RAD; +} + +/* +================ +Math::Rad2Deg +================ +*/ +OG_INLINE float Math::Rad2Deg( float f ) { + return f * RAD_TO_DEG; +} + +/* +================ +Math::Square +================ +*/ +OG_INLINE float Math::Square( float v ) { + return v * v; +} + +/* +================ +Math::Cube +================ +*/ +OG_INLINE float Math::Cube( float v ) { + return v * v * v; +} + +/* +================ +Math::Sec2Ms +================ +*/ +OG_INLINE int Math::Sec2Ms( int sec ) { + return sec * 1000; +} + +/* +================ +Math::Ms2Sec +================ +*/ +OG_INLINE int Math::Ms2Sec( int ms ) { + return FtoiFast( ms * 0.001f ); +} + +} + +#endif diff --git a/samples/Dogescript/example.djs b/samples/Dogescript/example.djs new file mode 100644 index 00000000..6903cc5a --- /dev/null +++ b/samples/Dogescript/example.djs @@ -0,0 +1,16 @@ +quiet + wow + such language + very syntax + github recognized wow +loud + +such language much friendly + rly friendly is true + plz console.loge with 'such friend, very inclusive' + but + plz console.loge with 'no love for doge' + wow +wow + +module.exports is language \ No newline at end of file diff --git a/samples/Eagle/Eagle.brd b/samples/Eagle/Eagle.brd new file mode 100644 index 00000000..27f3cbdd --- /dev/null +++ b/samples/Eagle/Eagle.brd @@ -0,0 +1,1396 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<b>Resistors, Capacitors, Inductors</b><p> +Based on the previous libraries: +<ul> +<li>r.lbr +<li>cap.lbr +<li>cap-fe.lbr +<li>captant.lbr +<li>polcap.lbr +<li>ipc-smd.lbr +</ul> +All SMD packages are defined according to the IPC specifications and CECC<p> +<author>Created by librarian@cadsoft.de</author><p> +<p> +for Electrolyt Capacitors see also :<p> +www.bccomponents.com <p> +www.panasonic.com<p> +www.kemet.com<p> +http://www.secc.co.jp/pdf/os_e/2004/e_os_all.pdf <b>(SANYO)</b> +<p> +for trimmer refence see : <u>www.electrospec-inc.com/cross_references/trimpotcrossref.asp</u><p> + +<table border=0 cellspacing=0 cellpadding=0 width="100%" cellpaddding=0> +<tr valign="top"> + +<! <td width="10">&nbsp;</td> +<td width="90%"> + +<b><font color="#0000FF" size="4">TRIM-POT CROSS REFERENCE</font></b> +<P> +<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2> + <TR> + <TD COLSPAN=8> + <FONT SIZE=3 FACE=ARIAL><B>RECTANGULAR MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">BOURNS</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">BI&nbsp;TECH</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">DALE-VISHAY</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">PHILIPS/MEPCO</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">MURATA</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">PANASONIC</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">SPECTROL</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">MILSPEC</FONT> + </B> + </TD><TD>&nbsp;</TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3 > + 3005P<BR> + 3006P<BR> + 3006W<BR> + 3006Y<BR> + 3009P<BR> + 3009W<BR> + 3009Y<BR> + 3057J<BR> + 3057L<BR> + 3057P<BR> + 3057Y<BR> + 3059J<BR> + 3059L<BR> + 3059P<BR> + 3059Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 89P<BR> + 89W<BR> + 89X<BR> + 89PH<BR> + 76P<BR> + 89XH<BR> + 78SLT<BR> + 78L&nbsp;ALT<BR> + 56P&nbsp;ALT<BR> + 78P&nbsp;ALT<BR> + T8S<BR> + 78L<BR> + 56P<BR> + 78P<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + T18/784<BR> + 783<BR> + 781<BR> + -<BR> + -<BR> + -<BR> + 2199<BR> + 1697/1897<BR> + 1680/1880<BR> + 2187<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 8035EKP/CT20/RJ-20P<BR> + -<BR> + RJ-20X<BR> + -<BR> + -<BR> + -<BR> + 1211L<BR> + 8012EKQ&nbsp;ALT<BR> + 8012EKR&nbsp;ALT<BR> + 1211P<BR> + 8012EKJ<BR> + 8012EKL<BR> + 8012EKQ<BR> + 8012EKR<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 2101P<BR> + 2101W<BR> + 2101Y<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 2102L<BR> + 2102S<BR> + 2102Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + EVMCOG<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 43P<BR> + 43W<BR> + 43Y<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 40L<BR> + 40P<BR> + 40Y<BR> + 70Y-T602<BR> + 70L<BR> + 70P<BR> + 70Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + RT/RTR12<BR> + RT/RTR12<BR> + RT/RTR12<BR> + -<BR> + RJ/RJR12<BR> + RJ/RJR12<BR> + RJ/RJR12<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=8>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=8> + <FONT SIZE=4 FACE=ARIAL><B>SQUARE MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3250L<BR> + 3250P<BR> + 3250W<BR> + 3250X<BR> + 3252P<BR> + 3252W<BR> + 3252X<BR> + 3260P<BR> + 3260W<BR> + 3260X<BR> + 3262P<BR> + 3262W<BR> + 3262X<BR> + 3266P<BR> + 3266W<BR> + 3266X<BR> + 3290H<BR> + 3290P<BR> + 3290W<BR> + 3292P<BR> + 3292W<BR> + 3292X<BR> + 3296P<BR> + 3296W<BR> + 3296X<BR> + 3296Y<BR> + 3296Z<BR> + 3299P<BR> + 3299W<BR> + 3299X<BR> + 3299Y<BR> + 3299Z<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66X&nbsp;ALT<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66X&nbsp;ALT<BR> + -<BR> + 64W&nbsp;ALT<BR> + -<BR> + 64P&nbsp;ALT<BR> + 64W&nbsp;ALT<BR> + 64X&nbsp;ALT<BR> + 64P<BR> + 64W<BR> + 64X<BR> + 66X&nbsp;ALT<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66P<BR> + 66W<BR> + 66X<BR> + 67P<BR> + 67W<BR> + 67X<BR> + 67Y<BR> + 67Z<BR> + 68P<BR> + 68W<BR> + 68X<BR> + 67Y&nbsp;ALT<BR> + 67Z&nbsp;ALT<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 5050<BR> + 5091<BR> + 5080<BR> + 5087<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + T63YB<BR> + T63XB<BR> + -<BR> + -<BR> + -<BR> + 5887<BR> + 5891<BR> + 5880<BR> + -<BR> + -<BR> + -<BR> + T93Z<BR> + T93YA<BR> + T93XA<BR> + T93YB<BR> + T93XB<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 8026EKP<BR> + 8026EKW<BR> + 8026EKM<BR> + 8026EKP<BR> + 8026EKB<BR> + 8026EKM<BR> + 1309X<BR> + 1309P<BR> + 1309W<BR> + 8024EKP<BR> + 8024EKW<BR> + 8024EKN<BR> + RJ-9P/CT9P<BR> + RJ-9W<BR> + RJ-9X<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3103P<BR> + 3103Y<BR> + 3103Z<BR> + 3103P<BR> + 3103Y<BR> + 3103Z<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3105P/3106P<BR> + 3105W/3106W<BR> + 3105X/3106X<BR> + 3105Y/3106Y<BR> + 3105Z/3105Z<BR> + 3102P<BR> + 3102W<BR> + 3102X<BR> + 3102Y<BR> + 3102Z<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + EVMCBG<BR> + EVMCCG<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 55-1-X<BR> + 55-4-X<BR> + 55-3-X<BR> + 55-2-X<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 50-2-X<BR> + 50-4-X<BR> + 50-3-X<BR> + -<BR> + -<BR> + -<BR> + 64P<BR> + 64W<BR> + 64X<BR> + 64Y<BR> + 64Z<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + RT/RTR22<BR> + RT/RTR22<BR> + RT/RTR22<BR> + RT/RTR22<BR> + RJ/RJR22<BR> + RJ/RJR22<BR> + RJ/RJR22<BR> + RT/RTR26<BR> + RT/RTR26<BR> + RT/RTR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RT/RTR24<BR> + RT/RTR24<BR> + RT/RTR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=8>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=8> + <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3323P<BR> + 3323S<BR> + 3323W<BR> + 3329H<BR> + 3329P<BR> + 3329W<BR> + 3339H<BR> + 3339P<BR> + 3339W<BR> + 3352E<BR> + 3352H<BR> + 3352K<BR> + 3352P<BR> + 3352T<BR> + 3352V<BR> + 3352W<BR> + 3362H<BR> + 3362M<BR> + 3362P<BR> + 3362R<BR> + 3362S<BR> + 3362U<BR> + 3362W<BR> + 3362X<BR> + 3386B<BR> + 3386C<BR> + 3386F<BR> + 3386H<BR> + 3386K<BR> + 3386M<BR> + 3386P<BR> + 3386S<BR> + 3386W<BR> + 3386X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 25P<BR> + 25S<BR> + 25RX<BR> + 82P<BR> + 82M<BR> + 82PA<BR> + -<BR> + -<BR> + -<BR> + 91E<BR> + 91X<BR> + 91T<BR> + 91B<BR> + 91A<BR> + 91V<BR> + 91W<BR> + 25W<BR> + 25V<BR> + 25P<BR> + -<BR> + 25S<BR> + 25U<BR> + 25RX<BR> + 25X<BR> + 72XW<BR> + 72XL<BR> + 72PM<BR> + 72RX<BR> + -<BR> + 72PX<BR> + 72P<BR> + 72RXW<BR> + 72RXL<BR> + 72X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + T7YB<BR> + T7YA<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + TXD<BR> + TYA<BR> + TYP<BR> + -<BR> + TYD<BR> + TX<BR> + -<BR> + 150SX<BR> + 100SX<BR> + 102T<BR> + 101S<BR> + 190T<BR> + 150TX<BR> + 101<BR> + -<BR> + -<BR> + 101SX<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ET6P<BR> + ET6S<BR> + ET6X<BR> + RJ-6W/8014EMW<BR> + RJ-6P/8014EMP<BR> + RJ-6X/8014EMX<BR> + TM7W<BR> + TM7P<BR> + TM7X<BR> + -<BR> + 8017SMS<BR> + -<BR> + 8017SMB<BR> + 8017SMA<BR> + -<BR> + -<BR> + CT-6W<BR> + CT-6H<BR> + CT-6P<BR> + CT-6R<BR> + -<BR> + CT-6V<BR> + CT-6X<BR> + -<BR> + -<BR> + 8038EKV<BR> + -<BR> + 8038EKX<BR> + -<BR> + -<BR> + 8038EKP<BR> + 8038EKZ<BR> + 8038EKW<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + 3321H<BR> + 3321P<BR> + 3321N<BR> + 1102H<BR> + 1102P<BR> + 1102T<BR> + RVA0911V304A<BR> + -<BR> + RVA0911H413A<BR> + RVG0707V100A<BR> + RVA0607V(H)306A<BR> + RVA1214H213A<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3104B<BR> + 3104C<BR> + 3104F<BR> + 3104H<BR> + -<BR> + 3104M<BR> + 3104P<BR> + 3104S<BR> + 3104W<BR> + 3104X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + EVMQ0G<BR> + EVMQIG<BR> + EVMQ3G<BR> + EVMS0G<BR> + EVMQ0G<BR> + EVMG0G<BR> + -<BR> + -<BR> + -<BR> + EVMK4GA00B<BR> + EVM30GA00B<BR> + EVMK0GA00B<BR> + EVM38GA00B<BR> + EVMB6<BR> + EVLQ0<BR> + -<BR> + EVMMSG<BR> + EVMMBG<BR> + EVMMAG<BR> + -<BR> + -<BR> + EVMMCS<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + EVMM1<BR> + -<BR> + -<BR> + EVMM0<BR> + -<BR> + -<BR> + EVMM3<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + 62-3-1<BR> + 62-1-2<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 67R<BR> + -<BR> + 67P<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 67X<BR> + 63V<BR> + 63S<BR> + 63M<BR> + -<BR> + -<BR> + 63H<BR> + 63P<BR> + -<BR> + -<BR> + 63X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + RJ/RJR50<BR> + RJ/RJR50<BR> + RJ/RJR50<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> +</TABLE> +<P>&nbsp;<P> +<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3> + <TR> + <TD COLSPAN=7> + <FONT color="#0000FF" SIZE=4 FACE=ARIAL><B>SMD TRIM-POT CROSS REFERENCE</B></FONT> + <P> + <FONT SIZE=4 FACE=ARIAL><B>MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3224G<BR> + 3224J<BR> + 3224W<BR> + 3269P<BR> + 3269W<BR> + 3269X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 44G<BR> + 44J<BR> + 44W<BR> + 84P<BR> + 84W<BR> + 84X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + ST63Z<BR> + ST63Y<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + ST5P<BR> + ST5W<BR> + ST5X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=7>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=7> + <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> + </TD> + </TR> + <TR> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3314G<BR> + 3314J<BR> + 3364A/B<BR> + 3364C/D<BR> + 3364W/X<BR> + 3313G<BR> + 3313J<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 23B<BR> + 23A<BR> + 21X<BR> + 21W<BR> + -<BR> + 22B<BR> + 22A<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ST5YL/ST53YL<BR> + ST5YJ/5T53YJ<BR> + ST-23A<BR> + ST-22B<BR> + ST-22<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ST-4B<BR> + ST-4A<BR> + -<BR> + -<BR> + -<BR> + ST-3B<BR> + ST-3A<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + EVM-6YS<BR> + EVM-1E<BR> + EVM-1G<BR> + EVM-1D<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + G4B<BR> + G4A<BR> + TR04-3S1<BR> + TRG04-2S1<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + DVR-43A<BR> + CVR-42C<BR> + CVR-42A/C<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> +</TABLE> +<P> +<FONT SIZE=4 FACE=ARIAL><B>ALT =&nbsp;ALTERNATE</B></FONT> +<P> + +&nbsp; +<P> +</td> +</tr> +</table> + + +<b>RESISTOR</b><p> + + + + + + + + +>NAME +>VALUE + + + + + + + +<b>Pin Header Connectors</b><p> +<author>Created by librarian@cadsoft.de</author> + + +<b>PIN HEADER</b> + + + + + + + + + +>NAME +>VALUE + + + + + + + + + + + + + + +<b>EAGLE Design Rules</b> +<p> +Die Standard-Design-Rules sind so gewählt, dass sie für +die meisten Anwendungen passen. Sollte ihre Platine +besondere Anforderungen haben, treffen Sie die erforderlichen +Einstellungen hier und speichern die Design Rules unter +einem neuen Namen ab. +<b>EAGLE Design Rules</b> +<p> +The default Design Rules have been set to cover +a wide range of applications. Your particular design +may have different requirements, so please make the +necessary adjustments and save your customized +design rules under a new name. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Eagle/Eagle.sch b/samples/Eagle/Eagle.sch new file mode 100644 index 00000000..5a72a868 --- /dev/null +++ b/samples/Eagle/Eagle.sch @@ -0,0 +1,3612 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<b>Frames for Sheet and Layout</b> + + + + + + + + + + + + + + + + + + + + +>DRAWING_NAME +>LAST_DATE_TIME +>SHEET +Sheet: + + + + + +<b>FRAME</b><p> +DIN A4, landscape with location and doc. field + + + + + + + + + + + + + + +<b>Resistors, Capacitors, Inductors</b><p> +Based on the previous libraries: +<ul> +<li>r.lbr +<li>cap.lbr +<li>cap-fe.lbr +<li>captant.lbr +<li>polcap.lbr +<li>ipc-smd.lbr +</ul> +All SMD packages are defined according to the IPC specifications and CECC<p> +<author>Created by librarian@cadsoft.de</author><p> +<p> +for Electrolyt Capacitors see also :<p> +www.bccomponents.com <p> +www.panasonic.com<p> +www.kemet.com<p> +http://www.secc.co.jp/pdf/os_e/2004/e_os_all.pdf <b>(SANYO)</b> +<p> +for trimmer refence see : <u>www.electrospec-inc.com/cross_references/trimpotcrossref.asp</u><p> + +<table border=0 cellspacing=0 cellpadding=0 width="100%" cellpaddding=0> +<tr valign="top"> + +<! <td width="10">&nbsp;</td> +<td width="90%"> + +<b><font color="#0000FF" size="4">TRIM-POT CROSS REFERENCE</font></b> +<P> +<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=2> + <TR> + <TD COLSPAN=8> + <FONT SIZE=3 FACE=ARIAL><B>RECTANGULAR MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">BOURNS</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">BI&nbsp;TECH</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">DALE-VISHAY</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">PHILIPS/MEPCO</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">MURATA</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">PANASONIC</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">SPECTROL</FONT> + </B> + </TD> + <TD ALIGN=CENTER> + <B> + <FONT SIZE=3 FACE=ARIAL color="#FF0000">MILSPEC</FONT> + </B> + </TD><TD>&nbsp;</TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3 > + 3005P<BR> + 3006P<BR> + 3006W<BR> + 3006Y<BR> + 3009P<BR> + 3009W<BR> + 3009Y<BR> + 3057J<BR> + 3057L<BR> + 3057P<BR> + 3057Y<BR> + 3059J<BR> + 3059L<BR> + 3059P<BR> + 3059Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 89P<BR> + 89W<BR> + 89X<BR> + 89PH<BR> + 76P<BR> + 89XH<BR> + 78SLT<BR> + 78L&nbsp;ALT<BR> + 56P&nbsp;ALT<BR> + 78P&nbsp;ALT<BR> + T8S<BR> + 78L<BR> + 56P<BR> + 78P<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + T18/784<BR> + 783<BR> + 781<BR> + -<BR> + -<BR> + -<BR> + 2199<BR> + 1697/1897<BR> + 1680/1880<BR> + 2187<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 8035EKP/CT20/RJ-20P<BR> + -<BR> + RJ-20X<BR> + -<BR> + -<BR> + -<BR> + 1211L<BR> + 8012EKQ&nbsp;ALT<BR> + 8012EKR&nbsp;ALT<BR> + 1211P<BR> + 8012EKJ<BR> + 8012EKL<BR> + 8012EKQ<BR> + 8012EKR<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 2101P<BR> + 2101W<BR> + 2101Y<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 2102L<BR> + 2102S<BR> + 2102Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + EVMCOG<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 43P<BR> + 43W<BR> + 43Y<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 40L<BR> + 40P<BR> + 40Y<BR> + 70Y-T602<BR> + 70L<BR> + 70P<BR> + 70Y<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + RT/RTR12<BR> + RT/RTR12<BR> + RT/RTR12<BR> + -<BR> + RJ/RJR12<BR> + RJ/RJR12<BR> + RJ/RJR12<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=8>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=8> + <FONT SIZE=4 FACE=ARIAL><B>SQUARE MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3250L<BR> + 3250P<BR> + 3250W<BR> + 3250X<BR> + 3252P<BR> + 3252W<BR> + 3252X<BR> + 3260P<BR> + 3260W<BR> + 3260X<BR> + 3262P<BR> + 3262W<BR> + 3262X<BR> + 3266P<BR> + 3266W<BR> + 3266X<BR> + 3290H<BR> + 3290P<BR> + 3290W<BR> + 3292P<BR> + 3292W<BR> + 3292X<BR> + 3296P<BR> + 3296W<BR> + 3296X<BR> + 3296Y<BR> + 3296Z<BR> + 3299P<BR> + 3299W<BR> + 3299X<BR> + 3299Y<BR> + 3299Z<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66X&nbsp;ALT<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66X&nbsp;ALT<BR> + -<BR> + 64W&nbsp;ALT<BR> + -<BR> + 64P&nbsp;ALT<BR> + 64W&nbsp;ALT<BR> + 64X&nbsp;ALT<BR> + 64P<BR> + 64W<BR> + 64X<BR> + 66X&nbsp;ALT<BR> + 66P&nbsp;ALT<BR> + 66W&nbsp;ALT<BR> + 66P<BR> + 66W<BR> + 66X<BR> + 67P<BR> + 67W<BR> + 67X<BR> + 67Y<BR> + 67Z<BR> + 68P<BR> + 68W<BR> + 68X<BR> + 67Y&nbsp;ALT<BR> + 67Z&nbsp;ALT<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 5050<BR> + 5091<BR> + 5080<BR> + 5087<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + T63YB<BR> + T63XB<BR> + -<BR> + -<BR> + -<BR> + 5887<BR> + 5891<BR> + 5880<BR> + -<BR> + -<BR> + -<BR> + T93Z<BR> + T93YA<BR> + T93XA<BR> + T93YB<BR> + T93XB<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 8026EKP<BR> + 8026EKW<BR> + 8026EKM<BR> + 8026EKP<BR> + 8026EKB<BR> + 8026EKM<BR> + 1309X<BR> + 1309P<BR> + 1309W<BR> + 8024EKP<BR> + 8024EKW<BR> + 8024EKN<BR> + RJ-9P/CT9P<BR> + RJ-9W<BR> + RJ-9X<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3103P<BR> + 3103Y<BR> + 3103Z<BR> + 3103P<BR> + 3103Y<BR> + 3103Z<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3105P/3106P<BR> + 3105W/3106W<BR> + 3105X/3106X<BR> + 3105Y/3106Y<BR> + 3105Z/3105Z<BR> + 3102P<BR> + 3102W<BR> + 3102X<BR> + 3102Y<BR> + 3102Z<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + EVMCBG<BR> + EVMCCG<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 55-1-X<BR> + 55-4-X<BR> + 55-3-X<BR> + 55-2-X<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 50-2-X<BR> + 50-4-X<BR> + 50-3-X<BR> + -<BR> + -<BR> + -<BR> + 64P<BR> + 64W<BR> + 64X<BR> + 64Y<BR> + 64Z<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + RT/RTR22<BR> + RT/RTR22<BR> + RT/RTR22<BR> + RT/RTR22<BR> + RJ/RJR22<BR> + RJ/RJR22<BR> + RJ/RJR22<BR> + RT/RTR26<BR> + RT/RTR26<BR> + RT/RTR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RJ/RJR26<BR> + RT/RTR24<BR> + RT/RTR24<BR> + RT/RTR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + RJ/RJR24<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=8>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=8> + <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> + </TD> + </TR> + <TR> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BOURN</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MURATA</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>SPECTROL</B></FONT> + </TD> + <TD ALIGN=CENTER> + <FONT SIZE=3 FACE=ARIAL><B>MILSPEC</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3323P<BR> + 3323S<BR> + 3323W<BR> + 3329H<BR> + 3329P<BR> + 3329W<BR> + 3339H<BR> + 3339P<BR> + 3339W<BR> + 3352E<BR> + 3352H<BR> + 3352K<BR> + 3352P<BR> + 3352T<BR> + 3352V<BR> + 3352W<BR> + 3362H<BR> + 3362M<BR> + 3362P<BR> + 3362R<BR> + 3362S<BR> + 3362U<BR> + 3362W<BR> + 3362X<BR> + 3386B<BR> + 3386C<BR> + 3386F<BR> + 3386H<BR> + 3386K<BR> + 3386M<BR> + 3386P<BR> + 3386S<BR> + 3386W<BR> + 3386X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 25P<BR> + 25S<BR> + 25RX<BR> + 82P<BR> + 82M<BR> + 82PA<BR> + -<BR> + -<BR> + -<BR> + 91E<BR> + 91X<BR> + 91T<BR> + 91B<BR> + 91A<BR> + 91V<BR> + 91W<BR> + 25W<BR> + 25V<BR> + 25P<BR> + -<BR> + 25S<BR> + 25U<BR> + 25RX<BR> + 25X<BR> + 72XW<BR> + 72XL<BR> + 72PM<BR> + 72RX<BR> + -<BR> + 72PX<BR> + 72P<BR> + 72RXW<BR> + 72RXL<BR> + 72X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + T7YB<BR> + T7YA<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + TXD<BR> + TYA<BR> + TYP<BR> + -<BR> + TYD<BR> + TX<BR> + -<BR> + 150SX<BR> + 100SX<BR> + 102T<BR> + 101S<BR> + 190T<BR> + 150TX<BR> + 101<BR> + -<BR> + -<BR> + 101SX<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ET6P<BR> + ET6S<BR> + ET6X<BR> + RJ-6W/8014EMW<BR> + RJ-6P/8014EMP<BR> + RJ-6X/8014EMX<BR> + TM7W<BR> + TM7P<BR> + TM7X<BR> + -<BR> + 8017SMS<BR> + -<BR> + 8017SMB<BR> + 8017SMA<BR> + -<BR> + -<BR> + CT-6W<BR> + CT-6H<BR> + CT-6P<BR> + CT-6R<BR> + -<BR> + CT-6V<BR> + CT-6X<BR> + -<BR> + -<BR> + 8038EKV<BR> + -<BR> + 8038EKX<BR> + -<BR> + -<BR> + 8038EKP<BR> + 8038EKZ<BR> + 8038EKW<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + 3321H<BR> + 3321P<BR> + 3321N<BR> + 1102H<BR> + 1102P<BR> + 1102T<BR> + RVA0911V304A<BR> + -<BR> + RVA0911H413A<BR> + RVG0707V100A<BR> + RVA0607V(H)306A<BR> + RVA1214H213A<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 3104B<BR> + 3104C<BR> + 3104F<BR> + 3104H<BR> + -<BR> + 3104M<BR> + 3104P<BR> + 3104S<BR> + 3104W<BR> + 3104X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + EVMQ0G<BR> + EVMQIG<BR> + EVMQ3G<BR> + EVMS0G<BR> + EVMQ0G<BR> + EVMG0G<BR> + -<BR> + -<BR> + -<BR> + EVMK4GA00B<BR> + EVM30GA00B<BR> + EVMK0GA00B<BR> + EVM38GA00B<BR> + EVMB6<BR> + EVLQ0<BR> + -<BR> + EVMMSG<BR> + EVMMBG<BR> + EVMMAG<BR> + -<BR> + -<BR> + EVMMCS<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + EVMM1<BR> + -<BR> + -<BR> + EVMM0<BR> + -<BR> + -<BR> + EVMM3<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + 62-3-1<BR> + 62-1-2<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 67R<BR> + -<BR> + 67P<BR> + -<BR> + -<BR> + -<BR> + -<BR> + 67X<BR> + 63V<BR> + 63S<BR> + 63M<BR> + -<BR> + -<BR> + 63H<BR> + 63P<BR> + -<BR> + -<BR> + 63X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + RJ/RJR50<BR> + RJ/RJR50<BR> + RJ/RJR50<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> +</TABLE> +<P>&nbsp;<P> +<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3> + <TR> + <TD COLSPAN=7> + <FONT color="#0000FF" SIZE=4 FACE=ARIAL><B>SMD TRIM-POT CROSS REFERENCE</B></FONT> + <P> + <FONT SIZE=4 FACE=ARIAL><B>MULTI-TURN</B></FONT> + </TD> + </TR> + <TR> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3224G<BR> + 3224J<BR> + 3224W<BR> + 3269P<BR> + 3269W<BR> + 3269X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 44G<BR> + 44J<BR> + 44W<BR> + 84P<BR> + 84W<BR> + 84X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + ST63Z<BR> + ST63Y<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + ST5P<BR> + ST5W<BR> + ST5X<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> + <TR> + <TD COLSPAN=7>&nbsp; + </TD> + </TR> + <TR> + <TD COLSPAN=7> + <FONT SIZE=4 FACE=ARIAL><B>SINGLE TURN</B></FONT> + </TD> + </TR> + <TR> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BOURNS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>BI&nbsp;TECH</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>DALE-VISHAY</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PHILIPS/MEPCO</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>PANASONIC</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>TOCOS</B></FONT> + </TD> + <TD> + <FONT SIZE=3 FACE=ARIAL><B>AUX/KYOCERA</B></FONT> + </TD> + </TR> + <TR> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 3314G<BR> + 3314J<BR> + 3364A/B<BR> + 3364C/D<BR> + 3364W/X<BR> + 3313G<BR> + 3313J<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + 23B<BR> + 23A<BR> + 21X<BR> + 21W<BR> + -<BR> + 22B<BR> + 22A<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ST5YL/ST53YL<BR> + ST5YJ/5T53YJ<BR> + ST-23A<BR> + ST-22B<BR> + ST-22<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + ST-4B<BR> + ST-4A<BR> + -<BR> + -<BR> + -<BR> + ST-3B<BR> + ST-3A<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + EVM-6YS<BR> + EVM-1E<BR> + EVM-1G<BR> + EVM-1D<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + G4B<BR> + G4A<BR> + TR04-3S1<BR> + TRG04-2S1<BR> + -<BR> + -<BR> + -<BR></FONT> + </TD> + <TD BGCOLOR="#cccccc" ALIGN=CENTER><FONT FACE=ARIAL SIZE=3> + -<BR> + -<BR> + DVR-43A<BR> + CVR-42C<BR> + CVR-42A/C<BR> + -<BR> + -<BR></FONT> + </TD> + </TR> +</TABLE> +<P> +<FONT SIZE=4 FACE=ARIAL><B>ALT =&nbsp;ALTERNATE</B></FONT> +<P> + +&nbsp; +<P> +</td> +</tr> +</table> + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> wave soldering<p> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +wave soldering + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +Source: http://download.siliconexpert.com/pdfs/2005/02/24/Semi_Ap/2/VSH/Resistor/dcrcwfre.pdf + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> wave soldering<p> +Source: http://download.siliconexpert.com/pdfs/2005/02/24/Semi_Ap/2/VSH/Resistor/dcrcwfre.pdf + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.10 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.25 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.12 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.10 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.25 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.25 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.12 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +MELF 0.25 W + + + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b><p> +type 0204, grid 5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0204, grid 7.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0207, grid 10 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0207, grid 12 mm + + + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + + + +<b>RESISTOR</b><p> +type 0207, grid 15mm + + + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + + + +<b>RESISTOR</b><p> +type 0207, grid 2.5 mm + + + + + + + +>NAME +>VALUE + + +<b>RESISTOR</b><p> +type 0207, grid 5 mm + + + + + + + +>NAME +>VALUE + + +<b>RESISTOR</b><p> +type 0207, grid 7.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0309, grid 10mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0309, grid 12.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0411, grid 12.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0411, grid 15 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0411, grid 3.81 mm + + + + + + +>NAME +>VALUE + + + +<b>RESISTOR</b><p> +type 0414, grid 15 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0414, grid 5 mm + + + + + + +>NAME +>VALUE + + + +<b>RESISTOR</b><p> +type 0617, grid 17.5 mm + + + + + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0617, grid 22.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0617, grid 5 mm + + + + + + +>NAME +>VALUE + + + +<b>RESISTOR</b><p> +type 0922, grid 22.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + + + +<b>RESISTOR</b><p> +type 0613, grid 5 mm + + + + + + +>NAME +>VALUE + + + +<b>RESISTOR</b><p> +type 0613, grid 15 mm + + + + + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type 0817, grid 22.5 mm + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE +0817 + + + + +<b>RESISTOR</b><p> +type 0817, grid 6.35 mm + + + + + + +>NAME +>VALUE +0817 + + + +<b>RESISTOR</b><p> +type V234, grid 12.5 mm + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type V235, grid 17.78 mm + + + + + + + + + + + + +>NAME +>VALUE + + + + +<b>RESISTOR</b><p> +type V526-0, grid 2.5 mm + + + + + + + + + + +>NAME +>VALUE + + +<b>Mini MELF 0102 Axial</b> + + + + +>NAME +>VALUE + + + +<b>RESISTOR</b><p> +type 0922, grid 7.5 mm + + + + + + +>NAME +>VALUE +0922 + + + +<b>CECC Size RC2211</b> Reflow Soldering<p> +source Beyschlag + + + + + + +>NAME +>VALUE + + +<b>CECC Size RC2211</b> Wave Soldering<p> +source Beyschlag + + + + + + +>NAME +>VALUE + + +<b>CECC Size RC3715</b> Reflow Soldering<p> +source Beyschlag + + + + + + + + +>NAME +>VALUE + + +<b>CECC Size RC3715</b> Wave Soldering<p> +source Beyschlag + + + + + + + + +>NAME +>VALUE + + +<b>CECC Size RC6123</b> Reflow Soldering<p> +source Beyschlag + + + + + + + + +>NAME +>VALUE + + +<b>CECC Size RC6123</b> Wave Soldering<p> +source Beyschlag + + + + + + + + +>NAME +>VALUE + + +<b>RESISTOR</b><p> +type RDH, grid 15 mm + + + + + + + + + + + + + + + + + + + + + + + + +>NAME +>VALUE +RDH + + + + +<b>RESISTOR</b><p> +type 0204, grid 2.5 mm + + + + + + +>NAME +>VALUE + + +<b>RESISTOR</b><p> +type 0309, grid 2.5 mm + + + + + + +>NAME +>VALUE + + + + + +<b>RESISTOR</b> chip<p> +Source: http://www.vishay.com/docs/20008/dcrcw.pdf + + +>NAME +>VALUE + + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RNC55<br> +Source: VISHAY .. vta56.pdf + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RNC60<br> +Source: VISHAY .. vta56.pdf + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RBR52<br> +Source: VISHAY .. vta56.pdf + + + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RBR53<br> +Source: VISHAY .. vta56.pdf + + + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RBR54<br> +Source: VISHAY .. vta56.pdf + + + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RBR55<br> +Source: VISHAY .. vta56.pdf + + + + + + + + + + +>NAME +>VALUE + + + + +<b>Bulk Metal® Foil Technology</b>, Tubular Axial Lead Resistors, Meets or Exceeds MIL-R-39005 Requirements<p> +MIL SIZE RBR56<br> +Source: VISHAY .. vta56.pdf + + + + + + + + + + +>NAME +>VALUE + + + + +<b>Package 4527</b><p> +Source: http://www.vishay.com/docs/31059/wsrhigh.pdf + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + +>NAME +>VALUE + + +<b>Wirewound Resistors, Precision Power</b><p> +Source: VISHAY wscwsn.pdf + + + + + + +>NAME +>VALUE + + +<b>CRCW1218 Thick Film, Rectangular Chip Resistors</b><p> +Source: http://www.vishay.com .. dcrcw.pdf + + + + +>NAME +>VALUE + + + + +<b>Chip Monolithic Ceramic Capacitors</b> Medium Voltage High Capacitance for General Use<p> +Source: http://www.murata.com .. GRM43DR72E224KW01.pdf + + + + + + +>NAME +>VALUE + + + + + + + + + + + + + + + +>NAME +>VALUE + + + + + + +<B>RESISTOR</B>, American symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<b>Pin Header Connectors</b><p> +<author>Created by librarian@cadsoft.de</author> + + +<b>PIN HEADER</b> + + + + + + + + + +>NAME +>VALUE + + + + + + + + + +>NAME +>VALUE + + + + + +<b>PIN HEADER</b> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/Frege/CommandLineClock.fr b/samples/Frege/CommandLineClock.fr new file mode 100644 index 00000000..5bdde621 --- /dev/null +++ b/samples/Frege/CommandLineClock.fr @@ -0,0 +1,44 @@ +{-- + This program displays the + current time on stdandard output + every other second. + -} + +module examples.CommandLineClock where + +data Date = native java.util.Date where + native new :: () -> IO (MutableIO Date) -- new Date() + native toString :: Mutable s Date -> ST s String -- d.toString() + +--- 'IO' action to give us the current time as 'String' +current :: IO String +current = do + d <- Date.new () + d.toString + +{- + "java.lang.Thread.sleep" takes a "long" and + returns nothing, but may throw an InterruptedException. + This is without doubt an IO action. + + public static void sleep(long millis) + throws InterruptedException + + Encoded in Frege: + - argument type long Long + - result void () + - does IO IO () + - throws ... throws .... + +-} +-- .... defined in frege.java.Lang +-- native sleep java.lang.Thread.sleep :: Long -> IO () throws InterruptedException + + +main args = + forever do + current >>= print + print "\r" + stdout.flush + Thread.sleep 999 + \ No newline at end of file diff --git a/samples/Frege/Concurrent.fr b/samples/Frege/Concurrent.fr new file mode 100644 index 00000000..5f9df994 --- /dev/null +++ b/samples/Frege/Concurrent.fr @@ -0,0 +1,147 @@ +module examples.Concurrent where + +import System.Random +import Java.Net (URL) +import Control.Concurrent as C + +main2 args = do + m <- newEmptyMVar + forkIO do + m.put 'x' + m.put 'y' + m.put 'z' + replicateM_ 3 do + c <- m.take + print "got: " + println c + + +example1 = do + forkIO (replicateM_ 100000 (putChar 'a')) + replicateM_ 100000 (putChar 'b') + +example2 = do + s <- getLine + case s.long of + Right n -> forkIO (setReminder n) >> example2 + Left _ -> println ("exiting ...") + +setReminder :: Long -> IO () +setReminder n = do + println ("Ok, I remind you in " ++ show n ++ " seconds") + Thread.sleep (1000L*n) + println (show n ++ " seconds is up!") + +table = "table" + +mainPhil _ = do + [fork1,fork2,fork3,fork4,fork5] <- mapM MVar.new [1..5] + forkIO (philosopher "Kant" fork5 fork1) + forkIO (philosopher "Locke" fork1 fork2) + forkIO (philosopher "Wittgenstein" fork2 fork3) + forkIO (philosopher "Nozick" fork3 fork4) + forkIO (philosopher "Mises" fork4 fork5) + return () + +philosopher :: String -> MVar Int -> MVar Int -> IO () +philosopher me left right = do + g <- Random.newStdGen + let phil g = do + let (tT,g1) = Random.randomR (60L, 120L) g + (eT, g2) = Random.randomR (80L, 160L) g1 + thinkTime = 300L * tT + eatTime = 300L * eT + + println(me ++ " is going to the dining room and takes his seat.") + fl <- left.take + println (me ++ " takes up left fork (" ++ show fl ++ ")") + rFork <- right.poll + case rFork of + Just fr -> do + println (me ++ " takes up right fork. (" ++ show fr ++ ")") + println (me ++ " is going to eat for " ++ show eatTime ++ "ms") + Thread.sleep eatTime + println (me ++ " finished eating.") + right.put fr + println (me ++ " took down right fork.") + left.put fl + println (me ++ " took down left fork.") + table.notifyAll + println(me ++ " is going to think for " ++ show thinkTime ++ "ms.") + Thread.sleep thinkTime + phil g2 + Nothing -> do + println (me ++ " finds right fork is already in use.") + left.put fl + println (me ++ " took down left fork.") + table.notifyAll + println (me ++ " is going to the bar to await notifications from table.") + table.wait + println (me ++ " got notice that something changed at the table.") + phil g2 + + inter :: InterruptedException -> IO () + inter _ = return () + + phil g `catch` inter + + +getURL xx = do + url <- URL.new xx + con <- url.openConnection + con.connect + is <- con.getInputStream + typ <- con.getContentType + -- stderr.println ("content-type is " ++ show typ) + ir <- InputStreamReader.new is (fromMaybe "UTF-8" (charset typ)) + `catch` unsupportedEncoding is + br <- BufferedReader.new ir + br.getLines + where + unsupportedEncoding :: InputStream -> UnsupportedEncodingException -> IO InputStreamReader + unsupportedEncoding is x = do + stderr.println x.catched + InputStreamReader.new is "UTF-8" + + charset ctyp = do + typ <- ctyp + case typ of + m~´charset=(\S+)´ -> m.group 1 + _ -> Nothing + + +type SomeException = Throwable + +main ["dining"] = mainPhil [] + +main _ = do + m1 <- MVar.newEmpty + m2 <- MVar.newEmpty + m3 <- MVar.newEmpty + + forkIO do + r <- (catchAll . getURL) "http://www.wikipedia.org/wiki/Haskell" + m1.put r + + forkIO do + r <- (catchAll . getURL) "htto://www.wikipedia.org/wiki/Java" + m2.put r + + forkIO do + r <- (catchAll . getURL) "http://www.wikipedia.org/wiki/Frege" + m3.put r + + r1 <- m1.take + r2 <- m2.take + r3 <- m3.take + println (result r1, result r2, result r3) + -- case r3 of + -- Right ss -> mapM_ putStrLn ss + -- Left _ -> return () + where + result :: (SomeException|[String]) -> (String|Int) + result (Left x) = Left x.getClass.getName + result (Right y) = (Right . sum . map length) y + -- mapM_ putStrLn r2 + + \ No newline at end of file diff --git a/samples/Frege/Sudoku.fr b/samples/Frege/Sudoku.fr new file mode 100644 index 00000000..88bfd966 --- /dev/null +++ b/samples/Frege/Sudoku.fr @@ -0,0 +1,561 @@ +package examples.Sudoku where + +import Data.TreeMap (Tree, keys) +import Data.List as DL hiding (find, union) + + +type Element = Int -- 1,2,3,4,5,6,7,8,9 +type Zelle = [Element] -- set of candidates +type Position = Int -- 0..80 +type Feld = (Position, Zelle) +type Brett = [Feld] + +--- data type for assumptions and conclusions +data Assumption = + !ISNOT Position Element + | !IS Position Element + + +derive Eq Assumption +derive Ord Assumption +instance Show Assumption where + show (IS p e) = pname p ++ "=" ++ e.show + show (ISNOT p e) = pname p ++ "/" ++ e.show + +showcs cs = joined " " (map Assumption.show cs) + +elements :: [Element] -- all possible elements +elements = [1 .. 9] + +{- + a b c d e f g h i + 0 1 2 | 3 4 5 | 6 7 8 1 + 9 10 11 |12 13 14 |15 16 17 2 + 18 19 20 |21 22 23 |24 25 26 3 + ---------|---------|-------- + 27 28 29 |30 31 32 |33 34 35 4 + 36 37 38 |39 40 41 |42 43 44 5 + 45 46 47 |48 49 50 |51 52 53 6 + ---------|---------|-------- + 54 55 56 |57 58 59 |60 61 62 7 + 63 64 65 |66 67 68 |69 70 71 8 + 72 73 74 |75 76 77 |78 79 80 9 +-} + +positions :: [Position] -- all possible positions +positions = [0..80] +rowstarts :: [Position] -- all positions where a row is starting +rowstarts = [0,9,18,27,36,45,54,63,72] +colstarts :: [Position] -- all positions where a column is starting +colstarts = [0,1,2,3,4,5,6,7,8] +boxstarts :: [Position] -- all positions where a box is starting +boxstarts = [0,3,6,27,30,33,54,57,60] +boxmuster :: [Position] -- pattern for a box, by adding upper left position results in real box +boxmuster = [0,1,2,9,10,11,18,19,20] + + +--- extract field for position +getf :: Brett -> Position -> Feld +getf (f:fs) p + | fst f == p = f + | otherwise = getf fs p +getf [] p = (p,[]) + + +--- extract cell for position +getc :: Brett -> Position -> Zelle +getc b p = snd (getf b p) + +--- compute the list of all positions that belong to the same row as a given position +row :: Position -> [Position] +row p = [z..(z+8)] where z = (p `quot` 9) * 9 + +--- compute the list of all positions that belong to the same col as a given position +col :: Position -> [Position] +col p = map (c+) rowstarts where c = p `mod` 9 + +--- compute the list of all positions that belong to the same box as a given position +box :: Position -> [Position] +box p = map (z+) boxmuster where + ri = p `div` 27 * 27 -- 0, 27 or 54, depending on row + ci = p `mod` 9 -- column index 0..8, 0,1,2 is left, 3,4,5 is middle, 6,7,8 is right + cs = ci `div` 3 * 3 -- 0, 3 or 6 + z = ri + cs + +--- check if candidate set has exactly one member, i.e. field has been solved +single :: Zelle -> Bool +single [_] = true +single _ = false + +unsolved :: Zelle -> Bool +unsolved [_] = false +unsolved _ = true + +-- list of rows, cols, boxes +allrows = map row rowstarts +allcols = map col colstarts +allboxs = map box boxstarts +allrcb = zip (repeat "row") allrows + ++ zip (repeat "col") allcols + ++ zip (repeat "box") allboxs + + +containers :: [(Position -> [Position], String)] +containers = [(row, "row"), (col, "col"), (box, "box")] + +-- ----------------- PRINTING ------------------------------------ +-- printable coordinate of field, upper left is a1, lower right is i9 +pname p = packed [chr (ord 'a' + p `mod` 9), chr (ord '1' + p `div` 9)] + +-- print board +printb b = mapM_ p1line allrows >> println "" + where + p1line row = do + print (joined "" (map pfld line)) + where line = map (getc b) row + +-- print field (brief) +-- ? = no candidate +-- 5 = field is 5 +-- . = some candidates +pfld [] = "?" +pfld [x] = show x +pfld zs = "0" + +-- print initial/final board +result msg b = do + println ("Result: " ++ msg) + print ("Board: ") + printb b + return b + +res012 b = case concatMap (getc b) [0,1,2] of + [a,b,c] -> a*100+b*10+c + _ -> 9999999 + +-- -------------------------- BOARD ALTERATION ACTIONS --------------------------------- +-- print a message about what is done to the board and return the new board +turnoff1 :: Position -> Zelle -> Brett -> IO Brett +turnoff1 i off b + | single nc = do + -- print (pname i) + -- print ": set to " + -- print (head nc) + -- println " (naked single)" + return newb + | otherwise = return newb + where + cell = getc b i + nc = filter (`notElem` off) cell + newb = (i, nc) : [ f | f <- b, fst f != i ] + +turnoff :: Int -> Zelle -> String -> Brett -> IO Brett +turnoff i off msg b = do + -- print (pname i) + -- print ": set to " + -- print nc + -- print " by clearing " + -- print off + -- print " " + -- println msg + return newb + where + cell = getc b i + nc = filter (`notElem` off) cell + newb = (i, nc) : [ f | f <- b, fst f != i ] + +turnoffh ps off msg b = foldM toh b ps + where + toh b p = turnoff p off msg b + +setto :: Position -> Element -> String -> Brett -> IO Brett +setto i n cname b = do + -- print (pname i) + -- print ": set to " + -- print n + -- print " (hidden single in " + -- print cname + -- println ")" + return newb + where + nf = [n] + newb = (i, nf) : [ f | f <- b, fst f != i ] + + +-- ----------------------------- SOLVING STRATEGIES --------------------------------------------- +-- reduce candidate sets that contains numbers already in same row, col or box +-- This finds (and logs) NAKED SINGLEs in passing. +reduce b = [ turnoff1 p sss | (p,cell) <- b, -- for each field + unsolved cell, -- with more than 1 candidate + -- single fields in containers that are candidates of that field + sss = [ s | (rcb, _) <- containers, [s] <- map (getc b) (rcb p), s `elem` cell], + sss != [] ] -- collect field index, elements to remove from candidate set + +-- look for a number that appears in exactly 1 candidate set of a container +-- this number can go in no other place (HIDDEN SINGLE) +hiddenSingle b = [ setto i n cname | -- select index, number, containername + (cname, rcb) <- allrcb, -- FOR rcb IN allrcb + n <- elements, -- FOR n IN elements + fs = filter (unsolved • snd) (map (getf b) rcb), + occurs = filter ((n `elem`) • snd) fs, + length occurs == 1, + (i, _) <- occurs ] + +-- look for NAKED PAIRS, TRIPLES, QUADS +nakedPair n b = [ turnoff p t ("(naked tuple in " ++ nm ++ ")") | -- SELECT pos, tuple, name + -- n <- [2,3,4], // FOR n IN [2,3,4] + (nm, rcb) <- allrcb, -- FOR rcb IN containers + fs = map (getf b) rcb, -- let fs = fields for rcb positions + u = (fold union [] . filter unsolved . map snd) fs, -- let u = union of non single candidates + t <- n `outof` u, -- FOR t IN n-tuples + hit = (filter ((`subset` t) . snd) . filter (unsolved . snd)) fs, + length hit == n, + (p, cell) <- fs, + p `notElem` map fst hit, + any (`elem` cell) t + ] + +-- look for HIDDEN PAIRS, TRIPLES or QUADS +hiddenPair n b = [ turnoff p off ("(hidden " ++ show t ++ " in " ++ nm ++ ")") | -- SELECT pos, tuple, name + -- n <- [2,3,4], // FOR n IN [2,3,4] + (nm, rcb) <- allrcb, -- FOR rcb IN containers + fs = map (getf b) rcb, -- let fs = fields for rcb positions + u = (fold union [] . filter ((>1) . length) . map snd) fs, -- let u = union of non single candidates + t <- n `outof` u, -- FOR t IN n-tuples + hit = (filter (any ( `elem` t) . snd) . filter (unsolved . snd)) fs, + length hit == n, + off = (fold union [] . map snd) hit `minus` t, + off != [], + (p, cell) <- hit, + ! (cell `subset` t) + ] + +a `subset` b = all (`elem` b) a +a `union` b = uniq (sort (a ++ b)) +a `minus` b = filter (`notElem` b) a +a `common` b = filter (`elem` b) a +n `outof` as + | length as < n = [] + | [] <- as = [] + | 1 >= n = map (:[]) as + | (a:bs) <- as = map (a:) ((n-1) `outof` bs) ++ (n `outof` bs) + | otherwise = undefined -- cannot happen because either as is empty or not + +same f a b = b `elem` f a + +intersectionlist = [(allboxs, row, "box/row intersection"), (allboxs, col, "box/col intersection"), + (allrows ++ allcols, box, "line/box intersection")] +intersections b = [ + turnoff pos [c] reason | -- SELECT position, candidate, reson + (from, container, reason) <- intersectionlist, + rcb <- from, + fs = (filter (unsolved . snd) . map (getf b)) rcb, -- fs = fields in from with more than 1 candidate + c <- (fold union [] • map snd) fs, -- FOR c IN union of candidates + cpos = (map fst • filter ((c `elem`) • snd)) fs, -- cpos = positions where c occurs + cpos != [], -- WHERE cpos is not empty + all (same container (head cpos)) (tail cpos), -- WHERE all positions are in the intersection + -- we can remove all occurences of c that are in container, but not in from + (pos, cell) <- map (getf b) (container (head cpos)), + c `elem` cell, + pos `notElem` rcb ] + + +-- look for an XY Wing +-- - there exists a cell A with candidates X and Y +-- - there exists a cell B with candidates X and Z that shares a container with A +-- - there exists a cell C with candidates Y and Z that shares a container with A +-- reasoning +-- - if A is X, B will be Z +-- - if A is Y, C will be Z +-- - since A will indeed be X or Y -> B or C will be Z +-- - thus, no cell that can see B and C can be Z +xyWing board = [ turnoff p [z] ("xy wing " ++ pname b ++ " " ++ pname c ++ " because of " ++ pname a) | + (a, [x,y]) <- board, -- there exists a cell a with candidates x and y + rcba = map (getf board) (row a ++ col a ++ box a), -- rcba = all fields that share a container with a + (b, [b1, b2]) <- rcba, + b != a, + b1 == x && b2 != y || b2 == x && b1 != y, -- there exists a cell B with candidates x and z + z = if b1 == x then b2 else b1, + (c, [c1, c2]) <- rcba, + c != a, c!= b, + c1 == y && c2 == z || c1 == z && c2 == y, -- there exists a cell C with candidates y and z + ps = (uniq . sort) ((row b ++ col b ++ box b) `common` (row c ++ col c ++ box c)), + -- remove z in ps + (p, cs) <- map (getf board) ps, + p != b, p != c, + z `elem` cs ] + +-- look for a N-Fish (2: X-Wing, 3: Swordfish, 4: Jellyfish) +-- When all candidates for a particular digit in N rows are located +-- in only N columns, we can eliminate all candidates from those N columns +-- which are not located on those N rows +fish n board = fish "row" allrows row col ++ fish "col" allcols col row where + fishname 2 = "X-Wing" + fishname 3 = "Swordfish" + fishname 4 = "Jellyfish" + fishname _ = "unknown fish" + fish nm allrows row col = [ turnoff p [x] (fishname n ++ " in " ++ nm ++ " " ++ show (map (pname . head) rset)) | + rset <- n `outof` allrows, -- take n rows (or cols) + x <- elements, -- look for certain number + rflds = map (filter ((>1) . length . snd) . map (getf board)) rset, -- unsolved fields in the rowset + colss = (map (map (head . col . fst) . filter ((x `elem`) . snd)) rflds), -- where x occurs in candidates + all ((>1) . length) colss, -- x must appear in at least 2 cols + cols = fold union [] colss, + length cols == n, + cstart <- cols, + (p, cell) <- map (getf board) (col cstart), + x `elem` cell, + all (p `notElem`) rset] + + +-- compute immediate consequences of an assumption of the form (p `IS` e) or (p `ISNOT` e) +conseq board (IS p e) = uniq (sort ([ p `ISNOT` x | x <- getc board p, x != e ] ++ + [ a `ISNOT` e | + (a,cs) <- map (getf board) (row p ++ col p ++ box p), + a != p, + e `elem` cs + ])) +conseq board (ISNOT p e) = uniq (sort ([ p `IS` x | cs = getc board p, length cs == 2, x <- cs, x != e ] ++ + [ a `IS` e | + cp <- [row p, box p, col p], + as = (filter ((e `elem`) . getc board) . filter (p!=)) cp, + length as == 1, + a = head as + ])) + +-- check if two assumptions contradict each other +contradicts (IS a x) (IS b y) = a==b && x!=y +contradicts (IS a x) (ISNOT b y) = a==b && x==y +contradicts (ISNOT a x) (IS b y) = a==b && x==y +contradicts (ISNOT _ _) (ISNOT _ _) = false + +-- get the Position of an Assumption +aPos (IS p _) = p +aPos (ISNOT p _) = p + +-- get List of elements that must be turned off when assumption is true/false +toClear board true (IS p x) = filter (x!=) (getc board p) +toClear board false (IS p x) = [x] +toClear board true (ISNOT p x) = [x] +toClear board false (ISNOT p x) = filter (x!=) (getc board p) + + +-- look for assumptions whose implications contradict themself +chain board paths = [ solution a (head cs) (reverse cs) | + (a, css) <- paths, + cs <- take 1 [ cs | cs <- css, contradicts a (head cs) ] + ] + where + solution a c cs = turnoff (aPos a) (toClear board false a) reason where + reason = "Assumption " ++ show a ++ " implies " ++ show c ++ "\n\t" + ++ showcs cs ++ "\n\t" + ++ "Therefore, " ++ show a ++ " must be false." + +-- look for an assumption that yields to contradictory implications +-- this assumption must be false +chainContra board paths = [ solution a (reverse pro) (reverse contra) | + (a, css) <- paths, -- FOR ALL assumptions "a" with list of conlusions "css" + (pro, contra) <- take 1 [ (pro, contra) | + pro <- (uniqBy (using head) . sortBy (comparing head)) css, -- FOR ALL conslusion chains "pro" + c = head pro, -- LET "c" BE the final conclusion + contra <- take 1 (filter ((contradicts c) . head) css) -- THE FIRST conclusion that contradicts c + ] + ] + where + solution a pro con = turnoff (aPos a) (toClear board false a) reason where + reason = ("assumption " ++ show a ++ " leads to contradictory conclusions\n\t" + ++ showcs pro ++ "\n\t" ++ showcs con) + + + +-- look for a common implication c of some assumptions ai, where at least 1 ai is true +-- so that (a0 OR a1 OR a2 OR ...) IMPLIES c +-- For all cells pi in same container that have x as candidate, we can construct (p0==x OR p1==x OR ... OR pi==x) +-- For a cell p with candidates ci, we can construct (p==c0 OR p==c1) +cellRegionChain board paths = [ solution b as (map head os) | + as <- cellas ++ regionas, -- one of as must be true + iss = filter ((`elem` as) . fst) paths, -- the implications for as + (a, ass) <- take 1 iss, -- implications for first assumption + fs <- (uniqBy (using head) . sortBy (comparing head)) ass, + b = head fs, -- final conclusions of first assumption + os = [fs] : map (take 1 . filter ((b==) . head) . snd) (tail iss), -- look for implications with same conclusion + all ([]!=) os] + where + cellas = [ map (p `IS`) candidates | (p, candidates@(_:_:_)) <- board ] + regionas = [ map (`IS` e) ps | + region <- map (map (getf board)) (allrows ++ allcols ++ allboxs), + e <- elements, + ps = map fst (filter ((e `elem`) . snd) region), + length ps > 1 ] + solution b as oss = turnoff (aPos b) (toClear board true b) reason where + reason = "all of the assumptions " ++ joined ", " (map show as) ++ " imply " ++ show b ++ "\n\t" + ++ joined "\n\t" (map (showcs . reverse) oss) ++ "\n\t" + ++ "One of them must be true, so " ++ show b ++ " must be true." + + +{- + Wir brauchen für einige Funktionen eine Datenstruktur wie + [ (Assumption, [[Assumption]]) ] + d.i. eine Liste von möglichen Annahmen samt aller Schlußketten. + Idealerweise sollte die Schlußkette in umgekehrter Reihenfolge vorliegen, + dann kann man einfach finden: + - Annahmen, die zum Selbstwiderspruch führen. + - alles, was aus einer bestimmten Annahme folgt (map (map head) [[a]]) + -... +-} +--- Liste aller Annahmen für ein bestimmtes Brett +assumptions :: Brett -> [Assumption] +assumptions board = [ a | + (p, cs) <- board, + !(single cs), + a <- map (ISNOT p) cs ++ map (IS p) cs ] + +consequences :: Brett -> [Assumption] -> [[Assumption]] +consequences board as = map (conseq board) as + +acstree :: Brett -> Tree Assumption [Assumption] +acstree board = Tree.fromList (zip as cs) + where + as = assumptions board + cs = consequences board as + +-- bypass maybe on tree lookup +find :: Tree Assumption [Assumption] -> Assumption -> [Assumption] +find t a + | Just cs <- t.lookup a = cs + | otherwise = error ("no consequences for " ++ show a) + +-- for performance resons, we confine ourselves to implication chains of length 20 per assumption +mkPaths :: Tree Assumption [Assumption] -> [ (Assumption, [[Assumption]]) ] +mkPaths acst = map impl (keys acst) -- {[a1], [a2], [a3] ] + where + -- [Assumption] -> [(a, [chains, ordered by length] + impl a = (a, impls [[a]]) + impls ns = (take 1000 • concat • takeUntil null • iterate expandchain) ns + -- expandchain :: [[Assumption]] -> [[Assumption]] + expandchain css = [ (n:a:as) | + (a : as) <- css, -- list of assumptions + n <- find acst a, -- consequences of a + n `notElem` as -- avoid loops + ] + -- uni (a:as) = a : uni (filter ((head a !=) • head) as) + -- uni [] = empty + -- empty = [] + + +-- ------------------ SOLVE A SUDOKU -------------------------- +-- Apply all available strategies until nothing changes anymore +-- Strategy functions are supposed to return a list of +-- functions, which, when applied to a board, give a changed board. +-- When a strategy does not find anything to alter, +-- it returns [], and the next strategy can be tried. +solve b + | all (single . snd) b = result "Solved" b + | any (([]==) . snd) b = result "not solvable" b + | res@(_:_) <- reduce b = apply b res >>=solve -- compute smallest candidate sets + -- comment "candidate sets are up to date" = () + | res@(_:_) <- hiddenSingle b = apply b res >>= solve -- find HIDDEN SINGLES + -- comment "no more hidden singles" = () + | res@(_:_) <- intersections b = apply b res >>= solve -- find locked candidates + -- comment "no more intersections" = () + | res@(_:_) <- nakedPair 2 b = apply b res >>= solve -- find NAKED PAIRS, TRIPLES or QUADRUPELS + -- comment "no more naked pairs" = () + | res@(_:_) <- hiddenPair 2 b = apply b res >>= solve -- find HIDDEN PAIRS, TRIPLES or QUADRUPELS + -- comment "no more hidden pairs" = () + -- res@(_:_) <- nakedPair 3 b = apply b res >>= solve // find NAKED PAIRS, TRIPLES or QUADRUPELS + -- | comment "no more naked triples" = () + -- res@(_:_) <- hiddenPair 3 b = apply b res >>= solve // find HIDDEN PAIRS, TRIPLES or QUADRUPELS + -- | comment "no more hidden triples" = () + -- res@(_:_) <- nakedPair 4 b = apply b res >>=solve // find NAKED PAIRS, TRIPLES or QUADRUPELS + -- | comment "no more naked quadruples" = () + -- res@(_:_) <- hiddenPair 4 b = apply b res >>=solve // find HIDDEN PAIRS, TRIPLES or QUADRUPELS + -- | comment "no more hidden quadruples" = () + | res@(_:_) <- xyWing b = apply b res >>=solve -- find XY WINGS + -- comment "no more xy wings" = () + | res@(_:_) <- fish 2 b = apply b res >>=solve -- find 2-FISH + -- comment "no more x-wings" = () + -- res@(_:_) <- fish 3 b = apply b res >>=solve // find 3-FISH + -- | comment "no more swordfish" = () + -- res@(_:_) <- fish 4 b = apply b res >>=solve // find 4-FISH + -- | comment "no more jellyfish" = () + -- | comment pcomment = () + | res@(_:_) <- chain b paths = apply b (take 9 res) >>= solve -- find forcing chains + | res@(_:_) <- cellRegionChain b paths = apply b (take 9 res) >>= solve -- find common conclusion for true assumption + | res@(_:_) <- chainContra b paths = apply b (take 9 res) >>= solve -- find assumptions that allow to infer both a and !a + -- comment "consistent conclusions only" = () + + | otherwise = result "ambiguous" b + where + apply brd fs = foldM (\b\f -> f b) brd fs + paths = mkPaths (acstree b) + -- pcomment = show (length paths) ++ " assumptions with " ++ show (fold (+) 0 (map (length <~ snd) paths)) + -- ++ " implication chains" + +-- comment com = do stderr << com << "\n" for false +-- log com = do stderr << com << "\n" for true + +--- turn a string into a row +mkrow :: String -> [Zelle] +mkrow s = mkrow1 xs + where + xs = s ++ "---------" -- make sure at least 9 elements + mkrow1 xs = (take 9 • filter ([]!=) • map f • unpacked) xs + f x | x >= '1' && x <= '9' = [ord x - ord '0'] + | x == ' ' = [] -- ignored + | otherwise = elements + +main ["-h"] = main [] +main ["-help"] = main [] +main [] = do + mapM_ stderr.println [ + "usage: java Sudoku file ...", + " java Sudoku position", + "where position is a 81 char string consisting of digits", + "One can get such a string by going to", + "http://www.sudokuoftheday.com/pages/s-o-t-d.php", + "Right click on the puzzle and open it in new tab", + "Copy the 81 digits from the URL in the address field of your browser.", + "", + "There is also a file with hard sudokus in examples/top95.txt\n"] + return () + + +main [s@#^[0-9\W]{81}$#] = solve board >> return () + where + board = zip positions felder + felder = decode s + +main files = forM_ files sudoku + where + sudoku file = do + br <- openReader file + lines <- BufferedReader.getLines br + bs <- process lines + ss <- mapM (\b -> print "Puzzle: " >> printb b >> solve b) bs + println ("Euler: " ++ show (sum (map res012 ss))) + return () + +-- "--3-" => [1..9, 1..9, [3], 1..9] +decode s = map candi (unpacked s) where + candi c | c >= '1' && c <= '9' = [(ord c - ord '0')] + | otherwise = elements +process [] = return [] +process (s:ss) + | length s == 81 = consider b1 + | length s == 9, + length acht == 8, + all ((9==) • length) acht = consider b2 + | otherwise = do + stderr.println ("skipped line: " ++ s) + process ss + where + acht = take 8 ss + neun = fold (++) "" (s:acht) + b1 = zip positions (decode s) + b2 = zip positions (decode neun) + consider b = do + -- print "Puzzle: " + -- printb b + bs <- process ss + return (b:bs) + diff --git a/samples/Frege/SwingExamples.fr b/samples/Frege/SwingExamples.fr new file mode 100644 index 00000000..73569546 --- /dev/null +++ b/samples/Frege/SwingExamples.fr @@ -0,0 +1,79 @@ +package examples.SwingExamples where + +import Java.Awt (ActionListener) +import Java.Swing + + +main _ = do + rs <- mapM Runnable.new [helloWorldGUI, buttonDemoGUI, celsiusConverterGUI] + mapM_ invokeLater rs + println "Hit enter to end ...." + s <- getLine + return () + +celsiusConverterGUI = do + tempTextField <- JTextField.new() + celsiusLabel <- JLabel.new () + convertButton <- JButton.new () + fahrenheitLabel <- JLabel.new () + frame <- JFrame.new () + frame.setDefaultCloseOperation JFrame.dispose_on_close + frame.setTitle "Celsius Converter" + celsiusLabel.setText "Celsius" + convertButton.setText "Convert" + let convertButtonActionPerformed _ = do + celsius <- tempTextField.getText + case celsius.double of + Left _ -> fahrenheitLabel.setText ("not a valid number: " ++ celsius) + Right c -> fahrenheitLabel.setText (show (c*1.8 + 32.0).long ++ " Fahrenheit") + return () + ActionListener.new convertButtonActionPerformed >>= convertButton.addActionListener + fahrenheitLabel.setText "Fahrenheit" + contentPane <- frame.getContentPane + layout <- GroupLayout.new contentPane + contentPane.setLayout layout + -- TODO continue + -- http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/learn/CelsiusConverterProject/src/learn/CelsiusConverterGUI.java + frame.pack + frame.setVisible true + +helloWorldGUI = do + frame <- JFrame.new "Hello World Frege" + frame.setDefaultCloseOperation(JFrame.dispose_on_close) + label <- JLabel.new "Hello World!" + cp <- frame.getContentPane + cp.add label + frame.pack + frame.setVisible true + +buttonDemoGUI = do + frame <- JFrame.new "Button Demo" + frame.setDefaultCloseOperation(JFrame.dispose_on_close) + newContentPane <- JPanel.new () + b1::JButton <- JButton.new "Disable middle button" + b1.setVerticalTextPosition SwingConstants.center + b1.setHorizontalTextPosition SwingConstants.leading + b2::JButton <- JButton.new "Middle button" + b2.setVerticalTextPosition SwingConstants.center + b2.setHorizontalTextPosition SwingConstants.leading + b3::JButton <- JButton.new "Enable middle button" + b3.setVerticalTextPosition SwingConstants.center + b3.setHorizontalTextPosition SwingConstants.leading + b3.setEnabled false + let action1 _ = do + b2.setEnabled false + b1.setEnabled false + b3.setEnabled true + action3 _ = do + b2.setEnabled true + b1.setEnabled true + b3.setEnabled false + ActionListener.new action1 >>= b1.addActionListener + ActionListener.new action3 >>= b3.addActionListener + newContentPane.add b1 + newContentPane.add b2 + newContentPane.add b3 + newContentPane.setOpaque true + frame.setContentPane newContentPane + frame.pack + frame.setVisible true diff --git a/samples/Game Maker Language/ClientBeginStep.gml b/samples/Game Maker Language/ClientBeginStep.gml new file mode 100644 index 00000000..64d14110 --- /dev/null +++ b/samples/Game Maker Language/ClientBeginStep.gml @@ -0,0 +1,642 @@ +/* + Originally from /Source/gg2/Scripts/Client/ClientBeginStep.gml in Gang Garrison 2 + + Copyright (C) 2008-2013 Faucet Software + http://www.ganggarrison.com + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3 of the License, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, + see . + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +// receive and interpret the server's message(s) +var i, playerObject, playerID, player, otherPlayerID, otherPlayer, sameVersion, buffer, plugins, pluginsRequired, usePlugins; + +if(tcp_eof(global.serverSocket)) { + if(gotServerHello) + show_message("You have been disconnected from the server."); + else + show_message("Unable to connect to the server."); + instance_destroy(); + exit; +} + +if(room == DownloadRoom and keyboard_check(vk_escape)) +{ + instance_destroy(); + exit; +} + +if(downloadingMap) +{ + while(tcp_receive(global.serverSocket, min(1024, downloadMapBytes-buffer_size(downloadMapBuffer)))) + { + write_buffer(downloadMapBuffer, global.serverSocket); + if(buffer_size(downloadMapBuffer) == downloadMapBytes) + { + write_buffer_to_file(downloadMapBuffer, "Maps/" + downloadMapName + ".png"); + downloadingMap = false; + buffer_destroy(downloadMapBuffer); + downloadMapBuffer = -1; + exit; + } + } + exit; +} + +roomchange = false; +do { + if(tcp_receive(global.serverSocket,1)) { + switch(read_ubyte(global.serverSocket)) { + case HELLO: + gotServerHello = true; + global.joinedServerName = receivestring(global.serverSocket, 1); + downloadMapName = receivestring(global.serverSocket, 1); + advertisedMapMd5 = receivestring(global.serverSocket, 1); + receiveCompleteMessage(global.serverSocket, 1, global.tempBuffer); + pluginsRequired = read_ubyte(global.tempBuffer); + plugins = receivestring(global.serverSocket, 1); + if(string_pos("/", downloadMapName) != 0 or string_pos("\", downloadMapName) != 0) + { + show_message("Server sent illegal map name: "+downloadMapName); + instance_destroy(); + exit; + } + + if (!noReloadPlugins && string_length(plugins)) + { + usePlugins = pluginsRequired || !global.serverPluginsPrompt; + if (global.serverPluginsPrompt) + { + var prompt; + if (pluginsRequired) + { + prompt = show_question( + "This server requires the following plugins to play on it: " + + string_replace_all(plugins, ",", "#") + + '#They are downloaded from the source: "' + + PLUGIN_SOURCE + + '"#The source states: "' + + PLUGIN_SOURCE_NOTICE + + '"#Do you wish to download them and continue connecting?' + ); + if (!prompt) + { + instance_destroy(); + exit; + } + } + else + { + prompt = show_question( + "This server suggests the following optional plugins to play on it: " + + string_replace_all(plugins, ",", "#") + + '#They are downloaded from the source: "' + + PLUGIN_SOURCE + + '"#The source states: "' + + PLUGIN_SOURCE_NOTICE + + '"#Do you wish to download them and use them?' + ); + if (prompt) + { + usePlugins = true; + } + } + } + if (usePlugins) + { + if (!loadserverplugins(plugins)) + { + show_message("Error ocurred loading server-sent plugins."); + instance_destroy(); + exit; + } + global.serverPluginsInUse = true; + } + } + noReloadPlugins = false; + + if(advertisedMapMd5 != "") + { + var download; + download = not file_exists("Maps/" + downloadMapName + ".png"); + if(!download and CustomMapGetMapMD5(downloadMapName) != advertisedMapMd5) + { + if(show_question("The server's copy of the map (" + downloadMapName + ") differs from ours.#Would you like to download this server's version of the map?")) + download = true; + else + { + instance_destroy(); + exit; + } + } + + if(download) + { + write_ubyte(global.serverSocket, DOWNLOAD_MAP); + socket_send(global.serverSocket); + receiveCompleteMessage(global.serverSocket,4,global.tempBuffer); + downloadMapBytes = read_uint(global.tempBuffer); + downloadMapBuffer = buffer_create(); + downloadingMap = true; + roomchange=true; + } + } + ClientPlayerJoin(global.serverSocket); + if(global.rewardKey != "" and global.rewardId != "") + { + var rewardId; + rewardId = string_copy(global.rewardId, 0, 255); + write_ubyte(global.serverSocket, REWARD_REQUEST); + write_ubyte(global.serverSocket, string_length(rewardId)); + write_string(global.serverSocket, rewardId); + } + if(global.queueJumping == true) + { + write_ubyte(global.serverSocket, CLIENT_SETTINGS); + write_ubyte(global.serverSocket, global.queueJumping); + } + socket_send(global.serverSocket); + break; + + case JOIN_UPDATE: + receiveCompleteMessage(global.serverSocket,2,global.tempBuffer); + global.playerID = read_ubyte(global.tempBuffer); + global.currentMapArea = read_ubyte(global.tempBuffer); + break; + + case FULL_UPDATE: + deserializeState(FULL_UPDATE); + break; + + case QUICK_UPDATE: + deserializeState(QUICK_UPDATE); + break; + + case CAPS_UPDATE: + deserializeState(CAPS_UPDATE); + break; + + case INPUTSTATE: + deserializeState(INPUTSTATE); + break; + + case PLAYER_JOIN: + player = instance_create(0,0,Player); + player.name = receivestring(global.serverSocket, 1); + + ds_list_add(global.players, player); + if(ds_list_size(global.players)-1 == global.playerID) { + global.myself = player; + instance_create(0,0,PlayerControl); + } + break; + + case PLAYER_LEAVE: + // Delete player from the game, adjust own ID accordingly + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + playerID = read_ubyte(global.tempBuffer); + player = ds_list_find_value(global.players, playerID); + removePlayer(player); + if(playerID < global.playerID) { + global.playerID -= 1; + } + break; + + case PLAYER_DEATH: + var causeOfDeath, assistantPlayerID, assistantPlayer; + receiveCompleteMessage(global.serverSocket,4,global.tempBuffer); + playerID = read_ubyte(global.tempBuffer); + otherPlayerID = read_ubyte(global.tempBuffer); + assistantPlayerID = read_ubyte(global.tempBuffer); + causeOfDeath = read_ubyte(global.tempBuffer); + + player = ds_list_find_value(global.players, playerID); + + otherPlayer = noone; + if(otherPlayerID != 255) + otherPlayer = ds_list_find_value(global.players, otherPlayerID); + + assistantPlayer = noone; + if(assistantPlayerID != 255) + assistantPlayer = ds_list_find_value(global.players, assistantPlayerID); + + doEventPlayerDeath(player, otherPlayer, assistantPlayer, causeOfDeath); + break; + + case BALANCE: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + balanceplayer=read_ubyte(global.tempBuffer); + if balanceplayer == 255 { + if !instance_exists(Balancer) instance_create(x,y,Balancer); + with(Balancer) notice=0; + } else { + player = ds_list_find_value(global.players, balanceplayer); + if(player.object != -1) { + with(player.object) { + instance_destroy(); + } + player.object = -1; + } + if(player.team==TEAM_RED) { + player.team = TEAM_BLUE; + } else { + player.team = TEAM_RED; + } + if !instance_exists(Balancer) instance_create(x,y,Balancer); + Balancer.name=player.name; + with (Balancer) notice=1; + } + break; + + case PLAYER_CHANGETEAM: + receiveCompleteMessage(global.serverSocket,2,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + if(player.object != -1) { + with(player.object) { + instance_destroy(); + } + player.object = -1; + } + player.team = read_ubyte(global.tempBuffer); + break; + + case PLAYER_CHANGECLASS: + receiveCompleteMessage(global.serverSocket,2,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + if(player.object != -1) { + with(player.object) { + instance_destroy(); + } + player.object = -1; + } + player.class = read_ubyte(global.tempBuffer); + break; + + case PLAYER_CHANGENAME: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + player.name = receivestring(global.serverSocket, 1); + if player=global.myself { + global.playerName=player.name + } + break; + + case PLAYER_SPAWN: + receiveCompleteMessage(global.serverSocket,3,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventSpawn(player, read_ubyte(global.tempBuffer), read_ubyte(global.tempBuffer)); + break; + + case CHAT_BUBBLE: + var bubbleImage; + receiveCompleteMessage(global.serverSocket,2,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + setChatBubble(player, read_ubyte(global.tempBuffer)); + break; + + case BUILD_SENTRY: + receiveCompleteMessage(global.serverSocket,6,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + buildSentry(player, read_ushort(global.tempBuffer)/5, read_ushort(global.tempBuffer)/5, read_byte(global.tempBuffer)); + break; + + case DESTROY_SENTRY: + receiveCompleteMessage(global.serverSocket,4,global.tempBuffer); + playerID = read_ubyte(global.tempBuffer); + otherPlayerID = read_ubyte(global.tempBuffer); + assistantPlayerID = read_ubyte(global.tempBuffer); + causeOfDeath = read_ubyte(global.tempBuffer); + + player = ds_list_find_value(global.players, playerID); + if(otherPlayerID == 255) { + doEventDestruction(player, noone, noone, causeOfDeath); + } else { + otherPlayer = ds_list_find_value(global.players, otherPlayerID); + if (assistantPlayerID == 255) { + doEventDestruction(player, otherPlayer, noone, causeOfDeath); + } else { + assistantPlayer = ds_list_find_value(global.players, assistantPlayerID); + doEventDestruction(player, otherPlayer, assistantPlayer, causeOfDeath); + } + } + break; + + case GRAB_INTEL: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventGrabIntel(player); + break; + + case SCORE_INTEL: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventScoreIntel(player); + break; + + case DROP_INTEL: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventDropIntel(player); + break; + + case RETURN_INTEL: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + doEventReturnIntel(read_ubyte(global.tempBuffer)); + break; + + case GENERATOR_DESTROY: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + team = read_ubyte(global.tempBuffer); + doEventGeneratorDestroy(team); + break; + + case UBER_CHARGED: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventUberReady(player); + break; + + case UBER: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + doEventUber(player); + break; + + case OMNOMNOMNOM: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + if(player.object != -1) { + with(player.object) { + omnomnomnom=true; + if(hp < 200) + { + canEat = false; + alarm[6] = eatCooldown; //10 second cooldown + } + if(player.team == TEAM_RED) { + omnomnomnomindex=0; + omnomnomnomend=31; + } else if(player.team==TEAM_BLUE) { + omnomnomnomindex=32; + omnomnomnomend=63; + } + xscale=image_xscale; + } + } + break; + + case TOGGLE_ZOOM: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + player = ds_list_find_value(global.players, read_ubyte(global.tempBuffer)); + if player.object != -1 { + toggleZoom(player.object); + } + break; + + case PASSWORD_REQUEST: + if(!usePreviousPwd) + global.clientPassword = get_string("Enter Password:", ""); + write_ubyte(global.serverSocket, string_length(global.clientPassword)); + write_string(global.serverSocket, global.clientPassword); + socket_send(global.serverSocket); + break; + + case PASSWORD_WRONG: + show_message("Incorrect Password."); + instance_destroy(); + exit; + + case INCOMPATIBLE_PROTOCOL: + show_message("Incompatible server protocol version."); + instance_destroy(); + exit; + + case KICK: + receiveCompleteMessage(global.serverSocket,1,global.tempBuffer); + reason = read_ubyte(global.tempBuffer); + if reason == KICK_NAME kickReason = "Name Exploit"; + else if reason == KICK_BAD_PLUGIN_PACKET kickReason = "Invalid plugin packet ID"; + else if reason == KICK_MULTI_CLIENT kickReason = "There are too many connections from your IP"; + else kickReason = ""; + show_message("You have been kicked from the server. "+kickReason+"."); + instance_destroy(); + exit; + + case ARENA_STARTROUND: + doEventArenaStartRound(); + break; + + case ARENA_ENDROUND: + with ArenaHUD clientArenaEndRound(); + break; + + case ARENA_RESTART: + doEventArenaRestart(); + break; + + case UNLOCKCP: + doEventUnlockCP(); + break; + + case MAP_END: + global.nextMap=receivestring(global.serverSocket, 1); + receiveCompleteMessage(global.serverSocket,2,global.tempBuffer); + global.winners=read_ubyte(global.tempBuffer); + global.currentMapArea=read_ubyte(global.tempBuffer); + global.mapchanging = true; + if !instance_exists(ScoreTableController) instance_create(0,0,ScoreTableController); + instance_create(0,0,WinBanner); + break; + + case CHANGE_MAP: + roomchange=true; + global.mapchanging = false; + global.currentMap = receivestring(global.serverSocket, 1); + global.currentMapMD5 = receivestring(global.serverSocket, 1); + if(global.currentMapMD5 == "") { // if this is an internal map (signified by the lack of an md5) + if(findInternalMapRoom(global.currentMap)) + room_goto_fix(findInternalMapRoom(global.currentMap)); + else + { + show_message("Error:#Server went to invalid internal map: " + global.currentMap + "#Exiting."); + instance_destroy(); + exit; + } + } else { // it's an external map + if(string_pos("/", global.currentMap) != 0 or string_pos("\", global.currentMap) != 0) + { + show_message("Server sent illegal map name: "+global.currentMap); + instance_destroy(); + exit; + } + if(!file_exists("Maps/" + global.currentMap + ".png") or CustomMapGetMapMD5(global.currentMap) != global.currentMapMD5) + { // Reconnect to the server to download the map + var oldReturnRoom; + oldReturnRoom = returnRoom; + returnRoom = DownloadRoom; + if (global.serverPluginsInUse) + noUnloadPlugins = true; + event_perform(ev_destroy,0); + ClientCreate(); + if (global.serverPluginsInUse) + noReloadPlugins = true; + returnRoom = oldReturnRoom; + usePreviousPwd = true; + exit; + } + room_goto_fix(CustomMapRoom); + } + + for(i=0; i. + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ +// Downloading code. + +var downloadHandle, url, tmpfile, window_oldshowborder, window_oldfullscreen; +timeLeft = 0; +counter = 0; +AudioControlPlaySong(-1, false); +window_oldshowborder = window_get_showborder(); +window_oldfullscreen = window_get_fullscreen(); +window_set_fullscreen(false); +window_set_showborder(false); + +if(global.updaterBetaChannel) + url = UPDATE_SOURCE_BETA; +else + url = UPDATE_SOURCE; + +tmpfile = temp_directory + "\gg2update.zip"; + +downloadHandle = httpGet(url, -1); + +while(!httpRequestStatus(downloadHandle)) +{ // while download isn't finished + sleep(floor(1000/30)); // sleep for the equivalent of one frame + io_handle(); // this prevents GameMaker from appearing locked-up + httpRequestStep(downloadHandle); + + // check if the user cancelled the download with the esc key + if(keyboard_check(vk_escape)) + { + httpRequestDestroy(downloadHandle); + window_set_showborder(window_oldshowborder); + window_set_fullscreen(window_oldfullscreen); + room_goto_fix(Menu); + exit; + } + + if(counter == 0 || counter mod 60 == 0) + timer = random(359)+1; + draw_sprite(UpdaterBackgroundS,0,0,0); + draw_set_color(c_white); + draw_set_halign(fa_left); + draw_set_valign(fa_center); + minutes=floor(timer/60); + seconds=floor(timer-minutes*60); + draw_text(x,y-20,string(minutes) + " minutes " + string(seconds) + " seconds Remaining..."); + counter+=1; + var progress, size; + progress = httpRequestResponseBodyProgress(downloadHandle); + size = httpRequestResponseBodySize(downloadHandle); + if (size != -1) + { + progressBar = floor((progress/size) * 20); + offset = 3; + for(i=0;i. + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +xoffset = view_xview[0]; +yoffset = view_yview[0]; +xsize = view_wview[0]; +ysize = view_hview[0]; + +if (distance_to_point(xoffset+xsize/2,yoffset+ysize/2) > 800) + exit; + +var xr, yr; +xr = round(x); +yr = round(y); + +image_alpha = cloakAlpha; + +if (global.myself.team == team and canCloak) + image_alpha = cloakAlpha/2 + 0.5; + +if (invisible) + exit; + +if(stabbing) + image_alpha -= power(currentWeapon.stab.alpha, 2); + +if team == global.myself.team && (player != global.myself || global.showHealthBar == 1){ + draw_set_alpha(1); + draw_healthbar(xr-10, yr-30, xr+10, yr-25,hp*100/maxHp,c_black,c_red,c_green,0,true,true); +} +if(distance_to_point(mouse_x, mouse_y)<25) { + if cloak && team!=global.myself.team exit; + draw_set_alpha(1); + draw_set_halign(fa_center); + draw_set_valign(fa_bottom); + if(team==TEAM_RED) { + draw_set_color(c_red); + } else { + draw_set_color(c_blue); + } + draw_text(xr, yr-35, player.name); + + if(team == global.myself.team && global.showTeammateStats) + { + if(weapons[0] == Medigun) + draw_text(xr,yr+50, "Superburst: " + string(currentWeapon.uberCharge/20) + "%"); + else if(weapons[0] == Shotgun) + draw_text(xr,yr+50, "Nuts 'N' Bolts: " + string(nutsNBolts)); + else if(weapons[0] == Minegun) + draw_text(xr,yr+50, "Lobbed Mines: " + string(currentWeapon.lobbed)); + } +} + +draw_set_alpha(1); +if team == TEAM_RED ubercolour = c_red; +if team == TEAM_BLUE ubercolour = c_blue; + +var sprite, overlaySprite; +if zoomed +{ + if (team == TEAM_RED) + sprite = SniperCrouchRedS; + else + sprite = SniperCrouchBlueS; + overlaySprite = sniperCrouchOverlay; +} +else +{ + sprite = sprite_index; + overlaySprite = overlay; +} + +if (omnomnomnom) +{ + draw_sprite_ext_overlay(omnomnomnomSprite,omnomnomnomOverlay,omnomnomnomindex,xr,yr,image_xscale,image_yscale,image_angle,c_white,1); + if (ubered) + draw_sprite_ext_overlay(omnomnomnomSprite,omnomnomnomOverlay,omnomnomnomindex,xr,yr,image_xscale,image_yscale,image_angle,ubercolour,0.7); +} +else if (taunting) +{ + draw_sprite_ext_overlay(tauntsprite,tauntOverlay,tauntindex,xr,yr,image_xscale,image_yscale,image_angle,c_white,1); + if (ubered) + draw_sprite_ext_overlay(tauntsprite,tauntOverlay,tauntindex,xr,yr,image_xscale,image_yscale,image_angle,ubercolour,0.7); +} +else if (player.humiliated) + draw_sprite_ext(humiliationPoses,floor(animationImage)+humiliationOffset,xr,yr,image_xscale,image_yscale,image_angle,c_white,image_alpha); +else if (!taunting) +{ + if (cloak) + { + if (!ubered) + draw_sprite_ext(sprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,c_white,image_alpha); + else if (ubered) + { + draw_sprite_ext(sprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,c_white,1); + draw_sprite_ext(sprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,ubercolour,0.7); + } + } + else + { + if (!ubered) + draw_sprite_ext_overlay(sprite,overlaySprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,c_white,image_alpha); + else if (ubered) + { + draw_sprite_ext_overlay(sprite,overlaySprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,c_white,1); + draw_sprite_ext_overlay(sprite,overlaySprite,floor(animationImage+animationOffset),xr,yr,image_xscale,image_yscale,image_angle,ubercolour,0.7); + } + } +} +if (burnDuration > 0 or burnIntensity > 0) { + for(i = 0; i < numFlames * burnIntensity / maxIntensity; i += 1) + { + draw_sprite_ext(FlameS, alarm[5] + i + random(2), x + flameArray_x[i], y + flameArray_y[i], 1, 1, 0, c_white, burnDuration / maxDuration * 0.71 + 0.35); + } +} + +// Copied from Lorgan's itemserver "angels" with slight modifications +// All credit be upon him +if (demon != -1) +{ + demonX = median(x-40,demonX,x+40); + demonY = median(y-40,demonY,y); + demonOffset += demonDir; + if (abs(demonOffset) > 15) + demonDir *= -1; + + var dir; + if (demonX > x) + dir = -1; + else + dir = 1; + + if (demonFrame > sprite_get_number(demon)) + demonFrame = 0; + + if (stabbing || ubered) + draw_sprite_ext(demon,demonFrame+floor(animationImage)+7*player.team,demonX,demonY+demonOffset,dir*1,1,0,c_white,1); + else + draw_sprite_ext(demon,demonFrame+floor(animationImage)+7*player.team,demonX,demonY+demonOffset,dir*1,1,0,c_white,image_alpha); + + demonFrame += 1; +} diff --git a/samples/Game Maker Language/characterDrawEvent.gml b/samples/Game Maker Language/characterDrawEvent.gml new file mode 100644 index 00000000..6dcd8fcc --- /dev/null +++ b/samples/Game Maker Language/characterDrawEvent.gml @@ -0,0 +1,80 @@ +// Originally from /spelunky/Scripts/Platform Engine/characterDrawEvent.gml in the Spelunky Community Update Project + +/********************************************************************************** + Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC + + This file is part of Spelunky. + + You can redistribute and/or modify Spelunky, including its source code, under + the terms of the Spelunky User License. + + Spelunky is distributed in the hope that it will be entertaining and useful, + but WITHOUT WARRANTY. Please see the Spelunky User License for more details. + + The Spelunky User License should be available in "Game Information", which + can be found in the Resource Explorer, or as an external file called COPYING. + If not, please obtain a new copy of Spelunky from + +***********************************************************************************/ + +/* +This event should be placed in the draw event of the platform character. +*/ +//draws the sprite +draw = true; +if (facing == RIGHT) image_xscale = -1; +else image_xscale = 1; + +if (blinkToggle != 1) +{ + if ((state == CLIMBING or (sprite_index == sPExit or sprite_index == sDamselExit or sprite_index == sTunnelExit)) and global.hasJetpack and not whipping) + { + draw_sprite_ext(sprite_index, -1, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha); + //draw_sprite(sprite_index,-1,x,y); + draw_sprite(sJetpackBack,-1,x,y); + draw = false; + } + else if (global.hasJetpack and facing == RIGHT) draw_sprite(sJetpackRight,-1,x-4,y-1); + else if (global.hasJetpack) draw_sprite(sJetpackLeft,-1,x+4,y-1); + if (draw) + { + if (redColor > 0) draw_sprite_ext(sprite_index, -1, x, y, image_xscale, image_yscale, image_angle, make_color_rgb(200 + redColor,0,0), image_alpha); + else draw_sprite_ext(sprite_index, -1, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha); + } + if (facing == RIGHT) + { + if (holdArrow == ARROW_NORM) + { + draw_sprite(sArrowRight, -1, x+4, y+1); + } + else if (holdArrow == ARROW_BOMB) + { + if (holdArrowToggle) draw_sprite(sBombArrowRight, 0, x+4, y+2); + else draw_sprite(sBombArrowRight, 1, x+4, y+2); + } + } + else if (facing == LEFT) + { + if (holdArrow == ARROW_NORM) + { + draw_sprite(sArrowLeft, -1, x-4, y+1); + } + else if (holdArrow == ARROW_BOMB) + { + if (holdArrowToggle) draw_sprite(sBombArrowLeft, 0, x-4, y+2); + else draw_sprite(sBombArrowLeft, 1, x-4, y+2); + } + } +} +/* +if canRun +{ + xOffset=80 + if player=1 + yOffset=120 + else + yOffset=143 + //draw the "flySpeed" bar, which shows how much speed the character has acquired while holding the "run" button + //draw_healthbar(view_xview[0]+224+xOffset,view_yview[0]+432+yOffset,view_xview[0]+400+xOffset,view_yview[0]+450+yOffset,flySpeed,make_color_rgb(0,64,128),c_blue,c_aqua,0,1,1) +} +*/ diff --git a/samples/Game Maker Language/characterStepEvent.gml b/samples/Game Maker Language/characterStepEvent.gml new file mode 100644 index 00000000..7416df80 --- /dev/null +++ b/samples/Game Maker Language/characterStepEvent.gml @@ -0,0 +1,1050 @@ +// Originally from /spelunky/Scripts/Platform Engine/characterStepEvent.gml in the Spelunky Community Update Project + +/********************************************************************************** + Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC + + This file is part of Spelunky. + + You can redistribute and/or modify Spelunky, including its source code, under + the terms of the Spelunky User License. + + Spelunky is distributed in the hope that it will be entertaining and useful, + but WITHOUT WARRANTY. Please see the Spelunky User License for more details. + + The Spelunky User License should be available in "Game Information", which + can be found in the Resource Explorer, or as an external file called COPYING. + If not, please obtain a new copy of Spelunky from + +***********************************************************************************/ + +/* +This script should be placed in the step event for the platform character. +It updates the keys used by the character, moves all of the solids, moves the +character, sets the sprite index, and sets the animation speed for the sprite. +*/ +hangCountMax = 3; + +////////////////////////////////////// +// KEYS +////////////////////////////////////// + +kLeft = checkLeft(); + +if (kLeft) kLeftPushedSteps += 1; +else kLeftPushedSteps = 0; + +kLeftPressed = checkLeftPressed(); +kLeftReleased = checkLeftReleased(); + +kRight = checkRight(); + +if (kRight) kRightPushedSteps += 1; +else kRightPushedSteps = 0; + +kRightPressed = checkRightPressed(); +kRightReleased = checkRightReleased(); + +kUp = checkUp(); +kDown = checkDown(); + +//key "run" +if canRun + kRun = 0; +// kRun=runKey +else + kRun=0 + +kJump = checkJump(); +kJumpPressed = checkJumpPressed(); +kJumpReleased = checkJumpReleased(); + +if (cantJump > 0) +{ + kJump = 0; + kJumpPressed = 0; + kJumpReleased = 0; + cantJump -= 1; +} +else +{ + if (global.isTunnelMan and + sprite_index == sTunnelAttackL and + !holdItem) + { + kJump = 0; + kJumpPressed = 0; + kJumpReleased = 0; + cantJump -= 1; + } +} + +kAttack = checkAttack(); +kAttackPressed = checkAttackPressed(); +kAttackReleased = checkAttackReleased(); + +kItemPressed = checkItemPressed(); + +xPrev = x; +yPrev = y; + +if (stunned or dead) +{ + kLeft = false; + kLeftPressed = false; + kLeftReleased = false; + kRight = false; + kRightPressed = false; + kRightReleased = false; + kUp = false; + kDown = false; + kJump = false; + kJumpPressed = false; + kJumpReleased = false; + kAttack = false; + kAttackPressed = false; + kAttackReleased = false; + kItemPressed = false; +} + +////////////////////////////////////////// +// Collisions +////////////////////////////////////////// + +colSolidLeft = false; +colSolidRight = false; +colLeft = false; +colRight = false; +colTop = false; +colBot = false; +colLadder = false; +colPlatBot = false; +colPlat = false; +colWaterTop = false; +colIceBot = false; +runKey = false; +if (isCollisionMoveableSolidLeft(1)) colSolidLeft = true; +if (isCollisionMoveableSolidRight(1)) colSolidRight = true; +if (isCollisionLeft(1)) colLeft = true; +if (isCollisionRight(1)) colRight = true; +if (isCollisionTop(1)) colTop = true; +if (isCollisionBottom(1)) colBot = true; +if (isCollisionLadder()) colLadder = true; +if (isCollisionPlatformBottom(1)) colPlatBot = true; +if (isCollisionPlatform()) colPlat = true; +if (isCollisionWaterTop(1)) colWaterTop = true; +if (collision_point(x, y+8, oIce, 0, 0)) colIceBot = true; +if (checkRun()) +{ + runHeld = 100; + runKey = true; +} + +if (checkAttack() and not whipping) +{ + runHeld += 1; + runKey = true; +} + +if (not runKey or (not kLeft and not kRight)) runHeld = 0; + +// allows the character to run left and right +// if state!=DUCKING and state!=LOOKING_UP and state!=CLIMBING +if (state != CLIMBING and state != HANGING) +{ + if (kLeftReleased and approximatelyZero(xVel)) xAcc -= 0.5 + if (kRightReleased and approximatelyZero(xVel)) xAcc += 0.5 + + if (kLeft and not kRight) + { + if (colSolidLeft) + { + // xVel = 3; + if (platformCharacterIs(ON_GROUND) and state != DUCKING) + { + xAcc -= 1; + pushTimer += 10; + //if (not SS_IsSoundPlaying(global.sndPush)) playSound(global.sndPush); + } + } + else if (kLeftPushedSteps > 2) and (facing=LEFT or approximatelyZero(xVel)) + { + xAcc -= runAcc; + } + facing = LEFT; + //if (platformCharacterIs(ON_GROUND) and abs(xVel) > 0 and alarm[3] < 1) alarm[3] = floor(16/-xVel); + } + + if (kRight and not kLeft) + { + if (colSolidRight) + { + // xVel = 3; + if (platformCharacterIs(ON_GROUND) and state != DUCKING) + { + xAcc += 1; + pushTimer += 10; + //if (not SS_IsSoundPlaying(global.sndPush)) playSound(global.sndPush); + } + } + else if (kRightPushedSteps > 2 or colSolidLeft) and (facing=RIGHT or approximatelyZero(xVel)) + { + xAcc += runAcc; + } + facing = RIGHT; + //if (platformCharacterIs(ON_GROUND) and abs(xVel) > 0 and alarm[3] < 1) alarm[3] = floor(16/xVel); + } +} + +/****************************************** + + LADDERS + +*******************************************/ + +if (state == CLIMBING) +{ + if (instance_exists(oCape)) + { + oCape.open = false; + } + kJumped = false; + ladderTimer = 10; + ladder = collision_point(x, y, oLadder, 0, 0); + if (ladder) x = ladder.x + 8; + + if (kLeft) facing = LEFT; + else if (kRight) facing = RIGHT; + if (kUp) + { + if (collision_point(x, y-8, oLadder, 0, 0) or collision_point(x, y-8, oLadderTop, 0, 0)) + { + yAcc -= climbAcc; + if (alarm[2] < 1) alarm[2] = 8; + } + } + else if (kDown) + { + if (collision_point(x, y+8, oLadder, 0, 0) or collision_point(x, y+8, oLadderTop, 0, 0)) + { + yAcc += climbAcc; + if (alarm[2] < 1) alarm[2] = 8; + } + else + state = FALLING; + if (colBot) state = STANDING; + } + + if (kJumpPressed and not whipping) + { + if (kLeft) + xVel = -departLadderXVel; + else if (kRight) + xVel = departLadderXVel; + else + xVel = 0; + yAcc += departLadderYVel; + state = JUMPING; + jumpButtonReleased = 0; + jumpTime = 0; + ladderTimer = 5; + } +} +else +{ + if (ladderTimer > 0) ladderTimer -= 1; +} + +if (platformCharacterIs(IN_AIR) and state != HANGING) +{ + yAcc += gravityIntensity; +} + +// Player has landed +if ((colBot or colPlatBot) and platformCharacterIs(IN_AIR) and yVel >= 0) +{ + if (not colPlat or colBot) + { + yVel = 0; + yAcc = 0; + state = RUNNING; + jumps = 0; + } + //playSound(global.sndLand); +} +if ((colBot or colPlatBot) and not colPlat) yVel = 0; + +// Player has just walked off of the edge of a solid +if (colBot == 0 and (not colPlatBot or colPlat) and platformCharacterIs(ON_GROUND)) +{ + state = FALLING; + yAcc += grav; + kJumped = true; + if (global.hasGloves) hangCount = 5; +} + +if (colTop) +{ + if (dead or stunned) yVel = -yVel * 0.8; + else if (state == JUMPING) yVel = abs(yVel*0.3) +} + +if (colLeft and facing == LEFT) or (colRight and facing == RIGHT) +{ + if (dead or stunned) xVel = -xVel * 0.5; + else xVel = 0; +} + +/****************************************** + + JUMPING + +*******************************************/ + +if (kJumpReleased and platformCharacterIs(IN_AIR)) +{ + kJumped = true; +} +else if (platformCharacterIs(ON_GROUND)) +{ + oCape.open = false; + kJumped = false; +} + +if (kJumpPressed and collision_point(x, y, oWeb, 0, 0)) +{ + obj = instance_place(x, y, oWeb); + obj.life -= 1; + yAcc += initialJumpAcc * 2; + yVel -= 3; + xAcc += xVel/2; + + state = JUMPING; + jumpButtonReleased = 0; + jumpTime = 0; + + grav = gravNorm; +} +else if (kJumpPressed and colWaterTop) +{ + yAcc += initialJumpAcc * 2; + yVel -= 3; + xAcc += xVel/2; + + state = JUMPING; + jumpButtonReleased = 0; + jumpTime = 0; + + grav = gravNorm; +} +else if (global.hasCape and kJumpPressed and kJumped and platformCharacterIs(IN_AIR)) +{ + if (not oCape.open) oCape.open = true; + else oCape.open = false; +} +else if (global.hasJetpack and kJump and kJumped and platformCharacterIs(IN_AIR) and jetpackFuel > 0) +{ + yAcc += initialJumpAcc; + yVel = -1; + jetpackFuel -= 1; + if (alarm[10] < 1) alarm[10] = 3; + + state = JUMPING; + jumpButtonReleased = 0; + jumpTime = 0; + + grav = 0; +} +else if (platformCharacterIs(ON_GROUND) and kJumpPressed and fallTimer == 0) +{ + if (xVel > 3 or xVel < -3) + { + yAcc += initialJumpAcc * 2; + xAcc += xVel * 2; + } + else + { + yAcc += initialJumpAcc * 2; + xAcc += xVel/2; + } + + if (global.hasJordans) + { + yAcc *= 3; + yAccLimit = 12; + grav = 0.5; + } + else if (global.hasSpringShoes) yAcc *= 1.5; + else + { + yAccLimit = 6; + grav = gravNorm; + } + + playSound(global.sndJump); + + pushTimer = 0; + + // the "state" gets changed to JUMPING later on in the code + state = FALLING; + // "variable jumping" states + jumpButtonReleased = 0; + jumpTime = 0; +} + +if (jumpTime < jumpTimeTotal) jumpTime += 1; +//let the character continue to jump +if (kJump == 0) jumpButtonReleased = 1; +if (jumpButtonReleased) jumpTime = jumpTimeTotal; + +gravityIntensity = (jumpTime/jumpTimeTotal) * grav; + +if (kUp and platformCharacterIs(ON_GROUND) and not colLadder) +{ + looking = UP; + if (xVel == 0 and xAcc == 0) state = LOOKING_UP; +} +else looking = 0; + +if (not kUp and state == LOOKING_UP) +{ + state=STANDING +} + +/****************************************** + + HANGING + +*******************************************/ + +if (not colTop) +{ +if (global.hasGloves and yVel > 0) +{ + if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kRight and colRight and + (collision_point(x+9, y-5, oSolid, 0, 0) or collision_point(x+9, y-6, oSolid, 0, 0))) + { + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; + } + else if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kLeft and colLeft and + (collision_point(x-9, y-5, oSolid, 0, 0) or collision_point(x-9, y-6, oSolid, 0, 0))) + { + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; + } +} +else if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kRight and colRight and + (collision_point(x+9, y-5, oTree, 0, 0) or collision_point(x+9, y-6, oTree, 0, 0))) +{ + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; +} +else if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kLeft and colLeft and + (collision_point(x-9, y-5, oTree, 0, 0) or collision_point(x-9, y-6, oTree, 0, 0))) +{ + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; +} +else if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kRight and colRight and + (collision_point(x+9, y-5, oSolid, 0, 0) or collision_point(x+9, y-6, oSolid, 0, 0)) and + not collision_point(x+9, y-9, oSolid, 0, 0) and not collision_point(x, y+9, oSolid, 0, 0)) +{ + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; +} +else if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kLeft and colLeft and + (collision_point(x-9, y-5, oSolid, 0, 0) or collision_point(x-9, y-6, oSolid, 0, 0)) and + not collision_point(x-9, y-9, oSolid, 0, 0) and not collision_point(x, y+9, oSolid, 0, 0)) +{ + state = HANGING; + move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; +} + +if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and state == FALLING and + (collision_point(x, y-5, oArrow, 0, 0) or collision_point(x, y-6, oArrow, 0, 0)) and + not collision_point(x, y-9, oArrow, 0, 0) and not collision_point(x, y+9, oArrow, 0, 0)) +{ + obj = instance_nearest(x, y-5, oArrow); + if (obj.stuck) + { + state = HANGING; + // move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; + } +} + +/* +if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and state == FALLING and + (collision_point(x, y-5, oTreeBranch, 0, 0) or collision_point(x, y-6, oTreeBranch, 0, 0)) and + not collision_point(x, y-9, oTreeBranch, 0, 0) and not collision_point(x, y+9, oTreeBranch, 0, 0)) +{ + state = HANGING; + // move_snap(1, 8); + yVel = 0; + yAcc = 0; + grav = 0; +} +*/ + +} + +if (hangCount > 0) hangCount -= 1; + +if (state == HANGING) +{ + if (instance_exists(oCape)) oCape.open = false; + kJumped = false; + + if (kDown and kJumpPressed) + { + grav = gravNorm; + state = FALLING; + yAcc -= grav; + hangCount = 5; + if (global.hasGloves) hangCount = 10; + } + else if (kJumpPressed) + { + grav = gravNorm; + if ((facing == RIGHT and kLeft) or (facing == LEFT and kRight)) + { + state = FALLING; + yAcc -= grav; + } + else + { + state = JUMPING; + yAcc += initialJumpAcc * 2; + if (facing == RIGHT) x -= 2; + else x += 2; + } + hangCount = hangCountMax; + } + + if ((facing == LEFT and not isCollisionLeft(2)) or + (facing == RIGHT and not isCollisionRight(2))) + { + grav = gravNorm; + state = FALLING; + yAcc -= grav; + hangCount = 4; + } +} +else +{ + grav = gravNorm; +} + +// pressing down while standing +if (kDown and platformCharacterIs(ON_GROUND) and not whipping) +{ + if (colBot) + { + state = DUCKING; + } + else if colPlatBot + { + // climb down ladder if possible, else jump down + fallTimer = 0; + if (not colBot) + { + ladder = 0; + ladder = instance_place(x, y+16, oLadder); + if (instance_exists(ladder)) + { + if (abs(x-(ladder.x+8)) < 4) + { + x = ladder.x + 8; + + xVel = 0; + yVel = 0; + xAcc = 0; + yAcc = 0; + state = CLIMBING; + } + } + else + { + y += 1; + state = FALLING; + yAcc += grav; + } + } + else + { + //the character can't move down because there is a solid in the way + state = RUNNING; + } + } +} +if (not kDown and state == DUCKING) +{ + state = STANDING; + xVel = 0; + xAcc = 0; +} +if (xVel == 0 and xAcc == 0 and state == RUNNING) +{ + state = STANDING; +} +if (xAcc != 0 and state == STANDING) +{ + state = RUNNING; +} +if (yVel < 0 and platformCharacterIs(IN_AIR) and state != HANGING) +{ + state = JUMPING; +} +if (yVel > 0 and platformCharacterIs(IN_AIR) and state != HANGING) +{ + state = FALLING; + setCollisionBounds(-5, -6, 5, 8); +} +else setCollisionBounds(-5, -8, 5, 8); + +// CLIMB LADDER +colPointLadder = collision_point(x, y, oLadder, 0, 0) or collision_point(x, y, oLadderTop, 0, 0); + +if ((kUp and platformCharacterIs(IN_AIR) and collision_point(x, y-8, oLadder, 0, 0) and ladderTimer == 0) or + (kUp and colPointLadder and ladderTimer == 0) or + (kDown and colPointLadder and ladderTimer == 0 and platformCharacterIs(ON_GROUND) and collision_point(x, y+9, oLadderTop, 0, 0) and xVel == 0)) +{ + ladder = 0; + ladder = instance_place(x, y-8, oLadder); + if (instance_exists(ladder)) + { + if (abs(x-(ladder.x+8)) < 4) + { + x = ladder.x + 8; + if (not collision_point(x, y, oLadder, 0, 0) and + not collision_point(x, y, oLadderTop, 0, 0)) + { + y = ladder.y + 14; + } + + xVel = 0; + yVel = 0; + xAcc = 0; + yAcc = 0; + state = CLIMBING; + } + } +} + +/* +if (sprite_index == sDuckToHangL or sprite_index == sDamselDtHL) +{ + ladder = 0; + if (facing == LEFT and collision_rectangle(x-8, y, x, y+16, oLadder, 0, 0) and not collision_point(x-4, y+16, oSolid, 0, 0)) + { + ladder = instance_nearest(x-4, y+16, oLadder); + } + else if (facing == RIGHT and collision_rectangle(x, y, x+8, y+16, oLadder, 0, 0) and not collision_point(x+4, y+16, oSolid, 0, 0)) + { + ladder = instance_nearest(x+4, y+16, oLadder); + } + + if (ladder) + { + x = ladder.x + 8; + + xVel = 0; + yVel = 0; + xAcc = 0; + yAcc = 0; + state = CLIMBING; + } +} +*/ +/* +if (colLadder and state == CLIMBING and kJumpPressed and not whipping) +{ + if (kLeft) + xVel = -departLadderXVel; + else if (kRight) + xVel = departLadderXVel; + else + xVel = 0; + yAcc += departLadderYVel; + state = JUMPING; + jumpButtonReleased = 0; + jumpTime = 0; + ladderTimer = 5; +} +*/ + +// Calculate horizontal/vertical friction +if (state == CLIMBING) +{ + xFric = frictionClimbingX; + yFric = frictionClimbingY; +} +else +{ + if (runKey and platformCharacterIs(ON_GROUND) and runHeld >= 10) + { + if (kLeft) // run + { + xVel -= 0.1; + xVelLimit = 6; + xFric = frictionRunningFastX; + } + else if (kRight) + { + xVel += 0.1; + xVelLimit = 6; + xFric = frictionRunningFastX; + } + } + else if (state == DUCKING) + { + if (xVel<2 and xVel>-2) + { + xFric = 0.2 + xVelLimit = 3; + image_speed = 0.8; + } + else if (kLeft and global.downToRun) // run + { + xVel -= 0.1; + xVelLimit = 6; + xFric = frictionRunningFastX; + } + else if (kRight and global.downToRun) + { + xVel += 0.1; + xVelLimit = 6; + xFric = frictionRunningFastX; + } + else + { + xVel *= 0.8; + if (xVel < 0.5) xVel = 0; + xFric = 0.2 + xVelLimit = 3; + image_speed = 0.8; + } + } + else + { + //decrease the friction when the character is "flying" + if (platformCharacterIs(IN_AIR)) + { + if (dead or stunned) xFric = 1.0; + else xFric = 0.8; + } + else + { + xFric = frictionRunningX; + } + } + + // Stuck on web or underwater + if (collision_point(x, y, oWeb, 0, 0)) + { + xFric = 0.2; + yFric = 0.2; + fallTimer = 0; + } + else if (collision_point(x, y, oWater, -1, -1)) + { + if (instance_exists(oCape)) oCape.open = false; + + if (state == FALLING and yVel > 0) + { + yFric = 0.5; + } + else if (not collision_point(x, y-9, oWater, -1, -1)) + { + yFric = 1; + } + else + { + yFric = 0.9; + } + } + else + { + swimming = false; + yFric = 1; + } +} + +if (colIceBot and state != DUCKING and not global.hasSpikeShoes) +{ + xFric = 0.98; + yFric = 1; +} + +// RUNNING + +if (platformCharacterIs(ON_GROUND)) +{ + if (state == RUNNING and kLeft and colLeft) + { + pushTimer += 1; + } + else if (state == RUNNING and kRight and colRight) + { + pushTimer += 1; + } + else + { + pushTimer = 0; + } + + if (platformCharacterIs(ON_GROUND) and not kJump and not kDown and not runKey) + { + xVelLimit = 3; + } + + + // ledge flip + if (state == DUCKING and abs(xVel) < 3 and facing == LEFT and + collision_point(x, y+9, oSolid, 0, 0) and not collision_line(x-1, y+9, x-10, y+9, oSolid, 0, 0) and kLeft) + { + state = DUCKTOHANG; + + if (holdItem) + { + holdItem.held = false; + if (holdItem.type == "Gold Idol") holdItem.y -= 8; + scrDropItem(-1, -4); + } + + with oMonkey + { + // knock off monkeys that grabbed you + if (status == 7) + { + xVel = -1; + yVel = -4; + status = 1; + vineCounter = 20; + grabCounter = 60; + } + } + } + else if (state == DUCKING and abs(xVel) < 3 and facing == RIGHT and + collision_point(x, y+9, oSolid, 0, 0) and not collision_line(x+1, y+9, x+10, y+9, oSolid, 0, 0) and kRight) + { + state = DUCKTOHANG; + + if (holdItem) + { + // holdItem.held = false; + if (holdItem.type == "Gold Idol") holdItem.y -= 8; + scrDropItem(1, -4); + } + + with oMonkey + { + // knock off monkeys that grabbed you + if (status == 7) + { + xVel = 1; + yVel = -4; + status = 1; + vineCounter = 20; + grabCounter = 60; + } + } + } +} + +if (state == DUCKTOHANG) +{ + x = xPrev; + y = yPrev; + xVel = 0; + yVel = 0; + xAcc = 0; + yAcc = 0; + grav = 0; +} + +// PARACHUTE AND CAPE +if (instance_exists(oParachute)) +{ + yFric = 0.5; +} +if (instance_exists(oCape)) +{ + if (oCape.open) yFric = 0.5; +} + +if (pushTimer > 100) pushTimer = 100; + +// limits the acceleration if it is too extreme +if (xAcc > xAccLimit) xAcc = xAccLimit; +else if (xAcc < -xAccLimit) xAcc = -xAccLimit; +if (yAcc > yAccLimit) yAcc = yAccLimit; +else if (yAcc < -yAccLimit) yAcc = -yAccLimit; + +// applies the acceleration +xVel += xAcc; +if (dead or stunned) yVel += 0.6; +else yVel += yAcc; + +// nullifies the acceleration +xAcc = 0; +yAcc = 0; + +// applies the friction to the velocity, now that the velocity has been calculated +xVel *= xFric; +yVel *= yFric; + +// apply ball and chain +if (instance_exists(oBall)) +{ + if (distance_to_object(oBall) >= 24) + { + if (xVel > 0 and oBall.x < x and abs(oBall.x-x) > 24) xVel = 0; + if (xVel < 0 and oBall.x > x and abs(oBall.x-x) > 24) xVel = 0; + if (yVel > 0 and oBall.y < y and abs(oBall.y-y) > 24) + { + if (abs(oBall.x-x) < 1) + { + x = oBall.x; + } + else if (oBall.x < x and not kRight) + { + if (xVel > 0) xVel *= -0.25; + else if (xVel == 0) xVel -= 1; + } + else if (oBall.x > x and not kLeft) + { + if (xVel < 0) xVel *= -0.25; + else if (xVel == 0) xVel += 1; + } + yVel = 0; + fallTimer = 0; + } + if (yVel < 0 and oBall.y > y and abs(oBall.y-y) > 24) yVel = 0; + } +} + +// apply the limits since the velocity may be too extreme +if (not dead and not stunned) +{ + if (xVel > xVelLimit) xVel = xVelLimit; + else if (xVel < -xVelLimit) xVel = -xVelLimit; +} +if (yVel > yVelLimit) yVel = yVelLimit; +else if (yVel < -yVelLimit) yVel = -yVelLimit; + +// approximates the "active" variables +if approximatelyZero(xVel) xVel=0 +if approximatelyZero(yVel) yVel=0 +if approximatelyZero(xAcc) xAcc=0 +if approximatelyZero(yAcc) yAcc=0 + +// prepares the character to move up a hill +// we need to use the "slopeYPrev" variable later to know the "true" y previous value +// keep this condition the same +if maxSlope>0 and platformCharacterIs(ON_GROUND) and xVel!=0 +{ + slopeYPrev=y + for(y=y;y>=slopeYPrev-maxSlope;y-=1) + if colTop + break + slopeChangeInY=slopeYPrev-y +} +else + slopeChangeInY=0 + +// moves the character, and balances out the effects caused by other processes +// keep this condition the same +if maxSlope*abs(xVel)>0 and platformCharacterIs(ON_GROUND) +{ + // we need to check if we should dampen out the speed as the character runs on upward slopes + xPrev=x + yPrev=slopeYPrev // we don't want to use y, because y is too high + yPrevHigh=y // we'll use the higher previous variable later + moveTo(xVel,yVel+slopeChangeInY) + dist=point_distance(xPrev,yPrev,x,y)// overall distance that has been traveled + // we should have only ran at xVel + if dist>abs(xVelInteger) + { + // show_message(string(dist)+ " "+string(abs(xVelInteger))) + excess=dist-abs(xVelInteger) + if(xVelInteger<0) + excess*=-1 + // move back since the character moved too far + x=xPrev + y=yPrevHigh // we need the character to be high so the character can move down + // this time we'll move the correct distance, but we need to shorten out the xVel a little + // these lines can be changed for different types of slowing down when running up hills + ratio=abs(xVelInteger)/dist*0.9 //can be changed + moveTo( round(xVelInteger*ratio),round(yVelInteger*ratio+slopeChangeInY) ) + } +} +else +{ + // we simply move xVel and yVel while in the air or on a ladder + moveTo(xVel,yVel) +} +// move the character downhill if possible +// we need to multiply maxDownSlope by the absolute value of xVel since the character normally runs at an xVel larger than 1 +if not colBot and maxDownSlope>0 and xVelInteger!=0 and platformCharacterIs(ON_GROUND) +{ + //the character is floating just above the slope, so move the character down + upYPrev=y + for(y=y;y<=upYPrev+maxDownSlope;y+=1) + if colBot // we hit a solid below + { + upYPrev=y // I know that this doesn't seem to make sense, because of the name of the variable, but it all works out correctly after we break out of this loop + break + } + y=upYPrev +} + +//figures out what the sprite index of the character should be +characterSprite(); + +//sets the previous state and the previously previous state +statePrevPrev = statePrev; +statePrev = state; + +//calculates the image_speed based on the character's velocity +if (state == RUNNING or state == DUCKING or state == LOOKING_UP) +{ + if (state == RUNNING or state == LOOKING_UP) image_speed = abs(xVel) * runAnimSpeed + 0.1; +} + +if (state == CLIMBING) image_speed = sqrt(sqr(abs(xVel))+sqr(abs(yVel))) * climbAnimSpeed +if (xVel >= 4 or xVel <= -4) +{ + image_speed = 1; + if (platformCharacterIs(ON_GROUND)) setCollisionBounds(-8, -8, 8, 8); + else setCollisionBounds(-5, -8, 5, 8); +} +else setCollisionBounds(-5, -8, 5, 8); +if (whipping) image_speed = 1; +if (state == DUCKTOHANG) +{ + image_index = 0; + image_speed = 0.8; +} +//limit the image_speed at 1 so the animation always looks good +if (image_speed > 1) image_speed = 1; diff --git a/samples/Game Maker Language/doEventPlayerDeath.gml b/samples/Game Maker Language/doEventPlayerDeath.gml new file mode 100644 index 00000000..47ee7780 --- /dev/null +++ b/samples/Game Maker Language/doEventPlayerDeath.gml @@ -0,0 +1,251 @@ +/* + Originally from /Source/gg2/Scripts/Events/doEventPlayerDeath.gml in Gang Garrison 2 + + Copyright (C) 2008-2013 Faucet Software + http://www.ganggarrison.com + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3 of the License, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, + see . + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +/** + * Perform the "player death" event, i.e. change the appropriate scores, + * destroy the character object to much splattering and so on. + * + * argument0: The player whose character died + * argument1: The player who inflicted the fatal damage (or noone for unknown) + * argument2: The player who assisted the kill (or noone for no assist) + * argument3: The source of the fatal damage + */ +var victim, killer, assistant, damageSource; +victim = argument0; +killer = argument1; +assistant = argument2; +damageSource = argument3; + +if(!instance_exists(killer)) + killer = noone; + +if(!instance_exists(assistant)) + assistant = noone; + +//************************************* +//* Scoring and Kill log +//************************************* + + +recordKillInLog(victim, killer, assistant, damageSource); + +victim.stats[DEATHS] += 1; +if(killer) +{ + if(damageSource == WEAPON_KNIFE || damageSource == WEAPON_BACKSTAB) + { + killer.stats[STABS] += 1; + killer.roundStats[STABS] += 1; + killer.stats[POINTS] += 1; + killer.roundStats[POINTS] +=1; + } + + if (victim.object.currentWeapon.object_index == Medigun) + { + if (victim.object.currentWeapon.uberReady) + { + killer.stats[BONUS] += 1; + killer.roundStats[BONUS] += 1; + killer.stats[POINTS] += 1; + killer.roundStats[POINTS] += 1; + } + } + + if (killer != victim) + { + killer.stats[KILLS] += 1; + killer.roundStats[KILLS] += 1; + killer.stats[POINTS] += 1; + killer.roundStats[POINTS] += 1; + if(victim.object.intel) + { + killer.stats[DEFENSES] += 1; + killer.roundStats[DEFENSES] += 1; + killer.stats[POINTS] += 1; + killer.roundStats[POINTS] += 1; + recordEventInLog(4, killer.team, killer.name, global.myself == killer); + } + } +} + +if (assistant) +{ + assistant.stats[ASSISTS] += 1; + assistant.roundStats[ASSISTS] += 1; + assistant.stats[POINTS] += .5; + assistant.roundStats[POINTS] += .5; +} + +//SPEC +if (victim == global.myself) + instance_create(victim.object.x, victim.object.y, Spectator); + +//************************************* +//* Gibbing +//************************************* +var xoffset, yoffset, xsize, ysize; + +xoffset = view_xview[0]; +yoffset = view_yview[0]; +xsize = view_wview[0]; +ysize = view_hview[0]; + +randomize(); +with(victim.object) { + if((damageSource == WEAPON_ROCKETLAUNCHER + or damageSource == WEAPON_MINEGUN or damageSource == FRAG_BOX + or damageSource == WEAPON_REFLECTED_STICKY or damageSource == WEAPON_REFLECTED_ROCKET + or damageSource == FINISHED_OFF_GIB or damageSource == GENERATOR_EXPLOSION) + and (player.class != CLASS_QUOTE) and (global.gibLevel>1) + and distance_to_point(xoffset+xsize/2,yoffset+ysize/2) < 900) { + if (hasReward(victim, 'PumpkinGibs')) + { + repeat(global.gibLevel * 2) { + createGib(x,y,PumpkinGib,hspeed,vspeed,random(145)-72, choose(0,1,1,2,2,3), false, true) + } + } + else + { + repeat(global.gibLevel) { + createGib(x,y,Gib,hspeed,vspeed,random(145)-72, 0, false) + } + switch(player.team) + { + case TEAM_BLUE : + repeat(global.gibLevel - 1) { + createGib(x,y,BlueClump,hspeed,vspeed,random(145)-72, 0, false) + } + break; + case TEAM_RED : + repeat(global.gibLevel - 1) { + createGib(x,y,RedClump,hspeed,vspeed,random(145)-72, 0, false) + } + break; + } + } + + repeat(global.gibLevel * 14) { + var blood; + blood = instance_create(x+random(23)-11,y+random(23)-11,BloodDrop); + blood.hspeed=(random(21)-10); + blood.vspeed=(random(21)-13); + if (hasReward(victim, 'PumpkinGibs')) + { + blood.sprite_index = PumpkinJuiceS; + } + } + if (!hasReward(victim, 'PumpkinGibs')) + { + //All Classes gib head, hands, and feet + if(global.gibLevel > 2 || choose(0,1) == 1) + createGib(x,y,Headgib,0,0,random(105)-52, player.class, false); + repeat(global.gibLevel -1){ + //Medic has specially colored hands + if (player.class == CLASS_MEDIC){ + if (player.team == TEAM_RED) + createGib(x,y,Hand, hspeed, vspeed, random(105)-52 , 9, false); + else + createGib(x,y,Hand, hspeed, vspeed, random(105)-52 , 10, false); + }else{ + createGib(x,y,Hand, hspeed, vspeed, random(105)-52 , player.class, false); + } + createGib(x,y,Feet,random(5)-2,random(3),random(13)-6 , player.class, true); + } + } + + //Class specific gibs + switch(player.class) { + case CLASS_PYRO : + if(global.gibLevel > 2 || choose(0,1) == 1) + createGib(x,y,Accesory,hspeed,vspeed,random(105)-52, 4, false) + break; + case CLASS_SOLDIER : + if(global.gibLevel > 2 || choose(0,1) == 1){ + switch(player.team) { + case TEAM_BLUE : + createGib(x,y,Accesory,hspeed,vspeed,random(105)-52, 2, false); + break; + case TEAM_RED : + createGib(x,y,Accesory,hspeed,vspeed,random(105)-52, 1, false); + break; + } + } + break; + case CLASS_ENGINEER : + if(global.gibLevel > 2 || choose(0,1) == 1) + createGib(x,y,Accesory,hspeed,vspeed,random(105)-52, 3, false) + break; + case CLASS_SNIPER : + if(global.gibLevel > 2 || choose(0,1) == 1) + createGib(x,y,Accesory,hspeed,vspeed,random(105)-52, 0, false) + break; + } + playsound(x,y,Gibbing); + } else { + var deadbody; + if player.class != CLASS_QUOTE playsound(x,y,choose(DeathSnd1, DeathSnd2)); + deadbody = instance_create(x,y-30,DeadGuy); + // 'GS' reward - *G*olden *S*tatue + if(hasReward(player, 'GS')) + { + deadbody.sprite_index = haxxyStatue; + deadbody.image_index = 0; + } + else + { + deadbody.sprite_index = sprite_index; + deadbody.image_index = CHARACTER_ANIMATION_DEAD; + } + deadbody.hspeed=hspeed; + deadbody.vspeed=vspeed; + if(hspeed>0) { + deadbody.image_xscale = -1; + } + } +} + +if (global.gg_birthday){ + myHat = instance_create(victim.object.x,victim.object.y,PartyHat); + myHat.image_index = victim.team; +} +if (global.xmas){ + myHat = instance_create(victim.object.x,victim.object.y,XmasHat); + myHat.image_index = victim.team; +} + + +with(victim.object) { + instance_destroy(); +} + +//************************************* +//* Deathcam +//************************************* +if( global.killCam and victim == global.myself and killer and killer != victim and !(damageSource == KILL_BOX || damageSource == FRAG_BOX || damageSource == FINISHED_OFF || damageSource == FINISHED_OFF_GIB || damageSource == GENERATOR_EXPLOSION)) { + instance_create(0,0,DeathCam); + DeathCam.killedby=killer; + DeathCam.name=killer.name; + DeathCam.oldxview=view_xview[0]; + DeathCam.oldyview=view_yview[0]; + DeathCam.lastDamageSource=damageSource; + DeathCam.team = global.myself.team; +} diff --git a/samples/Game Maker Language/faucet-http.gml b/samples/Game Maker Language/faucet-http.gml new file mode 100644 index 00000000..c9b4d0f5 --- /dev/null +++ b/samples/Game Maker Language/faucet-http.gml @@ -0,0 +1,1469 @@ +#define __http_init +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Creates global.__HttpClient +// real __http_init() + +global.__HttpClient = object_add(); +object_set_persistent(global.__HttpClient, true); + +#define __http_split +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// real __http_split(string text, delimeter delimeter, real limit) +// Splits string into items + +// text - string comma-separated values +// delimeter - delimeter to split by +// limit if non-zero, maximum times to split text +// When limited, the remaining text will be left as the last item. +// E.g. splitting "1,2,3,4,5" with delimeter "," and limit 2 yields this list: +// "1", "2", "3,4,5" + +// return value - ds_list containing strings of values + +var text, delimeter, limit; +text = argument0; +delimeter = argument1; +limit = argument2; + +var list, count; +list = ds_list_create(); +count = 0; + +while (string_pos(delimeter, text) != 0) +{ + ds_list_add(list, string_copy(text, 1, string_pos(delimeter,text) - 1)); + text = string_copy(text, string_pos(delimeter, text) + string_length(delimeter), string_length(text) - string_pos(delimeter, text)); + + count += 1; + if (limit and count == limit) + break; +} +ds_list_add(list, text); + +return list; + +#define __http_parse_url +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Parses a URL into its components +// real __http_parse_url(string url) + +// Return value is a ds_map containing keys for the different URL parts: (or -1 on failure) +// "url" - the URL which was passed in +// "scheme" - the URL scheme (e.g. "http") +// "host" - the hostname (e.g. "example.com" or "127.0.0.1") +// "port" - the port (e.g. 8000) - this is a real, unlike the others +// "abs_path" - the absolute path (e.g. "/" or "/index.html") +// "query" - the query string (e.g. "a=b&c=3") +// Parts which are not included will not be in the map +// e.g. http://example.com will not have the "port", "path" or "query" keys + +// This will *only* work properly for URLs of format: +// scheme ":" "//" host [ ":" port ] [ abs_path [ "?" query ]]" +// where [] denotes an optional component +// file: URLs will *not* work as they lack the authority (host:port) component +// It will not work correctly for IPv6 host values + +var url; +url = argument0; + +var map; +map = ds_map_create(); +ds_map_add(map, 'url', url); + +// before scheme +var colonPos; +// Find colon for end of scheme +colonPos = string_pos(':', url); +// No colon - bad URL +if (colonPos == 0) + return -1; +ds_map_add(map, 'scheme', string_copy(url, 1, colonPos - 1)); +url = string_copy(url, colonPos + 1, string_length(url) - colonPos); + +// before double slash +// remove slashes (yes this will screw up file:// but who cares) +while (string_char_at(url, 1) == '/') + url = string_copy(url, 2, string_length(url) - 1); + +// before hostname +var slashPos, colonPos; +// Find slash for beginning of path +slashPos = string_pos('/', url); +// No slash ahead - http://host format with no ending slash +if (slashPos == 0) +{ + // Find : for beginning of port + colonPos = string_pos(':', url); +} +else +{ + // Find : for beginning of port prior to / + colonPos = string_pos(':', string_copy(url, 1, slashPos - 1)); +} +// No colon - no port +if (colonPos == 0) +{ + // There was no slash + if (slashPos == 0) + { + ds_map_add(map, 'host', url); + return map; + } + // There was a slash + else + { + ds_map_add(map, 'host', string_copy(url, 1, slashPos - 1)); + url = string_copy(url, slashPos, string_length(url) - slashPos + 1); + } +} +// There's a colon - port specified +else +{ + // There was no slash + if (slashPos == 0) + { + ds_map_add(map, 'host', string_copy(url, 1, colonPos - 1)); + ds_map_add(map, 'port', real(string_copy(url, colonPos + 1, string_length(url) - colonPos))); + return map; + } + // There was a slash + else + { + ds_map_add(map, 'host', string_copy(url, 1, colonPos - 1)); + url = string_copy(url, colonPos + 1, string_length(url) - colonPos); + slashPos = string_pos('/', url); + ds_map_add(map, 'port', real(string_copy(url, 1, slashPos - 1))); + url = string_copy(url, slashPos, string_length(url) - slashPos + 1); + } +} + +// before path +var queryPos; +queryPos = string_pos('?', url); +// There's no ? - no query +if (queryPos == 0) +{ + ds_map_add(map, 'abs_path', url); + return map; +} +else +{ + ds_map_add(map, 'abs_path', string_copy(url, 1, queryPos - 1)); + ds_map_add(map, 'query', string_copy(url, queryPos + 1, string_length(url) - queryPos)); + return map; +} + +// Return -1 upon unlikely error +ds_map_destroy(map); +return -1; + +#define __http_resolve_url +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Takes a base URL and a URL reference and applies it to the base URL +// Returns resulting absolute URL +// string __http_resolve_url(string baseUrl, string refUrl) + +// Return value is a string containing the new absolute URL, or "" on failure + +// Works only for restricted URL syntax as understood by by http_resolve_url +// The sole restriction of which is that only scheme://authority/path URLs work +// This notably excludes file: URLs which lack the authority component + +// As described by RFC3986: +// URI-reference = URI / relative-ref +// relative-ref = relative-part [ "?" query ] [ "#" fragment ] +// relative-part = "//" authority path-abempty +// / path-absolute +// / path-noscheme +// / path-empty +// However http_resolve_url does *not* deal with fragments + +// Algorithm based on that of section 5.2.2 of RFC 3986 + +var baseUrl, refUrl; +baseUrl = argument0; +refUrl = argument1; + +// Parse base URL +var urlParts; +urlParts = __http_parse_url(baseUrl); +if (urlParts == -1) + return ''; + +// Try to parse reference URL +var refUrlParts, canParseRefUrl; +refUrlParts = __http_parse_url(refUrl); +canParseRefUrl = (refUrlParts != -1); +if (refUrlParts != -1) + ds_map_destroy(refUrlParts); + +var result; +result = ''; + +// Parsing of reference URL succeeded - it's absolute and we're done +if (canParseRefUrl) +{ + result = refUrl; +} +// Begins with '//' - scheme-relative URL +else if (string_copy(refUrl, 1, 2) == '//' and string_length(refUrl) > 2) +{ + result = ds_map_find_value(urlParts, 'scheme') + ':' + refUrl; +} +// Is or begins with '/' - absolute path relative URL +else if (((string_char_at(refUrl, 1) == '/' and string_length(refUrl) > 1) or refUrl == '/') +// Doesn't begin with ':' and is not blank - relative path relative URL + or (string_char_at(refUrl, 1) != ':' and string_length(refUrl) > 0)) +{ + // Find '?' for query + var queryPos; + queryPos = string_pos('?', refUrl); + // No query + if (queryPos == 0) + { + refUrl = __http_resolve_path(ds_map_find_value(urlParts, 'abs_path'), refUrl); + ds_map_replace(urlParts, 'abs_path', refUrl); + if (ds_map_exists(urlParts, 'query')) + ds_map_delete(urlParts, 'query'); + } + // Query exists, split + else + { + var path, query; + path = string_copy(refUrl, 1, queryPos - 1); + query = string_copy(refUrl, queryPos + 1, string_length(relUrl) - queryPos); + path = __http_resolve_path(ds_map_find_value(urlParts, 'abs_path'), path); + ds_map_replace(urlParts, 'abs_path', path); + if (ds_map_exists(urlParts, 'query')) + ds_map_replace(urlParts, 'query', query); + else + ds_map_add(urlParts, 'query', query); + } + result = __http_construct_url(urlParts); +} + +ds_map_destroy(urlParts); +return result; + +#define __http_resolve_path +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Takes a base path and a path reference and applies it to the base path +// Returns resulting absolute path +// string __http_resolve_path(string basePath, string refPath) + +// Return value is a string containing the new absolute path + +// Deals with UNIX-style / paths, not Windows-style \ paths +// Can be used to clean up .. and . in non-absolute paths too ('' as basePath) + +var basePath, refPath; +basePath = argument0; +refPath = argument1; + +// refPath begins with '/' (is absolute), we can ignore all of basePath +if (string_char_at(refPath, 1) == '/') +{ + basePath = refPath; + refPath = ''; +} + +var parts, refParts; +parts = __http_split(basePath, '/', 0); +refParts = __http_split(refPath, '/', 0); + +if (refPath != '') +{ + // Find last part of base path + var lastPart; + lastPart = ds_list_find_value(parts, ds_list_size(parts) - 1); + + // If it's not blank (points to a file), remove it + if (lastPart != '') + { + ds_list_delete(parts, ds_list_size(parts) - 1); + } + + // Concatenate refParts to end of parts + var i; + for (i = 0; i < ds_list_size(refParts); i += 1) + ds_list_add(parts, ds_list_find_value(refParts, i)); +} + +// We now don't need refParts any more +ds_list_destroy(refParts); + +// Deal with '..' and '.' +for (i = 0; i < ds_list_size(parts); i += 1) +{ + var part; + part = ds_list_find_value(parts, i); + + if (part == '.') + { + if (i == 1 or i == ds_list_size(parts) - 1) + ds_list_replace(parts, i, ''); + else + ds_list_delete(parts, i); + i -= 1; + continue; + } + else if (part == '..') + { + if (i > 1) + { + ds_list_delete(parts, i - 1); + ds_list_delete(part, i); + i -= 2; + } + else + { + ds_list_replace(parts, i, ''); + i -= 1; + } + continue; + } + else if (part == '' and i != 0 and i != ds_list_size(parts) - 1) + { + ds_list_delete(parts, i); + i -= 1; + continue; + } +} + +// Reconstruct path from parts +var path; +path = ''; +for (i = 0; i < ds_list_size(parts); i += 1) +{ + if (i != 0) + path += '/'; + path += ds_list_find_value(parts, i); +} + +ds_map_destroy(parts); +return path; + +#define __http_parse_hex +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Takes a lowercase hexadecimal string and returns its integer value +// real __http_parse_hex(string hexString) + +// Return value is the whole number value (or -1 if invalid) +// Only works for whole numbers (non-fractional numbers >= 0) and lowercase hex + +var hexString; +hexString = argument0; + +var result, hexValues; +result = 0; +hexValues = "0123456789abcdef"; + +var i; +for (i = 1; i <= string_length(hexString); i += 1) { + result *= 16; + var digit; + digit = string_pos(string_char_at(hexString, i), hexValues) - 1; + if (digit == -1) + return -1; + result += digit; +} + +return result; + +#define __http_construct_url +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Constructs an URL from its components (as http_parse_url would return) +// string __http_construct_url(real parts) + +// Return value is the string of the constructed URL +// Keys of parts map: +// "scheme" - the URL scheme (e.g. "http") +// "host" - the hostname (e.g. "example.com" or "127.0.0.1") +// "port" - the port (e.g. 8000) - this is a real, unlike the others +// "abs_path" - the absolute path (e.g. "/" or "/index.html") +// "query" - the query string (e.g. "a=b&c=3") +// Parts which are omitted will be omitted in the URL +// e.g. http://example.com lacks "port", "path" or "query" keys + +// This will *only* work properly for URLs of format: +// scheme ":" "//" host [ ":" port ] [ abs_path [ "?" query ]]" +// where [] denotes an optional component +// file: URLs will *not* work as they lack the authority (host:port) component +// Should work correctly for IPv6 host values, but bare in mind parse_url won't + +var parts; +parts = argument0; + +var url; +url = ''; + +url += ds_map_find_value(parts, 'scheme'); +url += '://'; +url += ds_map_find_value(parts, 'host'); +if (ds_map_exists(parts, 'port')) + url += ':' + string(ds_map_find_value(parts, 'port')); +if (ds_map_exists(parts, 'abs_path')) +{ + url += ds_map_find_value(parts, 'abs_path'); + if (ds_map_exists(parts, 'query')) + url += '?' + ds_map_find_value(parts, 'query'); +} + +return url; + +#define __http_prepare_request +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Internal function - prepares request +// void __http_prepare_request(real client, string url, real headers) + +// client - HttpClient object to prepare +// url - URL to send GET request to +// headers - ds_map of extra headers to send, -1 if none + +var client, url, headers; +client = argument0; +url = argument1; +headers = argument2; + +var parsed; +parsed = __http_parse_url(url); + +if (parsed == -1) + show_error("Error when making HTTP GET request - can't parse URL: " + url, true); + +if (!ds_map_exists(parsed, 'port')) + ds_map_add(parsed, 'port', 80); +if (!ds_map_exists(parsed, 'abs_path')) + ds_map_add(parsed, 'abs_path', '/'); + +with (client) +{ + destroyed = false; + CR = chr(13); + LF = chr(10); + CRLF = CR + LF; + socket = tcp_connect(ds_map_find_value(parsed, 'host'), ds_map_find_value(parsed, 'port')); + state = 0; + errored = false; + error = ''; + linebuf = ''; + line = 0; + statusCode = -1; + reasonPhrase = ''; + responseBody = buffer_create(); + responseBodySize = -1; + responseBodyProgress = -1; + responseHeaders = ds_map_create(); + requestUrl = url; + requestHeaders = headers; + + // Request = Request-Line ; Section 5.1 + // *(( general-header ; Section 4.5 + // | request-header ; Section 5.3 + // | entity-header ) CRLF) ; Section 7.1 + // CRLF + // [ message-body ] ; Section 4.3 + + // "The Request-Line begins with a method token, followed by the + // Request-URI and the protocol version, and ending with CRLF. The + // elements are separated by SP characters. No CR or LF is allowed + // except in the final CRLF sequence." + if (ds_map_exists(parsed, 'query')) + write_string(socket, 'GET ' + ds_map_find_value(parsed, 'abs_path') + '?' + ds_map_find_value(parsed, 'query') + ' HTTP/1.1' + CRLF); + else + write_string(socket, 'GET ' + ds_map_find_value(parsed, 'abs_path') + ' HTTP/1.1' + CRLF); + + // "A client MUST include a Host header field in all HTTP/1.1 request + // messages." + // "A "host" without any trailing port information implies the default + // port for the service requested (e.g., "80" for an HTTP URL)." + if (ds_map_find_value(parsed, 'port') == 80) + write_string(socket, 'Host: ' + ds_map_find_value(parsed, 'host') + CRLF); + else + write_string(socket, 'Host: ' + ds_map_find_value(parsed, 'host') + + ':' + string(ds_map_find_value(parsed, 'port')) + CRLF); + + // "An HTTP/1.1 server MAY assume that a HTTP/1.1 client intends to + // maintain a persistent connection unless a Connection header including + // the connection-token "close" was sent in the request." + write_string(socket, 'Connection: close' + CRLF); + + // "If no Accept-Encoding field is present in a request, the server MAY + // assume that the client will accept any content coding." + write_string(socket, 'Accept-Encoding:' + CRLF); + + // If headers specified + if (headers != -1) + { + var key; + // Iterate over headers map + for (key = ds_map_find_first(headers); is_string(key); key = ds_map_find_next(headers, key)) + { + write_string(socket, key + ': ' + ds_map_find_value(headers, key) + CRLF); + } + } + + // Send extra CRLF to terminate request + write_string(socket, CRLF); + + socket_send(socket); + + ds_map_destroy(parsed); +} + +#define __http_parse_header +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Internal function - parses header +// real __http_parse_header(string linebuf, real line) +// Returns false if it errored (caller should return and destroy) + +var linebuf, line; +linebuf = argument0; +line = argument1; + +// "HTTP/1.1 header field values can be folded onto multiple lines if the +// continuation line begins with a space or horizontal tab." +if ((string_char_at(linebuf, 1) == ' ' or ord(string_char_at(linebuf, 1)) == 9)) +{ + if (line == 1) + { + errored = true; + error = "First header line of response can't be a continuation, right?"; + return false; + } + headerValue = ds_map_find_value(responseHeaders, string_lower(headerName)) + + string_copy(linebuf, 2, string_length(linebuf) - 1); +} +// "Each header field consists +// of a name followed by a colon (":") and the field value. Field names +// are case-insensitive. The field value MAY be preceded by any amount +// of LWS, though a single SP is preferred." +else +{ + var colonPos; + colonPos = string_pos(':', linebuf); + if (colonPos == 0) + { + errored = true; + error = "No colon in a header line of response"; + return false; + } + headerName = string_copy(linebuf, 1, colonPos - 1); + headerValue = string_copy(linebuf, colonPos + 1, string_length(linebuf) - colonPos); + // "The field-content does not include any leading or trailing LWS: + // linear white space occurring before the first non-whitespace + // character of the field-value or after the last non-whitespace + // character of the field-value. Such leading or trailing LWS MAY be + // removed without changing the semantics of the field value." + while (string_char_at(headerValue, 1) == ' ' or ord(string_char_at(headerValue, 1)) == 9) + headerValue = string_copy(headerValue, 2, string_length(headerValue) - 1); +} + +ds_map_add(responseHeaders, string_lower(headerName), headerValue); + +if (string_lower(headerName) == 'content-length') +{ + responseBodySize = real(headerValue); + responseBodyProgress = 0; +} + +return true; + +#define __http_client_step +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Steps the HTTP client (needs to be called each step or so) + +var client; +client = argument0; + +with (client) +{ + if (errored) + exit; + + // Socket error + if (socket_has_error(socket)) + { + errored = true; + error = "Socket error: " + socket_error(socket); + return __http_client_destroy(); + } + + var available; + available = tcp_receive_available(socket); + + switch (state) + { + // Receiving lines + case 0: + if (!available && tcp_eof(socket)) + { + errored = true; + error = "Unexpected EOF when receiving headers/status code"; + return __http_client_destroy(); + } + + var bytesRead, c; + for (bytesRead = 1; bytesRead <= available; bytesRead += 1) + { + c = read_string(socket, 1); + // Reached end of line + // "HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all + // protocol elements except the entity-body (see appendix 19.3 for + // tolerant applications)." + if (c == LF and string_char_at(linebuf, string_length(linebuf)) == CR) + { + // Strip trailing CR + linebuf = string_copy(linebuf, 1, string_length(linebuf) - 1); + // First line - status code + if (line == 0) + { + // "The first line of a Response message is the Status-Line, consisting + // of the protocol version followed by a numeric status code and its + // associated textual phrase, with each element separated by SP + // characters. No CR or LF is allowed except in the final CRLF sequence." + var httpVer, spacePos; + spacePos = string_pos(' ', linebuf); + if (spacePos == 0) + { + errored = true; + error = "No space in first line of response"; + return __http_client_destroy(); + } + httpVer = string_copy(linebuf, 1, spacePos); + linebuf = string_copy(linebuf, spacePos + 1, string_length(linebuf) - spacePos); + + spacePos = string_pos(' ', linebuf); + if (spacePos == 0) + { + errored = true; + error = "No second space in first line of response"; + return __http_client_destroy(); + } + statusCode = real(string_copy(linebuf, 1, spacePos)); + reasonPhrase = string_copy(linebuf, spacePos + 1, string_length(linebuf) - spacePos); + } + // Other line + else + { + // Blank line, end of response headers + if (linebuf == '') + { + state = 1; + // write remainder + write_buffer_part(responseBody, socket, available - bytesRead); + responseBodyProgress = available - bytesRead; + break; + } + // Header + else + { + if (!__http_parse_header(linebuf, line)) + return __http_client_destroy(); + } + } + + linebuf = ''; + line += 1; + } + else + linebuf += c; + } + break; + // Receiving response body + case 1: + write_buffer(responseBody, socket); + responseBodyProgress += available; + if (tcp_eof(socket)) + { + if (ds_map_exists(responseHeaders, 'transfer-encoding')) + { + if (ds_map_find_value(responseHeaders, 'transfer-encoding') == 'chunked') + { + // Chunked transfer, let's decode it + var actualResponseBody, actualResponseSize; + actualResponseBody = buffer_create(); + actualResponseBodySize = 0; + + // Parse chunks + // chunk = chunk-size [ chunk-extension ] CRLF + // chunk-data CRLF + // chunk-size = 1*HEX + while (buffer_bytes_left(responseBody)) + { + var chunkSize, c; + chunkSize = ''; + + // Read chunk size byte by byte + while (buffer_bytes_left(responseBody)) + { + c = read_string(responseBody, 1); + if (c == CR or c == ';') + break; + else + chunkSize += c; + } + + // We found a semicolon - beginning of chunk-extension + if (c == ';') + { + // skip all extension stuff + while (buffer_bytes_left(responseBody) && c != CR) + { + c = read_string(responseBody, 1); + } + } + // Reached end of header + if (c == CR) + { + c += read_string(responseBody, 1); + // Doesn't end in CRLF + if (c != CRLF) + { + errored = true; + error = 'header of chunk in chunked transfer did not end in CRLF'; + buffer_destroy(actualResponseBody); + return __http_client_destroy(); + } + // chunk-size is empty - something's up! + if (chunkSize == '') + { + errored = true; + error = 'empty chunk-size in a chunked transfer'; + buffer_destroy(actualResponseBody); + return __http_client_destroy(); + } + chunkSize = __http_parse_hex(chunkSize); + // Parsing of size failed - not hex? + if (chunkSize == -1) + { + errored = true; + error = 'chunk-size was not hexadecimal in a chunked transfer'; + buffer_destroy(actualResponseBody); + return __http_client_destroy(); + } + // Is the chunk bigger than the remaining response? + if (chunkSize + 2 > buffer_bytes_left(responseBody)) + { + errored = true; + error = 'chunk-size was greater than remaining data in a chunked transfer'; + buffer_destroy(actualResponseBody); + return __http_client_destroy(); + } + // OK, everything's good, read the chunk + write_buffer_part(actualResponseBody, responseBody, chunkSize); + actualResponseBodySize += chunkSize; + // Check for CRLF + if (read_string(responseBody, 2) != CRLF) + { + errored = true; + error = 'chunk did not end in CRLF in a chunked transfer'; + return __http_client_destroy(); + } + } + else + { + errored = true; + error = 'did not find CR after reading chunk header in a chunked transfer, Faucet HTTP bug?'; + return __http_client_destroy(); + } + // if the chunk size is zero, then it was the last chunk + if (chunkSize == 0 + // trailer headers will be present + and ds_map_exists(responseHeaders, 'trailer')) + { + // Parse header lines + var line; + line = 1; + while (buffer_bytes_left(responseBody)) + { + var linebuf; + linebuf = ''; + while (buffer_bytes_left(responseBody)) + { + c = read_string(responseBody, 1); + if (c != CR) + linebuf += c; + else + break; + } + c += read_string(responseBody, 1); + if (c != CRLF) + { + errored = true; + error = 'trailer header did not end in CRLF in a chunked transfer'; + return __http_client_destroy(); + } + if (!__http_parse_header(linebuf, line)) + return __http_client_destroy(); + line += 1; + } + } + } + responseBodySize = actualResponseBodySize; + buffer_destroy(responseBody); + responseBody = actualResponseBody; + } + else + { + errored = true; + error = 'Unsupported Transfer-Encoding: "' + ds_map_find_value(responseHaders, 'transfer-encoding') + '"'; + return __http_client_destroy(); + } + } + else if (responseBodySize != -1) + { + if (responseBodyProgress < responseBodySize) + { + errored = true; + error = "Unexpected EOF, response body size is less than expected"; + return __http_client_destroy(); + } + } + // 301 Moved Permanently/302 Found/303 See Other/307 Moved Temporarily + if (statusCode == 301 or statusCode == 302 or statusCode == 303 or statusCode == 307) + { + if (ds_map_exists(responseHeaders, 'location')) + { + var location, resolved; + location = ds_map_find_value(responseHeaders, 'location'); + resolved = __http_resolve_url(requestUrl, location); + // Resolving URL didn't fail and it's http:// + if (resolved != '' and string_copy(resolved, 1, 7) == 'http://') + { + // Restart request + __http_client_destroy(); + __http_prepare_request(client, resolved, requestHeaders); + } + else + { + errored = true; + error = "301, 302, 303 or 307 response with invalid or unsupported Location URL ('" + location + "') - can't redirect"; + return __http_client_destroy(); + } + exit; + } + else + { + errored = true; + error = "301, 302, 303 or 307 response without Location header - can't redirect"; + return __http_client_destroy(); + } + } + else + state = 2; + } + break; + // Done. + case 2: + break; + } +} + +#define __http_client_destroy +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Clears up contents of an httpClient prior to destruction or after error + +if (!destroyed) { + socket_destroy(socket); + buffer_destroy(responseBody); + ds_map_destroy(responseHeaders); +} +destroyed = true; + +#define http_new_get +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Makes a GET HTTP request +// real http_new_get(string url) + +// url - URL to send GET request to + +// Return value is an HttpClient instance that can be passed to +// fct_http_request_status etc. +// (errors on failure to parse URL) + +var url, client; + +url = argument0; + +if (!variable_global_exists('__HttpClient')) + __http_init(); + +client = instance_create(0, 0, global.__HttpClient); +__http_prepare_request(client, url, -1); +return client; + +#define http_new_get_ex +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Makes a GET HTTP request with custom headers +// real http_new_get_ex(string url, real headers) + +// url - URL to send GET request to +// headers - ds_map of extra headers to send + +// Return value is an HttpClient instance that can be passed to +// fct_http_request_status etc. +// (errors on failure to parse URL) + +var url, headers, client; + +url = argument0; +headers = argument1; + +if (!variable_global_exists('__HttpClient')) + __http_init(); + +client = instance_create(0, 0, global.__HttpClient); +__http_prepare_request(client, url, headers); +return client; + +#define http_step +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Steps the HTTP client. This is what makes everything actually happen. +// Call it each step. Returns whether or not the request has finished. +// real http_step(real client) + +// client - HttpClient object + +// Return value is either: +// 0 - In progress +// 1 - Done or Errored + +// Example usage: +// req = http_new_get("http://example.com/x.txt"); +// while (http_step(req)) {} +// if (http_status_code(req) != 200) { +// // Errored! +// } else { +// // Hasn't errored, do stuff here. +// } + +var client; +client = argument0; + +__http_client_step(client); + +if (client.errored || client.state == 2) + return 1; +else + return 0; + +#define http_status_code +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the status code +// real http_status_code(real client) + +// client - HttpClient object + +// Return value is either: +// * 0, if the request has not yet finished +// * a negative value, if there was an internal Faucet HTTP error +// * a positive value, the status code of the HTTP request + +// "The Status-Code element is a 3-digit integer result code of the +// attempt to understand and satisfy the request. These codes are fully +// defined in section 10. The Reason-Phrase is intended to give a short +// textual description of the Status-Code. The Status-Code is intended +// for use by automata and the Reason-Phrase is intended for the human +// user. The client is not required to examine or display the Reason- +// Phrase." + +// See also: http_reason_phrase, gets the Reason-Phrase + +var client; +client = argument0; + +if (client.errored) + return -1; +else if (client.state == 2) + return client.statusCode; +else + return 0; + +#define http_reason_phrase +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the reason phrase +// string http_reason_phrase(real client) + +// client - HttpClient object +// Return value is either: +// * "", if the request has not yet finished +// * an internal Faucet HTTP error message, if there was one +// * the reason phrase of the HTTP request + +// "The Status-Code element is a 3-digit integer result code of the +// attempt to understand and satisfy the request. These codes are fully +// defined in section 10. The Reason-Phrase is intended to give a short +// textual description of the Status-Code. The Status-Code is intended +// for use by automata and the Reason-Phrase is intended for the human +// user. The client is not required to examine or display the Reason- +// Phrase." + +// See also: http_status_code, gets the Status-Code + +var client; +client = argument0; + +if (client.errored) + return client.error; +else if (client.state == 2) + return client.reasonPhrase; +else + return ""; + +#define http_response_body +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the response body returned by an HTTP request as a buffer +// real http_response_body(real client) + +// client - HttpClient object + +// Return value is a buffer if client hasn't errored and is finished + +var client; +client = argument0; + +return client.responseBody; + +#define http_response_body_size +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the size of response body returned by an HTTP request +// real http_response_body_size(real client) + +// client - HttpClient object + +// Return value is the size in bytes, or -1 if we don't know or don't know yet + +// Call this each time you use the size - it may have changed in the case of redirect + +var client; +client = argument0; + +return client.responseBodySize; + +#define http_response_body_progress +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the size of response body returned by an HTTP request which is so far downloaded +// real http_response_body_progress(real client) + +// client - HttpClient object + +// Return value is the size in bytes, or -1 if we haven't started yet or client has errored + +var client; +client = argument0; + +return client.responseBodyProgress; + +#define http_response_headers +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Gets the response headers returned by an HTTP request as a ds_map +// real http_response_headers(real client) + +// client - HttpClient object + +// Return value is a ds_map if client hasn't errored and is finished + +// All headers will have lowercase keys +// The ds_map is owned by the HttpClient, do not use ds_map_destroy() yourself +// Call when the request has finished - otherwise may be incomplete or missing + +var client; +client = argument0; + +return client.responseHeaders; + +#define http_destroy +// *** +// This function forms part of Faucet HTTP v1.0 +// https://github.com/TazeTSchnitzel/Faucet-HTTP-Extension +// +// Copyright (c) 2013-2014, Andrea Faulds +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +// *** + +// Cleans up HttpClient +// void http_destroy(real client) + +// client - HttpClient object + +var client; +client = argument0; + +with (client) +{ + __http_client_destroy(); + instance_destroy(); +} + diff --git a/samples/Game Maker Language/game_init.gml b/samples/Game Maker Language/game_init.gml new file mode 100644 index 00000000..4f5012d2 --- /dev/null +++ b/samples/Game Maker Language/game_init.gml @@ -0,0 +1,484 @@ +/* + Originally from /Source/gg2/Scripts/game_init.gml in Gang Garrison 2 + + Copyright (C) 2008-2013 Faucet Software + http://www.ganggarrison.com + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3 of the License, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, + see . + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +// Returns true if the game is successfully initialized, false if there was an error and we should quit. +{ + instance_create(0,0,RoomChangeObserver); + set_little_endian_global(true); + if file_exists("game_errors.log") file_delete("game_errors.log"); + if file_exists("last_plugin.log") file_delete("last_plugin.log"); + + // Delete old left-over files created by the updater + var backupFilename; + backupFilename = file_find_first("gg2-old.delete.me.*", 0); + while(backupFilename != "") + { + file_delete(backupFilename); + backupFilename = file_find_next(); + } + file_find_close(); + + var customMapRotationFile, restart; + restart = false; + + //import wav files for music + global.MenuMusic=sound_add(choose("Music/menumusic1.wav","Music/menumusic2.wav","Music/menumusic3.wav","Music/menumusic4.wav","Music/menumusic5.wav","Music/menumusic6.wav"), 1, true); + global.IngameMusic=sound_add("Music/ingamemusic.wav", 1, true); + global.FaucetMusic=sound_add("Music/faucetmusic.wav", 1, true); + if(global.MenuMusic != -1) + sound_volume(global.MenuMusic, 0.8); + if(global.IngameMusic != -1) + sound_volume(global.IngameMusic, 0.8); + if(global.FaucetMusic != -1) + sound_volume(global.FaucetMusic, 0.8); + + global.sendBuffer = buffer_create(); + global.tempBuffer = buffer_create(); + global.HudCheck = false; + global.map_rotation = ds_list_create(); + + global.CustomMapCollisionSprite = -1; + + window_set_region_scale(-1, false); + + ini_open("gg2.ini"); + global.playerName = ini_read_string("Settings", "PlayerName", "Player"); + if string_count("#",global.playerName) > 0 global.playerName = "Player"; + global.playerName = string_copy(global.playerName, 0, min(string_length(global.playerName), MAX_PLAYERNAME_LENGTH)); + global.fullscreen = ini_read_real("Settings", "Fullscreen", 0); + global.useLobbyServer = ini_read_real("Settings", "UseLobby", 1); + global.hostingPort = ini_read_real("Settings", "HostingPort", 8190); + global.music = ini_read_real("Settings", "Music", ini_read_real("Settings", "IngameMusic", MUSIC_BOTH)); + global.playerLimit = ini_read_real("Settings", "PlayerLimit", 10); + //thy playerlimit shalt not exceed 48! + if (global.playerLimit > 48) + { + if (global.dedicatedMode != 1) + show_message("Warning: Player Limit cannot exceed 48. It has been set to 48"); + global.playerLimit = 48; + ini_write_real("Settings", "PlayerLimit", 48); + } + global.multiClientLimit = ini_read_real("Settings", "MultiClientLimit", 3); + global.particles = ini_read_real("Settings", "Particles", PARTICLES_NORMAL); + global.gibLevel = ini_read_real("Settings", "Gib Level", 3); + global.killCam = ini_read_real("Settings", "Kill Cam", 1); + global.monitorSync = ini_read_real("Settings", "Monitor Sync", 0); + if global.monitorSync == 1 set_synchronization(true); + else set_synchronization(false); + global.medicRadar = ini_read_real("Settings", "Healer Radar", 1); + global.showHealer = ini_read_real("Settings", "Show Healer", 1); + global.showHealing = ini_read_real("Settings", "Show Healing", 1); + global.showHealthBar = ini_read_real("Settings", "Show Healthbar", 0); + global.showTeammateStats = ini_read_real("Settings", "Show Extra Teammate Stats", 0); + global.serverPluginsPrompt = ini_read_real("Settings", "ServerPluginsPrompt", 1); + global.restartPrompt = ini_read_real("Settings", "RestartPrompt", 1); + //user HUD settings + global.timerPos=ini_read_real("Settings","Timer Position", 0) + global.killLogPos=ini_read_real("Settings","Kill Log Position", 0) + global.kothHudPos=ini_read_real("Settings","KoTH HUD Position", 0) + global.clientPassword = ""; + // for admin menu + customMapRotationFile = ini_read_string("Server", "MapRotation", ""); + global.shuffleRotation = ini_read_real("Server", "ShuffleRotation", 1); + global.timeLimitMins = max(1, min(255, ini_read_real("Server", "Time Limit", 15))); + global.serverPassword = ini_read_string("Server", "Password", ""); + global.mapRotationFile = customMapRotationFile; + global.dedicatedMode = ini_read_real("Server", "Dedicated", 0); + global.serverName = ini_read_string("Server", "ServerName", "My Server"); + global.welcomeMessage = ini_read_string("Server", "WelcomeMessage", ""); + global.caplimit = max(1, min(255, ini_read_real("Server", "CapLimit", 5))); + global.caplimitBkup = global.caplimit; + global.autobalance = ini_read_real("Server", "AutoBalance",1); + global.Server_RespawntimeSec = ini_read_real("Server", "Respawn Time", 5); + global.rewardKey = unhex(ini_read_string("Haxxy", "RewardKey", "")); + global.rewardId = ini_read_string("Haxxy", "RewardId", ""); + global.mapdownloadLimitBps = ini_read_real("Server", "Total bandwidth limit for map downloads in bytes per second", 50000); + global.updaterBetaChannel = ini_read_real("General", "UpdaterBetaChannel", isBetaVersion()); + global.attemptPortForward = ini_read_real("Server", "Attempt UPnP Forwarding", 0); + global.serverPluginList = ini_read_string("Server", "ServerPluginList", ""); + global.serverPluginsRequired = ini_read_real("Server", "ServerPluginsRequired", 0); + if (string_length(global.serverPluginList) > 254) { + show_message("Error: Server plugin list cannot exceed 254 characters"); + return false; + } + var CrosshairFilename, CrosshairRemoveBG; + CrosshairFilename = ini_read_string("Settings", "CrosshairFilename", ""); + CrosshairRemoveBG = ini_read_real("Settings", "CrosshairRemoveBG", 1); + global.queueJumping = ini_read_real("Settings", "Queued Jumping", 0); + + global.backgroundHash = ini_read_string("Background", "BackgroundHash", "default"); + global.backgroundTitle = ini_read_string("Background", "BackgroundTitle", ""); + global.backgroundURL = ini_read_string("Background", "BackgroundURL", ""); + global.backgroundShowVersion = ini_read_real("Background", "BackgroundShowVersion", true); + + readClasslimitsFromIni(); + + global.currentMapArea=1; + global.totalMapAreas=1; + global.setupTimer=1800; + global.joinedServerName=""; + global.serverPluginsInUse=false; + // Create plugin packet maps + global.pluginPacketBuffers = ds_map_create(); + global.pluginPacketPlayers = ds_map_create(); + + ini_write_string("Settings", "PlayerName", global.playerName); + ini_write_real("Settings", "Fullscreen", global.fullscreen); + ini_write_real("Settings", "UseLobby", global.useLobbyServer); + ini_write_real("Settings", "HostingPort", global.hostingPort); + ini_key_delete("Settings", "IngameMusic"); + ini_write_real("Settings", "Music", global.music); + ini_write_real("Settings", "PlayerLimit", global.playerLimit); + ini_write_real("Settings", "MultiClientLimit", global.multiClientLimit); + ini_write_real("Settings", "Particles", global.particles); + ini_write_real("Settings", "Gib Level", global.gibLevel); + ini_write_real("Settings", "Kill Cam", global.killCam); + ini_write_real("Settings", "Monitor Sync", global.monitorSync); + ini_write_real("Settings", "Healer Radar", global.medicRadar); + ini_write_real("Settings", "Show Healer", global.showHealer); + ini_write_real("Settings", "Show Healing", global.showHealing); + ini_write_real("Settings", "Show Healthbar", global.showHealthBar); + ini_write_real("Settings", "Show Extra Teammate Stats", global.showTeammateStats); + ini_write_real("Settings", "Timer Position", global.timerPos); + ini_write_real("Settings", "Kill Log Position", global.killLogPos); + ini_write_real("Settings", "KoTH HUD Position", global.kothHudPos); + ini_write_real("Settings", "ServerPluginsPrompt", global.serverPluginsPrompt); + ini_write_real("Settings", "RestartPrompt", global.restartPrompt); + ini_write_string("Server", "MapRotation", customMapRotationFile); + ini_write_real("Server", "ShuffleRotation", global.shuffleRotation); + ini_write_real("Server", "Dedicated", global.dedicatedMode); + ini_write_string("Server", "ServerName", global.serverName); + ini_write_string("Server", "WelcomeMessage", global.welcomeMessage); + ini_write_real("Server", "CapLimit", global.caplimit); + ini_write_real("Server", "AutoBalance", global.autobalance); + ini_write_real("Server", "Respawn Time", global.Server_RespawntimeSec); + ini_write_real("Server", "Total bandwidth limit for map downloads in bytes per second", global.mapdownloadLimitBps); + ini_write_real("Server", "Time Limit", global.timeLimitMins); + ini_write_string("Server", "Password", global.serverPassword); + ini_write_real("General", "UpdaterBetaChannel", global.updaterBetaChannel); + ini_write_real("Server", "Attempt UPnP Forwarding", global.attemptPortForward); + ini_write_string("Server", "ServerPluginList", global.serverPluginList); + ini_write_real("Server", "ServerPluginsRequired", global.serverPluginsRequired); + ini_write_string("Settings", "CrosshairFilename", CrosshairFilename); + ini_write_real("Settings", "CrosshairRemoveBG", CrosshairRemoveBG); + ini_write_real("Settings", "Queued Jumping", global.queueJumping); + + ini_write_string("Background", "BackgroundHash", global.backgroundHash); + ini_write_string("Background", "BackgroundTitle", global.backgroundTitle); + ini_write_string("Background", "BackgroundURL", global.backgroundURL); + ini_write_real("Background", "BackgroundShowVersion", global.backgroundShowVersion); + + ini_write_real("Classlimits", "Scout", global.classlimits[CLASS_SCOUT]) + ini_write_real("Classlimits", "Pyro", global.classlimits[CLASS_PYRO]) + ini_write_real("Classlimits", "Soldier", global.classlimits[CLASS_SOLDIER]) + ini_write_real("Classlimits", "Heavy", global.classlimits[CLASS_HEAVY]) + ini_write_real("Classlimits", "Demoman", global.classlimits[CLASS_DEMOMAN]) + ini_write_real("Classlimits", "Medic", global.classlimits[CLASS_MEDIC]) + ini_write_real("Classlimits", "Engineer", global.classlimits[CLASS_ENGINEER]) + ini_write_real("Classlimits", "Spy", global.classlimits[CLASS_SPY]) + ini_write_real("Classlimits", "Sniper", global.classlimits[CLASS_SNIPER]) + ini_write_real("Classlimits", "Quote", global.classlimits[CLASS_QUOTE]) + + //screw the 0 index we will start with 1 + //map_truefort + maps[1] = ini_read_real("Maps", "ctf_truefort", 1); + //map_2dfort + maps[2] = ini_read_real("Maps", "ctf_2dfort", 2); + //map_conflict + maps[3] = ini_read_real("Maps", "ctf_conflict", 3); + //map_classicwell + maps[4] = ini_read_real("Maps", "ctf_classicwell", 4); + //map_waterway + maps[5] = ini_read_real("Maps", "ctf_waterway", 5); + //map_orange + maps[6] = ini_read_real("Maps", "ctf_orange", 6); + //map_dirtbowl + maps[7] = ini_read_real("Maps", "cp_dirtbowl", 7); + //map_egypt + maps[8] = ini_read_real("Maps", "cp_egypt", 8); + //arena_montane + maps[9] = ini_read_real("Maps", "arena_montane", 9); + //arena_lumberyard + maps[10] = ini_read_real("Maps", "arena_lumberyard", 10); + //gen_destroy + maps[11] = ini_read_real("Maps", "gen_destroy", 11); + //koth_valley + maps[12] = ini_read_real("Maps", "koth_valley", 12); + //koth_corinth + maps[13] = ini_read_real("Maps", "koth_corinth", 13); + //koth_harvest + maps[14] = ini_read_real("Maps", "koth_harvest", 14); + //dkoth_atalia + maps[15] = ini_read_real("Maps", "dkoth_atalia", 15); + //dkoth_sixties + maps[16] = ini_read_real("Maps", "dkoth_sixties", 16); + + //Server respawn time calculator. Converts each second to a frame. (read: multiply by 30 :hehe:) + if (global.Server_RespawntimeSec == 0) + { + global.Server_Respawntime = 1; + } + else + { + global.Server_Respawntime = global.Server_RespawntimeSec * 30; + } + + // I have to include this, or the client'll complain about an unknown variable. + global.mapchanging = false; + + ini_write_real("Maps", "ctf_truefort", maps[1]); + ini_write_real("Maps", "ctf_2dfort", maps[2]); + ini_write_real("Maps", "ctf_conflict", maps[3]); + ini_write_real("Maps", "ctf_classicwell", maps[4]); + ini_write_real("Maps", "ctf_waterway", maps[5]); + ini_write_real("Maps", "ctf_orange", maps[6]); + ini_write_real("Maps", "cp_dirtbowl", maps[7]); + ini_write_real("Maps", "cp_egypt", maps[8]); + ini_write_real("Maps", "arena_montane", maps[9]); + ini_write_real("Maps", "arena_lumberyard", maps[10]); + ini_write_real("Maps", "gen_destroy", maps[11]); + ini_write_real("Maps", "koth_valley", maps[12]); + ini_write_real("Maps", "koth_corinth", maps[13]); + ini_write_real("Maps", "koth_harvest", maps[14]); + ini_write_real("Maps", "dkoth_atalia", maps[15]); + ini_write_real("Maps", "dkoth_sixties", maps[16]); + + ini_close(); + + // parse the protocol version UUID for later use + global.protocolUuid = buffer_create(); + parseUuid(PROTOCOL_UUID, global.protocolUuid); + + global.gg2lobbyId = buffer_create(); + parseUuid(GG2_LOBBY_UUID, global.gg2lobbyId); + + // Create abbreviations array for rewards use + initRewards() + +var a, IPRaw, portRaw; +doubleCheck=0; +global.launchMap = ""; + + for(a = 1; a <= parameter_count(); a += 1) + { + if (parameter_string(a) == "-dedicated") + { + global.dedicatedMode = 1; + } + else if (parameter_string(a) == "-restart") + { + restart = true; + } + else if (parameter_string(a) == "-server") + { + IPRaw = parameter_string(a+1); + if (doubleCheck == 1) + { + doubleCheck = 2; + } + else + { + doubleCheck = 1; + } + } + else if (parameter_string(a) == "-port") + { + portRaw = parameter_string(a+1); + if (doubleCheck == 1) + { + doubleCheck = 2; + } + else + { + doubleCheck = 1; + } + } + else if (parameter_string(a) == "-map") + { + global.launchMap = parameter_string(a+1); + global.dedicatedMode = 1; + } + } + + if (doubleCheck == 2) + { + global.serverPort = real(portRaw); + global.serverIP = IPRaw; + global.isHost = false; + instance_create(0,0,Client); + } + + global.customMapdesginated = 0; + + // if the user defined a valid map rotation file, then load from there + + if(customMapRotationFile != "" && file_exists(customMapRotationFile) && global.launchMap == "") { + global.customMapdesginated = 1; + var fileHandle, i, mapname; + fileHandle = file_text_open_read(customMapRotationFile); + for(i = 1; !file_text_eof(fileHandle); i += 1) { + mapname = file_text_read_string(fileHandle); + // remove leading whitespace from the string + while(string_char_at(mapname, 0) == " " || string_char_at(mapname, 0) == chr(9)) { // while it starts with a space or tab + mapname = string_delete(mapname, 0, 1); // delete that space or tab + } + if(mapname != "" && string_char_at(mapname, 0) != "#") { // if it's not blank and it's not a comment (starting with #) + ds_list_add(global.map_rotation, mapname); + } + file_text_readln(fileHandle); + } + file_text_close(fileHandle); + } + + else if (global.launchMap != "") && (global.dedicatedMode == 1) + { + ds_list_add(global.map_rotation, global.launchMap); + } + + else { // else load from the ini file Maps section + //Set up the map rotation stuff + var i, sort_list; + sort_list = ds_list_create(); + for(i=1; i <= 16; i += 1) { + if(maps[i] != 0) ds_list_add(sort_list, ((100*maps[i])+i)); + } + ds_list_sort(sort_list, 1); + + // translate the numbers back into the names they represent + for(i=0; i < ds_list_size(sort_list); i += 1) { + switch(ds_list_find_value(sort_list, i) mod 100) { + case 1: + ds_list_add(global.map_rotation, "ctf_truefort"); + break; + case 2: + ds_list_add(global.map_rotation, "ctf_2dfort"); + break; + case 3: + ds_list_add(global.map_rotation, "ctf_conflict"); + break; + case 4: + ds_list_add(global.map_rotation, "ctf_classicwell"); + break; + case 5: + ds_list_add(global.map_rotation, "ctf_waterway"); + break; + case 6: + ds_list_add(global.map_rotation, "ctf_orange"); + break; + case 7: + ds_list_add(global.map_rotation, "cp_dirtbowl"); + break; + case 8: + ds_list_add(global.map_rotation, "cp_egypt"); + break; + case 9: + ds_list_add(global.map_rotation, "arena_montane"); + break; + case 10: + ds_list_add(global.map_rotation, "arena_lumberyard"); + break; + case 11: + ds_list_add(global.map_rotation, "gen_destroy"); + break; + case 12: + ds_list_add(global.map_rotation, "koth_valley"); + break; + case 13: + ds_list_add(global.map_rotation, "koth_corinth"); + break; + case 14: + ds_list_add(global.map_rotation, "koth_harvest"); + break; + case 15: + ds_list_add(global.map_rotation, "dkoth_atalia"); + break; + case 16: + ds_list_add(global.map_rotation, "dkoth_sixties"); + break; + + } + } + ds_list_destroy(sort_list); + } + + window_set_fullscreen(global.fullscreen); + + global.gg2Font = font_add_sprite(gg2FontS,ord("!"),false,0); + global.countFont = font_add_sprite(countFontS, ord("0"),false,2); + draw_set_font(global.gg2Font); + cursor_sprite = CrosshairS; + + if(!directory_exists(working_directory + "\Maps")) directory_create(working_directory + "\Maps"); + + instance_create(0, 0, AudioControl); + instance_create(0, 0, SSControl); + + // custom dialog box graphics + message_background(popupBackgroundB); + message_button(popupButtonS); + message_text_font("Century",9,c_white,1); + message_button_font("Century",9,c_white,1); + message_input_font("Century",9,c_white,0); + + //Key Mapping + ini_open("controls.gg2"); + global.jump = ini_read_real("Controls", "jump", ord("W")); + global.down = ini_read_real("Controls", "down", ord("S")); + global.left = ini_read_real("Controls", "left", ord("A")); + global.right = ini_read_real("Controls", "right", ord("D")); + global.attack = ini_read_real("Controls", "attack", MOUSE_LEFT); + global.special = ini_read_real("Controls", "special", MOUSE_RIGHT); + global.taunt = ini_read_real("Controls", "taunt", ord("F")); + global.chat1 = ini_read_real("Controls", "chat1", ord("Z")); + global.chat2 = ini_read_real("Controls", "chat2", ord("X")); + global.chat3 = ini_read_real("Controls", "chat3", ord("C")); + global.medic = ini_read_real("Controls", "medic", ord("E")); + global.drop = ini_read_real("Controls", "drop", ord("B")); + global.changeTeam = ini_read_real("Controls", "changeTeam", ord("N")); + global.changeClass = ini_read_real("Controls", "changeClass", ord("M")); + global.showScores = ini_read_real("Controls", "showScores", vk_shift); + ini_close(); + + calculateMonthAndDay(); + + if(!directory_exists(working_directory + "\Plugins")) directory_create(working_directory + "\Plugins"); + loadplugins(); + + /* Windows 8 is known to crash GM when more than three (?) sounds play at once + * We'll store the kernel version (Win8 is 6.2, Win7 is 6.1) and check it there. + ***/ + registry_set_root(1); // HKLM + global.NTKernelVersion = real(registry_read_string_ext("\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "CurrentVersion")); // SIC + + if (file_exists(CrosshairFilename)) + { + sprite_replace(CrosshairS,CrosshairFilename,1,CrosshairRemoveBG,false,0,0); + sprite_set_offset(CrosshairS,sprite_get_width(CrosshairS)/2,sprite_get_height(CrosshairS)/2); + } + if(global.dedicatedMode == 1) { + AudioControlToggleMute(); + room_goto_fix(Menu); + } else if(restart) { + room_goto_fix(Menu); + } + return true; +} diff --git a/samples/Game Maker Language/jsonion.gml b/samples/Game Maker Language/jsonion.gml new file mode 100644 index 00000000..e4d2a6cb --- /dev/null +++ b/samples/Game Maker Language/jsonion.gml @@ -0,0 +1,1861 @@ +// Originally from /jsonion.gml in JSOnion +// JSOnion v1.0.0d is licensed under the MIT licence. You may freely adapt and use this library in commercial and non-commercial projects. + +#define __jso_gmt_tuple +{ + + /** + tuple(>element_0<, >element_1<, ..., >element_n<): Return an n-tuple + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + //Position, address table and data + var pos, addr_table, data; + pos = 6*argument_count+4; + addr_table = ""; + data = ""; + + //Build the tuple element-by-element + var i, ca, isstr, datastr; + for (i=0; ith element of + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + //Capture arguments + var t, n, size; + t = argument0; + n = argument1; + size = __jso_gmt_size(t); + + //Search for the bounding positions for the th element in the address table + var start, afterend, isstr; + isstr = ord(string_char_at(t, 4+6*n))-$30; + start = real(string_copy(t, 5+6*n, 5)); + if (n < size-1) { + afterend = real(string_copy(t, 11+6*n, 5)); + } else { + afterend = string_length(t)+1; + } + + //Return the th element with the correct type + if (isstr) { + return string_copy(t, start, afterend-start); + } + else { + return real(string_copy(t, start, afterend-start)); + } + +} + +#define __jso_gmt_size +{ + + /** + size(tuple_source): Return the size of + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + return real(string_copy(argument0, 1, 3)); + +} + +#define __jso_gmt_numtostr +{ + + /** + __gmt_numtostr(num): Return string representation of . Decimal numbers expressed as scientific notation + with double precision (i.e. 15 digits) + @author: GameGeisha + @version: 1.2 (edited) + */ + if (frac(argument0) == 0) { + return string(argument0); + } + + var mantissa, exponent; + exponent = floor(log10(abs(argument0))); + mantissa = string_format(argument0/power(10,exponent), 15, 14); + var i, ca; + i = string_length(mantissa); + do { + ca = string_char_at(mantissa, i); + i -= 1; + } until (ca != "0") + if (ca != ".") { + mantissa = string_copy(mantissa, 1, i+1); + } + else { + mantissa = string_copy(mantissa, 1, i); + } + if (exponent != 0) { + return mantissa + "e" + string(exponent); + } + else { + return mantissa; + } + +} + +#define __jso_gmt_test_all +{ + + /** + test_all(): Runs all test suites + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + //Automated testing sequence + __jso_gmt_test_elem(); + __jso_gmt_test_size(); + __jso_gmt_test_numtostr(); + +} + +#define __jso_gmt_test_numtostr +{ + + /** + _test_numtostr(): Runs number-to-string tests + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + var tolerance; + tolerance = 1/10000000000; + + if (real(__jso_gmt_numtostr(9)) != 9) { + show_message("Scientific notation conversion failed for 1-digit integer! Result: " + __jso_gmt_numtostr(9)); + } + if (real(__jso_gmt_numtostr(500)) != 500) { + show_message("Scientific notation conversion failed for 3-digit integer! Result: " + __jso_gmt_numtostr(500)); + } + if (abs(real(__jso_gmt_numtostr(pi))-pi) > tolerance) { + show_message("Scientific notation conversion failed for pi! Result: " + __jso_gmt_numtostr(pi)); + } + if (abs(real(__jso_gmt_numtostr(104729.903455))-104729.903455) > tolerance) { + show_message("Scientific notation conversion failed for large decimal number! Result: " + __jso_gmt_numtostr(104729.903455)); + } + if (abs(real(__jso_gmt_numtostr(-pi))+pi) > tolerance) { + show_message("Scientific notation conversion failed for -pi! Result: " + __jso_gmt_numtostr(-pi)); + } + if (abs(real(__jso_gmt_numtostr(1/pi))-1/pi) > tolerance) { + show_message("Scientific notation conversion failed for 1/pi! Result: " + __jso_gmt_numtostr(1/pi)); + } + +} + +#define __jso_gmt_test_elem +{ + + /** + _test_elem(): Runs tuple element retrieval tests + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + if (__jso_gmt_elem(__jso_gmt_tuple("Qblock", "kll"), 0) != "Qblock") { + show_message("Element retrieval failed for simple string. #Should be:Qblock#Actual:" + __jso_gmt_elem(__jso_gmt_tuple("Qblock"), 0)); + } + if (__jso_gmt_elem(__jso_gmt_tuple(9, "Q", -7), 0) != 9) { + show_message("Element retrieval failed for simple number. #Should be 9#Actual:" + string(__jso_gmt_elem(__jso_gmt_tuple(9, "Q", 7), 0))); + } + if (__jso_gmt_elem(__jso_gmt_tuple("Qblock", "", "Negg"), 1) != "") { + show_message("Element retrieval failed for empty string#Should be empty string#Actual:"+string(__jso_gmt_elem(__jso_gmt_tuple("Qblock", "", "Negg"), 0))); + } + + if (__jso_gmt_elem(__jso_gmt_elem(__jso_gmt_tuple("Not this", __jso_gmt_tuple(0, 1, 2, 3), "Waahoo"), 1), 3) != 3) { + show_message("Element retrieval failed in nested tuple. #Should be 3#Actual:" + string(__jso_gmt_elem(__jso_gmt_elem(__jso_gmt_tuple("Not this", __jso_gmt_tuple(0, 1, 2, 3), "Waahoo"), 1), 3))); + } + +} + +#define __jso_gmt_test_size +{ + + /** + _test_size(): Runs tuple size tests + @author: GameGeisha + @version: 1.2 (GMTuple) + */ + + if (__jso_gmt_size(__jso_gmt_tuple("Waahoo", "Negg", 0)) != 3) { + show_message("Bad size for 3-tuple"); + } + if (__jso_gmt_size(__jso_gmt_tuple()) != 0) { + show_message("Bad size for null tuple"); + } + if (__jso_gmt_size(__jso_gmt_tuple(7)) != 1) { + show_message("Bad size for 1-tuple"); + } + if (__jso_gmt_size(__jso_gmt_tuple(1,2,3,4,5,6,7,8,9,10)) != 10) { + show_message("Bad size for 10-tuple"); + } + +} + +#define jso_new_map +{ + /** + jso_new_map(): Create a new map. + JSOnion version: 1.0.0d + */ + return ds_map_create(); +} + +#define jso_new_list +{ + /** + jso_new_list(): Create a new list. + JSOnion version: 1.0.0d + */ + return ds_list_create(); +} + +#define jso_map_add_real +{ + /** + jso_map_add_real(map, key, val): Add the key-value pair : to , where is a real value. + JSOnion version: 1.0.0d + */ + ds_map_add(argument0, argument1, argument2); +} + +#define jso_map_add_string +{ + /** + jso_map_add_string(map, key, str): Add the key-value pair : to , where is a string value. + JSOnion version: 1.0.0d + */ + ds_map_add(argument0, argument1, "s" + argument2); +} + +#define jso_map_add_sublist +{ + /** + jso_map_add_sublist(map, key, sublist): Add the key-value pair : to , where is a list. + JSOnion version: 1.0.0d + */ + ds_map_add(argument0, argument1, "l" + string(argument2)); +} + +#define jso_map_add_submap +{ + /** + jso_map_add_submap(map, key, submap): Add the key-value pair : to , where is a map. + JSOnion version: 1.0.0d + */ + ds_map_add(argument0, argument1, "m" + string(argument2)); +} + +#define jso_map_add_integer +{ + /** + jso_map_add_integer(map, key, int): Add the key-value pair : to , where is a integer value. + JSOnion version: 1.0.0d + */ + ds_map_add(argument0, argument1, floor(argument2)); +} + +#define jso_map_add_boolean +{ + /** + jso_map_add_boolean(map, key, bool): Add the key-value pair : to , where is a boolean value. + JSOnion version: 1.0.0d + */ + if (argument2) { + ds_map_add(argument0, argument1, "btrue"); + } else { + ds_map_add(argument0, argument1, "bfalse"); + } +} + +#define jso_list_add_real +{ + /** + jso_list_add_real(list, val): Append the real value to . + JSOnion version: 1.0.0d + */ + ds_list_add(argument0, argument1); +} + +#define jso_list_add_string +{ + /** + jso_list_add_string(list, str): Append the string value to . + JSOnion version: 1.0.0d + */ + ds_list_add(argument0, "s" + argument1); +} + +#define jso_list_add_sublist +{ + /** + jso_list_add_sublist(list, sublist): Append the list to . + JSOnion version: 1.0.0d + */ + ds_list_add(argument0, "l" + string(argument1)); +} + +#define jso_list_add_submap +{ + /** + jso_list_add_submap(list, submap): Append the map to . + JSOnion version: 1.0.0d + */ + ds_list_add(argument0, "m" + string(argument1)); +} + +#define jso_list_add_integer +{ + /** + jso_list_add_integer(list, int): Append the integer to . + JSOnion version: 1.0.0d + */ + ds_list_add(argument0, floor(argument1)); +} + +#define jso_list_add_boolean +{ + /** + jso_list_add_boolean(list, bool): Append the boolean value to . + JSOnion version: 1.0.0d + */ + if (argument1) { + ds_list_add(argument0, "btrue"); + } else { + ds_list_add(argument0, "bfalse"); + } +} + +#define jso_map_get +{ + /** + jso_map_get(map, key): Retrieve the value stored in with the key value , with the correct type. + JSOnion version: 1.0.0d + */ + + //Grab the value + var v; + v = ds_map_find_value(argument0, argument1); + + //String; could be string, map or list + if (is_string(v)) { + switch (string_char_at(v, 1)) { + case "s": + return string_delete(v, 1, 1); + break; + case "l": case "m": + return real(string_delete(v, 1, 1)); + break; + case "b": + if (v == "btrue") { + return true; + } + else if (v == "bfalse") { + return false; + } + else { + show_error("Invalid boolean value.", true); + } + break; + default: show_error("Invalid map contents.", true); break; + } + } + + //Real; return real value as-is + else { + return v; + } +} + +#define jso_map_get_type +{ + /** + jso_map_get_type(map, key): Return the type of value to which the key value is mapped to in . + JSOnion version: 1.0.0d + */ + + //Grab the value + var v; + v = ds_map_find_value(argument0, argument1); + + //String; could be string, map or list + if (is_string(v)) { + switch (string_char_at(v, 1)) { + case "s": + return jso_type_string; + break; + case "l": + return jso_type_list; + break; + case "m": + return jso_type_map; + break; + case "b": + return jso_type_boolean; + break; + default: show_error("Invalid map content type.", true); break; + } + } + + //Real + else { + return jso_type_real; + } +} + +#define jso_list_get +{ + /** + jso_list_get(list, index): Retrieve the value stored in at position , with the correct type. + JSOnion version: 1.0.0d + */ + + //Grab the value + var v; + v = ds_list_find_value(argument0, argument1); + + //String; could be string, map or list + if (is_string(v)) { + switch (string_char_at(v, 1)) { + case "s": + return string_delete(v, 1, 1); + break; + case "l": case "m": + return real(string_delete(v, 1, 1)); + break; + case "b": + if (v == "btrue") { + return true; + } + else if (v == "bfalse") { + return false; + } + else { + show_error("Invalid boolean value.", true); + } + break; + default: show_error("Invalid list contents.", true); break; + } + } + + //Real; return real value as-is + else { + return v; + } +} + +#define jso_list_get_type +{ + /** + jso_list_get_type(list, index): Retrieve the type of value found at position of . + JSOnion version: 1.0.0d + */ + + //Grab the value + var v; + v = ds_list_find_value(argument0, argument1); + + //String; could be string, map or list + if (is_string(v)) { + switch (string_char_at(v, 1)) { + case "s": + return jso_type_string; + break; + case "l": + return jso_type_list; + break; + case "m": + return jso_type_map; + break; + case "b": + return jso_type_boolean; + break; + default: show_error("Invalid list content type.", true); break; + } + } + + //Real + else { + return jso_type_real; + } +} + +#define jso_cleanup_map +{ + /** + jso_cleanup_map(map): Recursively free up . + JSOnion version: 1.0.0d + */ + + //Loop through all keys + var i, l, k; + l = ds_map_size(argument0); + k = ds_map_find_first(argument0); + for (i=0; i. + JSOnion version: 1.0.0d + */ + + //Loop through all elements + var i, l, v; + l = ds_list_size(argument0); + for (i=0; i): Return a JSON-encoded version of real value . + This uses scientific notation with up to 15 significant digits for decimal values. + For integers, it just uses string(). + This is adapted from the same algorithm used in GMTuple. + JSOnion version: 1.0.0d + */ + + return __jso_gmt_numtostr(argument0); +} + +#define jso_encode_string +{ + /** + jso_encode_string(str): Return a JSON-encoded version of string . + JSOnion version: 1.0.0d + */ + + //Iteratively reconstruct the string + var i, l, s, c; + s = ""; + l = string_length(argument0); + for (i=1; i<=l; i+=1) { + //Replace escape characters + c = string_char_at(argument0, i); + switch (ord(c)) { + case 34: case 92: case 47: //Double quotes, backslashes and slashes + s += "\" + c; + break; + case 8: //Backspace + s += "\b"; + break; + case 12: //Form feed + s += "\f"; + break; + case 10: //New line + s += "\n"; + break; + case 13: //Carriage return + s += "\r"; + break; + case 9: //Horizontal tab + s += "\t"; + break; + default: //Not an escape character + s += c; + break; + } + } + + //Add quotes + return '"' + s + '"'; +} + +#define jso_encode_list +{ + /** + jso_encode_list(list): Return a JSON-encoded version of list . + JSOnion version: 1.0.0d + */ + + //Iteratively encode each element + var i, l, s; + s = ""; + l = ds_list_size(argument0); + for (i=0; i 0) { + s += ","; + } + //Select correct encoding for each element, then recursively encode each + switch (jso_list_get_type(argument0, i)) { + case jso_type_real: + s += jso_encode_real(jso_list_get(argument0, i)); + break; + case jso_type_string: + s += jso_encode_string(jso_list_get(argument0, i)); + break; + case jso_type_map: + s += jso_encode_map(jso_list_get(argument0, i)); + break; + case jso_type_list: + s += jso_encode_list(jso_list_get(argument0, i)); + break; + case jso_type_boolean: + s += jso_encode_boolean(jso_list_get(argument0, i)); + break; + } + } + + //Done, add square brackets + return "[" + s + "]"; +} + +#define jso_encode_map +{ + /** + jso_encode_map(map): Return a JSON-encoded version of map . + JSOnion version: 1.0.0d + */ + + //Go through every key-value pair + var i, l, k, s; + s = ""; + l = ds_map_size(argument0); + k = ds_map_find_first(argument0); + for (i=0; i 0) { + s += ","; + } + //Find the key and encode it + if (is_real(k)) { + s += jso_encode_real(k); + } else { + s += jso_encode_string(k); + } + //Add the : separator + s += ":"; + //Select correct encoding for each value, then recursively encode each + switch (jso_map_get_type(argument0, k)) { + case jso_type_real: + s += jso_encode_real(jso_map_get(argument0, k)); + break; + case jso_type_string: + s += jso_encode_string(jso_map_get(argument0, k)); + break; + case jso_type_map: + s += jso_encode_map(jso_map_get(argument0, k)); + break; + case jso_type_list: + s += jso_encode_list(jso_map_get(argument0, k)); + break; + case jso_type_boolean: + s += jso_encode_boolean(jso_map_get(argument0, k)); + break; + } + //Get next key + k = ds_map_find_next(argument0, k); + } + + //Done, add braces + return "{" + s + "}"; +} + +#define jso_encode_integer +{ + /** + jso_encode_integer(int): Return a JSON-encoded version of the integer value . + JSOnion version: 1.0.0d + */ + return string(floor(argument0)); +} + +#define jso_encode_boolean +{ + /** + jso_encode_boolean(bool): Return a JSON-encoded version of the boolean value . + JSOnion version: 1.0.0d + */ + if (argument0) { + return "true"; + } else { + return "false"; + } +} + +#define jso_decode_map +{ + /** + jso_decode_map(json): Return a JSOnion-compatible map representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_map(argument0, 1), 0); +} + +#define jso_decode_list +{ + /** + jso_decode_list(json): Return a JSOnion-compatible list representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_list(argument0, 1), 0); +} + +#define jso_decode_string +{ + /** + jso_decode_string(json): Return a string representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_string(argument0, 1), 0); +} + +#define jso_decode_boolean +{ + /** + jso_decode_boolean(json): Return a boolean value representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_boolean(argument0, 1), 0); +} + +#define jso_decode_real +{ + /** + jso_decode_real(json): Return a real value representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_real(argument0, 1), 0); +} + +#define jso_decode_integer +{ + /** + jso_decode_integer(json): Return an integer value representing the JSON string . + JSOnion version: 1.0.0d + */ + return __jso_gmt_elem(_jso_decode_integer(argument0, 1), 0); +} + +#define _jso_decode_map +{ + /** + _jso_decode_map(json, startindex): Extract a map from JSON string starting at position . + Return a 2-tuple of the extracted map handle and the position after the ending }. + JSOnion version: 1.0.0d + */ + var i, len, map; + i = argument1; + len = string_length(argument0); + map = jso_new_map(); + + //Seek to first { + var c; + c = string_char_at(argument0, i); + if (c != "{") { + do { + i += 1; + c = string_char_at(argument0, i); + if (!_jso_is_whitespace_char(c)) && (c != "{") { + show_error("Cannot parse map at position " + string(i), true); + } + } until (c == "{") + } + i += 1; + + //Read until end of JSON or ending } + var found_end, state, found, current_key; + found_end = false; + state = 0; + for (i=i; i<=len && !found_end; i+=1) { + c = string_char_at(argument0, i); + switch (state) { + //0: Looking for a key or closing } + case 0: + switch (c) { + case "}": + found_end = true; + break; + case '"': + found = _jso_decode_string(argument0, i); + current_key = __jso_gmt_elem(found, 0); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": case "+": case "-": + found = _jso_decode_real(argument0, i); + current_key = __jso_gmt_elem(found, 0); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + //1: Looking for the : separator + case 1: + switch (c) { + case ":": + state = 2; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + //2: Looking for a value + case 2: + switch (c) { + case "[": + found = _jso_decode_list(argument0, i); + jso_map_add_sublist(map, current_key, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 3; + break; + case "{": + found = _jso_decode_map(argument0, i); + jso_map_add_submap(map, current_key, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 3; + break; + case '"': + found = _jso_decode_string(argument0, i); + jso_map_add_string(map, current_key, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 3; + break; + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": case "+": case "-": + found = _jso_decode_real(argument0, i); + jso_map_add_real(map, current_key, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 3; + break; + case "t": case "f": + found = _jso_decode_boolean(argument0, i); + jso_map_add_boolean(map, current_key, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 3; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + //3: Done looking for an entry, want comma or } + case 3: + switch (c) { + case "}": + found_end = true; + break; + case ",": + state = 0; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + } + } + + //Return extracted map with ending position if the ending } is found + if (found_end) { + return __jso_gmt_tuple(map, i); + } + //Ended too early, throw error + else { + show_error("Unexpected end of map in JSON string.", true); + } +} + +#define _jso_decode_list +{ + /** + _jso_decode_list(json, startindex): Extract a list from JSON string starting at position . + Return a 2-tuple of the extracted list handle and the position after the ending ]. + JSOnion version: 1.0.0d + */ + var i, len, list; + i = argument1; + len = string_length(argument0); + list = jso_new_list(); + + //Seek to first [ + var c; + c = string_char_at(argument0, i); + if (c != "[") { + do { + i += 1; + c = string_char_at(argument0, i); + if (!_jso_is_whitespace_char(c)) && (c != "[") { + show_error("Cannot parse list at position " + string(i), true); + } + } until (c == "[") + } + i += 1; + + //Read until end of JSON or ending ] + var found_end, state, found; + found_end = false; + state = 0; + for (i=i; i<=len && !found_end; i+=1) { + c = string_char_at(argument0, i); + switch (state) { + //0: Looking for an item + case 0: + switch (c) { + case "]": + found_end = true; + break; + case "[": + found = _jso_decode_list(argument0, i); + jso_list_add_sublist(list, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + case "{": + found = _jso_decode_map(argument0, i); + jso_list_add_submap(list, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + case '"': + found = _jso_decode_string(argument0, i); + jso_list_add_string(list, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": case "+": case "-": + found = _jso_decode_real(argument0, i); + jso_list_add_real(list, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + case "t": case "f": + found = _jso_decode_boolean(argument0, i); + jso_list_add_boolean(list, __jso_gmt_elem(found, 0)); + i = __jso_gmt_elem(found, 1)-1; + state = 1; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + //1: Done looking for an item, want comma or ] + case 1: + switch (c) { + case "]": + found_end = true; + break; + case ",": + state = 0; + break; + default: + if (!_jso_is_whitespace_char(c)) { + show_error("Unexpected character at position " + string(i) + ".", true); + } + break; + } + break; + } + } + + //Return extracted list with ending position if the ending ] is found + if (found_end) { + return __jso_gmt_tuple(list, i); + } + //Ended too early, throw error + else { + show_error("Unexpected end of list in JSON string.", true); + } +} + +#define _jso_decode_string +{ + /** + _jso_decode_string(json, startindex): Extract a string from JSON string starting at position . + Return a 2-tuple of the extracted string and the position after the ending double quote. + JSOnion version: 1.0.0d + */ + var i, len, str; + i = argument1; + len = string_length(argument0); + str = ""; + + //Seek to first double quote + var c; + c = string_char_at(argument0, i); + if (c != '"') { + do { + i += 1; + c = string_char_at(argument0, i); + } until (c == '"') + } + i += 1; + + //Read until end of JSON or ending double quote + var found_end, escape_mode; + found_end = false; + escape_mode = false; + for (i=i; i<=len && !found_end; i+=1) { + c = string_char_at(argument0, i); + //Escape mode + if (escape_mode) { + switch (c) { + case '"': case "\": case "/": + str += c; + escape_mode = false; + break; + case "b": + str += chr(8); + escape_mode = false; + break; + case "f": + str += chr(12); + escape_mode = false; + break; + case "n": + str += chr(10); + escape_mode = false; + break; + case "r": + str += chr(13); + escape_mode = false; + break; + case "t": + str += chr(9); + escape_mode = false; + break; + case "u": + var u; + if (len-i < 5) { + show_error("Invalid escape character at position " + string(i) + ".", true); + } else { + str += chr(_jso_hex_to_decimal(string_copy(argument0, i+1, 4))); + escape_mode = false; + i += 4; + } + break; + default: + show_error("Invalid escape character at position " + string(i) + ".", true); + break; + } + } + //Regular mode + else { + switch (c) { + case '"': found_end = true; break; + case "\": escape_mode = true; break; + default: str += c; break; + } + } + } + + //Return extracted string with ending position if the ending double quote is found + if (found_end) { + return __jso_gmt_tuple(str, i); + } + //Ended too early, throw error + else { + show_error("Unexpected end of string in JSON string.", true); + } +} + +#define _jso_decode_boolean +{ + /** + _jso_decode_boolean(json, startindex): Extract a boolean from JSON string starting at position . + Return a 2-tuple of the extracted boolean and the position after the last e. + JSOnion version: 1.0.0d + */ + var i, len, str; + i = argument1; + len = string_length(argument0); + + //Seek to first t or f that can be found + var c; + c = string_char_at(argument0, i); + if (c != "t") && (c != "f") { + do { + i += 1; + c = string_char_at(argument0, i); + if (!_jso_is_whitespace_char(c)) && (c != "t") && (c != "f") { + show_error("Cannot parse boolean value at position " + string(i), true); + } + } until (c == "t") || (c == "f") + } + + //Look for true if t is found + if (c == "t") && (string_copy(argument0, i, 4) == "true") { + return __jso_gmt_tuple(true, i+4); + } + //Look for false if f is found + else if (c == "f") && (string_copy(argument0, i, 5) == "false") { + return __jso_gmt_tuple(false, i+5); + } + //Error: unexpected ending + else { + show_error("Unexpected end of boolean in JSON string.", true); + } +} + +#define _jso_decode_real +{ + /** + _jso_decode_real(json, startindex): Extract a real value from JSON string starting at position . + Return a 2-tuple of the extracted real value and the position after the real value. + JSOnion version: 1.0.0d + */ + var i, len, str; + i = argument1; + len = string_length(argument0); + str = ""; + + //Seek to first character: +, -, or 0-9 + var c; + c = string_char_at(argument0, i); + if (string_pos(c, "0123456789+-") == 0) { + do { + i += 1; + c = string_char_at(argument0, i); + if (!_jso_is_whitespace_char(c)) && (string_pos(c, "0123456789+-") == 0) { + show_error("Cannot parse real value at position " + string(i), true); + } + } until (string_pos(c, "0123456789+-") > 0) + } + + //Determine starting state + var state; + switch (c) { + case "+": case "-": + state = 0; + break; + default: + state = 1; + break; + } + str += c; + i += 1; + + //Loop until no more digits found + var done; + done = false; + for (i=i; i<=len && !done; i+=1) { + c = string_char_at(argument0, i); + switch (state) { + //0: Found a sign, looking for a starting number + case 0: + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = 1; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + break; + //1: Found a starting digit, looking for decimal dot, e, E, or more digits + case 1: + if (_jso_is_whitespace_char(c)) || (string_pos(c, ":,]}") > 0) { + done = true; + i -= 1; + } else { + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + break; + case ".": + str += c; + state = 2; + break; + case "e": case "E": + str += c; + state = 3; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a dot, e, E or a digit.", true); + break; + } + } + break; + //2: Found a decimal dot, looking for more digits + case 2: + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = -2; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + break; + //-2: Found a decimal dot and a digit after it, looking for more digits, e, or E + case -2: + if (_jso_is_whitespace_char(c)) || (string_pos(c, ":,]}") > 0) { + done = true; + i -= 1; + } else { + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + break; + case "e": case "E": + str += c; + state = 3; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting an e, E or a digit.", true); + break; + } + } + break; + //3: Found an e/E, looking for +, - or more digits + case 3: + switch (c) { + case "+": case "-": + str += c; + state = 4; + break; + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = 5; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a +, - or a digit.", true); + break; + } + break; + //4: Found an e/E exponent sign, looking for more digits + case 4: + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = 5; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + break; + //5: Looking for final digits of the exponent + case 5: + if (_jso_is_whitespace_char(c)) || (string_pos(c, ":,]}") > 0) { + done = true; + i -= 1; + } else { + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = 5; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + } + break; + } + } + + //Am I still expecting more characters? + if (done) || (state == 1) || (state == -2) || (state == 5) { + return __jso_gmt_tuple(real(str), i); + } + //Error: unexpected ending + else { + show_error("Unexpected end of real in JSON string.", true); + } +} + +#define _jso_decode_integer +{ + /** + _jso_decode_real(json, startindex): Extract a real value from JSON string starting at position . + Return a 2-tuple of the extracted integer value (with leading i) and the position after the real value. + JSOnion version: 1.0.0d + */ + var i, len, str; + i = argument1; + len = string_length(argument0); + str = ""; + + //Seek to first character: +, -, or 0-9 + var c; + c = string_char_at(argument0, i); + if (string_pos(c, "0123456789+-") == 0) { + do { + i += 1; + c = string_char_at(argument0, i); + if (!_jso_is_whitespace_char(c)) && (string_pos(c, "0123456789+-") == 0) { + show_error("Cannot parse integer value at position " + string(i), true); + } + } until (string_pos(c, "0123456789+-") > 0) + } + + //Determine starting state + var state; + switch (c) { + case "+": case "-": + state = 0; + break; + default: + state = 1; + break; + } + str += c; + i += 1; + + //Loop until no more digits found + var done; + done = false; + for (i=i; i<=len && !done; i+=1) { + c = string_char_at(argument0, i); + switch (state) { + //0: Found a sign, looking for a starting number + case 0: + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + state = 1; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + break; + //1: Found a starting digit, looking for decimal dot, e, E, or more digits + case 1: + if (_jso_is_whitespace_char(c)) || (string_pos(c, ":,]}") > 0) { + done = true; + i -= 1; + } else { + switch (c) { + case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": + str += c; + break; + default: + show_error("Unexpected character at position " + string(i) + ", expecting a digit.", true); + break; + } + } + break; + } + } + + //Am I still expecting more characters? + if (done) || (state == 1) { + return __jso_gmt_tuple(floor(real(str)), i); + } + //Error: unexpected ending + else { + show_error("Unexpected end of integer in JSON string.", true); + } +} + +#define jso_compare_maps +{ + /** + jso_compare_maps(map1, map2): Return whether the contents of JSOnion-compatible maps and are the same. + JSOnion version: 1.0.0d + */ + + //If they aren't the same size, they can't be the same + var size; + size = ds_map_size(argument0); + if (size != ds_map_size(argument1)) { + return false; + } + + //Compare contents pairwise + var i, k, type, a, b; + k = ds_map_find_first(argument0); + for (i=0; i and are the same. + JSOnion version: 1.0.0d + */ + + //If they aren't the same size, they can't be the same + var size; + size = ds_list_size(argument0); + if (size != ds_list_size(argument1)) { + return false; + } + + //Compare contents pairwise + var i, type, a, b; + for (i=0; i, return whether a value exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i, return whether a value exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i, return the value that exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i, return the type of value that exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i, return the value that exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i, return the type of value that exists there. + JSOnion version: 1.0.0d + */ + + //Catch empty calls + if (argument_count < 2) { + show_error("Expected at least 2 arguments, got " + string(argument_count) + ".", true); + } + + //Build list of keys/indices + var i, key_list; + key_list = ds_list_create(); + for (i=1; i= ds_list_size(data)) { + switch (task_type) { + case 0: + return false; + break; + default: + show_error("Index overflow for nested lists in " + type_string + " lookup.", true); + break; + } + } + type = jso_list_get_type(data, k); + data = jso_list_get(data, k); + break; + //Trying to go through a leaf; don't attempt to look further + default: + switch (task_type) { + case 0: + return false; + break; + default: + show_error("Recursive overflow in " + type_string + " lookup.", true); + break; + } + break; + } + } + + //Can find something, return the value requested by the task + switch (task_type) { + case 0: + return true; + break; + case 1: + return data; + break; + case 2: + return type; + break; + } +} + +#define _jso_is_whitespace_char +{ + /** + _jso_is_whitespace_char(char): Return whether is a whitespace character. + Definition of whitespace is given by Unicode 6.0, Chapter 4.6. + JSOnion version: 1.0.0d + */ + switch (ord(argument0)) { + case $0009: + case $000A: + case $000B: + case $000C: + case $000D: + case $0020: + case $0085: + case $00A0: + case $1680: + case $180E: + case $2000: + case $2001: + case $2002: + case $2003: + case $2004: + case $2005: + case $2006: + case $2007: + case $2008: + case $2009: + case $200A: + case $2028: + case $2029: + case $202F: + case $205F: + case $3000: + return true; + } + return false; +} + +#define _jso_hex_to_decimal +{ + /** + _jso_hex_to_decimal(hex_string): Return the decimal value of the hex number represented by + JSOnion version: 1.0.0d + */ + var hex_string, hex_digits; + hex_string = string_lower(argument0); + hex_digits = "0123456789abcdef"; + + //Convert digit-by-digit + var i, len, digit_value, num; + len = string_length(hex_string); + num = 0; + for (i=1; i<=len; i+=1) { + digit_value = string_pos(string_char_at(hex_string, i), hex_digits)-1; + if (digit_value >= 0) { + num *= 16; + num += digit_value; + } + //Unknown character + else { + show_error("Invalid hex number: " + argument0, true); + } + } + return num; +} + diff --git a/samples/Game Maker Language/jsonion_test.gml b/samples/Game Maker Language/jsonion_test.gml new file mode 100644 index 00000000..3cf0d423 --- /dev/null +++ b/samples/Game Maker Language/jsonion_test.gml @@ -0,0 +1,1169 @@ +// Originally from /jsonion_test.gml in JSOnion +// JSOnion v1.0.0d is licensed under the MIT licence. You may freely adapt and use this library in commercial and non-commercial projects. + +#define assert_true +{ + /** + assert_true(result, errormsg): Display error unless is true. + */ + + if (!argument0) { + _assert_error_popup(argument1 + string_repeat(_assert_newline(), 2) + "Expected true, got false."); + } +} + +#define assert_false +{ + /** + assert_false(result, errormsg): Display error unless is false. + */ + + if (argument0) { + _assert_error_popup(argument1 + string_repeat(_assert_newline(), 2) + "Expected false, got true."); + } +} + +#define assert_equal +{ + /** + assert_equal(expected, result, errormsg): Display error unless and are equal. + */ + + //Safe equality check; won't crash even if the two are different types + var match; + match = is_string(argument0) == is_string(argument1); + if (match) { + match = argument0 == argument1; + } + + //No match? + if (!match) { + //Data types + var type; + type[0] = "(Real)"; + type[1] = "(String)"; + + //Construct message + var msg; + msg = argument2; + //Add expected value + msg += string_repeat(_assert_newline(), 2); + msg += "Expected " + type[is_string(argument0)] + ":" + _assert_newline(); + msg += _assert_debug_value(argument0); + //Add actual value + msg += string_repeat(_assert_newline(), 2); + msg += "Actual " + type[is_string(argument1)] + ":" + _assert_newline(); + msg += _assert_debug_value(argument1); + + //Display message + _assert_error_popup(msg); + } +} + +#define _assert_error_popup +{ + /** + _assert_error_popup(msg): Display an assertion error. + */ + + //Display message + if (os_browser == browser_not_a_browser) { + show_error(argument0, false); //Full-fledged error message for non-browser environments + } else { + show_message(argument0); //Browsers don't support show_error(), use show_message() instead + } +} + +#define _assert_debug_value +{ + /** + _assert_debug_value(val): Returns a low-level debug value for the value . + can be a string or a real value. + */ + + //String + if (is_string(argument0)) { + if (os_browser == browser_not_a_browser) { + return argument0; + } else { + return string_replace_all(argument0, "#", "\#"); + } + } + + //Numeric --- use GMTuple's algorithm + else { + + //Integers + if (frac(argument0) == 0) { + return string(argument0); + } + + //Decimal numbers; get exponent and mantissa + var mantissa, exponent; + exponent = floor(log10(abs(argument0))); + mantissa = string_format(argument0/power(10,exponent), 15, 14); + //Look for trailing zeros in the mantissa + var i, ca; + i = string_length(mantissa); + do { + ca = string_char_at(mantissa, i); + i -= 1; + } until (ca != "0") + //Remove the dot if only the first digit of the normalized mantissa is nonzero + if (ca != ".") { + mantissa = string_copy(mantissa, 1, i+1); + } + else { + mantissa = string_copy(mantissa, 1, i); + } + //Remove the exponent if it is 0 + if (exponent != 0) { + return mantissa + "e" + string(exponent); + } else { + return mantissa; + } + + //GMTuple algorithm done + } +} + +#define _assert_newline +{ + /** + _assert_newline(): Returns a system-appropriate newline character sequence. + */ + + if (os_browser == browser_not_a_browser) { + return chr(13) + chr(10); + } else { + return "#"; + } +} + +#define jso_test_all +{ + /** + jso_test_all(): Run the test suite for the JSOnion library. + JSOnion version: 1.0.0d + */ + var a, b; + a = current_time; + _test_jso_new(); + _test_jso_map_add(); + _test_jso_list_add(); + _test_jso_encode(); + _test_jso_compare(); + _test_jso_decode(); + _test_jso_lookup(); + _test_jso_bugs(); + __jso_gmt_test_all(); + b = current_time; + show_debug_message("JSOnion: Tests completed in " + string(b-a) + "ms."); +} + +#define _test_jso_new +{ + /** + _test_jso_new(): Test jso_new_*() functions. + JSOnion version: 1.0.0d + */ + + var expected, actual; + + //jso_new_map() + actual = jso_new_map(); + assert_true(actual >= 0, "jso_new_map() failed to create a new map."); + ds_map_destroy(actual); + + //jso_new_list() + actual = jso_new_list(); + assert_true(actual >= 0, "jso_new_list() failed to create a new list."); + ds_list_destroy(actual); +} + +#define _test_jso_map_add +{ + /** + _test_jso_map_add(): Test jso_map_add_*() functions. + JSOnion version: 1.0.0d + */ + + var expected, actual, key, map; + map = jso_new_map(); + + //jso_map_add_real() + expected = pi; + key = "pi"; + jso_map_add_real(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_real() failed to add the number."); + assert_equal(expected, actual, "jso_map_add_real() added the wrong number."); + ds_map_delete(map, key); + + //jso_map_add_string() + expected = "waahoo"; + key = "str"; + jso_map_add_string(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_string() failed to add the string."); + assert_equal(expected, actual, "jso_map_add_string() added the wrong string."); + ds_map_delete(map, key); + + //jso_map_add_sublist() + expected = jso_new_list(); + key = "sublist"; + jso_map_add_sublist(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_sublist() failed to add the new sublist."); + assert_equal(expected, actual, "jso_map_add_sublist() added the wrong sublist."); + ds_map_delete(map, key); + ds_list_destroy(expected); + + //jso_map_add_submap() + expected = jso_new_map(); + key = "sublist"; + jso_map_add_sublist(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_submap() failed to add the new submap."); + assert_equal(expected, actual, "jso_map_add_submap() added the wrong submap."); + ds_map_delete(map, key); + ds_map_destroy(expected); + + //jso_map_add_integer() + expected = 2345; + key = "integer"; + jso_map_add_integer(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_integer() failed to add the new integer."); + assert_equal(expected, actual, "jso_map_add_integer() added the wrong integer."); + ds_map_delete(map, key); + + //jso_map_add_boolean() --- true + expected = true; + key = "booleantrue"; + jso_map_add_boolean(map, key, expected); + actual = jso_map_get(map, key); + assert_true(ds_map_exists(map, key), "jso_map_add_boolean() failed to add true."); + assert_true(actual, "jso_map_add_boolean() added the wrong true."); + ds_map_delete(map, key); + + //jso_map_add_boolean() --- false + expected = false; + key = "booleanfalse"; + jso_map_add_boolean(map, key, expected); + actual = jso_map_get(map, key) + assert_true(ds_map_exists(map, key), "jso_map_add_boolean() failed to add false."); + assert_false(actual, "jso_map_add_boolean() added the wrong false."); + ds_map_delete(map, key); + + //Cleanup + ds_map_destroy(map); +} + +#define _test_jso_list_add +{ + /** + _test_jso_list_add(): Test jso_list_add_*() functions. + JSOnion version: 1.0.0d + */ + + var expected, actual, list; + list = jso_new_list(); + + //jso_list_add_real() + expected = pi; + jso_list_add_real(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_real() failed to add the number."); + assert_equal(expected, actual, "jso_list_add_real() added the wrong number."); + ds_list_clear(list); + + //jso_list_add_string() + expected = "waahoo"; + jso_list_add_string(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_string() failed to add the string."); + assert_equal(expected, actual, "jso_list_add_string() added the wrong string."); + ds_list_clear(list); + + //jso_list_add_sublist() + expected = jso_new_list(); + jso_list_add_sublist(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_sublist() failed to add the sublist."); + assert_equal(expected, actual, "jso_list_add_sublist() added the wrong sublist."); + ds_list_clear(list); + ds_list_destroy(expected); + + //jso_list_add_submap() + expected = jso_new_map(); + jso_list_add_submap(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_submap() failed to add the submap."); + assert_equal(expected, actual, "jso_list_add_submap() added the wrong submap."); + ds_list_clear(list); + ds_map_destroy(expected); + + //jso_list_add_integer() + expected = 2345; + jso_list_add_integer(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_integer() failed to add integer."); + assert_equal(expected, actual, "jso_list_add_integer() added the wrong integer."); + ds_list_clear(list); + + //jso_list_add_boolean() --- true + expected = true; + jso_list_add_boolean(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_boolean() failed to add boolean true."); + assert_true(actual, "jso_list_add_boolean() added the wrong boolean true."); + ds_list_clear(list); + + //jso_list_add_boolean() --- false + expected = false; + jso_list_add_boolean(list, expected); + actual = jso_list_get(list, 0); + assert_false(ds_list_empty(list), "jso_list_add_boolean() failed to add boolean false."); + assert_false(actual, "jso_list_add_boolean() added the wrong boolean false."); + ds_list_clear(list); + + //Cleanup + ds_list_destroy(list); +} + +#define _test_jso_encode +{ + /** + _test_jso_encode(): Tests jso_encode_*() functions. + JSOnion version: 1.0.0d + */ + + var original, expected, actual; + + //jso_encode_real() --- Positive + expected = 3.1415; + actual = jso_encode_real(3.1415); + assert_equal(expected, real(actual), "jso_encode_real() failed to encode positive real!"); + + //jso_encode_real() --- Negative + expected = -2.71828; + actual = jso_encode_real(-2.71828); + assert_equal(expected, real(actual), "jso_encode_real() failed to encode negative real!"); + + //jso_encode_real() --- Zero + expected = 0; + actual = jso_encode_integer(0); + assert_equal(expected, real(actual), "jso_encode_real() failed to encode zero!"); + + //jso_encode_integer() --- Positive + expected = "2345"; + actual = jso_encode_integer(2345); + assert_equal(expected, actual, "jso_encode_integer() failed to encode positive integer!"); + + //jso_encode_integer() --- Negative + expected = "-45"; + actual = jso_encode_integer(-45); + assert_equal(expected, actual, "jso_encode_integer() failed to encode negative integer!"); + + //jso_encode_integer() --- Zero + expected = "0"; + actual = jso_encode_integer(0); + assert_equal(expected, actual, "jso_encode_integer() failed to encode zero!"); + + //jso_encode_boolean() --- true + expected = "true"; + actual = jso_encode_boolean(true); + assert_equal(expected, actual, "jso_encode_boolean() failed to encode true!"); + + //jso_encode_boolean() --- false + expected = "false"; + actual = jso_encode_boolean(false); + assert_equal(expected, actual, "jso_encode_boolean() failed to encode false!"); + + //jso_encode_string() --- Simple string + expected = '"waahoo"'; + actual = jso_encode_string("waahoo"); + assert_equal(expected, actual, "jso_encode_string() failed to encode simple string!"); + + //jso_encode_string() --- Empty string + expected = '""'; + actual = jso_encode_string(""); + assert_equal(expected, actual, "jso_encode_string() failed to encode empty string!"); + + //jso_encode_string() --- Basic escape characters + expected = '"\\\"\b\f\n\r\t"'; + actual = jso_encode_string('\"' + chr(8) + chr(12) + chr(10) + chr(13) + chr(9)); + assert_equal(expected, actual, "jso_encode_string() failed to encode escape character string!"); + + //jso_encode_map() --- Empty map + var empty_map; + empty_map = jso_new_map(); + expected = "{}"; + actual = jso_encode_map(empty_map); + assert_equal(expected, actual, "jso_encode_map() failed to encode empty map!"); + jso_cleanup_map(empty_map); + + //jso_encode_map() --- One-element map + var one_map; + one_map = jso_new_map(); + jso_map_add_string(one_map, "key", "value"); + expected = '{"key":"value"}'; + actual = jso_encode_map(one_map); + assert_equal(expected, actual, "jso_encode_map() failed to encode one-element map!"); + jso_cleanup_map(one_map); + + //jso_encode_map() --- Multi-element map + var multi_map, ok1, ok2; + multi_map = jso_new_map(); + jso_map_add_string(multi_map, "key1", "value\1"); + jso_map_add_integer(multi_map, "key2", 2); + ok1 = '{"key1":"value\\1","key2":2}'; + ok2 = '{"key2":2,"key1":"value\\1"}'; + actual = jso_encode_map(multi_map); + assert_true((actual == ok1) || (actual == ok2), "jso_encode_map() failed to encode multi-element map!"); + jso_cleanup_map(multi_map); + + //jso_encode_list() --- Empty list + var empty_list; + empty_list = jso_new_list(); + expected = "[]"; + actual = jso_encode_list(empty_list); + assert_equal(expected, actual, "jso_encode_list() failed to encode empty list!"); + jso_cleanup_list(empty_list); + + //jso_encode_list() --- One-element nested list + var one_list; + one_list = jso_new_list(); + jso_list_add_submap(one_list, jso_new_map()); + expected = "[{}]"; + actual = jso_encode_list(one_list); + assert_equal(expected, actual, "jso_encode_list() failed to encode one-element nested list!"); + jso_cleanup_list(one_list); + + //jso_encode_list() --- Multi-element nested list + var multi_list, submap, sublist; + multi_list = jso_new_list(); + submap = jso_new_map(); + jso_map_add_string(submap, "1", "one"); + jso_list_add_submap(multi_list, submap); + jso_list_add_integer(multi_list, 2); + sublist = jso_new_list(); + jso_list_add_string(sublist, "three"); + jso_list_add_boolean(sublist, true); + jso_list_add_sublist(multi_list, sublist); + expected = '[{"1":"one"},2,["three",true]]'; + actual = jso_encode_list(multi_list); + assert_equal(expected, actual, "jso_encode_list() failed to encode one-element nested list!"); + jso_cleanup_list(multi_list); +} + +#define _test_jso_decode +{ + /** + _test_jso_decode(): Test core _jso_decode_*() functions. + The formatting is intentionally erratic here to simulate actual formatting deviations. + JSOnion version: 1.0.0d + */ + var json, expected, actual, expected_structure, actual_structure; + + ////Primitives + + //_jso_decode_string(): Empty string + json = '""'; + expected = __jso_gmt_tuple("", 3); + actual = _jso_decode_string(json, 1); + assert_equal(expected, actual, "_jso_decode_string() failed to decode an empty string!"); + + //_jso_decode_string(): Small string + json = '"key" '; + expected = __jso_gmt_tuple("key", 6); + actual = _jso_decode_string(json, 1); + assert_equal(expected, actual, "_jso_decode_string() failed to decode a small string!"); + + //_jso_decode_string(): Simple string + json = ' "The quick brown fox jumps over the lazy dog." '; + expected = __jso_gmt_tuple("The quick brown fox jumps over the lazy dog.", 49); + actual = _jso_decode_string(json, 1); + assert_equal(expected, actual, "_jso_decode_string() failed to decode a simple string!"); + + //_jso_decode_string(): Escape characters + json = ' "\"\\\b\f\n\r\t\u003A"'; + expected = __jso_gmt_tuple('"\' + chr(8) + chr(12) + chr(10) + chr(13) + chr(9) + chr($003a), 24); + actual = _jso_decode_string(json, 1); + assert_equal(expected, actual, "_jso_decode_string() failed to decode a string with escape characters!"); + + //_jso_decode_string(): Mixed characters + json = ' "\"\\\bWaahoo\f\n\r\tnegg\u003a"'; + expected = __jso_gmt_tuple('"\' + chr(8) + "Waahoo" + chr(12) + chr(10) + chr(13) + chr(9) + "negg" + chr($003a), 34); + actual = _jso_decode_string(json, 1); + assert_equal(expected, actual, "_jso_decode_string() failed to decode a string with mixed characters!"); + + //_jso_decode_boolean(): True + json = 'true'; + expected = __jso_gmt_tuple(true, 5); + actual = _jso_decode_boolean(json, 1); + assert_equal(expected, actual, "_jso_decode_boolean() failed to decode true!"); + + //_jso_decode_boolean(): False + json = ' false '; + expected = __jso_gmt_tuple(false, 8); + actual = _jso_decode_boolean(json, 1); + assert_equal(expected, actual, "_jso_decode_boolean() failed to decode false!"); + + //_jso_decode_real(): Zero + json = '0'; + expected = __jso_gmt_tuple(0, 2); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode standard zero!"); + + //_jso_decode_real(): Signed zero + json = ' +0 '; + expected = __jso_gmt_tuple(0, 5); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode signed zero!"); + + //_jso_decode_real(): Signed zero with decimal digits + json = ' -0.000'; + expected = __jso_gmt_tuple(0, 8); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode signed zero with decimal digits!"); + + //_jso_decode_real(): Positive real + json = '3.14159'; + expected = __jso_gmt_tuple(3.14159, 8); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode positive real number!"); + + //_jso_decode_real(): Negative real + json = ' -2.71828'; + expected = __jso_gmt_tuple(-2.71828, 10); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode negative real number!"); + + //_jso_decode_real(): Positive real with positive exponent + json = ' 3.14159e2'; + expected = __jso_gmt_tuple(3.14159*100, 11); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode positive real number with positive exponent!"); + + //_jso_decode_real(): Negative real with positive exponent + json = ' -2.71828E2'; + expected = __jso_gmt_tuple(-2.71828*100, 12); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode negative real number with positive exponent!"); + + //_jso_decode_real(): Positive real with negative exponent + json = ' 314.159e-2'; + expected = __jso_gmt_tuple(3.14159, 12); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode positive real number with negative exponent!"); + + //_jso_decode_real(): Negative real with negative exponent + json = ' -271.828E-2'; + expected = __jso_gmt_tuple(-2.71828, 13); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode negative real number with negative exponent!"); + + //_jso_decode_real(): Positive integer + json = ' +1729'; + expected = __jso_gmt_tuple(1729, 7); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode positive integer!"); + + //_jso_decode_real(): Negative integer + json = '-583'; + expected = __jso_gmt_tuple(-583, 5); + actual = _jso_decode_real(json, 1); + assert_equal(expected, actual, "_jso_decode_real() failed to decode negative integer!"); + + //_jso_decode_integer(): Zero + json = ' 0 '; + expected = __jso_gmt_tuple(0, 3); + actual = _jso_decode_integer(json, 1); + assert_equal(expected, actual, "_jso_decode_integer() failed to decode zero!"); + + //_jso_decode_integer(): Positive integer + json = ' 1729 '; + expected = __jso_gmt_tuple(1729, 6); + actual = _jso_decode_integer(json, 1); + assert_equal(expected, actual, "_jso_decode_integer() failed to decode positive integer!"); + + //_jso_decode_integer(): Negative integer + json = ' -583'; + expected = __jso_gmt_tuple(-583, 8); + actual = _jso_decode_integer(json, 1); + assert_equal(expected, actual, "_jso_decode_integer() failed to decode negative integer!"); + + + ////Data structures + + //_jso_decode_map(): Empty map #1 + json = '{}'; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 3); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (#1)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (#1)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode an empty map! (#1)"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): Empty map #2 + json = ' { } '; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 7); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (#2)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (#2)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode an empty map! (#2)"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): One-entry map + json = ' {"key": "value"} '; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 18); + jso_map_add_string(expected_structure, "key", "value"); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (one-entry map)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (one-entry map)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode a one-entry map!"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): Multi-entry map + json = ' {"key" : "value", "pi":3.14, "bool" : true} '; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 48); + jso_map_add_string(expected_structure, "key", "value"); + jso_map_add_real(expected_structure, "pi", 3.14); + jso_map_add_boolean(expected_structure, "bool", true); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (multi-entry map)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (multi-entry map)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode a multi-entry map!"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): Nested maps + var submap; + json = '{ "waahoo" : { "woohah" : 3 } , "woohah" : 4 }'; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 47); + jso_map_add_integer(expected_structure, "woohah", 4); + submap = jso_new_map(); + jso_map_add_integer(submap, "woohah", 3); + jso_map_add_submap(expected_structure, "waahoo", submap); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (nested map)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (nested map)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode a nested map!"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): Map with nested lists + var sublist, subsublist; + json = '{ "waahoo" : [ "woohah", [true] ] , "woohah" : 4 }'; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 51); + jso_map_add_real(expected_structure, "woohah", 4); + sublist = jso_new_list(); + jso_list_add_string(sublist, "woohah"); + subsublist = jso_new_list(); + jso_list_add_boolean(subsublist, true); + jso_list_add_sublist(sublist, subsublist); + jso_map_add_sublist(expected_structure, "waahoo", sublist); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (map with nested lists)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (map with nested lists)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode a map with nested lists!"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_map(): Mix-up nested map + var sublist; + json = ' { "waahoo" : [{}, "a", 1] }'; + expected_structure = jso_new_map(); + expected = __jso_gmt_tuple(expected_structure, 30); + sublist = jso_new_list(); + jso_list_add_submap(sublist, jso_new_map()); + jso_list_add_string(sublist, "a"); + jso_list_add_real(sublist, 1); + jso_map_add_sublist(expected_structure, "waahoo", sublist); + actual = _jso_decode_map(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_map() didn't stop at the right place! (mix-up nested map)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_map() didn't include the right prefix! (mix-up nested map)"); + assert_true(jso_compare_maps(expected_structure, actual_structure), "_jso_decode_map() failed to decode a mix-up nested map!"); + jso_cleanup_map(expected_structure); + jso_cleanup_map(actual_structure); + + //_jso_decode_list(): Empty list #1 + json = '[]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 3); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (#1)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (#1)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode an empty list! (#1)"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure) + + //_jso_decode_list(): Empty list #2 + json = ' [ ] '; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 6); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (#2)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (#2)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode an empty list! (#2)"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); + + //_jso_decode_list(): One-entry list + json = '[3]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 4); + jso_list_add_integer(expected_structure, 3); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (one-entry list)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (one-entry list)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode a one-entry list!"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); + + //_jso_decode_list(): Multi-entry list + json = ' [4,"multi-entry",true]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 24); + jso_list_add_real(expected_structure, 4); + jso_list_add_string(expected_structure, "multi-entry"); + jso_list_add_boolean(expected_structure, true); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (multi-entry list)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (multi-entry list)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode a multi-entry list!"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); + + //_jso_decode_list(): Nested list + var sublist; + json = ' [ [], 3, false, ["waahoo"]]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 29); + jso_list_add_sublist(expected_structure, jso_new_list()); + jso_list_add_integer(expected_structure, 3); + jso_list_add_boolean(expected_structure, false); + sublist = jso_new_list(); + jso_list_add_string(sublist, "waahoo"); + jso_list_add_sublist(expected_structure, sublist); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (nested list)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (nested list)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode a nested list!"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); + + //_jso_decode_list(): List with nested maps + var submap; + json = ' [3, false, { "waahoo":"woo"}]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 31); + jso_list_add_integer(expected_structure, 3); + jso_list_add_boolean(expected_structure, false); + submap = jso_new_map(); + jso_map_add_string(submap, "waahoo", "woo"); + jso_list_add_submap(expected_structure, submap); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (list with nested maps)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (list with nested maps)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode a list with nested maps!"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); + + //_jso_decode_list(): Mix-up nested list + var submap; + json = '[{}, {"a":[]}]'; + expected_structure = jso_new_list(); + expected = __jso_gmt_tuple(expected_structure, 15); + jso_list_add_submap(expected_structure, jso_new_map()); + submap = jso_new_map(); + jso_map_add_sublist(submap, "a", jso_new_list()); + jso_list_add_submap(expected_structure, submap); + actual = _jso_decode_list(json, 1); + actual_structure = __jso_gmt_elem(actual, 0); + assert_equal(__jso_gmt_elem(expected, 1), __jso_gmt_elem(actual, 1), "_jso_decode_list() didn't stop at the right place! (mix-up nested list)"); + assert_equal(actual_structure, __jso_gmt_elem(actual, 0), "_jso_decode_list() didn't include the right prefix! (mix-up nested list)"); + assert_true(jso_compare_lists(expected_structure, actual_structure), "_jso_decode_list() failed to decode a mix-up nested list!"); + jso_cleanup_list(expected_structure); + jso_cleanup_list(actual_structure); +} + +#define _test_jso_compare +{ + /** + _test_jso_compare(): Test basic jso_compare_*() functions. + JSOnion version: 1.0.0d + */ + var a, b; + + //jso_compare_maps(): Empty maps should equal each other + a = jso_new_map(); + b = jso_new_map(); + assert_true(jso_compare_maps(a, b), "Empty maps should equal each other. (#1)"); + assert_true(jso_compare_maps(b, a), "Empty maps should equal each other. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_maps(): An empty map should not equal a filled map + a = jso_new_map(); + b = jso_new_map(); + jso_map_add_string(b, "junk", "info"); + jso_map_add_integer(b, "taxi", 1729); + assert_false(jso_compare_maps(a, b), "An empty map should not equal a filled map. (#1)"); + assert_false(jso_compare_maps(b, a), "An empty map should not equal a filled map. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_maps(): Maps with same content entered in different orders should equal each other + a = jso_new_map(); + b = jso_new_map(); + jso_map_add_real(a, "A", 1); + jso_map_add_real(a, "B", 2); + jso_map_add_real(a, "C", 3); + jso_map_add_real(b, "C", 3); + jso_map_add_real(b, "A", 1); + jso_map_add_real(b, "B", 2); + assert_true(jso_compare_maps(a, b), "Maps with same content entered in different orders should equal each other. (#1)"); + assert_true(jso_compare_maps(b, a), "Maps with same content entered in different orders should equal each other. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_maps(): Maps with different keys should not equal each other + a = jso_new_map(); + b = jso_new_map(); + jso_map_add_real(a, "A", 1); + jso_map_add_real(a, "B", 2); + jso_map_add_real(a, "C", 3); + jso_map_add_real(b, "D", 3); + jso_map_add_real(b, "A", 1); + jso_map_add_real(b, "B", 2); + assert_false(jso_compare_maps(a, b), "Maps with different keys should not equal each other. (#1)"); + assert_false(jso_compare_maps(b, a), "Maps with different keys should not equal each other. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_maps(): Maps with different values should not equal each other + a = jso_new_map(); + b = jso_new_map(); + jso_map_add_real(a, "A", 5); + jso_map_add_real(a, "B", 6); + jso_map_add_real(a, "C", 9); + jso_map_add_real(b, "A", 5); + jso_map_add_real(b, "B", 6); + jso_map_add_real(b, "C", 8); + assert_false(jso_compare_maps(a, b), "Maps with different values should not equal each other. (#1)"); + assert_false(jso_compare_maps(b, a), "Maps with different values should not equal each other. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_maps(): Maps with corresponding values of different types should not equal each other, and should not crash. + a = jso_new_map(); + b = jso_new_map(); + jso_map_add_real(a, "A", 5); + jso_map_add_real(a, "B", 6); + jso_map_add_real(a, "C", 8); + jso_map_add_real(b, "A", 5); + jso_map_add_string(b, "B", "six"); + jso_map_add_real(b, "C", 8); + assert_false(jso_compare_maps(a, b), "Maps with corresponding values of different types should not equal each other, and should not crash. (#1)"); + assert_false(jso_compare_maps(b, a), "Maps with corresponding values of different types should not equal each other, and should not crash. (#2)"); + jso_cleanup_map(a); + jso_cleanup_map(b); + + //jso_compare_lists(): Empty lists should equal each other + a = jso_new_list(); + b = jso_new_list(); + assert_true(jso_compare_lists(a, b), "Empty lists should equal each other. (#1)"); + assert_true(jso_compare_lists(b, a), "Empty lists should equal each other. (#2)"); + jso_cleanup_list(a); + jso_cleanup_list(b); + + //jso_compare_lists(): An empty list should not equal a filled list + a = jso_new_list(); + b = jso_new_list(); + jso_list_add_string(b, "junk"); + jso_list_add_integer(b, 1729); + assert_false(jso_compare_lists(a, b), "An empty list should not equal a filled list. (#1)"); + assert_false(jso_compare_lists(b, a), "An empty list should not equal a filled list. (#2)"); + jso_cleanup_list(a); + jso_cleanup_list(b); + + //jso_compare_lists(): Lists with same content entered in different orders should not equal each other + a = jso_new_list(); + b = jso_new_list(); + jso_list_add_real(a, 1); + jso_list_add_real(a, 2); + jso_list_add_real(a, 3); + jso_list_add_real(b, 3); + jso_list_add_real(b, 1); + jso_list_add_real(b, 2); + assert_false(jso_compare_lists(a, b), "Lists with same content entered in different orders should not equal each other. (#1)"); + assert_false(jso_compare_lists(b, a), "Lists with same content entered in different orders should not equal each other. (#2)"); + jso_cleanup_list(a); + jso_cleanup_list(b); + + //jso_compare_lists(): Lists with corresponding entries of different types should not equal each other, should also not crash. + a = jso_new_list(); + b = jso_new_list(); + jso_list_add_real(a, 1); + jso_list_add_real(a, 2); + jso_list_add_real(a, 3); + jso_list_add_real(b, 1); + jso_list_add_string(b, "two"); + jso_list_add_real(b, 3); + assert_false(jso_compare_lists(a, b), "Lists with corresponding entries of different types should not equal each other, should also not crash. (#1)"); + assert_false(jso_compare_lists(b, a), "Lists with corresponding entries of different types should not equal each other, should also not crash. (#2)"); + jso_cleanup_list(a); + jso_cleanup_list(b); +} + +#define _test_jso_lookup +{ + /** + _test_jso_lookup(): Test core jso_*_lookup() and jso_*_check() functions for nested structures. + JSOnion version: 1.0.0d + */ + var json, structure, expected, actual; + + //jso_map_check(): Single argument --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3 }'; + structure = jso_decode_map(json); + assert_true(jso_map_check(structure, "one"), "jso_map_check() failed to find existing entry! (single argument)"); + jso_cleanup_map(structure); + + //jso_map_lookup(): Single argument --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3 }'; + structure = jso_decode_map(json); + expected = 1; + actual = jso_map_lookup(structure, "one") + assert_equal(expected, actual, "jso_map_lookup() found the wrong entry! (single argument)"); + jso_cleanup_map(structure); + + //jso_map_lookup_type(): Single argument --- exists + json = '{ "one" : -1, "two" : true, "three" : "trap" }'; + structure = jso_decode_map(json); + expected = jso_type_real; + actual = jso_map_lookup_type(structure, "one") + assert_equal(expected, actual, "jso_map_lookup_type() found the wrong type! (single argument)"); + jso_cleanup_map(structure); + + //jso_map_check(): Single argument --- doesn't exist + json = '{ "one" : 1, "two" : 2, "three" : 3 }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "four"), "jso_map_check() found an inexistent entry! (single argument)"); + jso_cleanup_map(structure); + + //jso_map_check(): Single argument --- doesn't exist + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":false } }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "A"), "jso_map_check() found an inexistent entry! (single argument, nested)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments (recurse) --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":false } }'; + structure = jso_decode_map(json); + assert_true(jso_map_check(structure, "four", "A"), "jso_map_check() failed to find existing entry! (multiple arguments)"); + jso_cleanup_map(structure); + + //jso_map_lookup(): Multiple arguments (recurse) --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":false } }'; + structure = jso_decode_map(json); + expected = true; + actual = jso_map_lookup(structure, "four", "A"); + assert_equal(expected, actual, "jso_map_lookup() found the wrong entry! (multiple arguments)"); + jso_cleanup_map(structure); + + //jso_map_lookup_type(): Multiple arguments (recurse) --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":"trap" } }'; + structure = jso_decode_map(json); + expected = jso_type_boolean; + actual = jso_map_lookup_type(structure, "four", "A"); + assert_equal(expected, actual, "jso_map_lookup_type() found the wrong type! (multiple arguments)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments (recurse) --- doesn't exist + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":false } }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "four", "C"), "jso_map_check() found an inexistent entry! (multiple arguments, 1)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments (recurse) --- doesn't exist + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : { "A":true, "B":false } }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "three", ""), "jso_map_check() found an inexistent entry! (multiple arguments, 2)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments with nested list --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : [ "A", true, ["B", false] ] }'; + structure = jso_decode_map(json); + assert_true(jso_map_check(structure, "four", 2, 1), "jso_map_check() failed to find an existing entry! (multiple arguments, nested)"); + jso_cleanup_map(structure); + + //jso_map_lookup(): Multiple arguments with nested list --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : [ "A", true, ["B", false] ] }'; + structure = jso_decode_map(json); + expected = false; + actual = jso_map_lookup(structure, "four", 2, 1); + assert_equal(expected, actual, "jso_map_lookup() failed to find an existing entry! (multiple arguments, nested)"); + jso_cleanup_map(structure); + + //jso_map_lookup_type(): Multiple arguments with nested list --- exists + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : [ "A", true, [false, "false"] ] }'; + structure = jso_decode_map(json); + expected = jso_type_string; + actual = jso_map_lookup_type(structure, "four", 2, 1); + assert_equal(expected, actual, "jso_map_lookup_type() found the wrong type! (multiple arguments, nested)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments with nested list --- wrong type + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : [ "A", true, ["B", false] ] }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "four", "A", 1), "jso_map_check() found an inexistent entry! (multiple arguments, nested, wrong type)"); + jso_cleanup_map(structure); + + //jso_map_check(): Multiple arguments with nested list --- index overflow + json = '{ "one" : 1, "two" : 2, "three" : 3, "four" : [ "A", true, ["B", false] ] }'; + structure = jso_decode_map(json); + assert_false(jso_map_check(structure, "four", 2, 3), "jso_map_check() found an inexistent entry! (multiple arguments, nested, index overflow)"); + jso_cleanup_map(structure); + + //jso_list_check(): Single argument --- exists + json = '["one", 2, "three", true, 5]'; + structure = jso_decode_list(json); + assert_true(jso_list_check(structure, 2), "jso_list_check() failed to find an existing index! (single argument)"); + jso_cleanup_list(structure); + + //jso_list_lookup(): Single argument --- exists + json = '["one", 2, "three", true, 5]'; + structure = jso_decode_list(json); + expected = "three"; + actual = jso_list_lookup(structure, 2); + assert_equal(expected, actual, "jso_list_lookup() found the wrong index! (single argument)"); + jso_cleanup_list(structure); + + //jso_list_lookup_type(): Single argument --- exists + json = '["one", 2, "three", true, 5]'; + structure = jso_decode_list(json); + expected = jso_type_string; + actual = jso_list_lookup_type(structure, 2); + assert_equal(expected, actual, "jso_list_lookup_type() found the wrong type! (single argument)"); + jso_cleanup_list(structure); + + //jso_list_check(): Single argument --- doesn't exist + json = '["one", 2, "three", true, 5]'; + structure = jso_decode_list(json); + assert_false(jso_list_check(structure, 5), "jso_list_check() found an inexistent index! (single argument)"); + jso_cleanup_list(structure); + + //jso_list_check(): Multiple arguments (recurse) --- exists + json = '["one", 2, ["three", 3], true, 5]'; + structure = jso_decode_list(json); + assert_true(jso_list_check(structure, 2, 1), "jso_list_check() failed to find an existing index! (multiple arguments)"); + jso_cleanup_list(structure); + + //jso_list_lookup(): Multiple arguments (recurse) --- exists + json = '["one", 2, ["three", 3], true, 5]'; + structure = jso_decode_list(json); + expected = 3; + actual = jso_list_lookup(structure, 2, 1); + assert_equal(expected, actual, "jso_list_lookup() failed to find an existing index! (multiple arguments)"); + jso_cleanup_list(structure); + + //jso_list_lookup_type(): Multiple arguments (recurse) --- exists + json = '["one", 2, ["three", 3], true, 5]'; + structure = jso_decode_list(json); + expected = jso_type_real; + actual = jso_list_lookup_type(structure, 2, 1); + assert_equal(expected, actual, "jso_list_lookup_type() found the wrong type! (multiple arguments)"); + jso_cleanup_list(structure); + + //jso_list_check(): Multiple arguments (recurse) --- doesn't exist, inner index overflow + json = '["one", 2, ["three", 3], true, 5]'; + structure = jso_decode_list(json); + assert_false(jso_list_check(structure, 2, 2), "jso_list_check() found an inexistent index! (multiple arguments, inner index overflow)"); + jso_cleanup_list(structure); + + //jso_list_check(): Multiple arguments (recurse) --- doesn't exist, trying to index single entry + json = '["one", 2, ["three", 3], true, 5]'; + structure = jso_decode_list(json); + assert_false(jso_list_check(structure, 1, 0), "jso_list_check() found an inexistent index! (multiple arguments, indexing single entry)"); + jso_cleanup_list(structure); + + //jso_list_check(): Multiple arguments with nested map --- exists + json = '["one", 2, {"three":3}, true, 5]'; + structure = jso_decode_list(json); + assert_true(jso_list_check(structure, 2, "three"), "jso_list_check() failed to find an existing entry! (multiple arguments, nested map)"); + jso_cleanup_list(structure); + + //jso_list_lookup(): Multiple arguments with nested map --- exists + json = '["one", 2, {"three":3}, true, 5]'; + structure = jso_decode_list(json); + expected = 3; + actual = jso_list_lookup(structure, 2, "three"); + assert_equal(expected, actual, "jso_list_lookup() failed to find an existing entry! (multiple arguments, nested map)"); + jso_cleanup_list(structure); + + //jso_list_lookup_type(): Multiple arguments with nested map --- exists + json = '["one", 2, {"three":false}, true, 5]'; + structure = jso_decode_list(json); + expected = jso_type_boolean; + actual = jso_list_lookup_type(structure, 2, "three"); + assert_equal(expected, actual, "jso_list_lookup_type() found the wrong type! (multiple arguments, nested map)"); + jso_cleanup_list(structure); + + //jso_list_exists(): Multiple arguments with nested map --- doesn't exist, key on single entry + json = '["one", 2, {"three":3}, true, 5]'; + structure = jso_decode_list(json); + assert_false(jso_list_check(structure, 1, ""), "jso_list_check() found an inexistent entry! (multiple arguments, nested map, key on single entry)"); + jso_cleanup_list(structure); + + //jso_list_exists(): Multiple arguments with nested map --- doesn't exist, bad key + json = '["one", 2, {"three":3}, true, 5]'; + structure = jso_decode_list(json); + assert_false(jso_list_check(structure, 2, ""), "jso_list_check() found an inexistent entry! (multiple arguments, nested map, bad key)"); + jso_cleanup_list(structure); +} + +#define _test_jso_bugs +{ + /** + _test_jso_bugs(): Test reported bugs. + JSOnion version: 1.0.0d + */ + var expected, actual; + + //jso_encode_map() --- One-element map + //Bug 1: Crash when encoding boolean-valued entries in maps, unknown variable jso_type_integer + var one_map; + one_map = jso_new_map(); + jso_map_add_boolean(one_map, "true", true); + expected = '{"true":true}'; + actual = jso_encode_map(one_map); + assert_equal(expected, actual, "jso_encode_map() failed to encode one-element map with boolean entry!"); + jso_cleanup_map(one_map); +} + diff --git a/samples/Game Maker Language/loadserverplugins.gml b/samples/Game Maker Language/loadserverplugins.gml new file mode 100644 index 00000000..26a26758 --- /dev/null +++ b/samples/Game Maker Language/loadserverplugins.gml @@ -0,0 +1,252 @@ +/* + Originally from /Source/gg2/Scripts/Plugins/loadserverplugins.gml in Gang Garrison 2 + + Copyright (C) 2008-2013 Faucet Software + http://www.ganggarrison.com + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3 of the License, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, + see . + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +// loads plugins from ganggarrison.com asked for by server +// argument0 - comma separated plugin list (pluginname@md5hash) +// returns true on success, false on failure +var list, hashList, text, i, pluginname, pluginhash, realhash, url, handle, filesize, progress, tempfile, tempdir, failed, lastContact, isCached; + +failed = false; +list = ds_list_create(); +lastContact = 0; +isCached = false; +isDebug = false; +hashList = ds_list_create(); + +// split plugin list string +list = split(argument0, ','); + +// Split hashes from plugin names +for (i = 0; i < ds_list_size(list); i += 1) +{ + text = ds_list_find_value(list, i); + pluginname = string_copy(text, 0, string_pos("@", text) - 1); + pluginhash = string_copy(text, string_pos("@", text) + 1, string_length(text) - string_pos("@", text)); + ds_list_replace(list, i, pluginname); + ds_list_add(hashList, pluginhash); +} + +// Check plugin names and check for duplicates +for (i = 0; i < ds_list_size(list); i += 1) +{ + pluginname = ds_list_find_value(list, i); + + // invalid plugin name + if (!checkpluginname(pluginname)) + { + show_message('Error loading server-sent plugins - invalid plugin name:#"' + pluginname + '"'); + return false; + } + // is duplicate + else if (ds_list_find_index(list, pluginname) != i) + { + show_message('Error loading server-sent plugins - duplicate plugin:#"' + pluginname + '"'); + return false; + } +} + +// Download plugins +for (i = 0; i < ds_list_size(list); i += 1) +{ + pluginname = ds_list_find_value(list, i); + pluginhash = ds_list_find_value(hashList, i); + isDebug = file_exists(working_directory + "\ServerPluginsDebug\" + pluginname + ".zip"); + isCached = file_exists(working_directory + "\ServerPluginsCache\" + pluginname + "@" + pluginhash); + tempfile = temp_directory + "\" + pluginname + ".zip.tmp"; + tempdir = temp_directory + "\" + pluginname + ".tmp"; + + // check to see if we have a local copy for debugging + if (isDebug) + { + file_copy(working_directory + "\ServerPluginsDebug\" + pluginname + ".zip", tempfile); + // show warning + if (global.isHost) + { + show_message( + "Warning: server-sent plugin '" + + pluginname + + "' is being loaded from ServerPluginsDebug. Make sure clients have the same version, else they may be unable to connect." + ); + } + else + { + show_message( + "Warning: server-sent plugin '" + + pluginname + + "' is being loaded from ServerPluginsDebug. Make sure the server has the same version, else you may be unable to connect." + ); + } + } + // otherwise, check if we have it cached + else if (isCached) + { + file_copy(working_directory + "\ServerPluginsCache\" + pluginname + "@" + pluginhash, tempfile); + } + // otherwise, download as usual + else + { + // construct the URL + // http://www.ganggarrison.com/plugins/$PLUGINNAME$@$PLUGINHASH$.zip) + url = PLUGIN_SOURCE + pluginname + "@" + pluginhash + ".zip"; + + // let's make the download handle + handle = httpGet(url, -1); + + // download it + while (!httpRequestStatus(handle)) { + // prevent game locking up + io_handle(); + + httpRequestStep(handle); + + if (!global.isHost) { + // send ping if we haven't contacted server in 20 seconds + // we need to do this to keep the connection open + if (current_time-lastContact > 20000) { + write_byte(global.serverSocket, PING); + socket_send(global.serverSocket); + lastContact = current_time; + } + } + + // draw progress bar since they may be waiting a while + filesize = httpRequestResponseBodySize(handle); + progress = httpRequestResponseBodyProgress(handle); + draw_background_ext(background_index[0], 0, 0, background_xscale[0], background_yscale[0], 0, c_white, 1); + draw_set_color(c_white); + draw_set_alpha(1); + draw_set_halign(fa_left); + draw_rectangle(50, 550, 300, 560, 2); + draw_text(50, 530, "Downloading server-sent plugin " + string(i + 1) + "/" + string(ds_list_size(list)) + ' - "' + pluginname + '"'); + if (filesize != -1) + draw_rectangle(50, 550, 50 + progress / filesize * 250, 560, 0); + screen_refresh(); + } + + // errored + if (httpRequestStatus(handle) == 2) + { + show_message('Error loading server-sent plugins - download failed for "' + pluginname + '":#' + httpRequestError(handle)); + failed = true; + break; + } + + // request failed + if (httpRequestStatusCode(handle) != 200) + { + show_message('Error loading server-sent plugins - download failed for "' + pluginname + '":#' + string(httpRequestStatusCode(handle)) + ' ' + httpRequestReasonPhrase(handle)); + failed = true; + break; + } + else + { + write_buffer_to_file(httpRequestResponseBody(handle), tempfile); + if (!file_exists(tempfile)) + { + show_message('Error loading server-sent plugins - download failed for "' + pluginname + '":# No such file?'); + failed = true; + break; + } + } + + httpRequestDestroy(handle); + } + + // check file integrity + realhash = GG2DLL_compute_MD5(tempfile); + if (realhash != pluginhash) + { + show_message('Error loading server-sent plugins - integrity check failed (MD5 hash mismatch) for:#"' + pluginname + '"'); + failed = true; + break; + } + + // don't try to cache debug plugins + if (!isDebug) + { + // add to cache if we don't already have it + if (!file_exists(working_directory + "\ServerPluginsCache\" + pluginname + "@" + pluginhash)) + { + // make sure directory exists + if (!directory_exists(working_directory + "\ServerPluginsCache")) + { + directory_create(working_directory + "\ServerPluginsCache"); + } + // store in cache + file_copy(tempfile, working_directory + "\ServerPluginsCache\" + pluginname + "@" + pluginhash); + } + } + + // let's get 7-zip to extract the files + extractzip(tempfile, tempdir); + + // if the directory doesn't exist, extracting presumably failed + if (!directory_exists(tempdir)) + { + show_message('Error loading server-sent plugins - extracting zip failed for:#"' + pluginname + '"'); + failed = true; + break; + } +} + +if (!failed) +{ + // Execute plugins + for (i = 0; i < ds_list_size(list); i += 1) + { + pluginname = ds_list_find_value(list, i); + tempdir = temp_directory + "\" + pluginname + ".tmp"; + + // Debugging facility, so we know *which* plugin caused compile/execute error + fp = file_text_open_write(working_directory + "\last_plugin.log"); + file_text_write_string(fp, pluginname); + file_text_close(fp); + + // packetID is (i), so make queues for it + ds_map_add(global.pluginPacketBuffers, i, ds_queue_create()); + ds_map_add(global.pluginPacketPlayers, i, ds_queue_create()); + + // Execute plugin + execute_file( + // the plugin's main gml file must be in the root of the zip + // it is called plugin.gml + tempdir + "\plugin.gml", + // the plugin needs to know where it is + // so the temporary directory is passed as first argument + tempdir, + // the plugin needs to know its packetID + // so it is passed as the second argument + i + ); + } +} + +// Delete last plugin log +file_delete(working_directory + "\last_plugin.log"); + +// Get rid of plugin list +ds_list_destroy(list); + +// Get rid of plugin hash list +ds_list_destroy(hashList); + +return !failed; diff --git a/samples/Game Maker Language/processClientCommands.gml b/samples/Game Maker Language/processClientCommands.gml new file mode 100644 index 00000000..6c241d4b --- /dev/null +++ b/samples/Game Maker Language/processClientCommands.gml @@ -0,0 +1,384 @@ +/* + Originally from /Source/gg2/Scripts/GameServer/processClientCommands.gml in Gang Garrison 2 + + Copyright (C) 2008-2013 Faucet Software + http://www.ganggarrison.com + + This program is free software; + you can redistribute it and/or modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 3 of the License, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, + see . + + Additional permission under GNU GPL version 3 section 7 + If you modify this Program, or any covered work, by linking or combining it with the Game Maker runtime library, + the 39dll library/extension, Hobbel's Download Manager DLL, or modified versions of these libraries, + the licensors of this Program grant you additional permission to convey the resulting work. +*/ + +var player, playerId, commandLimitRemaining; + +player = argument0; +playerId = argument1; + +// To prevent players from flooding the server, limit the number of commands to process per step and player. +commandLimitRemaining = 10; + +with(player) { + if(!variable_local_exists("commandReceiveState")) { + // 0: waiting for command byte. + // 1: waiting for command data length (1 byte) + // 2: waiting for command data. + commandReceiveState = 0; + commandReceiveExpectedBytes = 1; + commandReceiveCommand = 0; + } +} + +while(commandLimitRemaining > 0) { + var socket; + socket = player.socket; + if(!tcp_receive(socket, player.commandReceiveExpectedBytes)) { + return 0; + } + + switch(player.commandReceiveState) + { + case 0: + player.commandReceiveCommand = read_ubyte(socket); + switch(commandBytes[player.commandReceiveCommand]) { + case commandBytesInvalidCommand: + // Invalid byte received. Wait for another command byte. + break; + + case commandBytesPrefixLength1: + player.commandReceiveState = 1; + player.commandReceiveExpectedBytes = 1; + break; + + case commandBytesPrefixLength2: + player.commandReceiveState = 3; + player.commandReceiveExpectedBytes = 2; + break; + + default: + player.commandReceiveState = 2; + player.commandReceiveExpectedBytes = commandBytes[player.commandReceiveCommand]; + break; + } + break; + + case 1: + player.commandReceiveState = 2; + player.commandReceiveExpectedBytes = read_ubyte(socket); + break; + + case 3: + player.commandReceiveState = 2; + player.commandReceiveExpectedBytes = read_ushort(socket); + break; + + case 2: + player.commandReceiveState = 0; + player.commandReceiveExpectedBytes = 1; + commandLimitRemaining -= 1; + + switch(player.commandReceiveCommand) + { + case PLAYER_LEAVE: + socket_destroy(player.socket); + player.socket = -1; + break; + + case PLAYER_CHANGECLASS: + var class; + class = read_ubyte(socket); + if(getCharacterObject(player.team, class) != -1) + { + if(player.object != -1) + { + with(player.object) + { + if (collision_point(x,y,SpawnRoom,0,0) < 0) + { + if (!instance_exists(lastDamageDealer) || lastDamageDealer == player) + { + sendEventPlayerDeath(player, player, noone, BID_FAREWELL); + doEventPlayerDeath(player, player, noone, BID_FAREWELL); + } + else + { + var assistant; + assistant = secondToLastDamageDealer; + if (lastDamageDealer.object) + if (lastDamageDealer.object.healer) + assistant = lastDamageDealer.object.healer; + sendEventPlayerDeath(player, lastDamageDealer, assistant, FINISHED_OFF); + doEventPlayerDeath(player, lastDamageDealer, assistant, FINISHED_OFF); + } + } + else + instance_destroy(); + + } + } + else if(player.alarm[5]<=0) + player.alarm[5] = 1; + class = checkClasslimits(player, player.team, class); + player.class = class; + ServerPlayerChangeclass(playerId, player.class, global.sendBuffer); + } + break; + + case PLAYER_CHANGETEAM: + var newTeam, balance, redSuperiority; + newTeam = read_ubyte(socket); + + redSuperiority = 0 //calculate which team is bigger + with(Player) + { + if(team == TEAM_RED) + redSuperiority += 1; + else if(team == TEAM_BLUE) + redSuperiority -= 1; + } + if(redSuperiority > 0) + balance = TEAM_RED; + else if(redSuperiority < 0) + balance = TEAM_BLUE; + else + balance = -1; + + if(balance != newTeam) + { + if(getCharacterObject(newTeam, player.class) != -1 or newTeam==TEAM_SPECTATOR) + { + if(player.object != -1) + { + with(player.object) + { + if (!instance_exists(lastDamageDealer) || lastDamageDealer == player) + { + sendEventPlayerDeath(player, player, noone, BID_FAREWELL); + doEventPlayerDeath(player, player, noone, BID_FAREWELL); + } + else + { + var assistant; + assistant = secondToLastDamageDealer; + if (lastDamageDealer.object) + if (lastDamageDealer.object.healer) + assistant = lastDamageDealer.object.healer; + sendEventPlayerDeath(player, lastDamageDealer, assistant, FINISHED_OFF); + doEventPlayerDeath(player, lastDamageDealer, assistant, FINISHED_OFF); + } + } + player.alarm[5] = global.Server_Respawntime; + } + else if(player.alarm[5]<=0) + player.alarm[5] = 1; + var newClass; + newClass = checkClasslimits(player, newTeam, player.class); + if newClass != player.class + { + player.class = newClass; + ServerPlayerChangeclass(playerId, player.class, global.sendBuffer); + } + player.team = newTeam; + ServerPlayerChangeteam(playerId, player.team, global.sendBuffer); + ServerBalanceTeams(); + } + } + break; + + case CHAT_BUBBLE: + var bubbleImage; + bubbleImage = read_ubyte(socket); + if(global.aFirst) { + bubbleImage = 0; + } + write_ubyte(global.sendBuffer, CHAT_BUBBLE); + write_ubyte(global.sendBuffer, playerId); + write_ubyte(global.sendBuffer, bubbleImage); + + setChatBubble(player, bubbleImage); + break; + + case BUILD_SENTRY: + if(player.object != -1) + { + if(player.class == CLASS_ENGINEER + and collision_circle(player.object.x, player.object.y, 50, Sentry, false, true) < 0 + and player.object.nutsNBolts == 100 + and (collision_point(player.object.x,player.object.y,SpawnRoom,0,0) < 0) + and !player.sentry + and !player.object.onCabinet) + { + write_ubyte(global.sendBuffer, BUILD_SENTRY); + write_ubyte(global.sendBuffer, playerId); + write_ushort(global.serializeBuffer, round(player.object.x*5)); + write_ushort(global.serializeBuffer, round(player.object.y*5)); + write_byte(global.serializeBuffer, player.object.image_xscale); + buildSentry(player, player.object.x, player.object.y, player.object.image_xscale); + } + } + break; + + case DESTROY_SENTRY: + with(player.sentry) + instance_destroy(); + break; + + case DROP_INTEL: + if (player.object != -1) + { + if (player.object.intel) + { + sendEventDropIntel(player); + doEventDropIntel(player); + } + } + break; + + case OMNOMNOMNOM: + if(player.object != -1) { + if(!player.humiliated + and !player.object.taunting + and !player.object.omnomnomnom + and player.object.canEat + and player.class==CLASS_HEAVY) + { + write_ubyte(global.sendBuffer, OMNOMNOMNOM); + write_ubyte(global.sendBuffer, playerId); + with(player.object) + { + omnomnomnom = true; + if player.team == TEAM_RED { + omnomnomnomindex=0; + omnomnomnomend=31; + } else if player.team==TEAM_BLUE { + omnomnomnomindex=32; + omnomnomnomend=63; + } + xscale=image_xscale; + } + } + } + break; + + case TOGGLE_ZOOM: + if player.object != -1 { + if player.class == CLASS_SNIPER { + write_ubyte(global.sendBuffer, TOGGLE_ZOOM); + write_ubyte(global.sendBuffer, playerId); + toggleZoom(player.object); + } + } + break; + + case PLAYER_CHANGENAME: + var nameLength; + nameLength = socket_receivebuffer_size(socket); + if(nameLength > MAX_PLAYERNAME_LENGTH) + { + write_ubyte(player.socket, KICK); + write_ubyte(player.socket, KICK_NAME); + socket_destroy(player.socket); + player.socket = -1; + } + else + { + with(player) + { + if(variable_local_exists("lastNamechange")) + if(current_time - lastNamechange < 1000) + break; + lastNamechange = current_time; + name = read_string(socket, nameLength); + if(string_count("#",name) > 0) + { + name = "I <3 Bacon"; + } + write_ubyte(global.sendBuffer, PLAYER_CHANGENAME); + write_ubyte(global.sendBuffer, playerId); + write_ubyte(global.sendBuffer, string_length(name)); + write_string(global.sendBuffer, name); + } + } + break; + + case INPUTSTATE: + if(player.object != -1) + { + with(player.object) + { + keyState = read_ubyte(socket); + netAimDirection = read_ushort(socket); + aimDirection = netAimDirection*360/65536; + event_user(1); + } + } + break; + + case REWARD_REQUEST: + player.rewardId = read_string(socket, socket_receivebuffer_size(socket)); + player.challenge = rewardCreateChallenge(); + + write_ubyte(socket, REWARD_CHALLENGE_CODE); + write_binstring(socket, player.challenge); + break; + + case REWARD_CHALLENGE_RESPONSE: + var answer, i, authbuffer; + answer = read_binstring(socket, 16); + + with(player) + if(variable_local_exists("challenge") and variable_local_exists("rewardId")) + rewardAuthStart(player, answer, challenge, true, rewardId); + + break; + + case PLUGIN_PACKET: + var packetID, buf, success; + + packetID = read_ubyte(socket); + + // get packet data + buf = buffer_create(); + write_buffer_part(buf, socket, socket_receivebuffer_size(socket)); + + // try to enqueue + success = _PluginPacketPush(packetID, buf, player); + + // if it returned false, packetID was invalid + if (!success) + { + // clear up buffer + buffer_destroy(buf); + + // kick player + write_ubyte(player.socket, KICK); + write_ubyte(player.socket, KICK_BAD_PLUGIN_PACKET); + socket_destroy(player.socket); + player.socket = -1; + } + break; + + case CLIENT_SETTINGS: + var mirror; + mirror = read_ubyte(player.socket); + player.queueJump = mirror; + + write_ubyte(global.sendBuffer, CLIENT_SETTINGS); + write_ubyte(global.sendBuffer, playerId); + write_ubyte(global.sendBuffer, mirror); + break; + + } + break; + } +} diff --git a/samples/Game Maker Language/scrInitLevel.gml b/samples/Game Maker Language/scrInitLevel.gml new file mode 100644 index 00000000..af0cf274 --- /dev/null +++ b/samples/Game Maker Language/scrInitLevel.gml @@ -0,0 +1,298 @@ +// Originally from /spelunky/Scripts/Level Generation/scrInitLevel.gml in the Spelunky Community Update Project + +// +// scrInitLevel() +// +// Calls scrLevelGen(), scrRoomGen*(), and scrEntityGen() to build level. +// + +/********************************************************************************** + Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC + + This file is part of Spelunky. + + You can redistribute and/or modify Spelunky, including its source code, under + the terms of the Spelunky User License. + + Spelunky is distributed in the hope that it will be entertaining and useful, + but WITHOUT WARRANTY. Please see the Spelunky User License for more details. + + The Spelunky User License should be available in "Game Information", which + can be found in the Resource Explorer, or as an external file called COPYING. + If not, please obtain a new copy of Spelunky from + +***********************************************************************************/ + +global.levelType = 0; +//global.currLevel = 16; +if (global.currLevel > 4 and global.currLevel < 9) global.levelType = 1; +if (global.currLevel > 8 and global.currLevel < 13) global.levelType = 2; +if (global.currLevel > 12 and global.currLevel < 16) global.levelType = 3; +if (global.currLevel == 16) global.levelType = 4; + +if (global.currLevel <= 1 or + global.currLevel == 5 or + global.currLevel == 9 or + global.currLevel == 13) +{ + global.hadDarkLevel = false; +} + +// global.levelType = 3; // debug + +// DEBUG MODE // +/* +if (global.currLevel == 2) global.levelType = 4; +if (global.currLevel == 3) global.levelType = 2; +if (global.currLevel == 4) global.levelType = 3; +if (global.currLevel == 5) global.levelType = 4; +*/ + +// global.levelType = 0; + +global.startRoomX = 0; +global.startRoomY = 0; +global.endRoomX = 0; +global.endRoomY = 0; +oGame.levelGen = false; + +// this is used to determine the path to the exit (generally no bombs required) +for (i = 0; i < 4; i += 1) +{ + for (j = 0; j < 4; j += 1) + { + global.roomPath[i,j] = 0; + } +} + +// side walls +if (global.levelType == 4) + k = 54; +else if (global.levelType == 2) + k = 38; +else if (global.lake) + k = 41; +else + k = 33; +for (i = 0; i <= 42; i += 1) +{ + for (j = 0; j <= k; j += 1) + { + if (not isLevel()) + { + i = 999; + j = 999; + } + else if (global.levelType == 2) + { + if (i*16 == 0 or + i*16 == 656 or + j*16 == 0) + { + obj = instance_create(i*16, j*16, oDark); + obj.invincible = true; + obj.sprite_index = sDark; + } + } + else if (global.levelType == 4) + { + if (i*16 == 0 or + i*16 == 656 or + j*16 == 0) + { + obj = instance_create(i*16, j*16, oTemple); + obj.invincible = true; + if (not global.cityOfGold) obj.sprite_index = sTemple; + } + } + else if (global.lake) + { + if (i*16 == 0 or + i*16 == 656 or + j*16 == 0 or + j*16 >= 656) + { + obj = instance_create(i*16, j*16, oLush); obj.sprite_index = sLush; + obj.invincible = true; + } + } + else if (i*16 == 0 or + i*16 == 656 or + j*16 == 0 or + j*16 >= 528) + { + if (global.levelType == 0) { obj = instance_create(i*16, j*16, oBrick); obj.sprite_index = sBrick; } + else if (global.levelType == 1) { obj = instance_create(i*16, j*16, oLush); obj.sprite_index = sLush; } + else { obj = instance_create(i*16, j*16, oTemple); if (not global.cityOfGold) obj.sprite_index = sTemple; } + obj.invincible = true; + } + } +} + +if (global.levelType == 2) +{ + for (i = 0; i <= 42; i += 1) + { + instance_create(i*16, 40*16, oDark); + //instance_create(i*16, 35*16, oSpikes); + } +} + +if (global.levelType == 3) +{ + background_index = bgTemple; +} + +global.temp1 = global.gameStart; +scrLevelGen(); + +global.cemetary = false; +if (global.levelType == 1 and rand(1,global.probCemetary) == 1) global.cemetary = true; + +with oRoom +{ + if (global.levelType == 0) scrRoomGen(); + else if (global.levelType == 1) + { + if (global.blackMarket) scrRoomGenMarket(); + else scrRoomGen2(); + } + else if (global.levelType == 2) + { + if (global.yetiLair) scrRoomGenYeti(); + else scrRoomGen3(); + } + else if (global.levelType == 3) scrRoomGen4(); + else scrRoomGen5(); +} + +global.darkLevel = false; +//if (not global.hadDarkLevel and global.currLevel != 0 and global.levelType != 2 and global.currLevel != 16 and rand(1,1) == 1) +if (not global.hadDarkLevel and not global.noDarkLevel and global.currLevel != 0 and global.currLevel != 1 and global.levelType != 2 and global.currLevel != 16 and rand(1,global.probDarkLevel) == 1) +{ + global.darkLevel = true; + global.hadDarkLevel = true; + //instance_create(oPlayer1.x, oPlayer1.y, oFlare); +} + +if (global.blackMarket) global.darkLevel = false; + +global.genUdjatEye = false; +if (not global.madeUdjatEye) +{ + if (global.currLevel == 2 and rand(1,3) == 1) global.genUdjatEye = true; + else if (global.currLevel == 3 and rand(1,2) == 1) global.genUdjatEye = true; + else if (global.currLevel == 4) global.genUdjatEye = true; +} + +global.genMarketEntrance = false; +if (not global.madeMarketEntrance) +{ + if (global.currLevel == 5 and rand(1,3) == 1) global.genMarketEntrance = true; + else if (global.currLevel == 6 and rand(1,2) == 1) global.genMarketEntrance = true; + else if (global.currLevel == 7) global.genMarketEntrance = true; +} + +//////////////////////////// +// ENTITY / TREASURES +//////////////////////////// +global.temp2 = global.gameStart; +if (not isRoom("rTutorial") and not isRoom("rLoadLevel")) scrEntityGen(); + +if (instance_exists(oEntrance) and not global.customLevel) +{ + oPlayer1.x = oEntrance.x+8; + oPlayer1.y = oEntrance.y+8; +} + +if (global.darkLevel or + global.blackMarket or + global.snakePit or + global.cemetary or + global.lake or + global.yetiLair or + global.alienCraft or + global.sacrificePit or + global.cityOfGold) +{ + if (not isRoom("rLoadLevel")) + { + with oPlayer1 { alarm[0] = 10; } + } +} + +if (global.levelType == 4) scrSetupWalls(864); +else if (global.lake) scrSetupWalls(656); +else scrSetupWalls(528); + +// add background details +if (global.graphicsHigh) +{ + repeat(20) + { + // bg = instance_create(16*rand(1,42), 16*rand(1,33), oCaveBG); + if (global.levelType == 1 and rand(1,3) < 3) + tile_add(bgExtrasLush, 32*rand(0,1), 0, 32, 32, 16*rand(1,42), 16*rand(1,33), 10002); + else if (global.levelType == 2 and rand(1,3) < 3) + tile_add(bgExtrasIce, 32*rand(0,1), 0, 32, 32, 16*rand(1,42), 16*rand(1,33), 10002); + else if (global.levelType == 3 and rand(1,3) < 3) + tile_add(bgExtrasTemple, 32*rand(0,1), 0, 32, 32, 16*rand(1,42), 16*rand(1,33), 10002); + else + tile_add(bgExtras, 32*rand(0,1), 0, 32, 32, 16*rand(1,42), 16*rand(1,33), 10002); + } +} + +oGame.levelGen = true; + +// generate angry shopkeeper at exit if murderer or thief +if ((global.murderer or global.thiefLevel > 0) and isRealLevel()) +{ + with oExit + { + if (type == "Exit") + { + obj = instance_create(x, y, oShopkeeper); + obj.status = 4; + } + } + // global.thiefLevel -= 1; +} + +with oTreasure +{ + if (collision_point(x, y, oSolid, 0, 0)) + { + obj = instance_place(x, y, oSolid); + if (obj.invincible) instance_destroy(); + } +} + +with oWater +{ + if (sprite_index == sWaterTop or sprite_index == sLavaTop) + { + scrCheckWaterTop(); + } + /* + obj = instance_place(x-16, y, oWater); + if (instance_exists(obj)) + { + if (obj.sprite_index == sWaterTop or obj.sprite_index == sLavaTop) + { + if (type == "Lava") sprite_index = sLavaTop; + else sprite_index = sWaterTop; + } + } + obj = instance_place(x+16, y, oWater); + if (instance_exists(obj)) + { + if (obj.sprite_index == sWaterTop or obj.sprite_index == sLavaTop) + { + if (type == "Lava") sprite_index = sLavaTop; + else sprite_index = sWaterTop; + } + } + */ +} + +global.temp3 = global.gameStart; diff --git a/samples/Gnuplot/dashcolor.1.gnu b/samples/Gnuplot/dashcolor.1.gnu new file mode 100644 index 00000000..291747bd --- /dev/null +++ b/samples/Gnuplot/dashcolor.1.gnu @@ -0,0 +1,22 @@ +# set terminal pngcairo background "#ffffff" fontscale 1.0 dashed size 640, 480 +# set output 'dashcolor.1.png' +set label 1 "set style line 1 lt 2 lc rgb \"red\" lw 3" at -0.4, -0.25, 0 left norotate back textcolor rgb "red" nopoint offset character 0, 0, 0 +set label 2 "set style line 2 lt 2 lc rgb \"orange\" lw 2" at -0.4, -0.35, 0 left norotate back textcolor rgb "orange" nopoint offset character 0, 0, 0 +set label 3 "set style line 3 lt 2 lc rgb \"yellow\" lw 3" at -0.4, -0.45, 0 left norotate back textcolor rgb "yellow" nopoint offset character 0, 0, 0 +set label 4 "set style line 4 lt 2 lc rgb \"green\" lw 2" at -0.4, -0.55, 0 left norotate back textcolor rgb "green" nopoint offset character 0, 0, 0 +set label 5 "plot ... lt 1 lc 3 " at -0.4, -0.65, 0 left norotate back textcolor lt 3 nopoint offset character 0, 0, 0 +set label 6 "plot ... lt 3 lc 3 " at -0.4, -0.75, 0 left norotate back textcolor lt 3 nopoint offset character 0, 0, 0 +set label 7 "plot ... lt 5 lc 3 " at -0.4, -0.85, 0 left norotate back textcolor lt 3 nopoint offset character 0, 0, 0 +set style line 1 linetype 2 linecolor rgb "red" linewidth 3.000 pointtype 2 pointsize default pointinterval 0 +set style line 2 linetype 2 linecolor rgb "orange" linewidth 2.000 pointtype 2 pointsize default pointinterval 0 +set style line 3 linetype 2 linecolor rgb "yellow" linewidth 3.000 pointtype 2 pointsize default pointinterval 0 +set style line 4 linetype 2 linecolor rgb "green" linewidth 2.000 pointtype 2 pointsize default pointinterval 0 +set noxtics +set noytics +set title "Independent colors and dot/dash styles" +set xlabel "You will only see dashed lines if your current terminal setting permits it" +set xrange [ -0.500000 : 3.50000 ] noreverse nowriteback +set yrange [ -1.00000 : 1.40000 ] noreverse nowriteback +set bmargin 7 +unset colorbox +plot cos(x) ls 1 title 'ls 1', cos(x-.2) ls 2 title 'ls 2', cos(x-.4) ls 3 title 'ls 3', cos(x-.6) ls 4 title 'ls 4', cos(x-.8) lt 1 lc 3 title 'lt 1 lc 3', cos(x-1.) lt 3 lc 3 title 'lt 3 lc 3', cos(x-1.2) lt 5 lc 3 title 'lt 5 lc 3' diff --git a/samples/Gnuplot/histograms.2.gnu b/samples/Gnuplot/histograms.2.gnu new file mode 100644 index 00000000..e268ce01 --- /dev/null +++ b/samples/Gnuplot/histograms.2.gnu @@ -0,0 +1,15 @@ +# set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 +# set output 'histograms.2.png' +set boxwidth 0.9 absolute +set style fill solid 1.00 border lt -1 +set key inside right top vertical Right noreverse noenhanced autotitles nobox +set style histogram clustered gap 1 title offset character 0, 0, 0 +set datafile missing '-' +set style data histograms +set xtics border in scale 0,0 nomirror rotate by -45 offset character 0, 0, 0 autojustify +set xtics norangelimit font ",8" +set xtics () +set title "US immigration from Northern Europe\nPlot selected data columns as histogram of clustered boxes" +set yrange [ 0.00000 : 300000. ] noreverse nowriteback +i = 22 +plot 'immigration.dat' using 6:xtic(1) ti col, '' u 12 ti col, '' u 13 ti col, '' u 14 ti col diff --git a/samples/Gnuplot/rates.gp b/samples/Gnuplot/rates.gp new file mode 100644 index 00000000..aad2a52e --- /dev/null +++ b/samples/Gnuplot/rates.gp @@ -0,0 +1,14 @@ +#!/usr/bin/env gnuplot + +reset + +set terminal png +set output 'rates100.png' + +set xlabel "A2A price" +set ylabel "Response Rate" + +#set xr [0:5] +#set yr [0:6] + +plot 'rates100.dat' pt 7 notitle diff --git a/samples/Gnuplot/surface1.16.gnu b/samples/Gnuplot/surface1.16.gnu new file mode 100644 index 00000000..dd1ffefa --- /dev/null +++ b/samples/Gnuplot/surface1.16.gnu @@ -0,0 +1,40 @@ +# set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 +# set output 'surface1.16.png' +set dummy u,v +set label 1 "increasing v" at 6, 0, -1 left norotate back nopoint offset character 0, 0, 0 +set label 2 "u=0" at 5, 6.5, -1 left norotate back nopoint offset character 0, 0, 0 +set label 3 "u=1" at 5, 6.5, 0.100248 left norotate back nopoint offset character 0, 0, 0 +set arrow 1 from 5, -5, -1.2 to 5, 5, -1.2 head back nofilled linetype -1 linewidth 1.000 +set arrow 2 from 5, 6, -1 to 5, 5, -1 head back nofilled linetype -1 linewidth 1.000 +set arrow 3 from 5, 6, 0.100248 to 5, 5, 0.100248 head back nofilled linetype -1 linewidth 1.000 +set parametric +set view 70, 20, 1, 1 +set samples 51, 51 +set isosamples 2, 33 +set hidden3d back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover +set ztics -1.00000,0.25,1.00000 norangelimit +set title "\"fence plot\" using separate parametric surfaces" +set xlabel "X axis" +set xlabel offset character -3, -2, 0 font "" textcolor lt -1 norotate +set xrange [ -5.00000 : 5.00000 ] noreverse nowriteback +set ylabel "Y axis" +set ylabel offset character 3, -2, 0 font "" textcolor lt -1 rotate by -270 +set yrange [ -5.00000 : 5.00000 ] noreverse nowriteback +set zlabel "Z axis" +set zlabel offset character -5, 0, 0 font "" textcolor lt -1 norotate +set zrange [ -1.00000 : 1.00000 ] noreverse nowriteback +sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2) +GPFUN_sinc = "sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)" +xx = 6.08888888888889 +dx = 1.10888888888889 +x0 = -5 +x1 = -3.89111111111111 +x2 = -2.78222222222222 +x3 = -1.67333333333333 +x4 = -0.564444444444444 +x5 = 0.544444444444445 +x6 = 1.65333333333333 +x7 = 2.76222222222222 +x8 = 3.87111111111111 +x9 = 4.98 +splot [u=0:1][v=-4.99:4.99] x0, v, (u<0.5) ? -1 : sinc(x0,v) notitle, x1, v, (u<0.5) ? -1 : sinc(x1,v) notitle, x2, v, (u<0.5) ? -1 : sinc(x2,v) notitle, x3, v, (u<0.5) ? -1 : sinc(x3,v) notitle, x4, v, (u<0.5) ? -1 : sinc(x4,v) notitle, x5, v, (u<0.5) ? -1 : sinc(x5,v) notitle, x6, v, (u<0.5) ? -1 : sinc(x6,v) notitle, x7, v, (u<0.5) ? -1 : sinc(x7,v) notitle, x8, v, (u<0.5) ? -1 : sinc(x8,v) notitle, x9, v, (u<0.5) ? -1 : sinc(x9,v) notitle diff --git a/samples/Gnuplot/surface1.17.gnu b/samples/Gnuplot/surface1.17.gnu new file mode 100644 index 00000000..3d272bc7 --- /dev/null +++ b/samples/Gnuplot/surface1.17.gnu @@ -0,0 +1,46 @@ +# set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 +# set output 'surface1.17.png' +set dummy u,v +set label 1 "increasing v" at 6, 0, -1 left norotate back nopoint offset character 0, 0, 0 +set label 2 "increasing u" at 0, -5, -1.5 left norotate back nopoint offset character 0, 0, 0 +set label 3 "floor(u)%3=0" at 5, 6.5, -1 left norotate back nopoint offset character 0, 0, 0 +set label 4 "floor(u)%3=1" at 5, 6.5, 0.100248 left norotate back nopoint offset character 0, 0, 0 +set arrow 1 from 5, -5, -1.2 to 5, 5, -1.2 head back nofilled linetype -1 linewidth 1.000 +set arrow 2 from -5, -5, -1.2 to 5, -5, -1.2 head back nofilled linetype -1 linewidth 1.000 +set arrow 3 from 5, 6, -1 to 5, 5, -1 head back nofilled linetype -1 linewidth 1.000 +set arrow 4 from 5, 6, 0.100248 to 5, 5, 0.100248 head back nofilled linetype -1 linewidth 1.000 +set parametric +set view 70, 20, 1, 1 +set samples 51, 51 +set isosamples 30, 33 +set hidden3d back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover +set ztics -1.00000,0.25,1.00000 norangelimit +set title "\"fence plot\" using single parametric surface with undefined points" +set xlabel "X axis" +set xlabel offset character -3, -2, 0 font "" textcolor lt -1 norotate +set xrange [ -5.00000 : 5.00000 ] noreverse nowriteback +set ylabel "Y axis" +set ylabel offset character 3, -2, 0 font "" textcolor lt -1 rotate by -270 +set yrange [ -5.00000 : 5.00000 ] noreverse nowriteback +set zlabel "Z axis" +set zlabel offset character -5, 0, 0 font "" textcolor lt -1 norotate +set zrange [ -1.00000 : 1.00000 ] noreverse nowriteback +sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2) +GPFUN_sinc = "sinc(u,v) = sin(sqrt(u**2+v**2)) / sqrt(u**2+v**2)" +xx = 6.08888888888889 +dx = 1.11 +x0 = -5 +x1 = -3.89111111111111 +x2 = -2.78222222222222 +x3 = -1.67333333333333 +x4 = -0.564444444444444 +x5 = 0.544444444444445 +x6 = 1.65333333333333 +x7 = 2.76222222222222 +x8 = 3.87111111111111 +x9 = 4.98 +xmin = -4.99 +xmax = 5 +n = 10 +zbase = -1 +splot [u=.5:3*n-.5][v=-4.99:4.99] xmin+floor(u/3)*dx, v, ((floor(u)%3)==0) ? zbase : (((floor(u)%3)==1) ? sinc(xmin+u/3.*dx,v) : 1/0) notitle diff --git a/samples/Gnuplot/world2.1.gnu b/samples/Gnuplot/world2.1.gnu new file mode 100644 index 00000000..53dc22b6 --- /dev/null +++ b/samples/Gnuplot/world2.1.gnu @@ -0,0 +1,21 @@ +# set terminal pngcairo transparent enhanced font "arial,10" fontscale 1.0 size 500, 350 +# set output 'world2.1.png' +unset border +set dummy u,v +set angles degrees +set parametric +set view 60, 136, 1.22, 1.26 +set samples 64, 64 +set isosamples 13, 13 +set mapping spherical +set noxtics +set noytics +set noztics +set title "Labels colored by GeV plotted in spherical coordinate system" +set urange [ -90.0000 : 90.0000 ] noreverse nowriteback +set vrange [ 0.00000 : 360.000 ] noreverse nowriteback +set cblabel "GeV" +set cbrange [ 0.00000 : 8.00000 ] noreverse nowriteback +set colorbox user +set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.02, 0.75, 0 front bdefault +splot cos(u)*cos(v),cos(u)*sin(v),sin(u) notitle with lines lt 5, 'world.dat' notitle with lines lt 2, 'srl.dat' using 3:2:(1):1:4 with labels notitle point pt 6 lw .1 left offset 1,0 font "Helvetica,7" tc pal diff --git a/samples/Grammatical Framework/Foods.gf b/samples/Grammatical Framework/Foods.gf new file mode 100644 index 00000000..8ea02f39 --- /dev/null +++ b/samples/Grammatical Framework/Foods.gf @@ -0,0 +1,15 @@ +-- (c) 2009 Aarne Ranta under LGPL + +abstract Foods = { + flags startcat = Comment ; + cat + Comment ; Item ; Kind ; Quality ; + fun + Pred : Item -> Quality -> Comment ; + This, That, These, Those : Kind -> Item ; + Mod : Quality -> Kind -> Kind ; + Wine, Cheese, Fish, Pizza : Kind ; + Very : Quality -> Quality ; + Fresh, Warm, Italian, + Expensive, Delicious, Boring : Quality ; +} diff --git a/samples/Grammatical Framework/FoodsAfr.gf b/samples/Grammatical Framework/FoodsAfr.gf new file mode 100644 index 00000000..d0226710 --- /dev/null +++ b/samples/Grammatical Framework/FoodsAfr.gf @@ -0,0 +1,79 @@ +-- (c) 2009 Laurette Pretorius Sr & Jr and Ansu Berg under LGPL + +concrete FoodsAfr of Foods = open Prelude, Predef in{ + + flags coding=utf8; + + lincat + Comment = {s: Str} ; + Kind = {s: Number => Str} ; + Item = {s: Str ; n: Number} ; + Quality = {s: AdjAP => Str} ; + + lin + Pred item quality = {s = item.s ++ "is" ++ (quality.s ! Predic)}; + This kind = {s = "hierdie" ++ (kind.s ! Sg); n = Sg}; + That kind = {s = "daardie" ++ (kind.s ! Sg); n = Sg}; + These kind = {s = "hierdie" ++ (kind.s ! Pl); n = Pl}; + Those kind = {s = "daardie" ++ (kind.s ! Pl); n = Pl}; + Mod quality kind = {s = table{n => (quality.s ! Attr) ++ (kind.s!n)}}; + + Wine = declNoun_e "wyn"; + Cheese = declNoun_aa "kaas"; + Fish = declNoun_ss "vis"; + Pizza = declNoun_s "pizza"; + + Very quality = veryAdj quality; + + Fresh = regAdj "vars"; + Warm = regAdj "warm"; + Italian = smartAdj_e "Italiaans"; + Expensive = regAdj "duur"; + Delicious = smartAdj_e "heerlik"; + Boring = smartAdj_e "vervelig"; + + param + AdjAP = Attr | Predic ; + Number = Sg | Pl ; + + oper + --Noun operations (wyn, kaas, vis, pizza) + + declNoun_aa: Str -> {s: Number => Str} = \x -> + let v = tk 2 x + in + {s = table{Sg => x ; Pl => v + (last x) +"e"}}; + + declNoun_e: Str -> {s: Number => Str} = \x -> {s = table{Sg => x ; Pl => x + "e"}} ; + declNoun_s: Str -> {s: Number => Str} = \x -> {s = table{Sg => x ; Pl => x + "s"}} ; + + declNoun_ss: Str -> {s: Number => Str} = \x -> {s = table{Sg => x ; Pl => x + (last x) + "e"}} ; + + + --Adjective operations + + mkAdj : Str -> Str -> {s: AdjAP => Str} = \x,y -> {s = table{Attr => x; Predic => y}}; + + declAdj_e : Str -> {s : AdjAP=> Str} = \x -> mkAdj (x + "e") x; + declAdj_g : Str -> {s : AdjAP=> Str} = \w -> + let v = init w + in mkAdj (v + "ë") w ; + + declAdj_oog : Str -> {s : AdjAP=> Str} = \w -> + let v = init w + in + let i = init v + in mkAdj (i + "ë") w ; + + regAdj : Str -> {s : AdjAP=> Str} = \x -> mkAdj x x; + + veryAdj : {s: AdjAP => Str} -> {s : AdjAP=> Str} = \x -> {s = table{a => "baie" ++ (x.s!a)}}; + + + smartAdj_e : Str -> {s : AdjAP=> Str} = \a -> case a of + { + _ + "oog" => declAdj_oog a ; + _ + ("e" | "ie" | "o" | "oe") + "g" => declAdj_g a ; + _ => declAdj_e a + }; +} diff --git a/samples/Grammatical Framework/FoodsAmh.gf b/samples/Grammatical Framework/FoodsAmh.gf new file mode 100644 index 00000000..e8915d86 --- /dev/null +++ b/samples/Grammatical Framework/FoodsAmh.gf @@ -0,0 +1,21 @@ +concrete FoodsAmh of Foods ={ + flags coding = utf8; + lincat + Comment,Item,Kind,Quality = Str; + lin + Pred item quality = item ++ quality++ "ነው::" ; + This kind = "ይህ" ++ kind; + That kind = "ያ" ++ kind; + Mod quality kind = quality ++ kind; + Wine = "ወይን"; + Cheese = "አይብ"; + Fish = "ዓሳ"; + Very quality = "በጣም" ++ quality; + Fresh = "አዲስ"; + Warm = "ትኩስ"; + Italian = "የጥልያን"; + Expensive = "ውድ"; + Delicious = "ጣፋጭ"; + Boring = "አስቀያሚ"; + +} \ No newline at end of file diff --git a/samples/Grammatical Framework/FoodsBul.gf b/samples/Grammatical Framework/FoodsBul.gf new file mode 100644 index 00000000..ac912766 --- /dev/null +++ b/samples/Grammatical Framework/FoodsBul.gf @@ -0,0 +1,43 @@ +-- (c) 2009 Krasimir Angelov under LGPL + +concrete FoodsBul of Foods = { + + flags + coding = utf8; + + param + Gender = Masc | Fem | Neutr; + Number = Sg | Pl; + Agr = ASg Gender | APl ; + + lincat + Comment = Str ; + Quality = {s : Agr => Str} ; + Item = {s : Str; a : Agr} ; + Kind = {s : Number => Str; g : Gender} ; + + lin + Pred item qual = item.s ++ case item.a of {ASg _ => "е"; APl => "са"} ++ qual.s ! item.a ; + + This kind = {s=case kind.g of {Masc=>"този"; Fem=>"тази"; Neutr=>"това" } ++ kind.s ! Sg; a=ASg kind.g} ; + That kind = {s=case kind.g of {Masc=>"онзи"; Fem=>"онази"; Neutr=>"онова"} ++ kind.s ! Sg; a=ASg kind.g} ; + These kind = {s="тези" ++ kind.s ! Pl; a=APl} ; + Those kind = {s="онези" ++ kind.s ! Pl; a=APl} ; + + Mod qual kind = {s=\\n => qual.s ! (case n of {Sg => ASg kind.g; Pl => APl}) ++ kind.s ! n; g=kind.g} ; + + Wine = {s = table {Sg => "вино"; Pl => "вина"}; g = Neutr}; + Cheese = {s = table {Sg => "сирене"; Pl => "сирена"}; g = Neutr}; + Fish = {s = table {Sg => "риба"; Pl => "риби"}; g = Fem}; + Pizza = {s = table {Sg => "пица"; Pl => "пици"}; g = Fem}; + + Very qual = {s = \\g => "много" ++ qual.s ! g}; + + Fresh = {s = table {ASg Masc => "свеж"; ASg Fem => "свежа"; ASg Neutr => "свежо"; APl => "свежи"}}; + Warm = {s = table {ASg Masc => "горещ"; ASg Fem => "гореща"; ASg Neutr => "горещо"; APl => "горещи"}}; + Italian = {s = table {ASg Masc => "италиански"; ASg Fem => "италианска"; ASg Neutr => "италианско"; APl => "италиански"}}; + Expensive = {s = table {ASg Masc => "скъп"; ASg Fem => "скъпа"; ASg Neutr => "скъпо"; APl => "скъпи"}}; + Delicious = {s = table {ASg Masc => "превъзходен"; ASg Fem => "превъзходна"; ASg Neutr => "превъзходно"; APl => "превъзходни"}}; + Boring = {s = table {ASg Masc => "еднообразен"; ASg Fem => "еднообразна"; ASg Neutr => "еднообразно"; APl => "еднообразни"}}; + +} diff --git a/samples/Grammatical Framework/FoodsCat.gf b/samples/Grammatical Framework/FoodsCat.gf new file mode 100644 index 00000000..5ad38d0d --- /dev/null +++ b/samples/Grammatical Framework/FoodsCat.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +-- (c) 2009 Jordi Saludes under LGPL + +concrete FoodsCat of Foods = FoodsI with + (Syntax = SyntaxCat), + (LexFoods = LexFoodsCat) ; diff --git a/samples/Grammatical Framework/FoodsChi.gf b/samples/Grammatical Framework/FoodsChi.gf new file mode 100644 index 00000000..163aa0eb --- /dev/null +++ b/samples/Grammatical Framework/FoodsChi.gf @@ -0,0 +1,35 @@ +concrete FoodsChi of Foods = { +flags coding = utf8 ; +lincat + Comment, Item = Str ; + Kind = {s,c : Str} ; + Quality = {s,p : Str} ; +lin + Pred item quality = item ++ "是" ++ quality.s ++ quality.p ; + This kind = "这" ++ kind.c ++ kind.s ; + That kind = "那" ++ kind.c ++ kind.s ; + These kind = "这" ++ "些" ++ kind.s ; + Those kind = "那" ++ "些" ++ kind.s ; + Mod quality kind = { + s = quality.s ++ quality.p ++ kind.s ; + c = kind.c + } ; + Wine = geKind "酒" ; + Pizza = geKind "比 萨 饼" ; + Cheese = geKind "奶 酪" ; + Fish = geKind "鱼" ; + Very quality = longQuality ("非 常" ++ quality.s) ; + Fresh = longQuality "新 鲜" ; + Warm = longQuality "温 热" ; + Italian = longQuality "意 大 利 式" ; + Expensive = longQuality "昂 贵" ; + Delicious = longQuality "美 味" ; + Boring = longQuality "难 吃" ; +oper + mkKind : Str -> Str -> {s,c : Str} = \s,c -> + {s = s ; c = c} ; + geKind : Str -> {s,c : Str} = \s -> + mkKind s "个" ; + longQuality : Str -> {s,p : Str} = \s -> + {s = s ; p = "的"} ; +} diff --git a/samples/Grammatical Framework/FoodsCze.gf b/samples/Grammatical Framework/FoodsCze.gf new file mode 100644 index 00000000..3fec6814 --- /dev/null +++ b/samples/Grammatical Framework/FoodsCze.gf @@ -0,0 +1,35 @@ +-- (c) 2011 Katerina Bohmova under LGPL + +concrete FoodsCze of Foods = open ResCze in { + flags + coding = utf8 ; + lincat + Comment = {s : Str} ; + Quality = Adjective ; + Kind = Noun ; + Item = NounPhrase ; + lin + Pred item quality = + {s = item.s ++ copula ! item.n ++ + quality.s ! item.g ! item.n} ; + This = det Sg "tento" "tato" "toto" ; + That = det Sg "tamten" "tamta" "tamto" ; + These = det Pl "tyto" "tyto" "tato" ; + Those = det Pl "tamty" "tamty" "tamta" ; + Mod quality kind = { + s = \\n => quality.s ! kind.g ! n ++ kind.s ! n ; + g = kind.g + } ; + Wine = noun "víno" "vína" Neutr ; + Cheese = noun "sýr" "sýry" Masc ; + Fish = noun "ryba" "ryby" Fem ; + Pizza = noun "pizza" "pizzy" Fem ; + Very qual = {s = \\g,n => "velmi" ++ qual.s ! g ! n} ; + Fresh = regAdj "čerstv" ; + Warm = regAdj "tepl" ; + Italian = regAdj "italsk" ; + Expensive = regAdj "drah" ; + Delicious = regnfAdj "vynikající" ; + Boring = regAdj "nudn" ; +} + diff --git a/samples/Grammatical Framework/FoodsDut.gf b/samples/Grammatical Framework/FoodsDut.gf new file mode 100644 index 00000000..d4855e5c --- /dev/null +++ b/samples/Grammatical Framework/FoodsDut.gf @@ -0,0 +1,58 @@ +-- (c) 2009 Femke Johansson under LGPL + +concrete FoodsDut of Foods = { + + lincat + Comment = {s : Str}; + Quality = {s : AForm => Str}; + Kind = { s : Number => Str}; + Item = {s : Str ; n : Number}; + + lin + Pred item quality = + {s = item.s ++ copula ! item.n ++ quality.s ! APred}; + This = det Sg "deze"; + These = det Pl "deze"; + That = det Sg "die"; + Those = det Pl "die"; + + Mod quality kind = + {s = \\n => quality.s ! AAttr ++ kind.s ! n}; + Wine = regNoun "wijn"; + Cheese = noun "kaas" "kazen"; + Fish = noun "vis" "vissen"; + Pizza = noun "pizza" "pizza's"; + + Very a = {s = \\f => "erg" ++ a.s ! f}; + + Fresh = regadj "vers"; + Warm = regadj "warm"; + Italian = regadj "Italiaans"; + Expensive = adj "duur" "dure"; + Delicious = regadj "lekker"; + Boring = regadj "saai"; + + param + Number = Sg | Pl; + AForm = APred | AAttr; + + oper + det : Number -> Str -> + {s : Number => Str} -> {s : Str ; n: Number} = + \n,det,noun -> {s = det ++ noun.s ! n ; n=n}; + + noun : Str -> Str -> {s : Number => Str} = + \man,men -> {s = table {Sg => man; Pl => men}}; + + regNoun : Str -> {s : Number => Str} = + \wijn -> noun wijn (wijn + "en"); + + regadj : Str -> {s : AForm => Str} = + \koud -> adj koud (koud+"e"); + + adj : Str -> Str -> {s : AForm => Str} = + \duur, dure -> {s = table {APred => duur; AAttr => dure}}; + + copula : Number => Str = + table {Sg => "is" ; Pl => "zijn"}; +} diff --git a/samples/Grammatical Framework/FoodsEng.gf b/samples/Grammatical Framework/FoodsEng.gf new file mode 100644 index 00000000..e7359a4f --- /dev/null +++ b/samples/Grammatical Framework/FoodsEng.gf @@ -0,0 +1,43 @@ +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsEng of Foods = { + flags language = en_US; + lincat + Comment, Quality = {s : Str} ; + Kind = {s : Number => Str} ; + Item = {s : Str ; n : Number} ; + lin + Pred item quality = + {s = item.s ++ copula ! item.n ++ quality.s} ; + This = det Sg "this" ; + That = det Sg "that" ; + These = det Pl "these" ; + Those = det Pl "those" ; + Mod quality kind = + {s = \\n => quality.s ++ kind.s ! n} ; + Wine = regNoun "wine" ; + Cheese = regNoun "cheese" ; + Fish = noun "fish" "fish" ; + Pizza = regNoun "pizza" ; + Very a = {s = "very" ++ a.s} ; + Fresh = adj "fresh" ; + Warm = adj "warm" ; + Italian = adj "Italian" ; + Expensive = adj "expensive" ; + Delicious = adj "delicious" ; + Boring = adj "boring" ; + param + Number = Sg | Pl ; + oper + det : Number -> Str -> + {s : Number => Str} -> {s : Str ; n : Number} = + \n,det,noun -> {s = det ++ noun.s ! n ; n = n} ; + noun : Str -> Str -> {s : Number => Str} = + \man,men -> {s = table {Sg => man ; Pl => men}} ; + regNoun : Str -> {s : Number => Str} = + \car -> noun car (car + "s") ; + adj : Str -> {s : Str} = + \cold -> {s = cold} ; + copula : Number => Str = + table {Sg => "is" ; Pl => "are"} ; +} diff --git a/samples/Grammatical Framework/FoodsEpo.gf b/samples/Grammatical Framework/FoodsEpo.gf new file mode 100644 index 00000000..dd2400fe --- /dev/null +++ b/samples/Grammatical Framework/FoodsEpo.gf @@ -0,0 +1,48 @@ +-- (c) 2009 Julia Hammar under LGPL + +concrete FoodsEpo of Foods = open Prelude in { + + flags coding =utf8 ; + + lincat + Comment = SS ; + Kind, Quality = {s : Number => Str} ; + Item = {s : Str ; n : Number} ; + + lin + Pred item quality = ss (item.s ++ copula ! item.n ++ quality.s ! item.n) ; + This = det Sg "ĉi tiu" ; + That = det Sg "tiu" ; + These = det Pl "ĉi tiuj" ; + Those = det Pl "tiuj" ; + Mod quality kind = {s = \\n => quality.s ! n ++ kind.s ! n} ; + Wine = regNoun "vino" ; + Cheese = regNoun "fromaĝo" ; + Fish = regNoun "fiŝo" ; + Pizza = regNoun "pico" ; + Very quality = {s = \\n => "tre" ++ quality.s ! n} ; + Fresh = regAdj "freŝa" ; + Warm = regAdj "varma" ; + Italian = regAdj "itala" ; + Expensive = regAdj "altekosta" ; + Delicious = regAdj "bongusta" ; + Boring = regAdj "enuiga" ; + + param + Number = Sg | Pl ; + + oper + det : Number -> Str -> {s : Number => Str} -> {s : Str ; n : Number} = + \n,d,cn -> { + s = d ++ cn.s ! n ; + n = n + } ; + regNoun : Str -> {s : Number => Str} = + \vino -> {s = table {Sg => vino ; Pl => vino + "j"} + } ; + regAdj : Str -> {s : Number => Str} = + \nova -> {s = table {Sg => nova ; Pl => nova + "j"} + } ; + copula : Number => Str = \\_ => "estas" ; +} + diff --git a/samples/Grammatical Framework/FoodsFin.gf b/samples/Grammatical Framework/FoodsFin.gf new file mode 100644 index 00000000..34da5764 --- /dev/null +++ b/samples/Grammatical Framework/FoodsFin.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsFin of Foods = FoodsI with + (Syntax = SyntaxFin), + (LexFoods = LexFoodsFin) ; diff --git a/samples/Grammatical Framework/FoodsFre.gf b/samples/Grammatical Framework/FoodsFre.gf new file mode 100644 index 00000000..ac6c8c63 --- /dev/null +++ b/samples/Grammatical Framework/FoodsFre.gf @@ -0,0 +1,32 @@ +--# -path=.:../foods:present + +concrete FoodsFre of Foods = open SyntaxFre, ParadigmsFre in { + + flags coding = utf8 ; + + lincat + Comment = Utt ; + Item = NP ; + Kind = CN ; + Quality = AP ; + + lin + Pred item quality = mkUtt (mkCl item quality) ; + This kind = mkNP this_QuantSg kind ; + That kind = mkNP that_QuantSg kind ; + These kind = mkNP these_QuantPl kind ; + Those kind = mkNP those_QuantPl kind ; + Mod quality kind = mkCN quality kind ; + Very quality = mkAP very_AdA quality ; + + Wine = mkCN (mkN "vin" masculine) ; + Pizza = mkCN (mkN "pizza" feminine) ; + Cheese = mkCN (mkN "fromage" masculine) ; + Fish = mkCN (mkN "poisson" masculine) ; + Fresh = mkAP (mkA "frais" "fraîche" "frais" "fraîchement") ; + Warm = mkAP (mkA "chaud") ; + Italian = mkAP (mkA "italien") ; + Expensive = mkAP (mkA "cher") ; + Delicious = mkAP (mkA "délicieux") ; + Boring = mkAP (mkA "ennuyeux") ; + } \ No newline at end of file diff --git a/samples/Grammatical Framework/FoodsGer.gf b/samples/Grammatical Framework/FoodsGer.gf new file mode 100644 index 00000000..934cefb9 --- /dev/null +++ b/samples/Grammatical Framework/FoodsGer.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsGer of Foods = FoodsI with + (Syntax = SyntaxGer), + (LexFoods = LexFoodsGer) ; diff --git a/samples/Grammatical Framework/FoodsHeb.gf b/samples/Grammatical Framework/FoodsHeb.gf new file mode 100644 index 00000000..3d76b639 --- /dev/null +++ b/samples/Grammatical Framework/FoodsHeb.gf @@ -0,0 +1,108 @@ +--# -path=alltenses + +--(c) 2009 Dana Dannells +-- Licensed under LGPL + +concrete FoodsHeb of Foods = open Prelude in { + + flags coding=utf8 ; + + lincat + Comment = SS ; + Quality = {s: Number => Species => Gender => Str} ; + Kind = {s : Number => Species => Str ; g : Gender ; mod : Modified} ; + Item = {s : Str ; g : Gender ; n : Number ; sp : Species ; mod : Modified} ; + + + lin + Pred item quality = ss (item.s ++ quality.s ! item.n ! Indef ! item.g ) ; + This = det Sg Def "הזה" "הזאת"; + That = det Sg Def "ההוא" "ההיא" ; + These = det Pl Def "האלה" "האלה" ; + Those = det Pl Def "ההם" "ההן" ; + Mod quality kind = { + s = \\n,sp => kind.s ! n ! sp ++ quality.s ! n ! sp ! kind.g; + g = kind.g ; + mod = T + } ; + Wine = regNoun "יין" "יינות" Masc ; + Cheese = regNoun "גבינה" "גבינות" Fem ; + Fish = regNoun "דג" "דגים" Masc ; + Pizza = regNoun "פיצה" "פיצות" Fem ; + Very qual = {s = \\g,n,sp => "מאוד" ++ qual.s ! g ! n ! sp} ; + Fresh = regAdj "טרי" ; + Warm = regAdj "חם" ; + Italian = regAdj2 "איטלקי" ; + Expensive = regAdj "יקר" ; + Delicious = regAdj "טעים" ; + Boring = regAdj2 "משעמם"; + + param + Number = Sg | Pl ; + Gender = Masc | Fem ; + Species = Def | Indef ; + Modified = T | F ; + + oper + Noun : Type = {s : Number => Species => Str ; g : Gender ; mod : Modified } ; + Adj : Type = {s : Number => Species => Gender => Str} ; + + det : Number -> Species -> Str -> Str -> Noun -> + {s : Str ; g :Gender ; n : Number ; sp : Species ; mod : Modified} = + \n,sp,m,f,cn -> { + s = case cn.mod of { _ => cn.s ! n ! sp ++ case cn.g of {Masc => m ; Fem => f} }; + g = cn.g ; + n = n ; + sp = sp ; + mod = cn.mod + } ; + + noun : (gvina,hagvina,gvinot,hagvinot : Str) -> Gender -> Noun = + \gvina,hagvina,gvinot,hagvinot,g -> { + s = table { + Sg => table { + Indef => gvina ; + Def => hagvina + } ; + Pl => table { + Indef => gvinot ; + Def => hagvinot + } + } ; + g = g ; + mod = F + } ; + + regNoun : Str -> Str -> Gender -> Noun = + \gvina,gvinot, g -> + noun gvina (defH gvina) gvinot (defH gvinot) g ; + + defH : Str -> Str = \cn -> + case cn of {_ => "ה" + cn}; + + replaceLastLetter : Str -> Str = \c -> + case c of {"ף" => "פ" ; "ם" => "מ" ; "ן" => "נ" ; "ץ" => "צ" ; "ך" => "כ"; _ => c} ; + + adjective : (_,_,_,_ : Str) -> Adj = + \tov,tova,tovim,tovot -> { + s = table { + Sg => table { + Indef => table { Masc => tov ; Fem => tova } ; + Def => table { Masc => defH tov ; Fem => defH tova } + } ; + Pl => table { + Indef => table {Masc => tovim ; Fem => tovot } ; + Def => table { Masc => defH tovim ; Fem => defH tovot } + } + } + } ; + + regAdj : Str -> Adj = \tov -> + case tov of { to + c@? => + adjective tov (to + replaceLastLetter (c) + "ה" ) (to + replaceLastLetter (c) +"ים" ) (to + replaceLastLetter (c) + "ות" )}; + + regAdj2 : Str -> Adj = \italki -> + case italki of { italk+ c@? => + adjective italki (italk + replaceLastLetter (c) +"ת" ) (italk + replaceLastLetter (c)+ "ים" ) (italk + replaceLastLetter (c) + "ות" )}; + +} -- FoodsHeb diff --git a/samples/Grammatical Framework/FoodsHin.gf b/samples/Grammatical Framework/FoodsHin.gf new file mode 100644 index 00000000..67c29df8 --- /dev/null +++ b/samples/Grammatical Framework/FoodsHin.gf @@ -0,0 +1,75 @@ +-- (c) 2010 Vikash Rauniyar under LGPL + +concrete FoodsHin of Foods = { + + flags coding=utf8 ; + + param + Gender = Masc | Fem ; + Number = Sg | Pl ; + lincat + Comment = {s : Str} ; + Item = {s : Str ; g : Gender ; n : Number} ; + Kind = {s : Number => Str ; g : Gender} ; + Quality = {s : Gender => Number => Str} ; + lin + Pred item quality = { + s = item.s ++ quality.s ! item.g ! item.n ++ copula item.n + } ; + This kind = {s = "यह" ++ kind.s ! Sg ; g = kind.g ; n = Sg} ; + That kind = {s = "वह" ++ kind.s ! Sg ; g = kind.g ; n = Sg} ; + These kind = {s = "ये" ++ kind.s ! Pl ; g = kind.g ; n = Pl} ; + Those kind = {s = "वे" ++ kind.s ! Pl ; g = kind.g ; n = Pl} ; + Mod quality kind = { + s = \\n => quality.s ! kind.g ! n ++ kind.s ! n ; + g = kind.g + } ; + Wine = regN "मदिरा" ; + Cheese = regN "पनीर" ; + Fish = regN "मछली" ; + Pizza = regN "पिज़्ज़ा" ; + Very quality = {s = \\g,n => "अति" ++ quality.s ! g ! n} ; + Fresh = regAdj "ताज़ा" ; + Warm = regAdj "गरम" ; + Italian = regAdj "इटली" ; + Expensive = regAdj "बहुमूल्य" ; + Delicious = regAdj "स्वादिष्ट" ; + Boring = regAdj "अरुचिकर" ; + + oper + mkN : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = + \s,p,g -> { + s = table { + Sg => s ; + Pl => p + } ; + g = g + } ; + + regN : Str -> {s : Number => Str ; g : Gender} = \s -> case s of { + lark + "ा" => mkN s (lark + "े") Masc ; + lark + "ी" => mkN s (lark + "ीयँा") Fem ; + _ => mkN s s Masc + } ; + + mkAdj : Str -> Str -> Str -> {s : Gender => Number => Str} = \ms,mp,f -> { + s = table { + Masc => table { + Sg => ms ; + Pl => mp + } ; + Fem => \\_ => f + } + } ; + + regAdj : Str -> {s : Gender => Number => Str} = \a -> case a of { + acch + "ा" => mkAdj a (acch + "े") (acch + "ी") ; + _ => mkAdj a a a + } ; + + copula : Number -> Str = \n -> case n of { + Sg => "है" ; + Pl => "हैं" + } ; + + } diff --git a/samples/Grammatical Framework/FoodsI.gf b/samples/Grammatical Framework/FoodsI.gf new file mode 100644 index 00000000..f4113b72 --- /dev/null +++ b/samples/Grammatical Framework/FoodsI.gf @@ -0,0 +1,29 @@ +-- (c) 2009 Aarne Ranta under LGPL + +incomplete concrete FoodsI of Foods = + open Syntax, LexFoods in { + lincat + Comment = Utt ; + Item = NP ; + Kind = CN ; + Quality = AP ; + lin + Pred item quality = mkUtt (mkCl item quality) ; + This kind = mkNP this_Det kind ; + That kind = mkNP that_Det kind ; + These kind = mkNP these_Det kind ; + Those kind = mkNP those_Det kind ; + Mod quality kind = mkCN quality kind ; + Very quality = mkAP very_AdA quality ; + + Wine = mkCN wine_N ; + Pizza = mkCN pizza_N ; + Cheese = mkCN cheese_N ; + Fish = mkCN fish_N ; + Fresh = mkAP fresh_A ; + Warm = mkAP warm_A ; + Italian = mkAP italian_A ; + Expensive = mkAP expensive_A ; + Delicious = mkAP delicious_A ; + Boring = mkAP boring_A ; +} diff --git a/samples/Grammatical Framework/FoodsIce.gf b/samples/Grammatical Framework/FoodsIce.gf new file mode 100644 index 00000000..ab1297c7 --- /dev/null +++ b/samples/Grammatical Framework/FoodsIce.gf @@ -0,0 +1,84 @@ +--# -path=.:prelude + +-- (c) 2009 Martha Dis Brandt under LGPL + +concrete FoodsIce of Foods = open Prelude in { + + flags coding=utf8; + + lincat + Comment = SS ; + Quality = {s : Gender => Number => Defin => Str} ; + Kind = {s : Number => Str ; g : Gender} ; + Item = {s : Str ; g : Gender ; n : Number} ; + + lin + Pred item quality = ss (item.s ++ copula item.n ++ quality.s ! item.g ! item.n ! Ind) ; + This, That = det Sg "þessi" "þessi" "þetta" ; + These, Those = det Pl "þessir" "þessar" "þessi" ; + Mod quality kind = { s = \\n => quality.s ! kind.g ! n ! Def ++ kind.s ! n ; g = kind.g } ; + Wine = noun "vín" "vín" Neutr ; + Cheese = noun "ostur" "ostar" Masc ; + Fish = noun "fiskur" "fiskar" Masc ; + -- the word "pizza" is more commonly used in Iceland, but "flatbaka" is the Icelandic word for it + Pizza = noun "flatbaka" "flatbökur" Fem ; + Very qual = {s = \\g,n,defOrInd => "mjög" ++ qual.s ! g ! n ! defOrInd } ; + Fresh = regAdj "ferskur" ; + Warm = regAdj "heitur" ; + Boring = regAdj "leiðinlegur" ; + -- the order of the given adj forms is: mSg fSg nSg mPl fPl nPl mSgDef f/nSgDef _PlDef + Italian = adjective "ítalskur" "ítölsk" "ítalskt" "ítalskir" "ítalskar" "ítölsk" "ítalski" "ítalska" "ítalsku" ; + Expensive = adjective "dýr" "dýr" "dýrt" "dýrir" "dýrar" "dýr" "dýri" "dýra" "dýru" ; + Delicious = adjective "ljúffengur" "ljúffeng" "ljúffengt" "ljúffengir" "ljúffengar" "ljúffeng" "ljúffengi" "ljúffenga" "ljúffengu" ; + + param + Number = Sg | Pl ; + Gender = Masc | Fem | Neutr ; + Defin = Ind | Def ; + + oper + det : Number -> Str -> Str -> Str -> {s : Number => Str ; g : Gender} -> + {s : Str ; g : Gender ; n : Number} = + \n,masc,fem,neutr,cn -> { + s = case cn.g of {Masc => masc ; Fem => fem; Neutr => neutr } ++ cn.s ! n ; + g = cn.g ; + n = n + } ; + + noun : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = + \man,men,g -> { + s = table { + Sg => man ; + Pl => men + } ; + g = g + } ; + + adjective : (x1,_,_,_,_,_,_,_,x9 : Str) -> {s : Gender => Number => Defin => Str} = + \ferskur,fersk,ferskt,ferskir,ferskar,fersk_pl,ferski,ferska,fersku -> { + s = \\g,n,t => case of { + < Masc, Sg, Ind > => ferskur ; + < Masc, Pl, Ind > => ferskir ; + < Fem, Sg, Ind > => fersk ; + < Fem, Pl, Ind > => ferskar ; + < Neutr, Sg, Ind > => ferskt ; + < Neutr, Pl, Ind > => fersk_pl; + < Masc, Sg, Def > => ferski ; + < Fem, Sg, Def > | < Neutr, Sg, Def > => ferska ; + < _ , Pl, Def > => fersku + } + } ; + + regAdj : Str -> {s : Gender => Number => Defin => Str} = \ferskur -> + let fersk = Predef.tk 2 ferskur + in adjective + ferskur fersk (fersk + "t") + (fersk + "ir") (fersk + "ar") fersk + (fersk + "i") (fersk + "a") (fersk + "u") ; + + copula : Number -> Str = + \n -> case n of { + Sg => "er" ; + Pl => "eru" + } ; +} diff --git a/samples/Grammatical Framework/FoodsIta.gf b/samples/Grammatical Framework/FoodsIta.gf new file mode 100644 index 00000000..51baf9d7 --- /dev/null +++ b/samples/Grammatical Framework/FoodsIta.gf @@ -0,0 +1,8 @@ +--# -path=.:present + +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsIta of Foods = FoodsI with + (Syntax = SyntaxIta), + (LexFoods = LexFoodsIta) ; + diff --git a/samples/Grammatical Framework/FoodsJpn.gf b/samples/Grammatical Framework/FoodsJpn.gf new file mode 100644 index 00000000..9525ff16 --- /dev/null +++ b/samples/Grammatical Framework/FoodsJpn.gf @@ -0,0 +1,72 @@ +--# -path=.:../lib/src/prelude + +-- (c) 2009 Zofia Stankiewicz under LGPL + +concrete FoodsJpn of Foods = open Prelude in { + +flags coding=utf8 ; + + lincat + Comment = {s: Style => Str}; + Quality = {s: AdjUse => Str ; t: AdjType} ; + Kind = {s : Number => Str} ; + Item = {s : Str ; n : Number} ; + + lin + Pred item quality = {s = case quality.t of { + IAdj => table {Plain => item.s ++ quality.s ! APred ; Polite => item.s ++ quality.s ! APred ++ copula ! Polite ! item.n } ; + NaAdj => \\p => item.s ++ quality.s ! APred ++ copula ! p ! item.n } + } ; + This = det Sg "この" ; + That = det Sg "その" ; + These = det Pl "この" ; + Those = det Pl "その" ; + Mod quality kind = {s = \\n => quality.s ! Attr ++ kind.s ! n} ; + Wine = regNoun "ワインは" ; + Cheese = regNoun "チーズは" ; + Fish = regNoun "魚は" ; + Pizza = regNoun "ピザは" ; + Very quality = {s = \\a => "とても" ++ quality.s ! a ; t = quality.t } ; + Fresh = adj "新鮮な" "新鮮"; + Warm = regAdj "あたたかい" ; + Italian = adj "イタリアの" "イタリアのもの"; + Expensive = regAdj "たかい" ; + Delicious = regAdj "おいしい" ; + Boring = regAdj "つまらない" ; + + param + Number = Sg | Pl ; + AdjUse = Attr | APred ; -- na-adjectives have different forms as noun attributes and predicates + Style = Plain | Polite ; -- for phrase types + AdjType = IAdj | NaAdj ; -- IAdj can form predicates without the copula, NaAdj cannot + + oper + det : Number -> Str -> {s : Number => Str} -> {s : Str ; n : Number} = + \n,d,cn -> { + s = d ++ cn.s ! n ; + n = n + } ; + noun : Str -> Str -> {s : Number => Str} = + \sakana,sakana -> {s = \\_ => sakana } ; + + regNoun : Str -> {s : Number => Str} = + \sakana -> noun sakana sakana ; + + adj : Str -> Str -> {s : AdjUse => Str ; t : AdjType} = + \chosenna, chosen -> { + s = table { + Attr => chosenna ; + APred => chosen + } ; + t = NaAdj + } ; + + regAdj : Str -> {s: AdjUse => Str ; t : AdjType} =\akai -> { + s = \\_ => akai ; t = IAdj} ; + + copula : Style => Number => Str = + table { + Plain => \\_ => "だ" ; + Polite => \\_ => "です" } ; + +} diff --git a/samples/Grammatical Framework/FoodsLav.gf b/samples/Grammatical Framework/FoodsLav.gf new file mode 100644 index 00000000..efab6345 --- /dev/null +++ b/samples/Grammatical Framework/FoodsLav.gf @@ -0,0 +1,91 @@ +--# -path=.:prelude + +-- (c) 2009 Inese Bernsone under LGPL + +concrete FoodsLav of Foods = open Prelude in { + + flags + coding=utf8 ; + + lincat + Comment = SS ; + Quality = {s : Q => Gender => Number => Defin => Str } ; + Kind = {s : Number => Str ; g : Gender} ; + Item = {s : Str ; g : Gender ; n : Number } ; + + lin + Pred item quality = ss (item.s ++ {- copula item.n -} "ir" ++ quality.s ! Q1 ! item.g ! item.n ! Ind ) ; + This = det Sg "šis" "šī" ; + That = det Sg "tas" "tā" ; + These = det Pl "šie" "šīs" ; + Those = det Pl "tie" "tās" ; + Mod quality kind = {s = \\n => quality.s ! Q1 ! kind.g ! n ! Def ++ kind.s ! n ; g = kind.g } ; + Wine = noun "vīns" "vīni" Masc ; + Cheese = noun "siers" "sieri" Masc ; + Fish = noun "zivs" "zivis" Fem ; + Pizza = noun "pica" "picas" Fem ; + Very qual = {s = \\q,g,n,spec => "ļoti" ++ qual.s ! Q2 ! g ! n ! spec }; + + Fresh = adjective "svaigs" "svaiga" "svaigi" "svaigas" "svaigais" "svaigā" "svaigie" "svaigās" ; + Warm = regAdj "silts" ; + Italian = specAdj "itāļu" (regAdj "itālisks") ; + Expensive = regAdj "dārgs" ; + Delicious = regAdj "garšīgs" ; + Boring = regAdj "garlaicīgs" ; + + param + Number = Sg | Pl ; + Gender = Masc | Fem ; + Defin = Ind | Def ; + Q = Q1 | Q2 ; + + oper + det : Number -> Str -> Str -> {s : Number => Str ; g : Gender} -> + {s : Str ; g : Gender ; n : Number} = + \n,m,f,cn -> { + s = case cn.g of {Masc => m ; Fem => f} ++ cn.s ! n ; + g = cn.g ; + n = n + } ; + noun : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = + \man,men,g -> { + s = table { + Sg => man ; + Pl => men + } ; + g = g + } ; + adjective : (_,_,_,_,_,_,_,_ : Str) -> {s : Q => Gender => Number => Defin => Str} = + \skaists,skaista,skaisti,skaistas,skaistais,skaistaa,skaistie,skaistaas -> { + s = table { + _ => table { + Masc => table { + Sg => table {Ind => skaists ; Def => skaistais} ; + Pl => table {Ind => skaisti ; Def => skaistie} + } ; + Fem => table { + Sg => table {Ind => skaista ; Def => skaistaa} ; + Pl => table {Ind => skaistas ; Def => skaistaas} + } + } + } + } ; + + {- irregAdj : Str -> {s : Gender => Number => Defin => Str} = \itaalju -> + let itaalju = itaalju + in adjective itaalju (itaalju) (itaalju) (itaalju) (itaalju) (itaalju) (itaalju) (itaalju) ; -} + + regAdj : Str -> {s : Q => Gender => Number => Defin => Str} = \skaists -> + let skaist = init skaists + in adjective skaists (skaist + "a") (skaist + "i") (skaist + "as") (skaist + "ais") (skaist + "ā") (skaist + "ie") (skaist + "ās"); + + Adjective : Type = {s : Q => Gender => Number => Defin => Str} ; + + specAdj : Str -> Adjective -> Adjective = \s,a -> { + s = table { + Q2 => a.s ! Q1 ; + Q1 => \\_,_,_ => s + } + } ; + + } diff --git a/samples/Grammatical Framework/FoodsMlt.gf b/samples/Grammatical Framework/FoodsMlt.gf new file mode 100644 index 00000000..5fcd4de7 --- /dev/null +++ b/samples/Grammatical Framework/FoodsMlt.gf @@ -0,0 +1,105 @@ +-- (c) 2013 John J. Camilleri under LGPL + +concrete FoodsMlt of Foods = open Prelude in { + flags coding=utf8 ; + + lincat + Comment = SS ; + Quality = {s : Gender => Number => Str} ; + Kind = {s : Number => Str ; g : Gender} ; + Item = {s : Str ; g : Gender ; n : Number} ; + + lin + -- Pred item quality = ss (item.s ++ copula item.n item.g ++ quality.s ! item.g ! item.n) ; + Pred item quality = ss (item.s ++ quality.s ! item.g ! item.n) ; + + This kind = det Sg "dan" "din" kind ; + That kind = det Sg "dak" "dik" kind ; + These kind = det Pl "dawn" "" kind ; + Those kind = det Pl "dawk" "" kind ; + + Mod quality kind = { + s = \\n => kind.s ! n ++ quality.s ! kind.g ! n ; + g = kind.g + } ; + + Wine = noun "inbid" "inbejjed" Masc ; + Cheese = noun "ġobon" "ġobniet" Masc ; + Fish = noun "ħuta" "ħut" Fem ; + Pizza = noun "pizza" "pizzez" Fem ; + + Very qual = {s = \\g,n => qual.s ! g ! n ++ "ħafna"} ; + + Warm = adjective "sħun" "sħuna" "sħan" ; + Expensive = adjective "għali" "għalja" "għaljin" ; + Delicious = adjective "tajjeb" "tajba" "tajbin" ; + Boring = uniAdj "tad-dwejjaq" ; + Fresh = regAdj "frisk" ; + Italian = regAdj "Taljan" ; + + param + Number = Sg | Pl ; + Gender = Masc | Fem ; + + oper + --Create an adjective (full function) + --Params: Sing Masc, Sing Fem, Plural + adjective : (_,_,_ : Str) -> {s : Gender => Number => Str} = \iswed,sewda,suwed -> { + s = table { + Masc => table { + Sg => iswed ; + Pl => suwed + } ; + Fem => table { + Sg => sewda ; + Pl => suwed + } + } + } ; + + --Create a regular adjective + --Param: Sing Masc + regAdj : Str -> {s : Gender => Number => Str} = \frisk -> + adjective frisk (frisk + "a") (frisk + "i") ; + + --Create a "uni-adjective" eg tal-buzz + --Param: Sing Masc + uniAdj : Str -> {s : Gender => Number => Str} = \uni -> + adjective uni uni uni ; + + --Create a noun + --Params: Singular, Plural, Gender (inherent) + noun : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = \ktieb,kotba,g -> { + s = table { + Sg => ktieb ; + Pl => kotba + } ; + g = g + } ; + + --Copula is a linking verb + --Params: Number, Gender + -- copula : Number -> Gender -> Str = \n,g -> case n of { + -- Sg => case g of { Masc => "huwa" ; Fem => "hija" } ; + -- Pl => "huma" + -- } ; + + --Create an article, taking into account first letter of next word + article = pre { + "a"|"e"|"i"|"o"|"u" => "l-" ; + --cons@("ċ"|"d"|"n"|"r"|"s"|"t"|"x"|"ż") => "i" + cons + "-" ; + _ => "il-" + } ; + + --Create a determinant + --Params: Sg/Pl, Masc, Fem + det : Number -> Str -> Str -> {s : Number => Str ; g : Gender} -> {s : Str ; g : Gender ; n : Number} = \n,m,f,cn -> { + s = case n of { + Sg => case cn.g of {Masc => m ; Fem => f}; --string + Pl => m --default to masc + } ++ article ++ cn.s ! n ; + g = cn.g ; --gender + n = n --number + } ; + +} diff --git a/samples/Grammatical Framework/FoodsMon.gf b/samples/Grammatical Framework/FoodsMon.gf new file mode 100644 index 00000000..eda2012f --- /dev/null +++ b/samples/Grammatical Framework/FoodsMon.gf @@ -0,0 +1,49 @@ +--# -path=.:/GF/lib/src/prelude + +-- (c) 2009 Nyamsuren Erdenebadrakh under LGPL + +concrete FoodsMon of Foods = open Prelude in { + flags coding=utf8; + + lincat + Comment, Quality = SS ; + Kind = {s : Number => Str} ; + Item = {s : Str ; n : Number} ; + + lin + Pred item quality = ss (item.s ++ "бол" ++ quality.s) ; + This = det Sg "энэ" ; + That = det Sg "тэр" ; + These = det Pl "эдгээр" ; + Those = det Pl "тэдгээр" ; + Mod quality kind = {s = \\n => quality.s ++ kind.s ! n} ; + Wine = regNoun "дарс" ; + Cheese = regNoun "бяслаг" ; + Fish = regNoun "загас" ; + Pizza = regNoun "пицца" ; + Very = prefixSS "маш" ; + Fresh = ss "шинэ" ; + Warm = ss "халуун" ; + Italian = ss "итали" ; + Expensive = ss "үнэтэй" ; + Delicious = ss "амттай" ; + Boring = ss "амтгүй" ; + + param + Number = Sg | Pl ; + + oper + det : Number -> Str -> {s : Number => Str} -> {s : Str ; n : Number} = + \n,d,cn -> { + s = d ++ cn.s ! n ; + n = n + } ; + + regNoun : Str -> {s : Number => Str} = + \x -> {s = table { + Sg => x ; + Pl => x + "нууд"} + } ; + } + + diff --git a/samples/Grammatical Framework/FoodsNep.gf b/samples/Grammatical Framework/FoodsNep.gf new file mode 100644 index 00000000..ea02e64a --- /dev/null +++ b/samples/Grammatical Framework/FoodsNep.gf @@ -0,0 +1,60 @@ +-- (c) 2011 Dinesh Simkhada under LGPL + +concrete FoodsNep of Foods = { + + flags coding = utf8 ; + + lincat + Comment, Quality = {s : Str} ; + Kind = {s : Number => Str} ; + Item = {s : Str ; n : Number} ; + + lin + Pred item quality = + {s = item.s ++ quality.s ++ copula ! item.n} ; + + This = det Sg "यो" ; + That = det Sg "त्यो" ; + These = det Pl "यी" ; + Those = det Pl "ती" ; + Mod quality kind = + {s = \\n => quality.s ++ kind.s ! n} ; + + Wine = regNoun "रक्सी" ; + Cheese = regNoun "चिज" ; + Fish = regNoun "माछा" ; + Pizza = regNoun "पिज्जा" ; + Very a = {s = "धेरै" ++ a.s} ; + Fresh = adj "ताजा" ; + Warm = adj "तातो" ; + Italian = adj "इटालियन" ; + Expensive = adj "महँगो" | adj "बहुमूल्य" ; + Delicious = adj "स्वादिष्ट" | adj "मीठो" ; + Boring = adjPl "नमिठो" ; + + param + Number = Sg | Pl ; + + oper + det : Number -> Str -> + {s : Number => Str} -> {s : Str ; n : Number} = + \n,det,noun -> {s = det ++ noun.s ! n ; n = n} ; + + noun : Str -> Str -> {s : Number => Str} = + \man,men -> {s = table {Sg => man ; Pl => men}} ; + + regNoun : Str -> {s : Number => Str} = + \car -> noun car (car + "हरु") ; + + adjPl : Str -> {s : Str} = \a -> case a of { + bor + "ठो" => adj (bor + "ठा") ; + _ => adj a + } ; + + adj : Str -> {s : Str} = + \cold -> {s = cold} ; + + copula : Number => Str = + table {Sg => "छ" ; Pl => "छन्"} ; +} + diff --git a/samples/Grammatical Framework/FoodsOri.gf b/samples/Grammatical Framework/FoodsOri.gf new file mode 100644 index 00000000..ad4f492f --- /dev/null +++ b/samples/Grammatical Framework/FoodsOri.gf @@ -0,0 +1,30 @@ +concrete FoodsOri of Foods = { + +flags coding = utf8 ; + +lincat + Comment = Str; + Item = Str; + Kind = Str; + Quality = Str; + +lin + Pred item quality = item ++ quality ++ "ଅଟେ"; + This kind = "ଏଇ" ++ kind; + That kind = "ସେଇ" ++ kind; + These kind = "ଏଇ" ++ kind ++ "ଗୁଡିକ" ; + Those kind = "ସେଇ" ++ kind ++ "ଗୁଡିକ" ; + Mod quality kind = quality ++ kind; + Wine = "ମଦ"; + Cheese = "ଛେନା"; + Fish = "ମାଛ"; + Pizza = "ପିଜଜ଼ା" ; + Very quality = "ଅତି" ++ quality; + Fresh = "ତାଜା"; + Warm = "ଗରମ"; + Italian = "ଇଟାଲି"; + Expensive = "ମୁଲ୍ୟବାନ୍"; + Delicious = "ସ୍ଵାଦିସ୍ଟ "; + Boring = "ଅରୁଚିକର"; + +} diff --git a/samples/Grammatical Framework/FoodsPes.gf b/samples/Grammatical Framework/FoodsPes.gf new file mode 100644 index 00000000..c2e631e8 --- /dev/null +++ b/samples/Grammatical Framework/FoodsPes.gf @@ -0,0 +1,65 @@ +concrete FoodsPes of Foods = { + + flags optimize=noexpand ; coding=utf8 ; + + lincat + Comment = {s : Str} ; + Quality = {s : Add => Str; prep : Str} ; + Kind = {s : Add => Number => Str ; prep : Str}; + Item = {s : Str ; n : Number}; + lin + Pred item quality = {s = item.s ++ quality.s ! Indep ++ copula ! item.n} ; + This = det Sg "این" ; + That = det Sg "آن" ; + These = det Pl "این" ; + Those = det Pl "آن" ; + + Mod quality kind = {s = \\a,n => kind.s ! Attr ! n ++ kind.prep ++ quality.s ! a ; + prep = quality.prep + }; + Wine = regN "شراب" ; + Cheese = regN "پنیر" ; + Fish = regN "ماهى" ; + Pizza = regN "پیتزا" ; + Very a = {s = \\at => "خیلی" ++ a.s ! at ; prep = a.prep} ; + Fresh = adj "تازه" ; + Warm = adj "گرم" ; + Italian = adj "ایتالیایی" ; + Expensive = adj "گران" ; + Delicious = adj "لذىذ" ; + Boring = adj "ملال آور" ; -- it must be written as ملال آور. + + param + Number = Sg | Pl ; + Add = Indep | Attr ; + oper + det : Number -> Str -> {s: Add => Number => Str ; prep : Str} -> {s : Str ; n: Number} = + \n,det,noun -> {s = det ++ noun.s ! Indep ! n ; n = n }; + + noun : (x1,_,_,x4 : Str) -> {s : Add => Number => Str ; prep : Str} = \pytzA, pytzAy, pytzAhA,pr -> + {s = \\a,n => case of + { => pytzA ; => pytzAhA ; + =>pytzA ; => pytzAhA + "ى" }; + prep = pr + }; + + regN : Str -> {s: Add => Number => Str ; prep : Str} = \mrd -> + case mrd of + { _ + ("ا"|"ه"|"ى"|"و"|"") => noun mrd (mrd+"ى") (mrd + "ها") ""; + _ => noun mrd mrd (mrd + "ها") "e" + }; + + adj : Str -> {s : Add => Str; prep : Str} = \tAzh -> + case tAzh of + { _ + ("ا"|"ه"|"ى"|"و"|"") => mkAdj tAzh (tAzh ++ "ى") "" ; + _ => mkAdj tAzh tAzh "ه" + }; + + mkAdj : Str -> Str -> Str -> {s : Add => Str; prep : Str} = \tAzh, tAzhy, pr -> + {s = table {Indep => tAzh; + Attr => tAzhy}; + prep = pr + }; + copula : Number => Str = table {Sg => "است"; Pl => "هستند"}; + +} \ No newline at end of file diff --git a/samples/Grammatical Framework/FoodsPor.gf b/samples/Grammatical Framework/FoodsPor.gf new file mode 100644 index 00000000..6171c707 --- /dev/null +++ b/samples/Grammatical Framework/FoodsPor.gf @@ -0,0 +1,79 @@ +-- (c) 2009 Rami Shashati under LGPL + +concrete FoodsPor of Foods = open Prelude in { + flags coding=utf8; + + lincat + Comment = {s : Str} ; + Quality = {s : Gender => Number => Str} ; + Kind = {s : Number => Str ; g : Gender} ; + Item = {s : Str ; n : Number ; g : Gender } ; + + lin + Pred item quality = + {s = item.s ++ copula ! item.n ++ quality.s ! item.g ! item.n } ; + This = det Sg (table {Masc => "este" ; Fem => "esta"}) ; + That = det Sg (table {Masc => "esse" ; Fem => "essa"}) ; + These = det Pl (table {Masc => "estes" ; Fem => "estas"}) ; + Those = det Pl (table {Masc => "esses" ; Fem => "essas"}) ; + + Mod quality kind = { s = \\n => kind.s ! n ++ quality.s ! kind.g ! n ; g = kind.g } ; + + Wine = regNoun "vinho" Masc ; + Cheese = regNoun "queijo" Masc ; + Fish = regNoun "peixe" Masc ; + Pizza = regNoun "pizza" Fem ; + + Very a = { s = \\g,n => "muito" ++ a.s ! g ! n } ; + + Fresh = mkAdjReg "fresco" ; + Warm = mkAdjReg "quente" ; + Italian = mkAdjReg "Italiano" ; + Expensive = mkAdjReg "caro" ; + Delicious = mkAdjReg "delicioso" ; + Boring = mkAdjReg "chato" ; + + param + Number = Sg | Pl ; + Gender = Masc | Fem ; + + oper + QualityT : Type = {s : Gender => Number => Str} ; + + mkAdj : (_,_,_,_ : Str) -> QualityT = \bonito,bonita,bonitos,bonitas -> { + s = table { + Masc => table { Sg => bonito ; Pl => bonitos } ; + Fem => table { Sg => bonita ; Pl => bonitas } + } ; + } ; + + -- regular pattern + adjSozinho : Str -> QualityT = \sozinho -> + let sozinh = Predef.tk 1 sozinho + in mkAdj sozinho (sozinh + "a") (sozinh + "os") (sozinh + "as") ; + + -- for gender-independent adjectives + adjUtil : Str -> Str -> QualityT = \util,uteis -> + mkAdj util util uteis uteis ; + + -- smart paradigm for adjcetives + mkAdjReg : Str -> QualityT = \a -> case last a of { + "o" => adjSozinho a ; + "e" => adjUtil a (a + "s") + } ; + + ItemT : Type = {s : Str ; n : Number ; g : Gender } ; + + det : Number -> (Gender => Str) -> KindT -> ItemT = + \num,det,noun -> {s = det ! noun.g ++ noun.s ! num ; n = num ; g = noun.g } ; + + KindT : Type = {s : Number => Str ; g : Gender} ; + + noun : Str -> Str -> Gender -> KindT = + \animal,animais,gen -> {s = table {Sg => animal ; Pl => animais} ; g = gen } ; + + regNoun : Str -> Gender -> KindT = + \carro,gen -> noun carro (carro + "s") gen ; + + copula : Number => Str = table {Sg => "é" ; Pl => "são"} ; +} diff --git a/samples/Grammatical Framework/FoodsRon.gf b/samples/Grammatical Framework/FoodsRon.gf new file mode 100644 index 00000000..d7d917ff --- /dev/null +++ b/samples/Grammatical Framework/FoodsRon.gf @@ -0,0 +1,72 @@ +-- (c) 2009 Ramona Enache under LGPL + +concrete FoodsRon of Foods = +{ +flags coding=utf8 ; + +param Number = Sg | Pl ; + Gender = Masc | Fem ; + NGender = NMasc | NFem | NNeut ; +lincat +Comment = {s : Str}; +Quality = {s : Number => Gender => Str}; +Kind = {s : Number => Str; g : NGender}; +Item = {s : Str ; n : Number; g : Gender}; + +lin + +This = det Sg (mkTab "acest" "această"); +That = det Sg (mkTab "acel" "acea"); +These = det Pl (mkTab "acești" "aceste"); +Those = det Pl (mkTab "acei" "acele"); + +Wine = mkNoun "vin" "vinuri" NNeut ; +Cheese = mkNoun "brânză" "brânzeturi" NFem ; +Fish = mkNoun "peşte" "peşti" NMasc ; +Pizza = mkNoun "pizza" "pizze" NFem; + +Very a = {s = \\n,g => "foarte" ++ a.s ! n ! g}; + +Fresh = mkAdj "proaspăt" "proaspătă" "proaspeţi" "proaspete" ; +Warm = mkAdj "cald" "caldă" "calzi" "calde" ; +Italian = mkAdj "italian" "italiană" "italieni" "italiene" ; +Expensive = mkAdj "scump" "scumpă" "scumpi" "scumpe" ; +Delicious = mkAdj "delicios" "delcioasă" "delicioşi" "delicioase" ; +Boring = mkAdj "plictisitor" "plictisitoare" "plictisitori" "plictisitoare" ; + +Pred item quality = {s = item.s ++ copula ! item.n ++ quality.s ! item.n ! item.g} ; + +Mod quality kind = {s = \\n => kind.s ! n ++ quality.s ! n ! (getAgrGender kind.g n) ; g = kind.g}; + +oper + +mkTab : Str -> Str -> {s : Gender => Str} = \acesta, aceasta -> +{s = table{Masc => acesta; + Fem => aceasta}}; + +det : Number -> {s : Gender => Str} -> {s : Number => Str ; g : NGender} -> {s : Str; n : Number; g : Gender} = +\n,det,noun -> let gg = getAgrGender noun.g n + in + {s = det.s ! gg ++ noun.s ! n ; n = n ; g = gg}; + +mkNoun : Str -> Str -> NGender -> {s : Number => Str; g : NGender} = \peste, pesti,g -> +{s = table {Sg => peste; + Pl => pesti}; + g = g +}; + +oper mkAdj : (x1,_,_,x4 : Str) -> {s : Number => Gender => Str} = \scump, scumpa, scumpi, scumpe -> +{s = \\n,g => case of +{ => scump ; => scumpa; + => scumpi ; => scumpe +}}; + +copula : Number => Str = table {Sg => "este" ; Pl => "sunt"}; + +getAgrGender : NGender -> Number -> Gender = \ng,n -> +case of +{ => Masc ; => Fem; + => Masc ; => Fem +}; + +} diff --git a/samples/Grammatical Framework/FoodsSpa.gf b/samples/Grammatical Framework/FoodsSpa.gf new file mode 100644 index 00000000..972282ae --- /dev/null +++ b/samples/Grammatical Framework/FoodsSpa.gf @@ -0,0 +1,31 @@ +--# -path=.:present + +concrete FoodsSpa of Foods = open SyntaxSpa, StructuralSpa, ParadigmsSpa in { + + lincat + Comment = Utt ; + Item = NP ; + Kind = CN ; + Quality = AP ; + + lin + Pred item quality = mkUtt (mkCl item quality) ; + This kind = mkNP this_QuantSg kind ; + That kind = mkNP that_QuantSg kind ; + These kind = mkNP these_QuantPl kind ; + Those kind = mkNP those_QuantPl kind ; + Mod quality kind = mkCN quality kind ; + Very quality = mkAP very_AdA quality ; + Wine = mkCN (mkN "vino") ; + Pizza = mkCN (mkN "pizza") ; + Cheese = mkCN (mkN "queso") ; + Fish = mkCN (mkN "pescado") ; + Fresh = mkAP (mkA "fresco") ; + Warm = mkAP (mkA "caliente") ; + Italian = mkAP (mkA "italiano") ; + Expensive = mkAP (mkA "caro") ; + Delicious = mkAP (mkA "delicioso") ; + Boring = mkAP (mkA "aburrido") ; + +} + diff --git a/samples/Grammatical Framework/FoodsSwe.gf b/samples/Grammatical Framework/FoodsSwe.gf new file mode 100644 index 00000000..cbb35fb9 --- /dev/null +++ b/samples/Grammatical Framework/FoodsSwe.gf @@ -0,0 +1,7 @@ +--# -path=.:present + +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsSwe of Foods = FoodsI with + (Syntax = SyntaxSwe), + (LexFoods = LexFoodsSwe) ** {flags language = sv_SE;} ; diff --git a/samples/Grammatical Framework/FoodsTha.gf b/samples/Grammatical Framework/FoodsTha.gf new file mode 100644 index 00000000..b031a7e2 --- /dev/null +++ b/samples/Grammatical Framework/FoodsTha.gf @@ -0,0 +1,33 @@ +--# -path=.:alltenses + +concrete FoodsTha of Foods = open SyntaxTha, LexiconTha, + ParadigmsTha, (R=ResTha) in { + + flags coding = utf8 ; + + lincat + Comment = Utt ; + Item = NP ; + Kind = CN ; + Quality = AP ; + + lin + Pred item quality = mkUtt (mkCl item quality) ; + This kind = mkNP this_Det kind ; + That kind = mkNP that_Det kind ; + These kind = mkNP these_Det kind ; + Those kind = mkNP those_Det kind ; + Mod quality kind = mkCN quality kind ; + Very quality = mkAP very_AdA quality ; + Wine = mkCN (mkN (R.thword "เหล้าอ" "งุ่น") "ขวด") ; + Pizza = mkCN (mkN (R.thword "พิซ" "ซา") "ถาด") ; + Cheese = mkCN (mkN (R.thword "เนย" "แข็ง") "ก้อน") ; + Fish = mkCN fish_N ; + Fresh = mkAP (mkA "สด") ; + Warm = mkAP warm_A ; + Italian = mkAP (mkA " อิตาลี") ; + Expensive = mkAP (mkA "แพง") ; + Delicious = mkAP (mkA "อร่อย") ; + Boring = mkAP (mkA (R.thword "น่า" "เบิ่อ")) ; + +} diff --git a/samples/Grammatical Framework/FoodsTsn.gf b/samples/Grammatical Framework/FoodsTsn.gf new file mode 100644 index 00000000..a7a69a1a --- /dev/null +++ b/samples/Grammatical Framework/FoodsTsn.gf @@ -0,0 +1,178 @@ +--# -path=alltenses + +-- (c) 2009 Laurette Pretorius Sr & Jr and Ansu Berg under LGPL + +concrete FoodsTsn of Foods = open Prelude, Predef in { + flags coding = utf8; + lincat + Comment = {s:Str}; + Item = {s:Str; c:NounClass; n:Number}; + Kind = {w: Number => Str; r: Str; c: NounClass; q: Number => Str; b: Bool}; + Quality = {s: NounClass => Number => Str; p_form: Str; t: TType}; + lin + Pred item quality = {s = item.s ++ ((mkPredDescrCop quality.t) ! item.c ! item.n) ++ quality.p_form}; + + This kind = {s = (kind.w ! Sg) ++ (mkDemPron1 ! kind.c ! Sg) ++ (kind.q ! Sg); c = kind.c; n = Sg}; + That kind = {s = (kind.w ! Sg) ++ (mkDemPron2 ! kind.c ! Sg) ++ (kind.q ! Sg); c = kind.c; n = Sg}; + These kind = {s = (kind.w ! Pl) ++ (mkDemPron1 ! kind.c ! Pl) ++ (kind.q ! Pl); c = kind.c; n = Pl}; + Those kind = {s = (kind.w ! Pl) ++ (mkDemPron2 ! kind.c ! Pl) ++ (kind.q ! Pl); c = kind.c; n = Pl}; + + Mod quality kind = mkMod quality kind; + + -- Lexicon + Wine = mkNounNC14_6 "jalwa"; + Cheese = mkNounNC9_10 "kase"; + Fish = mkNounNC9_10 "thlapi"; + Pizza = mkNounNC9_10 "pizza"; + Very quality = smartVery quality; + Fresh = mkVarAdj "ntsha"; + Warm = mkOrdAdj "bothitho"; + Italian = mkPerAdj "Itali"; + Expensive = mkVerbRel "tura"; + Delicious = mkOrdAdj "monate"; + Boring = mkOrdAdj "bosula"; + + param + NounClass = NC9_10 | NC14_6; + Number = Sg | Pl; + TType = P | V | ModV | R ; + oper + mkMod : {s: NounClass => Number => Str; p_form: Str; t: TType} -> {w: Number => Str; r: Str; c: NounClass; q: Number => Str; b: Bool} -> {w: Number => Str; r: Str; c: NounClass; q: Number => Str; + b: Bool} = \x,y -> case y.b of + { + True => {w = y.w; r = y.r; c = y.c; + q = table { + Sg => ((y.q ! Sg) ++ "le" ++ ((smartQualRelPart (x.t)) ! y.c ! Sg) ++ ((smartDescrCop (x.t)) ! y.c ! Sg) ++ (x.s ! y.c ! Sg)); + Pl => ((y.q ! Pl) ++ "le" ++ ((smartQualRelPart (x.t))! y.c ! Pl) ++ ((smartDescrCop (x.t)) ! y.c ! Pl) ++(x.s ! y.c ! Pl)) + }; b = True + }; + False => {w = y.w; r = y.r; c = y.c; + q = table { + Sg => ((y.q ! Sg) ++ ((smartQualRelPart (x.t)) ! y.c ! Sg) ++ ((smartDescrCop (x.t)) ! y.c ! Sg) ++ (x.s ! y.c ! Sg)); + Pl => ((y.q ! Pl) ++ ((smartQualRelPart (x.t)) ! y.c ! Pl) ++ ((smartDescrCop (x.t)) ! y.c ! Pl) ++(x.s ! y.c ! Pl)) + }; b = True + } + }; + + mkNounNC14_6 : Str -> {w: Number => Str; r: Str; c: NounClass; q: Number => Str; b: Bool} = \x -> {w = table {Sg => "bo" + x; Pl => "ma" + x}; r = x; c = NC14_6; + q = table {Sg => ""; Pl => ""}; b = False}; + + mkNounNC9_10 : Str -> {w: Number => Str; r: Str; c: NounClass; q: Number => Str; b: Bool} = \x -> {w = table {Sg => "" + x; Pl => "di" + x}; r = x; c = NC9_10; + q = table {Sg => ""; Pl => ""}; b = False}; + + mkVarAdj : Str -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table { + NC9_10 => table {Sg => "" + x; Pl => "di" + x}; + NC14_6 => table {Sg => "bo" + x; Pl => "ma" + x} + }; + p_form = x; + t = R; + }; + + mkOrdAdj : Str -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table { + NC9_10 => table {Sg => "" + x; Pl => "" + x}; + NC14_6 => table {Sg => "" + x; Pl => "" + x} + }; + p_form = x; + t = R; + }; + + mkVerbRel : Str -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table { + NC9_10 => table {Sg => x + "ng"; Pl => x + "ng"}; + NC14_6 => table {Sg => x + "ng"; Pl => x + "ng"} + }; + p_form = x; + t = V; + }; + + mkPerAdj : Str -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table { + NC9_10 => table {Sg => "" + x; Pl => "" + x}; + NC14_6 => table {Sg => "" + x; Pl => "" + x} + }; + p_form = "mo" ++ x; + t = P; + }; + + mkVeryAdj : {s: NounClass => Number => Str; p_form: Str; t: TType} -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table{c => table{n => (x.s!c!n) ++ "thata"}}; p_form = x.p_form ++ "thata"; t = x.t + }; + + mkVeryVerb : {s: NounClass => Number => Str; p_form: Str; t: TType} -> {s: NounClass => Number => Str; p_form: Str; t: TType} = \x -> + { + s = table{c => table{n => (x.s!c!n) ++ "thata"}}; p_form = x.p_form ++ "thata"; t = ModV + }; + + smartVery : {s: NounClass => Number => Str; p_form: Str; t: TType} -> {s: NounClass => Number => Str; p_form: Str; t: TType} = +\x -> case x.t of --(x.s!c!n) + { + (V | ModV) => mkVeryVerb x; + --ModV => mkVeryVerb x; + _ => mkVeryAdj x + }; + + mkDemPron1 : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "e"; Pl => "tse"}; + NC14_6 => table {Sg => "bo"; Pl => "a"} + }; + + mkDemPron2 : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "eo"; Pl => "tseo"}; + NC14_6 => table {Sg => "boo"; Pl => "ao"} + }; + + smartQualRelPart : TType -> (NounClass => Number => Str) = \x -> case x of + { + P => mkQualRelPart_PName; + _ => mkQualRelPart + }; + + mkQualRelPart : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "e"; Pl => "tse"}; + NC14_6 => table {Sg => "bo"; Pl => "a"} + }; + + mkQualRelPart_PName : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "ya"; Pl => "tsa"}; + NC14_6 => table {Sg => "ba"; Pl => "a"} + }; + + smartDescrCop : TType -> (NounClass => Number => Str) = \x -> case x of + { + P => mkDescrCop_PName; + _ => mkDescrCop + }; + + mkDescrCop : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "e"; Pl => "di"}; + NC14_6 => table {Sg => "bo"; Pl => "a"} + }; + + mkDescrCop_PName : NounClass => Number => Str = table + { + NC9_10 => table {Sg => "ga"; Pl => "ga"}; + NC14_6 => table {Sg => "ga"; Pl => "ga"} + }; + + mkPredDescrCop : TType -> (NounClass => Number => Str) = \x -> case x of + { + V => table {NC9_10 => table {Sg => "e" ++ "a"; Pl => "di" ++ "a"}; + NC14_6 => table {Sg => "bo" ++ "a"; Pl => "a" ++ "a"}}; + + _ => table {NC9_10 => table {Sg => "e"; Pl => "di"}; + NC14_6 => table {Sg => "bo"; Pl => "a"}} + }; + +} diff --git a/samples/Grammatical Framework/FoodsTur.gf b/samples/Grammatical Framework/FoodsTur.gf new file mode 100644 index 00000000..9d6cd035 --- /dev/null +++ b/samples/Grammatical Framework/FoodsTur.gf @@ -0,0 +1,140 @@ +{- + File : FoodsTur.gf + Author : Server Çimen + Version : 1.0 + Created on: August 26, 2009 + + This file contains concrete grammar of Foods abstract grammar for Turkish Language. + This grammar is to be used for Fridge demo and developed in the scope of GF Resource + Grammar Summer School. + +-} + +concrete FoodsTur of Foods = open Predef in { + flags + coding=utf8 ; + lincat + Comment = {s : Str} ; + Quality = {s : Str ; c : Case; softness : Softness; h : Harmony} ; + Kind = {s : Case => Number => Str} ; + Item = {s : Str; n : Number} ; + lin + This = det Sg "bu" ; + That = det Sg "şu" ; + These = det Pl "bu" ; + Those = det Pl "şu" ; + -- Reason for excluding plural form of copula: In Turkish if subject is not a human being, + -- then singular form of copula is used regardless of the number of subject. Since all + -- possible subjects are non human, copula do not need to have plural form. + Pred item quality = {s = item.s ++ quality.s ++ "&+" ++ copula ! quality.softness ! quality.h} ;--! item.n} ; + Mod quality kind = {s = case quality.c of { + Nom => \\t,n => quality.s ++ kind.s ! t ! n ; + Gen => \\t,n => quality.s ++ kind.s ! Gen ! n + } + } ; + Wine = mkN "şarap" "şaraplar" "şarabı" "şarapları" ; + Cheese = mkN "peynir" "peynirler" "peyniri" "peynirleri" ; + Fish = mkN "balık" "balıklar" "balığı" "balıkları" ; + Pizza = mkN "pizza" "pizzalar" "pizzası" "pizzaları" ; + Very a = {s = "çok" ++ a.s ; c = a.c; softness = a.softness; h = a.h} ; + Fresh = adj "taze" Nom; + Warm = adj "ılık" Nom; + Italian = adj "İtalyan" Gen ; + Expensive = adj "pahalı" Nom; + Delicious = adj "lezzetli" Nom; + Boring = adj "sıkıcı" Nom; + param + Number = Sg | Pl ; + Case = Nom | Gen ; + Harmony = I_Har | Ih_Har | U_Har | Uh_Har ; --Ih = İ; Uh = Ü + Softness = Soft | Hard ; + oper + det : Number -> Str -> {s : Case => Number => Str} -> {s : Str; n : Number} = + \num,det,noun -> {s = det ++ noun.s ! Nom ! num; n = num} ; + mkN = overload { + mkN : Str -> Str -> {s : Case => Number => Str} = regNoun ; + mkn : Str -> Str -> Str -> Str-> {s : Case => Number => Str} = noun ; + } ; + regNoun : Str -> Str -> {s : Case => Number => Str} = + \peynir,peynirler -> noun peynir peynirler [] [] ; + noun : Str -> Str -> Str -> Str-> {s : Case => Number => Str} = + \sarap,saraplar,sarabi,saraplari -> { + s = table { + Nom => table { + Sg => sarap ; + Pl => saraplar + } ; + Gen => table { + Sg => sarabi ; + Pl => saraplari + } + } + }; + {- + Since there is a bug in overloading, this overload is useless. + + mkA = overload { + mkA : Str -> {s : Str; c : Case; softness : Softness; h : Harmony} = \base -> adj base Nom ; + mkA : Str -> Case -> {s : Str; c : Case; softness : Softness; h : Harmony} = adj ; + } ; + -} + adj : Str -> Case -> {s : Str; c : Case; softness : Softness; h : Harmony} = + \italyan,ca -> {s = italyan ; c = ca; softness = (getSoftness italyan); h = (getHarmony italyan)} ; + -- See the comment at lines 26 and 27 for excluded plural form of copula. + copula : Softness => Harmony {-=> Number-} => Str = + table { + Soft => table { + I_Har => "dır" ;--table { + -- Sg => "dır" ; + -- Pl => "dırlar" + --} ; + Ih_Har => "dir" ;--table { + --Sg => "dir" ; + --Pl => "dirler" + --} ; + U_Har => "dur" ;--table { + -- Sg => "dur" ; + -- Pl => "durlar" + --} ; + Uh_Har => "dür" --table { + --Sg => "dür" ; + --Pl => "dürler" + --} + } ; + Hard => table { + I_Har => "tır" ;--table { + --Sg => "tır" ; + --Pl => "tırlar" + --} ; + Ih_Har => "tir" ;--table { + --Sg => "tir" ; + --Pl => "tirler" + --} ; + U_Har => "tur" ;--table { + -- Sg => "tur" ; + -- Pl => "turlar" + --} ; + Uh_Har => "tür"--table { + --Sg => "tür" ; + --Pl => "türler" + --} + } + } ; + + getHarmony : Str -> Harmony + = \base -> case base of { + _+c@("ı"|"a"|"i"|"e"|"u"|"o"|"ü"|"ö")+ + ("b"|"v"|"d"|"z"|"j"|"c"|"g"|"ğ"|"l"|"r"|"m"|"n"|"y"|"p"|"f"|"t"|"s"|"ş"|"ç"|"k"|"h")* => + case c of { + ("ı"|"a") => I_Har ; + ("i"|"e") => Ih_Har ; + ("u"|"o") => U_Har ; + ("ü"|"ö") => Uh_Har + } + } ; + getSoftness : Str -> Softness + = \base -> case base of { + _+("f"|"s"|"t"|"k"|"ç"|"ş"|"h"|"p") => Hard ; + _ => Soft + } ; +} \ No newline at end of file diff --git a/samples/Grammatical Framework/FoodsUrd.gf b/samples/Grammatical Framework/FoodsUrd.gf new file mode 100644 index 00000000..186b2f92 --- /dev/null +++ b/samples/Grammatical Framework/FoodsUrd.gf @@ -0,0 +1,53 @@ +-- (c) 2009 Shafqat Virk under LGPL + +concrete FoodsUrd of Foods = { + + flags coding=utf8 ; + + + param Number = Sg | Pl ; + param Gender = Masc | Fem; + + oper coupla : Number -> Str =\n -> case n of {Sg => "ہے" ; Pl => "ہیں"}; + + + lincat + Comment = {s : Str} ; + Item = {s: Str ; n: Number ; g:Gender}; + Kind = {s: Number => Str ; g:Gender}; + Quality = {s: Gender => Number => Str}; + + lin + Pred item quality = {s = item.s ++ quality.s ! item.g ! item.n ++ coupla item.n} ; + This kind = {s = "یھ" ++ kind.s ! Sg; n= Sg ; g = kind.g } ; + These kind = {s = "یھ" ++ kind.s ! Pl; n = Pl ; g = kind.g} ; + That kind = {s = "وہ" ++ kind.s ! Sg; n= Sg ; g = kind.g} ; + Those kind = {s = "وہ" ++ kind.s ! Pl; n=Pl ; g = kind.g} ; + Mod quality kind = {s = \\n => quality.s ! kind.g ! n ++ kind.s ! n ; g = kind.g}; + Wine = {s = table { Sg => "شراب" ; Pl => "شرابیں"} ; g = Fem}; + Cheese = {s = table { Sg => "پنیر" ; Pl => "پنیریں"} ; g = Fem}; + Fish = {s = table { Sg => "مچھلی" ; Pl => "مچھلیاں"} ; g = Fem}; + Pizza = {s = table { Sg => "پیزہ" ; Pl => "پیزے"} ; g = Masc}; + Very quality = {s = \\g,n => "بہت" ++ quality.s ! g ! n} ; + Fresh = regAdj "تازہ" ; + Warm = regAdj "گرم" ; + Italian = regAdj "اٹا لوی" ; + Expensive = regAdj "مہنگا" ; + Delicious = regAdj "مزیدار" ; + Boring = regAdj "فضول" ; + + oper + regAdj : Str -> {s: Gender => Number => Str} = \a -> case a of { + x + "ا" => mkAdj a (x+"ے") (x+"ی"); + _ => mkAdj a a a + }; + mkAdj : Str -> Str -> Str -> {s: Gender => Number => Str} = \s,p,f -> { + s = table { + Masc => table { + Sg => s; + Pl => p + }; + Fem => \\_ => f + } + }; + } \ No newline at end of file diff --git a/samples/Grammatical Framework/LexFoods.gf b/samples/Grammatical Framework/LexFoods.gf new file mode 100644 index 00000000..12ace208 --- /dev/null +++ b/samples/Grammatical Framework/LexFoods.gf @@ -0,0 +1,15 @@ +-- (c) 2009 Aarne Ranta under LGPL + +interface LexFoods = open Syntax in { + oper + wine_N : N ; + pizza_N : N ; + cheese_N : N ; + fish_N : N ; + fresh_A : A ; + warm_A : A ; + italian_A : A ; + expensive_A : A ; + delicious_A : A ; + boring_A : A ; +} diff --git a/samples/Grammatical Framework/LexFoodsCat.gf b/samples/Grammatical Framework/LexFoodsCat.gf new file mode 100644 index 00000000..624fc98c --- /dev/null +++ b/samples/Grammatical Framework/LexFoodsCat.gf @@ -0,0 +1,18 @@ +-- (c) 2009 Jordi Saludes under LGPL + +instance LexFoodsCat of LexFoods = + open SyntaxCat, ParadigmsCat, (M = MorphoCat) in { + flags + coding = utf8 ; + oper + wine_N = mkN "vi" "vins" M.Masc ; + pizza_N = mkN "pizza" ; + cheese_N = mkN "formatge" ; + fish_N = mkN "peix" "peixos" M.Masc; + fresh_A = mkA "fresc" "fresca" "frescos" "fresques" "frescament"; + warm_A = mkA "calent" ; + italian_A = mkA "italià" "italiana" "italians" "italianes" "italianament" ; + expensive_A = mkA "car" ; + delicious_A = mkA "deliciós" "deliciosa" "deliciosos" "delicioses" "deliciosament"; + boring_A = mkA "aburrit" "aburrida" "aburrits" "aburrides" "aburridament" ; +} diff --git a/samples/Grammatical Framework/LexFoodsFin.gf b/samples/Grammatical Framework/LexFoodsFin.gf new file mode 100644 index 00000000..dbf8af6b --- /dev/null +++ b/samples/Grammatical Framework/LexFoodsFin.gf @@ -0,0 +1,21 @@ +-- (c) 2009 Aarne Ranta under LGPL + +instance LexFoodsFin of LexFoods = + open SyntaxFin, ParadigmsFin in { + flags coding=utf8; + oper + wine_N = mkN "viini" ; + pizza_N = mkN "pizza" ; + cheese_N = mkN "juusto" ; + fish_N = mkN "kala" ; + fresh_A = mkA "tuore" ; + warm_A = mkA + (mkN "lämmin" "lämpimän" "lämmintä" "lämpimänä" "lämpimään" + "lämpiminä" "lämpimiä" "lämpimien" "lämpimissä" "lämpimiin" + ) + "lämpimämpi" "lämpimin" ; + italian_A = mkA "italialainen" ; + expensive_A = mkA "kallis" ; + delicious_A = mkA "herkullinen" ; + boring_A = mkA "tylsä" ; +} diff --git a/samples/Grammatical Framework/LexFoodsGer.gf b/samples/Grammatical Framework/LexFoodsGer.gf new file mode 100644 index 00000000..253384f2 --- /dev/null +++ b/samples/Grammatical Framework/LexFoodsGer.gf @@ -0,0 +1,17 @@ +-- (c) 2009 Aarne Ranta under LGPL + +instance LexFoodsGer of LexFoods = + open SyntaxGer, ParadigmsGer in { + flags coding=utf8; + oper + wine_N = mkN "Wein" ; + pizza_N = mkN "Pizza" "Pizzen" feminine ; + cheese_N = mkN "Käse" "Käse" masculine ; + fish_N = mkN "Fisch" ; + fresh_A = mkA "frisch" ; + warm_A = mkA "warm" "wärmer" "wärmste" ; + italian_A = mkA "italienisch" ; + expensive_A = mkA "teuer" ; + delicious_A = mkA "köstlich" ; + boring_A = mkA "langweilig" ; +} diff --git a/samples/Grammatical Framework/LexFoodsIta.gf b/samples/Grammatical Framework/LexFoodsIta.gf new file mode 100644 index 00000000..11de5fcd --- /dev/null +++ b/samples/Grammatical Framework/LexFoodsIta.gf @@ -0,0 +1,16 @@ +-- (c) 2009 Aarne Ranta under LGPL + +instance LexFoodsIta of LexFoods = + open SyntaxIta, ParadigmsIta in { + oper + wine_N = mkN "vino" ; + pizza_N = mkN "pizza" ; + cheese_N = mkN "formaggio" ; + fish_N = mkN "pesce" ; + fresh_A = mkA "fresco" ; + warm_A = mkA "caldo" ; + italian_A = mkA "italiano" ; + expensive_A = mkA "caro" ; + delicious_A = mkA "delizioso" ; + boring_A = mkA "noioso" ; +} diff --git a/samples/Grammatical Framework/LexFoodsSwe.gf b/samples/Grammatical Framework/LexFoodsSwe.gf new file mode 100644 index 00000000..f9f02c33 --- /dev/null +++ b/samples/Grammatical Framework/LexFoodsSwe.gf @@ -0,0 +1,17 @@ +-- (c) 2009 Aarne Ranta under LGPL + +instance LexFoodsSwe of LexFoods = + open SyntaxSwe, ParadigmsSwe in { + flags coding=utf8; + oper + wine_N = mkN "vin" "vinet" "viner" "vinerna" ; + pizza_N = mkN "pizza" ; + cheese_N = mkN "ost" ; + fish_N = mkN "fisk" ; + fresh_A = mkA "färsk" ; + warm_A = mkA "varm" ; + italian_A = mkA "italiensk" ; + expensive_A = mkA "dyr" ; + delicious_A = mkA "läcker" ; + boring_A = mkA "tråkig" ; +} diff --git a/samples/Grammatical Framework/ResCze.gf b/samples/Grammatical Framework/ResCze.gf new file mode 100644 index 00000000..56b4aa6e --- /dev/null +++ b/samples/Grammatical Framework/ResCze.gf @@ -0,0 +1,46 @@ +-- (c) 2011 Katerina Bohmova under LGPL + +resource ResCze = open Prelude in { + flags + coding = utf8 ; + param + Number = Sg | Pl ; + Gender = Masc | Fem | Neutr; + oper + NounPhrase : Type = + {s : Str ; g : Gender ; n : Number} ; + Noun : Type = {s : Number => Str ; g : Gender} ; + Adjective : Type = {s : Gender => Number => Str} ; + + det : Number -> Str -> Str -> Str -> Noun -> NounPhrase = + \n,m,f,ne,cn -> { + s = table {Masc => m ; Fem => f; Neutr => ne} ! cn.g ++ + cn.s ! n ; + g = cn.g ; + n = n + } ; + noun : Str -> Str -> Gender -> Noun = + \muz,muzi,g -> { + s = table {Sg => muz ; Pl => muzi} ; + g = g + } ; + adjective : (msg,fsg,nsg,mpl,fpl,npl : Str) -> Adjective = + \msg,fsg,nsg,mpl,fpl,npl -> { + s = table { + Masc => table {Sg => msg ; Pl => mpl} ; + Fem => table {Sg => fsg ; Pl => fpl} ; + Neutr => table {Sg => nsg ; Pl => npl} + } + } ; + regAdj : Str -> Adjective = + \mlad -> + adjective (mlad+"ý") (mlad+"á") (mlad+"é") + (mlad+"é") (mlad+"é") (mlad+"á") ; + regnfAdj : Str -> Adjective = + \vynikajici -> + adjective vynikajici vynikajici vynikajici + vynikajici vynikajici vynikajici; + copula : Number => Str = + table {Sg => "je" ; Pl => "jsou"} ; +} + diff --git a/samples/Grammatical Framework/transFoodsHin.gf b/samples/Grammatical Framework/transFoodsHin.gf new file mode 100644 index 00000000..21d1d2ac --- /dev/null +++ b/samples/Grammatical Framework/transFoodsHin.gf @@ -0,0 +1,75 @@ +-- (c) 2009 Aarne Ranta under LGPL + +concrete FoodsHin of Foods = { + + flags coding=utf8 ; + + param + Gender = Masc | Fem ; + Number = Sg | Pl ; + lincat + Comment = {s : Str} ; + Item = {s : Str ; g : Gender ; n : Number} ; + Kind = {s : Number => Str ; g : Gender} ; + Quality = {s : Gender => Number => Str} ; + lin + Pred item quality = { + s = item.s ++ quality.s ! item.g ! item.n ++ copula item.n + } ; + This kind = {s = "yah" ++ kind.s ! Sg ; g = kind.g ; n = Sg} ; + That kind = {s = "vah" ++ kind.s ! Sg ; g = kind.g ; n = Sg} ; + These kind = {s = "ye" ++ kind.s ! Pl ; g = kind.g ; n = Pl} ; + Those kind = {s = "ve" ++ kind.s ! Pl ; g = kind.g ; n = Pl} ; + Mod quality kind = { + s = \\n => quality.s ! kind.g ! n ++ kind.s ! n ; + g = kind.g + } ; + Wine = regN "madirA" ; + Cheese = regN "panIr" ; + Fish = regN "maClI" ; + Pizza = regN "pijjA" ; + Very quality = {s = \\g,n => "bahut" ++ quality.s ! g ! n} ; + Fresh = regAdj "tAzA" ; + Warm = regAdj "garam" ; + Italian = regAdj "i-t.alI" ; + Expensive = regAdj "mahaNgA" ; + Delicious = regAdj "rucikar" ; + Boring = regAdj "pEriyA" ; + + oper + mkN : Str -> Str -> Gender -> {s : Number => Str ; g : Gender} = + \s,p,g -> { + s = table { + Sg => s ; + Pl => p + } ; + g = g + } ; + + regN : Str -> {s : Number => Str ; g : Gender} = \s -> case s of { + lark + "A" => mkN s (lark + "e") Masc ; + lark + "I" => mkN s (lark + "iyaM") Fem ; + _ => mkN s s Masc + } ; + + mkAdj : Str -> Str -> Str -> {s : Gender => Number => Str} = \ms,mp,f -> { + s = table { + Masc => table { + Sg => ms ; + Pl => mp + } ; + Fem => \\_ => f + } + } ; + + regAdj : Str -> {s : Gender => Number => Str} = \a -> case a of { + acch + "A" => mkAdj a (acch + "e") (acch + "I") ; + _ => mkAdj a a a + } ; + + copula : Number -> Str = \n -> case n of { + Sg => "hE" ; + Pl => "hEN" + } ; + + } diff --git a/samples/JSONiq/detail.jq b/samples/JSONiq/detail.jq new file mode 100644 index 00000000..9ae43f8b --- /dev/null +++ b/samples/JSONiq/detail.jq @@ -0,0 +1,9 @@ +(: Query for returning one database entry :) + +import module namespace req = "http://www.28msec.com/modules/http-request"; +import module namespace catalog = "http://guide.com/catalog"; + +variable $id := (req:param-values("id"), "London")[1]; +variable $part := (req:param-values("part"), "main")[1]; + +catalog:get-data-by-key($id, $part) diff --git a/samples/JSONiq/query.jq b/samples/JSONiq/query.jq new file mode 100644 index 00000000..d1abbaba --- /dev/null +++ b/samples/JSONiq/query.jq @@ -0,0 +1,17 @@ +(: Query for searching the database for keywords :) + +import module namespace index = "http://guide.com/index"; +import module namespace catalog = "http://guide.com/catalog"; + +import module namespace req = "http://www.28msec.com/modules/http-request"; + +variable $phrase := (req:param-values("q"), "London")[1]; +variable $limit := integer((req:param-values("limit"), 5)[1]); + +[ +for $result at $idx in index:index-search($phrase) +where $idx le $limit +let $data := catalog:get-data-by-id($result.s, $result.p) +return + {| { score : $result.r } , $data |} +] diff --git a/samples/M/Comment.m b/samples/M/Comment.m new file mode 100644 index 00000000..6ddd7653 --- /dev/null +++ b/samples/M/Comment.m @@ -0,0 +1,36 @@ +Comment ; + ; this is a comment block + ; comments always start with a semicolon + ; the next line, while not a comment, is a legal blank line + + ;whitespace alone is a valid line in a routine + ;** Comments can have any graphic character, but no "control" + ;** characters + + ;graphic characters such as: !@#$%^&*()_+=-{}[]|\:"?/>.<, + ;the space character is considered a graphic character, even + ;though you can't see it. + ; ASCII characters whose numeric code is above 128 and below 32 + ; are NOT allowed on a line in a routine. + ;; multiple semicolons are okay + ; a line that has a tag must have whitespace after the tag, bug + ; does not have to have a comment or a command on it +Tag1 + ; + ;Tags can start with % or an uppercase or lowercase alphabetic + ; or can be a series of numeric characters +%HELO ; + ; +0123 ; + ; +%987 ; + ; the most common label is uppercase alphabetic +LABEL ; + ; + ; Tags can be followed directly by an open parenthesis and a + ; formal list of variables, and a close parenthesis +ANOTHER(X) ; + ; + ;Normally, a subroutine would be ended by a QUIT command, but we + ; are taking advantage of the rule that the END of routine is an + ; implicit QUIT diff --git a/samples/Mathematica/Init.m b/samples/Mathematica/Init.m new file mode 100644 index 00000000..720d6100 --- /dev/null +++ b/samples/Mathematica/Init.m @@ -0,0 +1,3 @@ +(* Mathematica Init File *) + +Get[ "Foobar`Foobar`"] diff --git a/samples/Mathematica/PacletInfo.m b/samples/Mathematica/PacletInfo.m new file mode 100644 index 00000000..489b58c7 --- /dev/null +++ b/samples/Mathematica/PacletInfo.m @@ -0,0 +1,17 @@ +(* Paclet Info File *) + +(* created 2014/02/07*) + +Paclet[ + Name -> "Foobar", + Version -> "0.0.1", + MathematicaVersion -> "8+", + Description -> "Example of an automatically generated PacletInfo file.", + Creator -> "Chris Granade", + Extensions -> + { + {"Documentation", Language -> "English", MainPage -> "Guides/Foobar"} + } +] + + diff --git a/samples/Mathematica/Predicates.m b/samples/Mathematica/Predicates.m new file mode 100644 index 00000000..3c569691 --- /dev/null +++ b/samples/Mathematica/Predicates.m @@ -0,0 +1,150 @@ +(* ::Package:: *) + +BeginPackage["Predicates`"]; + + +(* ::Title:: *) +(*Predicates*) + + +(* ::Section::Closed:: *) +(*Fuzzy Logic*) + + +(* ::Subsection:: *) +(*Documentation*) + + +PossiblyTrueQ::usage="Returns True if the argument is not definitely False."; +PossiblyFalseQ::usage="Returns True if the argument is not definitely True."; +PossiblyNonzeroQ::usage="Returns True if and only if its argument is not definitely zero."; + + +(* ::Subsection:: *) +(*Implimentation*) + + +Begin["`Private`"]; + + +PossiblyTrueQ[expr_]:=\[Not]TrueQ[\[Not]expr] + + +PossiblyFalseQ[expr_]:=\[Not]TrueQ[expr] + + +End[]; + + +(* ::Section::Closed:: *) +(*Numbers and Lists*) + + +(* ::Subsection:: *) +(*Documentation*) + + +AnyQ::usage="Given a predicate and a list, retuns True if and only if that predicate is True for at least one element of the list."; +AnyElementQ::usage="Returns True if cond matches any element of L."; +AllQ::usage="Given a predicate and a list, retuns True if and only if that predicate is True for all elements of the list."; +AllElementQ::usage="Returns True if cond matches any element of L."; + + +AnyNonzeroQ::usage="Returns True if L is a list such that at least one element is definitely not zero."; +AnyPossiblyNonzeroQ::usage="Returns True if expr is a list such that at least one element is not definitely zero."; + + +RealQ::usage="Returns True if and only if the argument is a real number"; +PositiveQ::usage="Returns True if and only if the argument is a positive real number"; +NonnegativeQ::usage="Returns True if and only if the argument is a non-negative real number"; +PositiveIntegerQ::usage="Returns True if and only if the argument is a positive integer"; +NonnegativeIntegerQ::usage="Returns True if and only if the argument is a non-negative integer"; + + +IntegerListQ::usage="Returns True if and only if the input is a list of integers."; +PositiveIntegerListQ::usage="Returns True if and only if the input is a list of positive integers."; +NonnegativeIntegerListQ::usage="Returns True if and only if the input is a list of non-negative integers."; +IntegerOrListQ::usage="Returns True if and only if the input is a list of integers or an integer."; +PositiveIntegerOrListQ::usage="Returns True if and only if the input is a list of positive integers or a positive integer."; +NonnegativeIntegerOrListQ::usage="Returns True if and only if the input is a list of positive integers or a positive integer."; + + +SymbolQ::usage="Returns True if argument is an unassigned symbol."; +SymbolOrNumberQ::usage="Returns True if argument is a number of has head 'Symbol'"; + + +(* ::Subsection:: *) +(*Implimentation*) + + +Begin["`Private`"]; + + +AnyQ[cond_, L_] := Fold[Or, False, cond /@ L] + + +AnyElementQ[cond_,L_]:=AnyQ[cond,Flatten[L]] + + +AllQ[cond_, L_] := Fold[And, True, cond /@ L] + + +AllElementQ[cond_, L_] := Fold[And, True, cond /@ L] + + +AnyNonzeroQ[L_]:=AnyElementQ[#!=0&,L] + + +PossiblyNonzeroQ[expr_]:=PossiblyTrueQ[expr!=0] + + +AnyPossiblyNonzeroQ[expr_]:=AnyElementQ[PossiblyNonzeroQ,expr] + + +RealQ[n_]:=TrueQ[Im[n]==0]; + + +PositiveQ[n_]:=Positive[n]; + + +PositiveIntegerQ[n_]:=PositiveQ[n]\[And]IntegerQ[n]; + + +NonnegativeQ[n_]:=TrueQ[RealQ[n]&&n>=0]; + + +NonnegativeIntegerQ[n_]:=NonnegativeQ[n]\[And]IntegerQ[n]; + + +IntegerListQ[input_]:=ListQ[input]&&Not[MemberQ[IntegerQ/@input,False]]; + + +IntegerOrListQ[input_]:=IntegerListQ[input]||IntegerQ[input]; + + +PositiveIntegerListQ[input_]:=IntegerListQ[input]&&Not[MemberQ[Positive[input],False]]; + + +PositiveIntegerOrListQ[input_]:=PositiveIntegerListQ[input]||PositiveIntegerQ[input]; + + +NonnegativeIntegerListQ[input_]:=IntegerListQ[input]&&Not[MemberQ[NonnegativeIntegerQ[input],False]]; + + +NonnegativeIntegerOrListQ[input_]:=NonnegativeIntegerListQ[input]||NonnegativeIntegerQ[input]; + + +SymbolQ[a_]:=Head[a]===Symbol; + + +SymbolOrNumberQ[a_]:=NumericQ[a]||Head[a]===Symbol; + + +End[]; + + +(* ::Section:: *) +(*Epilogue*) + + +EndPackage[]; diff --git a/samples/Objective-C++/EventHandlerMac.mm b/samples/Objective-C++/EventHandlerMac.mm new file mode 100644 index 00000000..f6028c0b --- /dev/null +++ b/samples/Objective-C++/EventHandlerMac.mm @@ -0,0 +1,778 @@ +// grabbed from https://raw.github.com/AOKP/external_webkit/61b2fb934bdd3a5fea253e2de0bcf8a47a552333/Source/WebCore/page/mac/EventHandlerMac.mm + +/* + * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "EventHandler.h" + +#include "AXObjectCache.h" +#include "BlockExceptions.h" +#include "Chrome.h" +#include "ChromeClient.h" +#include "ClipboardMac.h" +#include "DragController.h" +#include "EventNames.h" +#include "FocusController.h" +#include "Frame.h" +#include "FrameLoader.h" +#include "FrameView.h" +#include "KeyboardEvent.h" +#include "MouseEventWithHitTestResults.h" +#include "NotImplemented.h" +#include "Page.h" +#include "PlatformKeyboardEvent.h" +#include "PlatformWheelEvent.h" +#include "RenderWidget.h" +#include "RuntimeApplicationChecks.h" +#include "Scrollbar.h" +#include "Settings.h" +#include "WebCoreSystemInterface.h" +#include +#include + +#if !(defined(OBJC_API_VERSION) && OBJC_API_VERSION > 0) +static inline IMP method_setImplementation(Method m, IMP i) +{ + IMP oi = m->method_imp; + m->method_imp = i; + return oi; +} +#endif + +namespace WebCore { + +#if ENABLE(DRAG_SUPPORT) +const double EventHandler::TextDragDelay = 0.15; +#endif + +static RetainPtr& currentNSEventSlot() +{ + DEFINE_STATIC_LOCAL(RetainPtr, event, ()); + return event; +} + +NSEvent *EventHandler::currentNSEvent() +{ + return currentNSEventSlot().get(); +} + +class CurrentEventScope { + WTF_MAKE_NONCOPYABLE(CurrentEventScope); +public: + CurrentEventScope(NSEvent *); + ~CurrentEventScope(); + +private: + RetainPtr m_savedCurrentEvent; +#ifndef NDEBUG + RetainPtr m_event; +#endif +}; + +inline CurrentEventScope::CurrentEventScope(NSEvent *event) + : m_savedCurrentEvent(currentNSEventSlot()) +#ifndef NDEBUG + , m_event(event) +#endif +{ + currentNSEventSlot() = event; +} + +inline CurrentEventScope::~CurrentEventScope() +{ + ASSERT(currentNSEventSlot() == m_event); + currentNSEventSlot() = m_savedCurrentEvent; +} + +bool EventHandler::wheelEvent(NSEvent *event) +{ + Page* page = m_frame->page(); + if (!page) + return false; + + CurrentEventScope scope(event); + + PlatformWheelEvent wheelEvent(event, page->chrome()->platformPageClient()); + handleWheelEvent(wheelEvent); + + return wheelEvent.isAccepted(); +} + +PassRefPtr EventHandler::currentKeyboardEvent() const +{ + NSEvent *event = [NSApp currentEvent]; + if (!event) + return 0; + switch ([event type]) { + case NSKeyDown: { + PlatformKeyboardEvent platformEvent(event); + platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown); + return KeyboardEvent::create(platformEvent, m_frame->document()->defaultView()); + } + case NSKeyUp: + return KeyboardEvent::create(event, m_frame->document()->defaultView()); + default: + return 0; + } +} + +bool EventHandler::keyEvent(NSEvent *event) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + ASSERT([event type] == NSKeyDown || [event type] == NSKeyUp); + + CurrentEventScope scope(event); + return keyEvent(PlatformKeyboardEvent(event)); + + END_BLOCK_OBJC_EXCEPTIONS; + + return false; +} + +void EventHandler::focusDocumentView() +{ + Page* page = m_frame->page(); + if (!page) + return; + + if (FrameView* frameView = m_frame->view()) { + if (NSView *documentView = frameView->documentView()) + page->chrome()->focusNSView(documentView); + } + + page->focusController()->setFocusedFrame(m_frame); +} + +bool EventHandler::passWidgetMouseDownEventToWidget(const MouseEventWithHitTestResults& event) +{ + // Figure out which view to send the event to. + RenderObject* target = targetNode(event) ? targetNode(event)->renderer() : 0; + if (!target || !target->isWidget()) + return false; + + // Double-click events don't exist in Cocoa. Since passWidgetMouseDownEventToWidget will + // just pass currentEvent down to the widget, we don't want to call it for events that + // don't correspond to Cocoa events. The mousedown/ups will have already been passed on as + // part of the pressed/released handling. + return passMouseDownEventToWidget(toRenderWidget(target)->widget()); +} + +bool EventHandler::passWidgetMouseDownEventToWidget(RenderWidget* renderWidget) +{ + return passMouseDownEventToWidget(renderWidget->widget()); +} + +static bool lastEventIsMouseUp() +{ + // Many AppKit widgets run their own event loops and consume events while the mouse is down. + // When they finish, currentEvent is the mouseUp that they exited on. We need to update + // the WebCore state with this mouseUp, which we never saw. This method lets us detect + // that state. Handling this was critical when we used AppKit widgets for form elements. + // It's not clear in what cases this is helpful now -- it's possible it can be removed. + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + NSEvent *currentEventAfterHandlingMouseDown = [NSApp currentEvent]; + return EventHandler::currentNSEvent() != currentEventAfterHandlingMouseDown + && [currentEventAfterHandlingMouseDown type] == NSLeftMouseUp + && [currentEventAfterHandlingMouseDown timestamp] >= [EventHandler::currentNSEvent() timestamp]; + END_BLOCK_OBJC_EXCEPTIONS; + + return false; +} + +bool EventHandler::passMouseDownEventToWidget(Widget* pWidget) +{ + // FIXME: This function always returns true. It should be changed either to return + // false in some cases or the return value should be removed. + + RefPtr widget = pWidget; + + if (!widget) { + LOG_ERROR("hit a RenderWidget without a corresponding Widget, means a frame is half-constructed"); + return true; + } + + // In WebKit2 we will never have an NSView. Just return early and let the regular event handler machinery take care of + // dispatching the event. + if (!widget->platformWidget()) + return false; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + NSView *nodeView = widget->platformWidget(); + ASSERT([nodeView superview]); + NSView *view = [nodeView hitTest:[[nodeView superview] convertPoint:[currentNSEvent() locationInWindow] fromView:nil]]; + if (!view) { + // We probably hit the border of a RenderWidget + return true; + } + + Page* page = m_frame->page(); + if (!page) + return true; + + if (page->chrome()->client()->firstResponder() != view) { + // Normally [NSWindow sendEvent:] handles setting the first responder. + // But in our case, the event was sent to the view representing the entire web page. + if ([currentNSEvent() clickCount] <= 1 && [view acceptsFirstResponder] && [view needsPanelToBecomeKey]) + page->chrome()->client()->makeFirstResponder(view); + } + + // We need to "defer loading" while tracking the mouse, because tearing down the + // page while an AppKit control is tracking the mouse can cause a crash. + + // FIXME: In theory, WebCore now tolerates tear-down while tracking the + // mouse. We should confirm that, and then remove the deferrsLoading + // hack entirely. + + bool wasDeferringLoading = page->defersLoading(); + if (!wasDeferringLoading) + page->setDefersLoading(true); + + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + NSView *outerView = widget->getOuterView(); + widget->beforeMouseDown(outerView, widget.get()); + [view mouseDown:currentNSEvent()]; + widget->afterMouseDown(outerView, widget.get()); + m_sendingEventToSubview = false; + + if (!wasDeferringLoading) + page->setDefersLoading(false); + + // Remember which view we sent the event to, so we can direct the release event properly. + m_mouseDownView = view; + m_mouseDownWasInSubframe = false; + + // Many AppKit widgets run their own event loops and consume events while the mouse is down. + // When they finish, currentEvent is the mouseUp that they exited on. We need to update + // the EventHandler state with this mouseUp, which we never saw. + // If this event isn't a mouseUp, we assume that the mouseUp will be coming later. There + // is a hole here if the widget consumes both the mouseUp and subsequent events. + if (lastEventIsMouseUp()) + m_mousePressed = false; + + END_BLOCK_OBJC_EXCEPTIONS; + + return true; +} + +// Note that this does the same kind of check as [target isDescendantOf:superview]. +// There are two differences: This is a lot slower because it has to walk the whole +// tree, and this works in cases where the target has already been deallocated. +static bool findViewInSubviews(NSView *superview, NSView *target) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + NSEnumerator *e = [[superview subviews] objectEnumerator]; + NSView *subview; + while ((subview = [e nextObject])) { + if (subview == target || findViewInSubviews(subview, target)) { + return true; + } + } + END_BLOCK_OBJC_EXCEPTIONS; + + return false; +} + +NSView *EventHandler::mouseDownViewIfStillGood() +{ + // Since we have no way of tracking the lifetime of m_mouseDownView, we have to assume that + // it could be deallocated already. We search for it in our subview tree; if we don't find + // it, we set it to nil. + NSView *mouseDownView = m_mouseDownView; + if (!mouseDownView) { + return nil; + } + FrameView* topFrameView = m_frame->view(); + NSView *topView = topFrameView ? topFrameView->platformWidget() : nil; + if (!topView || !findViewInSubviews(topView, mouseDownView)) { + m_mouseDownView = nil; + return nil; + } + return mouseDownView; +} + +#if ENABLE(DRAG_SUPPORT) +bool EventHandler::eventLoopHandleMouseDragged(const MouseEventWithHitTestResults&) +{ + NSView *view = mouseDownViewIfStillGood(); + + if (!view) + return false; + + if (!m_mouseDownWasInSubframe) { + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + BEGIN_BLOCK_OBJC_EXCEPTIONS; + [view mouseDragged:currentNSEvent()]; + END_BLOCK_OBJC_EXCEPTIONS; + m_sendingEventToSubview = false; + } + + return true; +} +#endif // ENABLE(DRAG_SUPPORT) + +bool EventHandler::eventLoopHandleMouseUp(const MouseEventWithHitTestResults&) +{ + NSView *view = mouseDownViewIfStillGood(); + if (!view) + return false; + + if (!m_mouseDownWasInSubframe) { + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + BEGIN_BLOCK_OBJC_EXCEPTIONS; + [view mouseUp:currentNSEvent()]; + END_BLOCK_OBJC_EXCEPTIONS; + m_sendingEventToSubview = false; + } + + return true; +} + +bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& event, Frame* subframe, HitTestResult* hoveredNode) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + switch ([currentNSEvent() type]) { + case NSLeftMouseDragged: + case NSOtherMouseDragged: + case NSRightMouseDragged: + // This check is bogus and results in , but removing it breaks a number of + // layout tests. + if (!m_mouseDownWasInSubframe) + return false; +#if ENABLE(DRAG_SUPPORT) + if (subframe->page()->dragController()->didInitiateDrag()) + return false; +#endif + case NSMouseMoved: + // Since we're passing in currentNSEvent() here, we can call + // handleMouseMoveEvent() directly, since the save/restore of + // currentNSEvent() that mouseMoved() does would have no effect. + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + subframe->eventHandler()->handleMouseMoveEvent(currentPlatformMouseEvent(), hoveredNode); + m_sendingEventToSubview = false; + return true; + + case NSLeftMouseDown: { + Node* node = targetNode(event); + if (!node) + return false; + RenderObject* renderer = node->renderer(); + if (!renderer || !renderer->isWidget()) + return false; + Widget* widget = toRenderWidget(renderer)->widget(); + if (!widget || !widget->isFrameView()) + return false; + if (!passWidgetMouseDownEventToWidget(toRenderWidget(renderer))) + return false; + m_mouseDownWasInSubframe = true; + return true; + } + case NSLeftMouseUp: { + if (!m_mouseDownWasInSubframe) + return false; + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + subframe->eventHandler()->handleMouseReleaseEvent(currentPlatformMouseEvent()); + m_sendingEventToSubview = false; + return true; + } + default: + return false; + } + END_BLOCK_OBJC_EXCEPTIONS; + + return false; +} + +static IMP originalNSScrollViewScrollWheel; +static bool _nsScrollViewScrollWheelShouldRetainSelf; +static void selfRetainingNSScrollViewScrollWheel(NSScrollView *, SEL, NSEvent *); + +static bool nsScrollViewScrollWheelShouldRetainSelf() +{ + ASSERT(isMainThread()); + + return _nsScrollViewScrollWheelShouldRetainSelf; +} + +static void setNSScrollViewScrollWheelShouldRetainSelf(bool shouldRetain) +{ + ASSERT(isMainThread()); + + if (!originalNSScrollViewScrollWheel) { + Method method = class_getInstanceMethod(objc_getRequiredClass("NSScrollView"), @selector(scrollWheel:)); + originalNSScrollViewScrollWheel = method_setImplementation(method, reinterpret_cast(selfRetainingNSScrollViewScrollWheel)); + } + + _nsScrollViewScrollWheelShouldRetainSelf = shouldRetain; +} + +static void selfRetainingNSScrollViewScrollWheel(NSScrollView *self, SEL selector, NSEvent *event) +{ + bool shouldRetainSelf = isMainThread() && nsScrollViewScrollWheelShouldRetainSelf(); + + if (shouldRetainSelf) + [self retain]; + originalNSScrollViewScrollWheel(self, selector, event); + if (shouldRetainSelf) + [self release]; +} + +bool EventHandler::passWheelEventToWidget(PlatformWheelEvent& wheelEvent, Widget* widget) +{ + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + if (!widget) + return false; + + NSView* nodeView = widget->platformWidget(); + if (!nodeView) { + // WebKit2 code path. + if (!widget->isFrameView()) + return false; + + return static_cast(widget)->frame()->eventHandler()->handleWheelEvent(wheelEvent); + } + + if ([currentNSEvent() type] != NSScrollWheel || m_sendingEventToSubview) + return false; + + ASSERT(nodeView); + ASSERT([nodeView superview]); + NSView *view = [nodeView hitTest:[[nodeView superview] convertPoint:[currentNSEvent() locationInWindow] fromView:nil]]; + if (!view) + // We probably hit the border of a RenderWidget + return false; + + ASSERT(!m_sendingEventToSubview); + m_sendingEventToSubview = true; + // Work around which can cause -[NSScrollView scrollWheel:] to + // crash if the NSScrollView is released during timer or network callback dispatch + // in the nested tracking runloop that -[NSScrollView scrollWheel:] runs. + setNSScrollViewScrollWheelShouldRetainSelf(true); + [view scrollWheel:currentNSEvent()]; + setNSScrollViewScrollWheelShouldRetainSelf(false); + m_sendingEventToSubview = false; + return true; + + END_BLOCK_OBJC_EXCEPTIONS; + return false; +} + +void EventHandler::mouseDown(NSEvent *event) +{ + FrameView* v = m_frame->view(); + if (!v || m_sendingEventToSubview) + return; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + m_frame->loader()->resetMultipleFormSubmissionProtection(); + + m_mouseDownView = nil; + + CurrentEventScope scope(event); + + handleMousePressEvent(currentPlatformMouseEvent()); + + END_BLOCK_OBJC_EXCEPTIONS; +} + +void EventHandler::mouseDragged(NSEvent *event) +{ + FrameView* v = m_frame->view(); + if (!v || m_sendingEventToSubview) + return; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + CurrentEventScope scope(event); + handleMouseMoveEvent(currentPlatformMouseEvent()); + + END_BLOCK_OBJC_EXCEPTIONS; +} + +void EventHandler::mouseUp(NSEvent *event) +{ + FrameView* v = m_frame->view(); + if (!v || m_sendingEventToSubview) + return; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + CurrentEventScope scope(event); + + // Our behavior here is a little different that Qt. Qt always sends + // a mouse release event, even for a double click. To correct problems + // in khtml's DOM click event handling we do not send a release here + // for a double click. Instead we send that event from FrameView's + // handleMouseDoubleClickEvent. Note also that the third click of + // a triple click is treated as a single click, but the fourth is then + // treated as another double click. Hence the "% 2" below. + int clickCount = [event clickCount]; + if (clickCount > 0 && clickCount % 2 == 0) + handleMouseDoubleClickEvent(currentPlatformMouseEvent()); + else + handleMouseReleaseEvent(currentPlatformMouseEvent()); + + m_mouseDownView = nil; + + END_BLOCK_OBJC_EXCEPTIONS; +} + +/* + A hack for the benefit of AK's PopUpButton, which uses the Carbon menu manager, which thus + eats all subsequent events after it is starts its modal tracking loop. After the interaction + is done, this routine is used to fix things up. When a mouse down started us tracking in + the widget, we post a fake mouse up to balance the mouse down we started with. When a + key down started us tracking in the widget, we post a fake key up to balance things out. + In addition, we post a fake mouseMoved to get the cursor in sync with whatever we happen to + be over after the tracking is done. + */ +void EventHandler::sendFakeEventsAfterWidgetTracking(NSEvent *initiatingEvent) +{ + FrameView* view = m_frame->view(); + if (!view) + return; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + + m_sendingEventToSubview = false; + int eventType = [initiatingEvent type]; + if (eventType == NSLeftMouseDown || eventType == NSKeyDown) { + NSEvent *fakeEvent = nil; + if (eventType == NSLeftMouseDown) { + fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseUp + location:[initiatingEvent locationInWindow] + modifierFlags:[initiatingEvent modifierFlags] + timestamp:[initiatingEvent timestamp] + windowNumber:[initiatingEvent windowNumber] + context:[initiatingEvent context] + eventNumber:[initiatingEvent eventNumber] + clickCount:[initiatingEvent clickCount] + pressure:[initiatingEvent pressure]]; + + [NSApp postEvent:fakeEvent atStart:YES]; + } else { // eventType == NSKeyDown + fakeEvent = [NSEvent keyEventWithType:NSKeyUp + location:[initiatingEvent locationInWindow] + modifierFlags:[initiatingEvent modifierFlags] + timestamp:[initiatingEvent timestamp] + windowNumber:[initiatingEvent windowNumber] + context:[initiatingEvent context] + characters:[initiatingEvent characters] + charactersIgnoringModifiers:[initiatingEvent charactersIgnoringModifiers] + isARepeat:[initiatingEvent isARepeat] + keyCode:[initiatingEvent keyCode]]; + [NSApp postEvent:fakeEvent atStart:YES]; + } + // FIXME: We should really get the current modifierFlags here, but there's no way to poll + // them in Cocoa, and because the event stream was stolen by the Carbon menu code we have + // no up-to-date cache of them anywhere. + fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved + location:[[view->platformWidget() window] convertScreenToBase:[NSEvent mouseLocation]] + modifierFlags:[initiatingEvent modifierFlags] + timestamp:[initiatingEvent timestamp] + windowNumber:[initiatingEvent windowNumber] + context:[initiatingEvent context] + eventNumber:0 + clickCount:0 + pressure:0]; + [NSApp postEvent:fakeEvent atStart:YES]; + } + + END_BLOCK_OBJC_EXCEPTIONS; +} + +void EventHandler::mouseMoved(NSEvent *event) +{ + // Reject a mouse moved if the button is down - screws up tracking during autoscroll + // These happen because WebKit sometimes has to fake up moved events. + if (!m_frame->view() || m_mousePressed || m_sendingEventToSubview) + return; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + CurrentEventScope scope(event); + mouseMoved(currentPlatformMouseEvent()); + END_BLOCK_OBJC_EXCEPTIONS; +} + +static bool frameHasPlatformWidget(Frame* frame) +{ + if (FrameView* frameView = frame->view()) { + if (frameView->platformWidget()) + return true; + } + + return false; +} + +bool EventHandler::passMousePressEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) +{ + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe); + + // WebKit2 code path. + subframe->eventHandler()->handleMousePressEvent(mev.event()); + return true; +} + +bool EventHandler::passMouseMoveEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe, HitTestResult* hoveredNode) +{ + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe, hoveredNode); + + // WebKit2 code path. + if (m_mouseDownMayStartDrag && !m_mouseDownWasInSubframe) + return false; + subframe->eventHandler()->handleMouseMoveEvent(mev.event(), hoveredNode); + return true; +} + +bool EventHandler::passMouseReleaseEventToSubframe(MouseEventWithHitTestResults& mev, Frame* subframe) +{ + // WebKit1 code path. + if (frameHasPlatformWidget(m_frame)) + return passSubframeEventToSubframe(mev, subframe); + + // WebKit2 code path. + subframe->eventHandler()->handleMouseReleaseEvent(mev.event()); + return true; +} + +PlatformMouseEvent EventHandler::currentPlatformMouseEvent() const +{ + NSView *windowView = nil; + if (Page* page = m_frame->page()) + windowView = page->chrome()->platformPageClient(); + return PlatformMouseEvent(currentNSEvent(), windowView); +} + +#if ENABLE(CONTEXT_MENUS) +bool EventHandler::sendContextMenuEvent(NSEvent *event) +{ + Page* page = m_frame->page(); + if (!page) + return false; + return sendContextMenuEvent(PlatformMouseEvent(event, page->chrome()->platformPageClient())); +} +#endif // ENABLE(CONTEXT_MENUS) + +#if ENABLE(DRAG_SUPPORT) +bool EventHandler::eventMayStartDrag(NSEvent *event) +{ + Page* page = m_frame->page(); + if (!page) + return false; + return eventMayStartDrag(PlatformMouseEvent(event, page->chrome()->platformPageClient())); +} +#endif // ENABLE(DRAG_SUPPORT) + +bool EventHandler::eventActivatedView(const PlatformMouseEvent& event) const +{ + return m_activationEventNumber == event.eventNumber(); +} + +#if ENABLE(DRAG_SUPPORT) + +PassRefPtr EventHandler::createDraggingClipboard() const +{ + NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; + // Must be done before ondragstart adds types and data to the pboard, + // also done for security, as it erases data from the last drag + [pasteboard declareTypes:[NSArray array] owner:nil]; + return ClipboardMac::create(Clipboard::DragAndDrop, pasteboard, ClipboardWritable, m_frame); +} + +#endif + +bool EventHandler::tabsToAllFormControls(KeyboardEvent* event) const +{ + Page* page = m_frame->page(); + if (!page) + return false; + + KeyboardUIMode keyboardUIMode = page->chrome()->client()->keyboardUIMode(); + bool handlingOptionTab = isKeyboardOptionTab(event); + + // If tab-to-links is off, option-tab always highlights all controls + if ((keyboardUIMode & KeyboardAccessTabsToLinks) == 0 && handlingOptionTab) + return true; + + // If system preferences say to include all controls, we always include all controls + if (keyboardUIMode & KeyboardAccessFull) + return true; + + // Otherwise tab-to-links includes all controls, unless the sense is flipped via option-tab. + if (keyboardUIMode & KeyboardAccessTabsToLinks) + return !handlingOptionTab; + + return handlingOptionTab; +} + +bool EventHandler::needsKeyboardEventDisambiguationQuirks() const +{ + Document* document = m_frame->document(); + + // RSS view needs arrow key keypress events. + if (applicationIsSafari() && (document->url().protocolIs("feed") || document->url().protocolIs("feeds"))) + return true; + Settings* settings = m_frame->settings(); + if (!settings) + return false; + +#if ENABLE(DASHBOARD_SUPPORT) + if (settings->usesDashboardBackwardCompatibilityMode()) + return true; +#endif + + if (settings->needsKeyboardEventDisambiguationQuirks()) + return true; + + return false; +} + +unsigned EventHandler::accessKeyModifiers() +{ + // Control+Option key combinations are usually unused on Mac OS X, but not when VoiceOver is enabled. + // So, we use Control in this case, even though it conflicts with Emacs-style key bindings. + // See for more detail. + if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled()) + return PlatformKeyboardEvent::CtrlKey; + + return PlatformKeyboardEvent::CtrlKey | PlatformKeyboardEvent::AltKey; +} + +} diff --git a/samples/Objective-C++/objsql.mm b/samples/Objective-C++/objsql.mm new file mode 100644 index 00000000..f71ca8eb --- /dev/null +++ b/samples/Objective-C++/objsql.mm @@ -0,0 +1,1372 @@ +/* + * objsql.m - implementaion simple persistence layer using objcpp.h + * ======== + * + * Created by John Holdsworth on 01/04/2009. + * Copyright 2009 John Holdsworth. + * + * $Id: //depot/4.4/ObjCpp/objsql.mm#11 $ + * $DateTime: 2012/09/05 00:20:47 $ + * + * C++ classes to wrap up XCode classes for operator overload of + * useful operations such as access to NSArrays and NSDictionary + * by subscript or NSString operators such as + for concatenation. + * + * This works as the Apple Objective-C compiler supports source + * which mixes C++ with objective C. To enable this: for each + * source file which will include/import this header file, select + * it in Xcode and open it's "Info". To enable mixed compilation, + * for the file's "File Type" select: "sourcecode.cpp.objcpp". + * + * For bugs or ommisions please email objcpp@johnholdsworth.com + * + * Home page for updates and docs: http://objcpp.johnholdsworth.com + * + * You may make commercial use of this source in applications without + * charge but not sell it as source nor can you remove this notice from + * this source if you redistribute. You can make any changes you like + * to this code before redistribution but please annotate them below. + * + * If you find it useful please send a donation via paypal to account + * objcpp@johnholdsworth.com. Thanks. + * + * THIS CODE IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND EITHER + * EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING + * WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS + * THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING + * ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED + * TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED + * BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH + * ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +#import +#import + +#import "objsql.h" + +#if 0 +#ifdef OODEBUG +#define OODEBUG_SQL 1 +#endif +#endif + +OOOODatabase OODB; + +static NSString *kOOObject = @"__OOOBJECT__", *kOOInsert = @"__ISINSERT__", *kOOUpdate = @"__ISUPDATE__", *kOOExecSQL = @"__OOEXEC__"; + +#pragma mark OORecord abstract superclass for records + +@implementation OORecord + ++ (id)record OO_AUTORETURNS { + return OO_AUTORELEASE( [[self alloc] init] ); +} + ++ (id)insert OO_AUTORETURNS { + OORecord *record = [self record]; + [record insert]; + return record; +} + ++ (id)insertWithParent:(id)parent { + return [[OODatabase sharedInstance] copyJoinKeysFrom:parent to:[self insert]]; +} + +- (id)insert { [[OODatabase sharedInstance] insert:self]; return self; } +- (id)delete { [[OODatabase sharedInstance] delete:self]; return self; } + +- (void)update { [[OODatabase sharedInstance] update:self]; } +- (void)indate { [[OODatabase sharedInstance] indate:self]; } +- (void)upsert { [[OODatabase sharedInstance] upsert:self]; } + +- (int)commit { return [[OODatabase sharedInstance] commit]; } +- (int)rollback { return [[OODatabase sharedInstance] rollback]; } + +// to handle null values for ints, floats etc. +- (void)setNilValueForKey:(NSString *)key { + static OOReference zeroForNull; + if ( !zeroForNull ) + zeroForNull = [NSNumber numberWithInt:0]; + [self setValue:zeroForNull forKey:key]; +} + ++ (OOArray)select { + return [[OODatabase sharedInstance] select:nil intoClass:self joinFrom:nil]; +} + ++ (OOArray)select:(cOOString)sql { + return [[OODatabase sharedInstance] select:sql intoClass:self joinFrom:nil]; +} + ++ (OOArray)selectRecordsRelatedTo:(id)parent { + return [[OODatabase sharedInstance] select:nil intoClass:self joinFrom:parent]; +} + +- (OOArray)select { + return [[OODatabase sharedInstance] select:nil intoClass:[self class] joinFrom:self]; +} + +/** + import a flat file with column values separated by the delimiter specified into + the table associated with this class. + */ + ++ (int)importFrom:(OOFile &)file delimiter:(cOOString)delim { + OOArray rows = [OOMetaData import:file.string() intoClass:self delimiter:delim]; + [[OODatabase sharedInstance] insertArray:rows]; + return [OODatabase commit]; +} + +/** + Export a flat file with all rows in the table associated with the record subclass. + */ + ++ (BOOL)exportTo:(OOFile &)file delimiter:(cOOString)delim { + return file.save( [OOMetaData export:[self select] delimiter:delim] ); +} + +/** + populate a view with the string values taken from the ivars of the record + */ + +- (void)bindToView:(OOView *)view delegate:(id)delegate { + [OOMetaData bindRecord:self toView:view delegate:delegate]; +} + +/** + When the delegate method os sent use this method to update the record's values + */ + +- (void)updateFromView:(OOView *)view { + [OOMetaData updateRecord:self fromView:view]; +} + +/** + Default description is dictionary containing values of all ivars + */ + +- (NSString *)description { + OOMetaData *metaData = [OOMetaData metaDataForClass:[self class]]; + // hack required where record contains a field "description" to avoid recursion + OOStringArray ivars; ivars <<= *metaData->ivars; ivars -= "description"; + return [*[metaData encode:[self dictionaryWithValuesForKeys:ivars]] description]; +} + +@end + +#pragma mark OOAdaptor - all methods required by objsql to access a database + +/** + An internal class representing the interface to a particular database, in this case sqlite3. + */ + +@interface OOAdaptor : NSObject { + sqlite3 *db; + sqlite3_stmt *stmt; + struct _str_link { + struct _str_link *next; char str[1]; + } *strs; + OO_UNSAFE OODatabase *owner; +} + +- initPath:(cOOString)path database:(OODatabase *)database; +- (BOOL)prepare:(cOOString)sql; + +- (BOOL)bindCols:(cOOStringArray)columns values:(cOOValueDictionary)values startingAt:(int)pno bindNulls:(BOOL)bindNulls; +- (OOArray)bindResultsIntoInstancesOfClass:(Class)recordClass metaData:(OOMetaData *)metaData; +- (sqlite_int64)lastInsertRowID; + +@end + +@interface NSData(OOExtras) +- initWithDescription:(NSString *)description; +@end + +#pragma mark OODatabase is the low level interface to a particular database + +@implementation OODatabase + +static OOReference sharedInstance; + +/** + By default database file is "objsql.db" in the user/application's "Documents" directory + and a single shared OODatabase instance used for all db operations. + */ + ++ (OODatabase *)sharedInstance { + if ( !sharedInstance ) + [self sharedInstanceForPath:OODocument("objsql.db").path()]; + return sharedInstance; +} + +/** + Shared instance can be switched between any file paths. + */ + + + (OODatabase *)sharedInstanceForPath:(cOOString)path { + if ( !!sharedInstance ) + sharedInstance = OONil; + if ( !!path ) + OO_RELEASE( sharedInstance = [[OODatabase alloc] initPath:path] ); + return sharedInstance; +} + ++ (BOOL)exec:(cOOString)fmt, ... { + va_list argp; va_start(argp, fmt); + NSString *sql = [[NSString alloc] initWithFormat:fmt arguments:argp]; + va_end( argp ); + return [[self sharedInstance] exec:OO_AUTORELEASE( sql )]; +} + ++ (OOArray)select:(cOOString)select intoClass:(Class)recordClass joinFrom:(id)parent { + return [[self sharedInstance] select:select intoClass:recordClass joinFrom:parent]; +} ++ (OOArray)select:(cOOString)select intoClass:(Class)recordClass { + return [[self sharedInstance] select:select intoClass:recordClass joinFrom:nil]; +} ++ (OOArray)select:(cOOString)select { + return [[self sharedInstance] select:select intoClass:nil joinFrom:nil]; +} + ++ (int)insertArray:(const OOArray &)objects { return [[self sharedInstance] insertArray:objects]; } ++ (int)deleteArray:(const OOArray &)objects { return [[self sharedInstance] deleteArray:objects]; } + ++ (int)insert:(id)object { return [[self sharedInstance] insert:object]; } ++ (int)delete:(id)object { return [[self sharedInstance] delete:object]; } ++ (int)update:(id)object { return [[self sharedInstance] update:object]; } + ++ (int)indate:(id)object { return [[self sharedInstance] indate:object]; } ++ (int)upsert:(id)object { return [[self sharedInstance] upsert:object]; } + ++ (int)commit { return [[self sharedInstance] commit]; } ++ (int)rollback { return [[self sharedInstance] rollback]; } ++ (int)commitTransaction { return [[OODatabase sharedInstance] commitTransaction]; } + +/** + Designated initialiser for OODatabase instances. Generally only the shared instance is used + and the OODatabase class object is messaged instead. + */ + +- initPath:(cOOString)path { + if ( self = [super init] ) + OO_RELEASE( adaptor = [[OOAdaptor alloc] initPath:path database:self] ); + return self; +} + +/** + Automatically register all classes which are subclasses of a record abstract superclass (e.g. OORecord). + */ + +- (OOStringArray)registerSubclassesOf:(Class)recordSuperClass { + int numClasses = objc_getClassList( NULL, 0 ); + Class *classes = (Class *)malloc( sizeof *classes * numClasses ); + OOArray viewClasses; + OOStringArray classNames; + + // scan all registered classes for relevant subclasses + numClasses = objc_getClassList( classes, numClasses ); + for ( int c=0 ; cresults. + */ + +- (BOOL)exec:(cOOString)fmt, ... { + va_list argp; va_start(argp, fmt); + NSString *sql = [[NSString alloc] initWithFormat:fmt arguments:argp]; + va_end( argp ); + results = [self select:sql intoClass:NULL joinFrom:nil]; + OO_RELEASE( sql ); + return !errcode; +} + +/** + Return a single value from row 1, column one from sql sent to the database as a string. + */ + +- (OOString)stringForSql:(cOOString)fmt, ... { + va_list argp; va_start(argp, fmt); + NSString *sql = OO_AUTORELEASE( [[NSString alloc] initWithFormat:fmt arguments:argp] ); + va_end( argp ); + if( [self exec:"%@", sql] && results > 0 ) { + NSString *aColumnName = [[**results[0] allKeys] objectAtIndex:0]; + return [(NSNumber *)(*results[0])[aColumnName] stringValue]; + } + else + return nil; +} + +/** + Used to initialise new child records automatically from parent in relation. + */ + +- (id)copyJoinKeysFrom:(id)parent to:(id)newChild { + OOMetaData *parentMetaData = [self tableMetaDataForClass:[parent class]], + *childMetaData = [self tableMetaDataForClass:[newChild class]]; + OOStringArray commonColumns = [parentMetaData naturalJoinTo:childMetaData->columns]; //// + OOValueDictionary keyValues = [parentMetaData encode:[parent dictionaryWithValuesForKeys:commonColumns]]; + [newChild setValuesForKeysWithDictionary:[childMetaData decode:keyValues]]; + return newChild; +} + +/** + Build a where clause for the columns specified. + */ + +- (OOString)whereClauseFor:(cOOStringArray)columns values:(cOOValueDictionary)values qualifyNulls:(BOOL)qualifyNulls { + OOString out; + for ( int i=0 ; ijoinableColumns]; + joinValues = [parentMetaData encode:[parent dictionaryWithValuesForKeys:sharedColumns]]; + + sql += [self whereClauseFor:sharedColumns values:joinValues qualifyNulls:NO]; + } + + if ( [metaData->recordClass respondsToSelector:@selector(ooOrderBy)] ) + sql += OOFormat( @"\norder by %@", [metaData->recordClass ooOrderBy] ); + +#ifdef OODEBUG_SQL + NSLog( @"-[OOMetaData prepareSql:] %@\n%@", *sql, *joinValues ); +#endif + + if ( ![*adaptor prepare:sql] ) + return NO; + + return !parent || [*adaptor bindCols:sharedColumns values:joinValues startingAt:1 bindNulls:NO]; +} + +/** + Determine a list of the tables which have a natural join to the record passed in. + If the record is a specific instance of from a table this should determine if + there are any record which exist using the join. + */ + +- (OOArray)tablesRelatedByNaturalJoinFrom:(id)record { + OOMetaData *metaData = [record class] == [OOMetaData class] ? + record : [self tableMetaDataForClass:[record class]]; + + OOStringArray tablesWithNaturalJoin; + tablesWithNaturalJoin <<= metaData->tablesWithNaturalJoin; + + if ( record && record != metaData ) + for ( int i=0 ; i > tmpResults = [*adaptor bindResultsIntoInstancesOfClass:NULL metaData:nil]; + + if ( ![(*tmpResults[0])["result"] intValue] ) + ~tablesWithNaturalJoin[i--]; + } + + return tableMetaDataByClassName[+tablesWithNaturalJoin]; +} + +/** + Perform a select from a table on the database using either the sql specified + orselect all columns from the table associated with the record class passed in. + If a parent is passed in make a natural join from that record. + */ + +- (OOArray)select:(cOOString)select intoClass:(Class)recordClass joinFrom:(id)parent { + OOMetaData *metaData = [self tableMetaDataForClass:recordClass ? recordClass : [parent class]]; + OOString sql = !select ? + OOFormat( @"select %@\nfrom %@", *(metaData->outcols/", "), *metaData->tableName ) : *select; + + if ( ![self prepareSql:sql joinFrom:parent toTable:metaData] ) + return nil; + + return [*adaptor bindResultsIntoInstancesOfClass:recordClass metaData:metaData]; +} + +- (OOArray)select:(cOOString)select intoClass:(Class)recordClass { + return [self select:select intoClass:recordClass joinFrom:nil]; +} + +- (OOArray)select:(cOOString)select { + return [self select:select intoClass:nil joinFrom:nil]; +} + +/** + Returns sqlite3 row identifier for a record instance. + */ + +- (long long)rowIDForRecord:(id)record { + OOMetaData *metaData = [self tableMetaDataForClass:[record class]]; + OOString sql = OOFormat( @"select ROWID from %@", *metaData->tableName ); + OOArray > idResults = [self select:sql intoClass:nil joinFrom:record]; + return [*(*idResults[0])[@"rowid"] longLongValue]; +} + +/** + Returns sqlite3 row identifier for last inserted record. + */ + +- (long long)lastInsertRowID { + return [*adaptor lastInsertRowID]; +} + +/** + Insert an array of record objects into the database. This needs to be commited to take effect. + */ + +- (int)insertArray:(const OOArray &)objects { + int count = 0; + for ( id object in *objects ) + count = [self insert:object]; + return count; +} + +/** + Delete an array of record objects from the database. This needs to be commited to take effect. + */ + +- (int)deleteArray:(const OOArray &)objects { + int count = 0; + for ( id object in *objects ) + if ( ![object respondsToSelector:@selector(delete)] ) + count = [self delete:object]; + else { + [object delete]; + count++; + } + return count; +} + +/** + Insert the values of the record class instance at the time this method was called into the db. + (must be commited to take effect). Returns the total number of outstanding inserts/updates/deletes. + */ + +- (int)insert:(id)record { + return transaction += OOValueDictionary( kOOObject, record, kOOInsert, kCFNull, nil ); +} + +/** + Use the values of the record instance at the time this method is called in a where clause to + delete from the database when commit is called. Returns the total number of outstanding + inserts/updates/deletes. + */ + +- (int)delete:(id)record { + return transaction += OOValueDictionary( kOOObject, record, nil ); +} + +/** + Call this method if you intend to make changes to the record object and save them to the database. + This takes a snapshot of the previous values to use as a key for the update operation when "commit" + is called. Returns the total number of outstanding inserts/updates/deletes. + */ + +- (int)update:(id)record { + OOMetaData *metaData = [self tableMetaDataForClass:[record class]]; + OOValueDictionary oldValues = [metaData encode:[record dictionaryWithValuesForKeys:metaData->columns]]; + for ( NSString *key in *metaData->tocopy ) + OO_RELEASE( oldValues[key] = [oldValues[key] copy] ); + oldValues[kOOUpdate] = OONull; + oldValues[kOOObject] = record; + return transaction += oldValues; +} + +/** + Inserts a record into the database the deletes any previous record with the same key. + This ensures the record's rowid changes if this is used by child records. + */ + +- (int)indate:(id)record { + OOMetaData *metaData = [self tableMetaDataForClass:[record class]]; + OOString sql = OOFormat( @"select rowid from %@", *metaData->tableName ); + OOArray existing = [self select:sql intoClass:nil joinFrom:record]; + int count = [self insert:record]; + for ( NSDictionary *exist in *existing ) { + OOString sql = OOFormat( @"delete from %@ where rowid = %ld", *metaData->tableName, + (long)[[exist objectForKey:@"rowid"] longLongValue] ); + transaction += OOValueDictionary( kOOExecSQL, *sql, nil ); + } + return count; +} + +/** + Inserts a record into the database unless another record with the same key column values + exists in which case it will do an update of the previous record (preserving the ROWID.) + */ + +- (int)upsert:(id)record { + OOArray existing = [self select:nil intoClass:[record class] joinFrom:record]; + if ( existing > 1 ) + OOWarn( @"-[ODatabase upsert:] Duplicate record for upsert: %@", record ); + if ( existing > 0 ) { + [self update:existing[0]]; + (*transaction[-1])[kOOObject] = record; + return transaction; + } + else + return [self insert:record]; +} + +/** + Commit all pending inserts, updates and deletes to the database. Use commitTransaction to perform + this inside a database transaction. + */ + +- (int)commit { + int commited = 0; + + for ( int i=0 ; i object = *values[kOOObject]; values -= kOOObject; + BOOL isInsert = !!~values[kOOInsert], isUpdate = !!~values[kOOUpdate]; + + OOMetaData *metaData = [self tableMetaDataForClass:[object class]]; + OOValueDictionary newValues = [metaData encode:[object dictionaryWithValuesForKeys:metaData->columns]]; + OOStringArray changedCols; + + if ( isUpdate ) { + for ( NSString *name in *metaData->columns ) + if ( ![*newValues[name] isEqual:values[name]] ) + changedCols += name; + } + else + values = newValues; + + OOString sql = isInsert ? + OOFormat( @"insert into %@ (%@) values (", *metaData->tableName, *(metaData->columns/", ") ) : + OOFormat( isUpdate ? @"update %@ set" : @"delete from %@", *metaData->tableName ); + + int nchanged = changedCols; + if ( isUpdate && nchanged == 0 ) { + OOWarn( @"%s %@ (%@)", errmsg = (char *)"-[ODatabase commit:] Update of unchanged record", *object, *(lastSQL = sql) ); + continue; + } + + for ( int i=0 ; icolumns ; i++ ) + sql += i==0 ? quote : commaQuote; + sql += ")"; + } + else + sql += [self whereClauseFor:metaData->columns values:values qualifyNulls:YES]; + +#ifdef OODEBUG_SQL + NSLog( @"-[OODatabase commit]: %@ %@", *sql, *values ); +#endif + + if ( ![*adaptor prepare:sql] ) + continue; + + if ( isUpdate ) + [*adaptor bindCols:changedCols values:newValues startingAt:1 bindNulls:YES]; + [*adaptor bindCols:metaData->columns values:values startingAt:1+nchanged bindNulls:isInsert]; + + [*adaptor bindResultsIntoInstancesOfClass:nil metaData:metaData]; + commited += updateCount; + } + + transaction = nil; + return commited; +} + +/** + Commit all pending inserts, updates, deletes to the database inside a transaction. + */ + +- (int)commitTransaction { + [self exec:"BEGIN TRANSACTION"]; + int updated = [self commit]; + return [self exec:"COMMIT"] ? updated : 0; +} + +/** + Rollback any outstanding inserts, updates, or deletes. Please note updated values + are also rolled back inside the actual record in the application as well. + */ + +- (int)rollback { + for ( NSMutableDictionary *d in *transaction ) { + OODictionary values = d; + + if ( !!~values[kOOUpdate] ) { + OORef record = ~values[kOOObject]; + OOMetaData *metaData = [self tableMetaDataForClass:[*record class]]; + +#ifndef OO_ARC + for ( NSString *name in *metaData->boxed ) + OO_RELEASE( (id)[[*record valueForKey:name] pointerValue] ); +#endif + + [*record setValuesForKeysWithDictionary:[metaData decode:values]]; + } + } + return (int)[*~transaction count]; +} + +/** + Find/create an instance of the OOMetaData class which describes a record class and its associated table. + If the table does not exist it will be created along with indexes for columns/ivars which have + upper case names for use in joins. Details of the tables parameters can be controlled by using + methods in the OOTableCustomisation protool. If it does not exist a meta table class which + prepresents OOMetaData records themselves is also created from which the list of all registered + tables can be selected. + */ + +- (OOMetaData *)tableMetaDataForClass:(Class)recordClass { + if ( !recordClass || recordClass == [OOMetaData class] ) + return [OOMetaData metaDataForClass:[OOMetaData class]]; + + OOString className = class_getName( recordClass ); + OOMetaData *metaData = tableMetaDataByClassName[className]; + + if ( !metaData ) { + metaData = [OOMetaData metaDataForClass:recordClass]; + +#ifdef OODEBUG_SQL + NSLog(@"\n%@", *metaData->createTableSQL); +#endif + + if ( metaData->tableName[0] != '_' && + [self stringForSql:"select count(*) from sqlite_master where name = '%@'", + *metaData->tableName] == "0" ) + if ( [self exec:"%@", *metaData->createTableSQL] ) + for ( NSString *idx in *metaData->indexes ) + if ( ![self exec:idx] ) + OOWarn( @"-[OOMetaData tableMetaDataForClass:] Error creating index: %@", idx ); + + tableMetaDataByClassName[className] = metaData; + } + + return metaData; +} + +@end + +#pragma mark OOAdaptor - implements all access to a particular database + +@implementation OOAdaptor + +/** + Connect to/create sqlite3 database + */ + +- (OOAdaptor *)initPath:(cOOString)path database:(OODatabase *)database { + if ( self = [super init] ) { + owner = database; + OOFile( OOFile( path ).directory() ).mkdir(); + if ( (owner->errcode = sqlite3_open( path, &db )) != SQLITE_OK ) { + OOWarn( @"-[OOAdaptor initPath:database:] Error opening database at path: %@", *path ); + return nil; + } + } + return self; +} + +/** + Prepare a sql statement after which values can be bound and results returned. + */ + +- (BOOL)prepare:(cOOString)sql { + if ( (owner->errcode = sqlite3_prepare_v2( db, owner->lastSQL = sql, -1, &stmt, 0 )) != SQLITE_OK ) + OOWarn(@"-[OOAdaptor prepare:] Could not prepare sql: \"%@\" - %s", *owner->lastSQL, owner->errmsg = (char *)sqlite3_errmsg( db ) ); + return owner->errcode == SQLITE_OK; +} + +- (int)bindValue:(id)value asParameter:(int)pno { +#ifdef OODEBUG_BIND + NSLog( @"-[OOAdaptor bindValue:bindValue:] bind parameter #%d as: %@", pno, value ); +#endif + if ( !value || value == OONull ) + return sqlite3_bind_null( stmt, pno ); +#if OOSQL_THREAD_SAFE_BUT_USES_MORE_MEMORY + else if ( [value isKindOfClass:[NSString class]] ) + return sqlite3_bind_text( stmt, pno, [value UTF8String], -1, SQLITE_STATIC ); +#else + else if ( [value isKindOfClass:[NSString class]] ) { + int len = (int)[value lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + struct _str_link *str = (struct _str_link *)malloc( sizeof *str + len ); + str->next = strs; + strs = str; + [value getCString:str->str maxLength:len+1 encoding:NSUTF8StringEncoding]; + return sqlite3_bind_text( stmt, pno, str->str, len, SQLITE_STATIC ); + } +#endif + else if ( [value isKindOfClass:[NSData class]] ) + return sqlite3_bind_blob( stmt, pno, [value bytes], (int)[value length], SQLITE_STATIC ); + + const char *type = [value objCType]; + if ( type ) + switch ( type[0] ) { + case 'c': case 's': case 'i': case 'l': + case 'C': case 'S': case 'I': case 'L': + return sqlite3_bind_int( stmt, pno, [value intValue] ); + case 'q': case 'Q': + return sqlite3_bind_int64( stmt, pno, [value longLongValue] ); + case 'f': case 'd': + return sqlite3_bind_double( stmt, pno, [value doubleValue] ); + } + + OOWarn( @"-[OOAdaptor bindValue:bindValue:] Undefined type in bind of parameter #%d: %s, value: %@", pno, type, value ); + return -1; +} + +/** + Bind parameters from a prepared SQL statement. The "objCType" method is used to determine the type to bind. + */ + +- (BOOL)bindCols:(cOOStringArray)columns values:(cOOValueDictionary)values startingAt:(int)pno bindNulls:(BOOL)bindNulls { + int errcode; + for ( NSString *name in *columns ) + if ( bindNulls || *values[name] != OONull ) + if ( (errcode = [self bindValue:values[name] asParameter:pno++]) != SQLITE_OK ) + OOWarn( @"-[OOAdaptor bindCols:...] Bind failed column: %@ - %s (%d)", name, owner->errmsg = (char *)sqlite3_errmsg( db ), owner->errcode = errcode ); + return owner->errcode == SQLITE_OK; +} + +/** + Return a dictionary containing the values for a row returned by the database from a select. + These values need to be decoded using a classes metadata to set the ivar values later. + */ + +- (OOValueDictionary)valuesForNextRow { + int ncols = sqlite3_column_count( stmt ); + OOValueDictionary values; + + for ( int i=0 ; i)bindResultsIntoInstancesOfClass:(Class)recordClass metaData:(OOMetaData *)metaData { + OOArray out; + BOOL awakeFromDB = [recordClass instancesRespondToSelector:@selector(awakeFromDB)]; + + while( (owner->errcode = sqlite3_step( stmt )) == SQLITE_ROW ) { + OOValueDictionary values = [self valuesForNextRow]; + if ( recordClass ) { + id record = [[recordClass alloc] init]; + [record setValuesForKeysWithDictionary:[metaData decode:values]]; + + if ( awakeFromDB ) + [record awakeFromDB]; + + out += record; + OO_RELEASE( record ); + } + else + out += values; + } + + if ( owner->errcode != SQLITE_DONE ) + OOWarn(@"-[OOAdaptor bindResultsIntoInstancesOfClass:metaData:] Not done (bind) stmt: %@ - %s", *owner->lastSQL, owner->errmsg = (char *)sqlite3_errmsg( db ) ); + else { + owner->errcode = SQLITE_OK; + out.alloc(); + } + + while ( strs != NULL ) { + struct _str_link *next = strs->next; + free( strs ); + strs = next; + } + owner->updateCount = sqlite3_changes( db ); + sqlite3_finalize( stmt ); + return out; +} + +- (sqlite_int64)lastInsertRowID { + return sqlite3_last_insert_rowid( db ); +} + +- (void) dealloc { + sqlite3_close( db ); + OO_DEALLOC( super ); +} + +@end + +#pragma mark OOMetaData instances represent a table in the database and it's record class + +@implementation OOMetaData + +static OODictionary metaDataByClass; +static OOMetaData *tableOfTables; + ++ (NSString *)ooTableTitle { return @"Table MetaData"; } + ++ (OOMetaData *)metaDataForClass:(Class)recordClass OO_RETURNS { + if ( !tableOfTables ) + OO_RELEASE( tableOfTables = [[OOMetaData alloc] initClass:[OOMetaData class]] ); + OOMetaData *metaData = metaDataByClass[recordClass]; + if ( !metaData ) + OO_RELEASE( metaData = [[OOMetaData alloc] initClass:recordClass] ); + return metaData; +} + ++ (OOArray)selectRecordsRelatedTo:(id)record { + return [[OODatabase sharedInstance] tablesRelatedByNaturalJoinFrom:record]; +} + +- initClass:(Class)aClass { + if ( !(self = [super init]) ) + return self; + recordClass = aClass; + metaDataByClass[recordClass] = self; + recordClassName = class_getName( recordClass ); + tableTitle = [recordClass respondsToSelector:@selector(ooTableTitle)] ? + [recordClass ooTableTitle] : *recordClassName; + tableName = [recordClass respondsToSelector:@selector(ooTableName)] ? + [recordClass ooTableName] : *recordClassName; + + if ( aClass == [OOMetaData class] ) { + ivars = columns = outcols = boxed = unbox = + "tableTitle tableName recordClassName keyColumns ivars columns outcols"; + return self; + } + + createTableSQL = OOFormat( @"create table %@ (", *tableName ); + + OOArray hierarchy; + do + hierarchy += aClass; + while ( (aClass = [aClass superclass]) && aClass != [NSObject class] ); + + for ( int h=(int)hierarchy-1 ; h>=0 ; h-- ) { + aClass = (Class)hierarchy[h]; /// + Ivar *ivarInfo = class_copyIvarList( aClass, NULL ); + if ( !ivarInfo ) + continue; + + for ( int in=0 ; ivarInfo[in] ; in++ ) { + OOString columnName = ivar_getName( ivarInfo[in] ); + ivars += columnName; + + OOString type = types[columnName] = ivar_getTypeEncoding( ivarInfo[in] ), dbtype = ""; + + SEL columnSel = sel_getUid(columnName); + switch ( type[0] ) { + case 'c': case 's': case 'i': case 'l': + case 'C': case 'S': case 'I': case 'L': + case 'q': case 'Q': + dbtype = @"int"; + break; + case 'f': case 'd': + dbtype = @"real"; + break; + case '{': + static OOPattern isOORef( "=\"ref\"@\"NS" ); + if( !(type & isOORef) ) + OOWarn( @"-[OOMetaData initClass:] Invalid structure type for ivar %@ in class %@: %@", *columnName, *recordClassName, *type ); + boxed += columnName; + if ( ![recordClass instancesRespondToSelector:columnSel] ) { + unbox += columnName; + if ( [[recordClass superclass] instancesRespondToSelector:columnSel] ) + OOWarn( @"-[OOMetaData initClass:] Superclass of class %@ is providing method for column: %@", *recordClassName, *columnName ); + } + case '@': + static OOPattern isNSString( "NS(Mutable)?String\"" ), + isNSDate( "\"NSDate\"" ), isNSData( "NS(Mutable)?Data\"" ); + if ( type & isNSString ) + dbtype = @"text"; + else if ( type & isNSDate ) { + dbtype = @"real"; + dates += columnName; + } + else { + if ( !(type & isNSData) ) + archived += columnName; + blobs += columnName; + dbtype = @"blob"; + } + break; + default: + OOWarn( @"-[OOMetaData initClass:] Unknown data type '%@' in class %@", *type, *tableName ); + archived += columnName; + blobs += columnName; + dbtype = @"blob"; + break; + } + + if ( dbtype == @"text" ) + tocopy += columnName; + + if ( columnName == @"rowid" || columnName == @"ROWID" || + columnName == @"OID" || columnName == @"_ROWID_" ) { + outcols += columnName; + continue; + } + + createTableSQL += OOFormat(@"%s\n\t%@ %@ /* %@ */", + !columns?"":",", *columnName, *dbtype, *type ); + + if ( iswupper( columnName[columnName[0] != '_' ? 0 : 1] ) ) + indexes += OOFormat(@"create index %@_%@ on %@ (%@)\n", + *tableName, *columnName, + *tableName, *columnName); + + if ( class_getName( [aClass superclass] )[0] != '_' ) { + columns += columnName; + outcols += columnName; + joinableColumns += columnName; + } + } + + free( ivarInfo ); + } + + if ( [recordClass respondsToSelector:@selector(ooTableKey)] ) + createTableSQL += OOFormat( @",\n\tprimary key (%@)", + *(keyColumns = [recordClass ooTableKey]) ); + + if ( [recordClass respondsToSelector:@selector(ooConstraints)] ) + createTableSQL += OOFormat( @",\n\t%@", [recordClass ooConstraints] ); + + createTableSQL += "\n)\n"; + + if ( [recordClass respondsToSelector:@selector(ooTableSql)] ) { + createTableSQL = [recordClass ooTableSql]; + indexes = nil; + } + + tableOfTables->tablesWithNaturalJoin += recordClassName; + tablesWithNaturalJoin += recordClassName; + + for( Class other in [*metaDataByClass allKeys] ) { + OOMetaData *otherMetaData = metaDataByClass[other]; + if ( other == recordClass || otherMetaData == tableOfTables ) + continue; + + if ( [self naturalJoinTo:otherMetaData->joinableColumns] > 0 ) + tablesWithNaturalJoin += otherMetaData->recordClassName; + if ( [otherMetaData naturalJoinTo:joinableColumns] > 0 ) + otherMetaData->tablesWithNaturalJoin += recordClassName; + } + + return self; +} + +/** + Find the columns shared between two classes and that have upper case names (are indexed). + */ + +- (OOStringArray)naturalJoinTo:(cOOStringArray)to { + //NSLog( @"%@ -- %@", *columns, *to ); + OOStringArray commonColumns = columns & to; + for ( int i=0 ; i)import:(const OOArray > &)nodes intoClass:(Class)recordClass { + OOMetaData *metaData = [self metaDataForClass:recordClass]; + OOArray out; + + for ( NSMutableDictionary *dict in *nodes ) { + OOStringDictionary node = dict, values; + for ( NSString *ivar in *metaData->columns ) + values[ivar] = node[ivar]; + + id record = [[recordClass alloc] init]; + [record setValuesForKeysWithDictionary:[metaData decode:values]]; + out += record; + OO_RELEASE( record ); + } + + return out; +} + +/** + Convert a string taken from a flat file into record instances which can be inserted into the database. + */ + ++ (OOArray)import:(cOOString)string intoClass:(Class)recordClass delimiter:(cOOString)delim { + OOMetaData *metaData = [self metaDataForClass:recordClass]; + // remove escaped newlines then split by newline + OOStringArray lines = (string - @"\\\\\n") / @"\n"; + lines--; // pop last empty line + + OOArray out; + for ( int l=0 ; l values; + values[metaData->columns] = *lines[l] / delim; + + // empty columns are taken as null values + for ( NSString *key in *metaData->columns ) + if ( [*values[key] isEqualToString:@""] ) + values[key] = OONull; + + // convert description strings to NSData + for ( NSString *key in *metaData->blobs ) + OO_RELEASE( values[key] = (NSString *)[[NSData alloc] initWithDescription:values[key]] ); + + id record = [[recordClass alloc] init]; + [record setValuesForKeysWithDictionary:[metaData decode:values]]; + out += record; + OO_RELEASE( record ); + } + + return out; +} + +/** + Convert a set of records selected from the database into a string which can be saved to disk. + */ + ++ (OOString)export:(const OOArray &)array delimiter:(cOOString)delim { + OOMetaData *metaData = nil; + OOString out; + + for ( id record in *array ) { + if ( !metaData ) + metaData = [record isKindOfClass:[NSDictionary class]] ? + OONull : [self metaDataForClass:[record class]]; + + OODictionary values = metaData == OONull ? record : + *[metaData encode:[record dictionaryWithValuesForKeys:metaData->columns]]; + + OOStringArray line; + NSString *blank = @""; + for ( NSString *key in *metaData->columns ) + line += *values[key] != OONull ? [values[key] stringValue] : blank; + + out += line/delim+"\n"; + } + + return out; +} + +/** + Bind a record to a view containing elements which are to display values from the record. + The ivar number is selected by the subview's tag value and it's ".text" property if set to + the value returned record value "stringValue" for the ivar. Supports images stored as + NSData objects, UISwitches bound to boolean valuea and UITextField for alll other values. + */ + ++ (void)bindRecord:(id)record toView:(OOView *)view delegate:(id)delegate { +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + OOMetaData *metaData = [self metaDataForClass:[record class]]; + OOValueDictionary values = [metaData encode:[record dictionaryWithValuesForKeys:metaData->ivars]]; + + for ( int i=0 ; iivars ; i++ ) { + UILabel *label = (UILabel *)[view viewWithTag:1+i]; + id value = values[metaData->ivars[i]]; + + if ( [label isKindOfClass:[UIImageView class]] ) + ((UIImageView *)label).image = value != OONull ? [UIImage imageWithData:(NSData *)value] : nil; + else if ( [label isKindOfClass:[UISwitch class]] ) { + UISwitch *uiSwitch = (UISwitch *)label; + uiSwitch.on = value != OONull ? [value charValue] : 0; + if ( delegate ) + [uiSwitch addTarget:delegate action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged]; + } + else if ( [label isKindOfClass:[UIWebView class]] ) + [(UIWebView *)label loadHTMLString:value != OONull ? value : @"" baseURL:nil]; + else if ( label ) { + label.text = value != OONull ? [value stringValue] : @""; + if ( [label isKindOfClass:[UITextView class]] ) { + [(UITextView *)label setContentOffset:CGPointMake(0,0) animated:NO]; + [(UITextView *)label scrollRangeToVisible:NSMakeRange(0,0)]; + } + } + + if ( [label respondsToSelector:@selector(delegate)] ) + ((UITextField *)label).delegate = delegate; + label.hidden = NO; + + if ( (label = (UILabel *)[view viewWithTag:-1-i]) ) { + label.text = **metaData->ivars[i]; + label.hidden = NO; + } + } + + OOView *subView; + for ( int i=metaData->ivars ; (subView = [view viewWithTag:1+i]) ; i++ ) { + subView.hidden = YES; + if ( (subView = [view viewWithTag:-1-i]) ) + subView.hidden =YES; + } +#endif +} + +/** + When the delegate method fires this method should be called to update + the record with the modified value before updating the database. + */ + ++ (void)updateRecord:(id)record fromView:(OOView *)view { +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + if ( view.tag > 0 && [view respondsToSelector:@selector(text)] ) { + OOMetaData *metaData = [self metaDataForClass:[record class]]; + NSString *name = *metaData->ivars[view.tag-1]; + OOString type = metaData->types[name]; + id value = OO_RETAIN(((UITextField *)view).text ); + + if ( type[0] == '{' ) { +#ifdef OO_ARC + ooArcRetain( value ); +#endif + value = [[NSValue alloc] initWithBytes:&value objCType:@encode(id)]; +#ifndef OO_ARC + OO_RELEASE( (id)[[record valueForKey:name] pointerValue] ); +#endif + } + + [record setValue:value forKey:name]; + OO_RELEASE( value ); + } + for ( OOView *subview in [view subviews] ) + [self updateRecord:record fromView:subview]; +#endif +} + +@end + +@implementation OOView(OOExtras) + +- copyView { + NSData *archived = [NSKeyedArchiver archivedDataWithRootObject:self]; + OOView *copy = [NSKeyedUnarchiver unarchiveObjectWithData:archived]; +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED + copy.frame = CGRectMake(0.0, 0.0, self.frame.size.width, self.frame.size.height); +#else + copy.frame = NSMakeRect(0.0, 0.0, self.frame.size.width, self.frame.size.height); +#endif + return copy; +} + +@end + +@implementation NSData(OOExtras) + +static int unhex ( unsigned char ch ) { + return ch >= 'a' ? 10 + ch - 'a' : ch >= 'A' ? 10 + ch - 'A' : ch - '0'; +} + +- initWithDescription:(NSString *)description { + NSInteger len = [description length]/2, lin = [description lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + char *bytes = (char *)malloc( len ), *optr = bytes, *hex = (char *)malloc( lin+1 ); + [description getCString:hex maxLength:lin+1 encoding:NSUTF8StringEncoding]; + + for ( char *iptr = hex ; *iptr ; iptr+=2 ) { + if ( *iptr == '<' || *iptr == ' ' || *iptr == '>' ) + iptr--; + else + *optr++ = unhex( *iptr )*16 + unhex( *(iptr+1) ); + } + + free( hex ); + return [self initWithBytesNoCopy:bytes length:optr-bytes freeWhenDone:YES]; +} + +- (NSString *)stringValue { return [self description]; } + +@end + +@interface NSString(OOExtras) +@end +@implementation NSString(OOExtras) +- (char)charValue { return [self intValue]; } +- (char)shortValue { return [self intValue]; } +- (NSString *)stringValue { return self; } +@end + +@interface NSArray(OOExtras) +@end +@implementation NSArray(OOExtras) +- (NSString *)stringValue { + static OOReplace reformat( "/(\\s)\\s+|^\\(|\\)$|\"/$1/" ); + return &([self description] | reformat); +} +@end + +@interface NSDictionary(OOExtras) +@end +@implementation NSDictionary(OOExtras) +- (NSString *)stringValue { + static OOReplace reformat( "/(\\s)\\s+|^\\{|\\}$|\"/$1/" ); + return &([self description] | reformat); +} +@end + +#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED +@interface UISwitch(OOExtras) +@end +@implementation UISwitch(OOExtras) +- (NSString *)text { return self.on ? @"1" : @"0"; } +@end +#endif + diff --git a/samples/PureScript/Control.Arrow.purs b/samples/PureScript/Control.Arrow.purs new file mode 100644 index 00000000..56ae846f --- /dev/null +++ b/samples/PureScript/Control.Arrow.purs @@ -0,0 +1,34 @@ +module Control.Arrow where + +import Data.Tuple + +class Arrow a where + arr :: forall b c. (b -> c) -> a b c + first :: forall b c d. a b c -> a (Tuple b d) (Tuple c d) + +instance arrowFunction :: Arrow (->) where + arr f = f + first f (Tuple b d) = Tuple (f b) d + +second :: forall a b c d. (Category a, Arrow a) => a b c -> a (Tuple d b) (Tuple d c) +second f = arr swap >>> first f >>> arr swap + +swap :: forall a b. Tuple a b -> Tuple b a +swap (Tuple x y) = Tuple y x + +infixr 3 *** +infixr 3 &&& + +(***) :: forall a b b' c c'. (Category a, Arrow a) => a b c -> a b' c' -> a (Tuple b b') (Tuple c c') +(***) f g = first f >>> second g + +(&&&) :: forall a b b' c c'. (Category a, Arrow a) => a b c -> a b c' -> a b (Tuple c c') +(&&&) f g = arr (\b -> Tuple b b) >>> (f *** g) + +class ArrowZero a where + zeroArrow :: forall b c. a b c + +infixr 5 <+> + +class ArrowPlus a where + (<+>) :: forall b c. a b c -> a b c -> a b c diff --git a/samples/PureScript/Data.Foreign.purs b/samples/PureScript/Data.Foreign.purs new file mode 100644 index 00000000..d3d64f59 --- /dev/null +++ b/samples/PureScript/Data.Foreign.purs @@ -0,0 +1,111 @@ +module Data.Foreign + ( Foreign(..) + , ForeignParser(ForeignParser) + , parseForeign + , parseJSON + , ReadForeign + , read + , prop + ) where + +import Prelude +import Data.Array +import Data.Either +import Data.Maybe +import Data.Tuple +import Data.Traversable + +foreign import data Foreign :: * + +foreign import fromString + "function fromString (str) { \ + \ try { \ + \ return _ps.Data_Either.Right(JSON.parse(str)); \ + \ } catch (e) { \ + \ return _ps.Data_Either.Left(e.toString()); \ + \ } \ + \}" :: String -> Either String Foreign + +foreign import readPrimType + "function readPrimType (typeName) { \ + \ return function (value) { \ + \ if (toString.call(value) == '[object ' + typeName + ']') { \ + \ return _ps.Data_Either.Right(value);\ + \ } \ + \ return _ps.Data_Either.Left('Value is not a ' + typeName + ''); \ + \ }; \ + \}" :: forall a. String -> Foreign -> Either String a + +foreign import readMaybeImpl + "function readMaybeImpl (value) { \ + \ return value === undefined || value === null ? _ps.Data_Maybe.Nothing : _ps.Data_Maybe.Just(value); \ + \}" :: forall a. Foreign -> Maybe Foreign + +foreign import readPropImpl + "function readPropImpl (k) { \ + \ return function (obj) { \ + \ return _ps.Data_Either.Right(obj[k]);\ + \ }; \ + \}" :: forall a. String -> Foreign -> Either String Foreign + +foreign import showForeignImpl + "var showForeignImpl = JSON.stringify;" :: Foreign -> String + +instance showForeign :: Prelude.Show Foreign where + show = showForeignImpl + +data ForeignParser a = ForeignParser (Foreign -> Either String a) + +parseForeign :: forall a. ForeignParser a -> Foreign -> Either String a +parseForeign (ForeignParser p) x = p x + +parseJSON :: forall a. (ReadForeign a) => String -> Either String a +parseJSON json = fromString json >>= parseForeign read + +instance monadForeignParser :: Prelude.Monad ForeignParser where + return x = ForeignParser \_ -> Right x + (>>=) (ForeignParser p) f = ForeignParser \x -> case p x of + Left err -> Left err + Right x' -> parseForeign (f x') x + +instance applicativeForeignParser :: Prelude.Applicative ForeignParser where + pure x = ForeignParser \_ -> Right x + (<*>) (ForeignParser f) (ForeignParser p) = ForeignParser \x -> case f x of + Left err -> Left err + Right f' -> f' <$> p x + +instance functorForeignParser :: Prelude.Functor ForeignParser where + (<$>) f (ForeignParser p) = ForeignParser \x -> f <$> p x + +class ReadForeign a where + read :: ForeignParser a + +instance readString :: ReadForeign String where + read = ForeignParser $ readPrimType "String" + +instance readNumber :: ReadForeign Number where + read = ForeignParser $ readPrimType "Number" + +instance readBoolean :: ReadForeign Boolean where + read = ForeignParser $ readPrimType "Boolean" + +instance readArray :: (ReadForeign a) => ReadForeign [a] where + read = + let arrayItem (Tuple i x) = case parseForeign read x of + Right result -> Right result + Left err -> Left $ "Error reading item at index " ++ (show i) ++ ":\n" ++ err + in + (ForeignParser $ readPrimType "Array") >>= \xs -> + ForeignParser \_ -> arrayItem `traverse` (zip (range 0 (length xs)) xs) + +instance readMaybe :: (ReadForeign a) => ReadForeign (Maybe a) where + read = (ForeignParser $ Right <<< readMaybeImpl) >>= \x -> + ForeignParser \_ -> case x of + Just x' -> parseForeign read x' >>= return <<< Just + Nothing -> return Nothing + +prop :: forall a. (ReadForeign a) => String -> ForeignParser a +prop p = (ForeignParser \x -> readPropImpl p x) >>= \x -> + ForeignParser \_ -> case parseForeign read x of + Right result -> Right result + Left err -> Left $ "Error reading property '" ++ p ++ "':\n" ++ err diff --git a/samples/PureScript/Data.Map.purs b/samples/PureScript/Data.Map.purs new file mode 100644 index 00000000..0733fac3 --- /dev/null +++ b/samples/PureScript/Data.Map.purs @@ -0,0 +1,90 @@ +module Data.Map + ( Map(), + empty, + singleton, + insert, + lookup, + delete, + alter, + toList, + fromList, + union, + map + ) where + +import qualified Prelude as P + +import Data.Array (concat) +import Data.Foldable (foldl) +import Data.Maybe +import Data.Tuple + +data Map k v = Leaf | Branch { key :: k, value :: v, left :: Map k v, right :: Map k v } + +instance eqMap :: (P.Eq k, P.Eq v) => P.Eq (Map k v) where + (==) m1 m2 = toList m1 P.== toList m2 + (/=) m1 m2 = P.not (m1 P.== m2) + +instance showMap :: (P.Show k, P.Show v) => P.Show (Map k v) where + show m = "fromList " P.++ P.show (toList m) + +empty :: forall k v. Map k v +empty = Leaf + +singleton :: forall k v. k -> v -> Map k v +singleton k v = Branch { key: k, value: v, left: empty, right: empty } + +insert :: forall k v. (P.Eq k, P.Ord k) => k -> v -> Map k v -> Map k v +insert k v Leaf = singleton k v +insert k v (Branch b@{ key = k1 }) | k P.== k1 = Branch (b { key = k, value = v }) +insert k v (Branch b@{ key = k1 }) | k P.< k1 = Branch (b { left = insert k v b.left }) +insert k v (Branch b) = Branch (b { right = insert k v b.right }) + +lookup :: forall k v. (P.Eq k, P.Ord k) => k -> Map k v -> Maybe v +lookup k Leaf = Nothing +lookup k (Branch { key = k1, value = v }) | k P.== k1 = Just v +lookup k (Branch { key = k1, left = left }) | k P.< k1 = lookup k left +lookup k (Branch { right = right }) = lookup k right + +findMinKey :: forall k v. (P.Ord k) => Map k v -> Tuple k v +findMinKey (Branch { key = k, value = v, left = Leaf }) = Tuple k v +findMinKey (Branch b) = findMinKey b.left + +delete :: forall k v. (P.Eq k, P.Ord k) => k -> Map k v -> Map k v +delete k Leaf = Leaf +delete k (Branch b@{ key = k1, left = Leaf }) | k P.== k1 = + case b of + { left = Leaf } -> b.right + { right = Leaf } -> b.left + _ -> glue b.left b.right +delete k (Branch b@{ key = k1 }) | k P.< k1 = Branch (b { left = delete k b.left }) +delete k (Branch b) = Branch (b { right = delete k b.right }) + +alter :: forall k v. (P.Eq k, P.Ord k) => (Maybe v -> Maybe v) -> k -> Map k v -> Map k v +alter f k Leaf = case f Nothing of + Nothing -> Leaf + Just v -> singleton k v +alter f k (Branch b@{ key = k1, value = v }) | k P.== k1 = case f (Just v) of + Nothing -> glue b.left b.right + Just v' -> Branch (b { value = v' }) +alter f k (Branch b@{ key = k1 }) | k P.< k1 = Branch (b { left = alter f k b.left }) +alter f k (Branch b) = Branch (b { right = alter f k b.right }) + +glue :: forall k v. (P.Eq k, P.Ord k) => Map k v -> Map k v -> Map k v +glue left right = + let Tuple minKey root = findMinKey right in + Branch { key: minKey, value: root, left: left, right: delete minKey right } + +toList :: forall k v. Map k v -> [Tuple k v] +toList Leaf = [] +toList (Branch b) = toList b.left `concat` [Tuple b.key b.value] `concat` toList b.right + +fromList :: forall k v. (P.Eq k, P.Ord k) => [Tuple k v] -> Map k v +fromList = foldl (\m (Tuple k v) -> insert k v m) empty + +union :: forall k v. (P.Eq k, P.Ord k) => Map k v -> Map k v -> Map k v +union m1 m2 = foldl (\m (Tuple k v) -> insert k v m) m2 (toList m1) + +map :: forall k v1 v2. (P.Eq k, P.Ord k) => (v1 -> v2) -> Map k v1 -> Map k v2 +map _ Leaf = Leaf +map f (Branch b) = Branch (b { value = f b.value, left = map f b.left, right = map f b.right }) diff --git a/samples/PureScript/ReactiveJQueryTest.purs b/samples/PureScript/ReactiveJQueryTest.purs new file mode 100644 index 00000000..d1d941dc --- /dev/null +++ b/samples/PureScript/ReactiveJQueryTest.purs @@ -0,0 +1,128 @@ +module ReactiveJQueryTest where + +import Prelude ((+), (++), (<$>), (<*>), ($), (<<<), flip, return, show) +import Control.Monad +import Control.Monad.Eff +import Control.Monad.JQuery +import Control.Reactive +import Control.Reactive.JQuery +import Data.Array (map, head, length) +import Data.Foldable +import Data.Foreign +import Data.Maybe +import Data.Monoid +import Data.Traversable +import Debug.Trace +import Global (parseInt) + +main = do + personDemo + todoListDemo + +greet firstName lastName = "Hello, " ++ firstName ++ " " ++ lastName ++ "!" + +personDemo = do + -- Create new reactive variables to hold the user's names + firstName <- newRVar "John" + lastName <- newRVar "Smith" + + -- Get the document body + b <- body + + -- Create a text box for the first name + firstNameDiv <- create "
" + firstNameInput <- create "" + "First Name: " `appendText` firstNameDiv + firstNameInput `append` firstNameDiv + firstNameDiv `append` b + + -- Create a text box for the last name + lastNameDiv <- create "
" + lastNameInput <- create "" + "Last Name: " `appendText` lastNameDiv + lastNameInput `append` lastNameDiv + lastNameDiv `append` b + + -- Bind the text box values to the name variables + bindValueTwoWay firstName firstNameInput + bindValueTwoWay lastName lastNameInput + + -- Create a paragraph to display a greeting + greeting <- create "

" + { color: "red" } `css` greeting + greeting `append` b + + -- Bind the text property of the greeting paragraph to a computed property + let greetingC = greet <$> toComputed firstName <*> toComputed lastName + bindTextOneWay greetingC greeting + +todoListDemo = do + -- Get the document body + b <- body + + -- Create an array + arr <- newRArray + + text1 <- newRVar "Learn PureScript" + comp1 <- newRVar false + insertRArray arr { text: text1, completed: comp1 } 0 + + ul <- create "

    " + + -- Bind the ul to the array + bindArray arr ul $ \entry indexR -> do + li <- create "
  • " + + completedInput <- create "" + setAttr "type" "checkbox" completedInput + completedInput `append` li + sub1 <- bindCheckedTwoWay entry.completed completedInput + + textInput <- create "" + textInput `append` li + sub2 <- bindValueTwoWay entry.text textInput + + btn <- create "