diff --git a/.travis.yml b/.travis.yml index b24209c5..943c1b12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,11 @@ -before_install: sudo apt-get install libicu-dev -y +before_install: + - sudo apt-get install libicu-dev -y + - gem update --system 2.1.11 rvm: - 1.8.7 - 1.9.2 - 1.9.3 + - 2.0.0 - ree notifications: disabled: true diff --git a/Gemfile b/Gemfile index 851fabc2..3df9dcfc 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,7 @@ source 'https://rubygems.org' gemspec + +if RUBY_VERSION < "1.9.3" + # escape_utils 1.0.0 requires 1.9.3 and above + gem "escape_utils", "0.3.2" +end diff --git a/LICENSE b/LICENSE index d1d7570c..f09a7d0a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2013 GitHub, Inc. +Copyright (c) 2011-2014 GitHub, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 8a084513..1ff2ed8f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,17 @@ # Linguist -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. +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. ## Features ### Language detection -Linguist defines the list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and lexer must be defined there. +Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and a lexer must be defined there. -Most languages are detected by their file extension. This is the fastest and most common situation. - -For disambiguating between files with common extensions, we use a [Bayesian classifier](https://github.com/github/linguist/blob/master/lib/linguist/classifier.rb). For an example, this helps us tell the difference between `.h` files which could be either C, C++, or Obj-C. - -In the actual GitHub app we deal with `Grit::Blob` objects. For testing, there is a simple `FileBlob` API. +Most languages are detected by their file extension. For disambiguating between files with common extensions, we first apply some common-sense heuristics to pick out obvious languages. After that, we use a +[statistical +classifier](https://github.com/github/linguist/blob/master/lib/linguist/classifier.rb). +This process can help us tell the difference between, for example, `.h` files which could be either C, C++, or Obj-C. ```ruby @@ -27,13 +26,11 @@ See [lib/linguist/language.rb](https://github.com/github/linguist/blob/master/li The actual syntax highlighting is handled by our Pygments wrapper, [pygments.rb](https://github.com/tmm1/pygments.rb). It also provides a [Lexer abstraction](https://github.com/tmm1/pygments.rb/blob/master/lib/pygments/lexer.rb) that determines which highlighter should be used on a file. -We typically run on a pre-release version of Pygments, [pygments.rb](https://github.com/tmm1/pygments.rb), to get early access to new lexers. The [languages.yml](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) file is a dump of the lexers we have available on our server. - ### Stats -The Language Graph you see on every repository is built by aggregating the languages of all repo's blobs. The top language in the graph determines the project's primary language. Collectively, these stats make up the [Top Languages](https://github.com/languages) page. +The Language stats bar that you see on every repository is built by aggregating the languages of each file in that repository. The top language in the graph determines the project's primary language. -The repository stats API can be used on a directory: +The repository stats API, accessed through `#languages`, can be used on a directory: ```ruby project = Linguist::Repository.from_directory(".") @@ -41,10 +38,27 @@ project.language.name #=> "Ruby" project.languages #=> { "Ruby" => 0.98, "Shell" => 0.02 } ``` -These stats are also printed out by the binary. Try running `linguist` on itself: +These stats are also printed out by the `linguist` binary. You can use the +`--breakdown` flag, and the binary will also output the breakdown of files by language. - $ bundle exec linguist lib/ - 100% Ruby +You can try running `linguist` on the `lib/` directory in this repository itself: + + $ bundle exec linguist lib/ --breakdown + + 100.00% Ruby + + Ruby: + linguist/blob_helper.rb + linguist/classifier.rb + linguist/file_blob.rb + linguist/generated.rb + linguist/heuristics.rb + linguist/language.rb + linguist/md5.rb + linguist/repository.rb + linguist/samples.rb + linguist/tokenizer.rb + linguist.rb #### Ignore vendored files @@ -82,14 +96,18 @@ To run the tests: ## Contributing -The majority of patches won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a configuration file. +The majority of contributions won't need to touch any Ruby code at all. The [master language list](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) is just a YAML configuration file. We try to only add languages once they have some usage on GitHub, so please note in-the-wild usage examples in your pull request. Almost all bug fixes or new language additions should come with some additional code samples. Just drop them under [`samples/`](https://github.com/github/linguist/tree/master/samples) in the correct subdirectory and our test suite will automatically test them. In most cases you shouldn't need to add any new assertions. +To update the `samples.json` after adding new files to [`samples/`](https://github.com/github/linguist/tree/master/samples): + + bundle exec rake samples + ### Testing -Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay, be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away. +Sometimes getting the tests running can be too much work, especially if you don't have much Ruby experience. It's okay: be lazy and let our build bot [Travis](http://travis-ci.org/#!/github/linguist) run the tests for you. Just open a pull request and the bot will start cranking away. Here's our current build status, which is hopefully green: [![Build Status](https://secure.travis-ci.org/github/linguist.png?branch=master)](http://travis-ci.org/github/linguist) diff --git a/Rakefile b/Rakefile index 08ce419b..e89e75a9 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,7 @@ +require 'json' require 'rake/clean' require 'rake/testtask' +require 'yaml' task :default => :test @@ -13,6 +15,13 @@ task :samples do File.open('lib/linguist/samples.json', 'w') { |io| io.write json } end +task :build_gem do + languages = YAML.load_file("lib/linguist/languages.yml") + File.write("lib/linguist/languages.json", JSON.dump(languages)) + `gem build github-linguist.gemspec` + File.delete("lib/linguist/languages.json") +end + namespace :classifier do LIMIT = 1_000 diff --git a/bin/linguist b/bin/linguist index d28aaf7b..2cfa8064 100755 --- a/bin/linguist +++ b/bin/linguist @@ -1,19 +1,39 @@ #!/usr/bin/env ruby # linguist — detect language type for a file, or, given a directory, determine language breakdown -# -# usage: linguist +# usage: linguist [<--breakdown>] require 'linguist/file_blob' require 'linguist/repository' path = ARGV[0] || Dir.pwd +# special case if not given a directory but still given the --breakdown option +if path == "--breakdown" + path = Dir.pwd + breakdown = true +end + +ARGV.shift +breakdown = true if ARGV[0] == "--breakdown" + if File.directory?(path) repo = Linguist::Repository.from_directory(path) repo.languages.sort_by { |_, size| size }.reverse.each do |language, size| - percentage = ((size / repo.size.to_f) * 100).round - puts "%-4s %s" % ["#{percentage}%", language] + percentage = ((size / repo.size.to_f) * 100) + percentage = sprintf '%.2f' % percentage + puts "%-7s %s" % ["#{percentage}%", language] + end + if breakdown + puts + file_breakdown = repo.breakdown_by_file + file_breakdown.each do |lang, files| + puts "#{lang}:" + files.each do |file| + puts file + end + puts + end end elsif File.file?(path) blob = Linguist::FileBlob.new(path, Dir.pwd) diff --git a/github-linguist.gemspec b/github-linguist.gemspec index 71846285..ca7647b8 100644 --- a/github-linguist.gemspec +++ b/github-linguist.gemspec @@ -1,20 +1,23 @@ Gem::Specification.new do |s| s.name = 'github-linguist' - s.version = '2.9.5' + 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.' s.authors = "GitHub" s.homepage = "https://github.com/github/linguist" + s.license = "MIT" s.files = Dir['lib/**/*'] s.executables << 'linguist' s.add_dependency 'charlock_holmes', '~> 0.6.6' - s.add_dependency 'escape_utils', '~> 0.3.1' + s.add_dependency 'escape_utils', '>= 0.3.1' s.add_dependency 'mime-types', '~> 1.19' - s.add_dependency 'pygments.rb', '~> 0.5.2' - s.add_development_dependency 'mocha' + s.add_dependency 'pygments.rb', '~> 0.5.4' + s.add_development_dependency 'json' + s.add_development_dependency 'mocha' s.add_development_dependency 'rake' s.add_development_dependency 'yajl-ruby' end diff --git a/lib/linguist.rb b/lib/linguist.rb index e717fb67..ad8337c8 100644 --- a/lib/linguist.rb +++ b/lib/linguist.rb @@ -1,5 +1,6 @@ require 'linguist/blob_helper' require 'linguist/generated' +require 'linguist/heuristics' require 'linguist/language' require 'linguist/repository' require 'linguist/samples' diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index 81956e47..37793a36 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -190,9 +190,9 @@ module Linguist # Public: Is the blob safe to colorize? # # We use Pygments for syntax highlighting blobs. Pygments - # can be too slow for very large blobs or for certain + # can be too slow for very large blobs or for certain # corner-case blobs. - # + # # Return true or false def safe_to_colorize? !large? && text? && !high_ratio_of_long_lines? diff --git a/lib/linguist/classifier.rb b/lib/linguist/classifier.rb index a9707b28..5370bdd8 100644 --- a/lib/linguist/classifier.rb +++ b/lib/linguist/classifier.rb @@ -15,8 +15,8 @@ module Linguist # # Returns nothing. # - # Set LINGUIST_DEBUG=1 or =2 to see probabilities per-token, - # per-language. See also dump_all_tokens, below. + # Set LINGUIST_DEBUG=1 or =2 to see probabilities per-token or + # per-language. See also #dump_all_tokens, below. def self.train!(db, language, data) tokens = Tokenizer.tokenize(data) @@ -78,18 +78,13 @@ module Linguist def classify(tokens, languages) return [] if tokens.nil? tokens = Tokenizer.tokenize(tokens) if tokens.is_a?(String) - scores = {} - if verbosity >= 2 - dump_all_tokens(tokens, languages) - end + + debug_dump_all_tokens(tokens, languages) if verbosity >= 2 + languages.each do |language| - scores[language] = tokens_probability(tokens, language) + - language_probability(language) - if verbosity >= 1 - printf "%10s = %10.3f + %7.3f = %10.3f\n", - language, tokens_probability(tokens, language), language_probability(language), scores[language] - end + scores[language] = tokens_probability(tokens, language) + language_probability(language) + debug_dump_probabilities(tokens, language, scores[language]) if verbosity >= 1 end scores.sort { |a, b| b[1] <=> a[1] }.map { |score| [score[0], score[1]] } @@ -135,6 +130,11 @@ module Linguist @verbosity ||= (ENV['LINGUIST_DEBUG'] || 0).to_i end + def debug_dump_probabilities(tokens, language, score) + printf("%10s = %10.3f + %7.3f = %10.3f\n", + language, tokens_probability(tokens, language), language_probability(language), score) + end + # Internal: show a table of probabilities for each pair. # # The number in each table entry is the number of "points" that each @@ -145,22 +145,22 @@ module Linguist # how much more likely (log of probability ratio) that token is to # appear in one language vs. the least-likely language. Dashes # indicate the least-likely language (and zero points) for each token. - def dump_all_tokens(tokens, languages) + def debug_dump_all_tokens(tokens, languages) maxlen = tokens.map { |tok| tok.size }.max - + printf "%#{maxlen}s", "" puts " #" + languages.map { |lang| sprintf("%10s", lang) }.join - - tokmap = Hash.new(0) - tokens.each { |tok| tokmap[tok] += 1 } - - tokmap.sort.each { |tok, count| + + token_map = Hash.new(0) + tokens.each { |tok| token_map[tok] += 1 } + + token_map.sort.each { |tok, count| arr = languages.map { |lang| [lang, token_probability(tok, lang)] } min = arr.map { |a,b| b }.min minlog = Math.log(min) if !arr.inject(true) { |result, n| result && n[1] == arr[0][1] } printf "%#{maxlen}s%5d", tok, count - + puts arr.map { |ent| ent[1] == min ? " -" : sprintf("%10.3f", count * (Math.log(ent[1]) - minlog)) }.join diff --git a/lib/linguist/generated.rb b/lib/linguist/generated.rb index 424ffbec..5c3de141 100644 --- a/lib/linguist/generated.rb +++ b/lib/linguist/generated.rb @@ -58,7 +58,12 @@ module Linguist generated_parser? || generated_net_docfile? || generated_net_designer_file? || - generated_protocol_buffer? + generated_postscript? || + generated_protocol_buffer? || + generated_jni_header? || + composer_lock? || + node_modules? || + vcr_cassette? end # Internal: Is the blob an XCode project file? @@ -73,14 +78,16 @@ module Linguist # Internal: Is the blob minified files? # - # Consider a file minified if it contains more than 5% spaces. + # Consider a file minified if the average line length is + # greater then 110c. + # # Currently, only JS and CSS files are detected by this method. # # Returns true or false. def minified_files? return unless ['.js', '.css'].include? extname - if data && data.length > 200 - (data.each_char.count{ |c| c <= ' ' } / data.length.to_f) < 0.05 + if lines.any? + (lines.inject(0) { |n, l| n += l.length } / lines.length) > 110 else false end @@ -171,6 +178,29 @@ module Linguist false end + # Internal: Is the blob of PostScript generated? + # + # PostScript files are often generated by other programs. If they tell us so, + # we can detect them. + # + # Returns true or false. + def generated_postscript? + return false unless ['.ps', '.eps'].include? extname + + # We analyze the "%%Creator:" comment, which contains the author/generator + # of the file. If there is one, it should be in one of the first few lines. + creator = lines[0..9].find {|line| line =~ /^%%Creator: /} + return false if creator.nil? + + # Most generators write their version number, while human authors' or companies' + # names don't contain numbers. So look if the line contains digits. Also + # look for some special cases without version numbers. + return creator =~ /[0-9]/ || + creator.include?("mpage") || + creator.include?("draw") || + creator.include?("ImageMagick") + end + # Internal: Is the blob a C++, Java or Python source file generated by the # Protocol Buffer compiler? # @@ -181,5 +211,40 @@ module Linguist return lines[0].include?("Generated by the protocol buffer compiler. DO NOT EDIT!") end + + # Internal: Is the blob a C/C++ header generated by the Java JNI tool javah? + # + # Returns true of false. + def generated_jni_header? + return false unless extname == '.h' + return false unless lines.count > 2 + + return lines[0].include?("/* DO NOT EDIT THIS FILE - it is machine generated */") && + lines[1].include?("#include ") + end + + # Internal: Is the blob part of node_modules/, which are not meant for humans in pull requests. + # + # Returns true or false. + def node_modules? + !!name.match(/node_modules\//) + end + + # Internal: Is the blob a generated php composer lock file? + # + # Returns true or false. + def composer_lock? + !!name.match(/composer.lock/) + end + + # Is the blob a VCR Cassette file? + # + # Returns true or false + def vcr_cassette? + return false unless extname == '.yml' + return false unless lines.count > 2 + # VCR Cassettes have "recorded_with: VCR" in the second last line. + return lines[-2].include?("recorded_with: VCR") + end end end diff --git a/lib/linguist/heuristics.rb b/lib/linguist/heuristics.rb new file mode 100644 index 00000000..a3de46e9 --- /dev/null +++ b/lib/linguist/heuristics.rb @@ -0,0 +1,80 @@ +module Linguist + # A collection of simple heuristics that can be used to better analyze languages. + class Heuristics + ACTIVE = false + + # Public: Given an array of String language names, + # apply heuristics against the given data and return an array + # of matching languages, or nil. + # + # data - Array of tokens or String data to analyze. + # languages - Array of language name Strings to restrict to. + # + # Returns an array of Languages or [] + def self.find_by_heuristics(data, languages) + if active? + if languages.all? { |l| ["Objective-C", "C++"].include?(l) } + disambiguate_c(data, languages) + end + if languages.all? { |l| ["Perl", "Prolog"].include?(l) } + disambiguate_pl(data, languages) + end + if languages.all? { |l| ["ECL", "Prolog"].include?(l) } + disambiguate_ecl(data, languages) + end + if languages.all? { |l| ["TypeScript", "XML"].include?(l) } + disambiguate_ts(data, languages) + end + if languages.all? { |l| ["Common Lisp", "OpenCL"].include?(l) } + disambiguate_cl(data, languages) + end + end + end + + # .h extensions are ambigious between C, C++, and Objective-C. + # We want to shortcut look for Objective-C _and_ now C++ too! + # + # Returns an array of Languages or [] + def self.disambiguate_c(data, languages) + matches = [] + matches << Language["Objective-C"] if data.include?("@interface") + matches << Language["C++"] if data.include?("#include ") + matches + end + + def self.disambiguate_pl(data, languages) + matches = [] + matches << Language["Prolog"] if data.include?(":-") + matches << Language["Perl"] if data.include?("use strict") + matches + end + + def self.disambiguate_ecl(data, languages) + matches = [] + matches << Language["Prolog"] if data.include?(":-") + matches << Language["ECL"] if data.include?(":=") + matches + end + + def self.disambiguate_ts(data, languages) + matches = [] + if (data.include?("")) + matches << Language["XML"] + else + matches << Language["TypeScript"] + end + matches + end + + def self.disambiguate_cl(data, languages) + matches = [] + matches << Language["Common Lisp"] if data.include?("(defun ") + matches << Language["OpenCL"] if /\/\* |\/\/ |^\}/.match(data) + matches + end + + def self.active? + !!ACTIVE + end + end +end diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 0a8d3d54..955becb3 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -1,8 +1,13 @@ require 'escape_utils' require 'pygments' require 'yaml' +begin + require 'json' +rescue LoadError +end require 'linguist/classifier' +require 'linguist/heuristics' require 'linguist/samples' module Linguist @@ -15,17 +20,29 @@ module Linguist @index = {} @name_index = {} @alias_index = {} - @extension_index = Hash.new { |h,k| h[k] = [] } - @filename_index = Hash.new { |h,k| h[k] = [] } + + @extension_index = Hash.new { |h,k| h[k] = [] } + @interpreter_index = Hash.new { |h,k| h[k] = [] } + @filename_index = Hash.new { |h,k| h[k] = [] } + @primary_extension_index = {} # Valid Languages types - TYPES = [:data, :markup, :programming] + TYPES = [:data, :markup, :programming, :prose] # Names of non-programming languages that we will still detect # # Returns an array def self.detectable_markup - ["CSS", "Less", "Sass"] + ["CSS", "Less", "Sass", "SCSS", "Stylus", "TeX"] + end + + # Detect languages by a specific type + # + # type - A symbol that exists within TYPES + # + # Returns an array + def self.by_type(type) + all.select { |h| h.type == type } end # Internal: Create a new Language object @@ -63,6 +80,16 @@ module Linguist @extension_index[extension] << language end + if @primary_extension_index.key?(language.primary_extension) + raise ArgumentError, "Duplicate primary extension: #{language.primary_extension}" + end + + @primary_extension_index[language.primary_extension] = language + + language.interpreters.each do |interpreter| + @interpreter_index[interpreter] << language + end + language.filenames.each do |filename| @filename_index[filename] << language end @@ -87,16 +114,32 @@ module Linguist name += ".script!" end + # First try to find languages that match based on filename. possible_languages = find_by_filename(name) + # If there is more than one possible language with that extension (or no + # extension at all, in the case of extensionless scripts), we need to continue + # our detection work if possible_languages.length > 1 data = data.call() if data.respond_to?(:call) + possible_language_names = possible_languages.map(&:name) + + # Don't bother with emptiness if data.nil? || data == "" nil - elsif result = Classifier.classify(Samples::DATA, data, possible_languages.map(&:name)).first - Language[result[0]] + # Check if there's a shebang line and use that as authoritative + elsif (result = find_by_shebang(data)) && !result.empty? + result.first + # No shebang. Still more work to do. Try to find it with our heuristics. + elsif (determined = Heuristics.find_by_heuristics(data, possible_language_names)) && !determined.empty? + determined.first + # Lastly, fall back to the probablistic classifier. + elsif classified = Classifier.classify(Samples::DATA, data, possible_language_names ).first + # Return the actual Language object based of the string language name (i.e., first element of `#classify`) + Language[classified[0]] end else + # Simplest and most common case, we can just return the one match based on extension possible_languages.first end end @@ -148,7 +191,24 @@ module Linguist # Returns all matching Languages or [] if none were found. def self.find_by_filename(filename) basename, extname = File.basename(filename), File.extname(filename) - @filename_index[basename] + @extension_index[extname] + langs = [@primary_extension_index[extname]] + + @filename_index[basename] + + @extension_index[extname] + langs.compact.uniq + end + + # Public: Look up Languages by shebang line. + # + # data - Array of tokens or String data to analyze. + # + # Examples + # + # Language.find_by_shebang("#!/bin/bash\ndate;") + # # => [#] + # + # Returns the matching Language + def self.find_by_shebang(data) + @interpreter_index[Linguist.interpreter_from_shebang(data)] end # Public: Look up Language by its name or lexer. @@ -236,6 +296,7 @@ module Linguist # Set extensions or default to []. @extensions = attributes[:extensions] || [] + @interpreters = attributes[:interpreters] || [] @filenames = attributes[:filenames] || [] unless @primary_extension = attributes[:primary_extension] @@ -348,6 +409,15 @@ module Linguist # Returns the extension String. attr_reader :primary_extension + # Public: Get interpreters + # + # Examples + # + # # => ['awk', 'gawk', 'mawk' ...] + # + # Returns the interpreters Array + attr_reader :interpreters + # Public: Get filenames # # Examples @@ -415,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 @@ -441,11 +511,22 @@ module Linguist end extensions = Samples::DATA['extnames'] + interpreters = Samples::DATA['interpreters'] filenames = Samples::DATA['filenames'] popular = YAML.load_file(File.expand_path("../popular.yml", __FILE__)) - YAML.load_file(File.expand_path("../languages.yml", __FILE__)).each do |name, options| + languages_yml = File.expand_path("../languages.yml", __FILE__) + languages_json = File.expand_path("../languages.json", __FILE__) + + if File.exist?(languages_json) && defined?(JSON) + languages = JSON.load(File.read(languages_json)) + else + languages = YAML.load_file(languages_yml) + end + + languages.each do |name, options| options['extensions'] ||= [] + options['interpreters'] ||= [] options['filenames'] ||= [] if extnames = extensions[name] @@ -456,6 +537,18 @@ module Linguist end end + if interpreters == nil + interpreters = {} + end + + if interpreter_names = interpreters[name] + interpreter_names.each do |interpreter| + if !options['interpreters'].include?(interpreter) + options['interpreters'] << interpreter + end + end + end + if fns = filenames[name] fns.each do |filename| if !options['filenames'].include?(filename) @@ -476,6 +569,7 @@ module Linguist :searchable => options.key?('searchable') ? options['searchable'] : true, :search_term => options['search_term'], :extensions => options['extensions'].sort, + :interpreters => options['interpreters'].sort, :primary_extension => options['primary_extension'], :filenames => options['filenames'], :popular => popular.include?(name) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index bb55f135..7a83b568 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -10,6 +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 +# 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 @@ -22,13 +23,19 @@ # Any additions or modifications (even trivial) should have corresponding # test change in `test/test_blob.rb`. # -# Please keep this list alphabetized. +# Please keep this list alphabetized. Capitalization comes before lower case. ABAP: type: programming lexer: ABAP primary_extension: .abap +ANTLR: + type: programming + color: "#9DC3FF" + lexer: ANTLR + primary_extension: .g4 + ASP: type: programming color: "#6a40fd" @@ -46,6 +53,18 @@ ASP: - .aspx - .axd +ATS: + type: programming + color: "#1ac620" + primary_extension: .dats + lexer: OCaml + aliases: + - ats2 + extensions: + - .atxt + - .hats + - .sats + ActionScript: type: programming lexer: ActionScript 3 @@ -62,6 +81,11 @@ Ada: extensions: - .ads +Agda: + type: programming + color: "#467C91" + primary_extension: .agda + ApacheConf: type: markup aliases: @@ -78,6 +102,10 @@ AppleScript: aliases: - osascript primary_extension: .applescript + extensions: + - .scpt + interpreters: + - osascript Arc: type: programming @@ -91,6 +119,22 @@ Arduino: lexer: C++ primary_extension: .ino +AsciiDoc: + type: prose + lexer: Text only + ace_mode: asciidoc + wrap: true + primary_extension: .asciidoc + extensions: + - .adoc + - .asc + +AspectJ: + type: programming + lexer: AspectJ + color: "#1957b0" + primary_extension: .aj + Assembly: type: programming lexer: NASM @@ -112,14 +156,29 @@ AutoHotkey: - ahk primary_extension: .ahk +AutoIt: + type: programming + color: "#36699B" + aliases: + - au3 + - AutoIt3 + - AutoItScript + primary_extension: .au3 + Awk: type: programming lexer: Awk primary_extension: .awk extensions: + - .auk - .gawk - .mawk - .nawk + interpreters: + - awk + - gawk + - mawk + - nawk Batchfile: type: programming @@ -134,9 +193,23 @@ Batchfile: Befunge: primary_extension: .befunge +BlitzBasic: + type: programming + aliases: + - blitzplus + - blitz3d + primary_extension: .bb + extensions: + - .decls + BlitzMax: primary_extension: .bmx +Bluespec: + type: programming + lexer: verilog + primary_extension: .bsv + Boo: type: programming color: "#d4bec1" @@ -147,6 +220,11 @@ Brainfuck: extensions: - .bf +Brightscript: + type: programming + lexer: Text only + primary_extension: .brs + Bro: type: programming primary_extension: .bro @@ -156,6 +234,7 @@ C: color: "#555" primary_extension: .c extensions: + - .cats - .w C#: @@ -167,6 +246,7 @@ C#: - csharp primary_extension: .cs extensions: + - .cshtml - .csx C++: @@ -180,12 +260,15 @@ C++: extensions: - .C - .c++ + - .cc - .cxx - .H - .h++ - .hh + - .hpp - .hxx - .tcc + - .tpp C-ObjDump: type: data @@ -223,7 +306,7 @@ COBOL: CSS: ace_mode: css - color: "#1f085e" + color: "#563d7c" primary_extension: .css Ceylon: @@ -235,14 +318,37 @@ ChucK: lexer: Java primary_extension: .ck +Cirru: + type: programming + color: "#aaaaff" + primary_extension: .cirru + # ace_mode: cirru + # lexer: Cirru + lexer: Text only + extensions: + - .cr + +Clean: + type: programming + color: "#3a81ad" + lexer: Text only + primary_extension: .icl + extensions: + - .dcl + Clojure: type: programming ace_mode: clojure color: "#db5855" primary_extension: .clj extensions: + - .cl2 + - .cljc - .cljs + - .cljscm - .cljx + - .hic + - .cljs.hl filenames: - riemann.config @@ -260,6 +366,8 @@ CoffeeScript: - .iced filenames: - Cakefile + interpreters: + - coffee ColdFusion: type: programming @@ -281,9 +389,16 @@ Common Lisp: primary_extension: .lisp extensions: - .asd + - .cl - .lsp - .ny - .podsl + interpreters: + - lisp + - sbcl + - ccl + - clisp + - ecl Coq: type: programming @@ -297,10 +412,28 @@ Cpp-ObjDump: - .c++objdump - .cxx-objdump +Creole: + type: prose + lexer: Text only + wrap: true + primary_extension: .creole + +Crystal: + type: programming + lexer: Ruby + primary_extension: .cr + ace_mode: ruby + Cucumber: lexer: Gherkin primary_extension: .feature +Cuda: + lexer: CUDA + primary_extension: .cu + extensions: + - .cuh + Cython: type: programming group: Python @@ -321,6 +454,14 @@ D-ObjDump: lexer: d-objdump primary_extension: .d-objdump +DM: + type: programming + color: "#075ff1" + lexer: C++ + primary_extension: .dm + aliases: + - byond + DOT: type: programming lexer: Text only @@ -338,6 +479,7 @@ Darcs Patch: Dart: type: programming + color: "#98BAD6" primary_extension: .dart DCPU-16 ASM: @@ -352,10 +494,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 @@ -363,7 +514,7 @@ Ecere Projects: lexer: JSON primary_extension: .epj -Ecl: +ECL: type: programming color: "#8a1267" primary_extension: .ecl @@ -371,6 +522,14 @@ Ecl: extensions: - .eclxml +Eagle: + type: markup + color: "#3994bc" + lexer: XML + primary_extension: .sch + extensions: + - .brd + Eiffel: type: programming lexer: Text only @@ -387,7 +546,6 @@ Elixir: Elm: type: programming lexer: Haskell - group: Haskell primary_extension: .elm Emacs Lisp: @@ -398,6 +556,8 @@ Emacs Lisp: - elisp - emacs primary_extension: .el + filenames: + - .emacs extensions: - .emacs @@ -420,6 +580,14 @@ F#: - .fsi - .fsx +FLUX: + type: programming + color: "#33CCFF" + primary_extension: .fx + lexer: Text only + extensions: + - .flux + FORTRAN: type: programming lexer: Fortran @@ -472,6 +640,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 @@ -513,6 +692,23 @@ Gettext Catalog: extensions: - .pot +Glyph: + type: programming + color: "#e4cc98" + 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" @@ -549,6 +745,8 @@ Groovy: ace_mode: groovy color: "#e69f56" primary_extension: .groovy + interpreters: + - groovy Groovy Server Pages: group: Groovy @@ -566,6 +764,7 @@ HTML: extensions: - .htm - .xhtml + - .html.hl HTML+Django: type: markup @@ -609,6 +808,16 @@ Handlebars: type: markup lexer: Text only primary_extension: .handlebars + extensions: + - .hbs + - .html.handlebars + - .html.hbs + +Harbour: + type: programming + lexer: Text only + color: "#0e60e3" + primary_extension: .hb Haskell: type: programming @@ -619,13 +828,25 @@ Haskell: Haxe: type: programming - lexer: haXe ace_mode: haxe color: "#346d51" primary_extension: .hx extensions: - .hxsl +Hy: + type: programming + lexer: Clojure + ace_mode: clojure + color: "#7891b1" + primary_extension: .hy + +IDL: + type: programming + lexer: Text only + color: "#e3592c" + primary_extension: .pro + INI: type: data extensions: @@ -634,6 +855,17 @@ INI: - .properties primary_extension: .ini +Idris: + type: programming + lexer: Text only + primary_extension: .idr + extensions: + - .lidr + +Inno Setup: + primary_extension: .iss + lexer: Text only + IRC log: lexer: IRC logs search_term: irc @@ -653,12 +885,45 @@ Ioke: color: "#078193" primary_extension: .ik +J: + type: programming + lexer: Text only + primary_extension: .ijs + JSON: type: data group: JavaScript ace_mode: json searchable: false primary_extension: .json + extensions: + - .sublime-keymap + - .sublime_metrics + - .sublime-mousemap + - .sublime-project + - .sublime_session + - .sublime-settings + - .sublime-workspace + filenames: + - .jshintrc + - composer.lock + +JSON5: + type: data + lexer: JavaScript + primary_extension: .json5 + +JSONLD: + type: data + group: JavaScript + ace_mode: json + lexer: JavaScript + primary_extension: .jsonld + +Jade: + group: HTML + type: markup + primary_extension: .jade Java: type: programming @@ -677,7 +942,7 @@ Java Server Pages: JavaScript: type: programming ace_mode: javascript - color: "#f15501" + color: "#f7df1e" aliases: - js - node @@ -685,20 +950,31 @@ JavaScript: extensions: - ._js - .bones + - .es6 - .jake - .jsfl - .jsm - .jss - .jsx + - .njs - .pac - .sjs - .ssjs filenames: - Jakefile + interpreters: + - node Julia: type: programming primary_extension: .jl + color: "#a270ba" + +KRL: + lexer: Text only + type: programming + color: "#f5c800" + primary_extension: .krl Kotlin: type: programming @@ -720,7 +996,6 @@ LLVM: Lasso: type: programming lexer: Lasso - ace_mode: lasso color: "#2584c3" primary_extension: .lasso @@ -728,7 +1003,6 @@ Less: type: markup group: CSS lexer: CSS - ace_mode: less primary_extension: .less LilyPond: @@ -737,6 +1011,13 @@ LilyPond: extensions: - .ily +Literate Agda: + type: programming + group: Agda + primary_extension: .lagda + extensions: + - .lagda + Literate CoffeeScript: type: programming group: CoffeeScript @@ -771,10 +1052,6 @@ LiveScript: Logos: type: programming primary_extension: .xm - extensions: - - .x - - .xi - - .xmi Logtalk: type: programming @@ -790,13 +1067,17 @@ Lua: extensions: - .nse - .rbxs + interpreters: + - lua M: type: programming lexer: Common Lisp aliases: - mumps - primary_extension: .m + primary_extension: .mumps + extensions: + - .m Makefile: aliases: @@ -809,6 +1090,8 @@ Makefile: - makefile - Makefile - GNUmakefile + interpreters: + - make Mako: primary_extension: .mako @@ -816,7 +1099,7 @@ Mako: - .mao Markdown: - type: markup + type: prose lexer: Text only ace_mode: markdown wrap: true @@ -827,6 +1110,18 @@ Markdown: - .mkdown - .ron +Mask: + type: markup + lexer: SCSS + color: "#f97732" + ace_mode: scss + primary_extension: .mask + +Mathematica: + type: programming + primary_extension: .mathematica + lexer: Text only + Matlab: type: programming color: "#bb92ac" @@ -835,15 +1130,23 @@ Matlab: Max: type: programming color: "#ce279c" - lexer: Text only + lexer: JSON aliases: - max/msp - maxmsp search_term: max/msp - primary_extension: .mxt + primary_extension: .maxpat extensions: - .maxhelp - - .maxpat + - .maxproj + - .mxt + - .pat + +MediaWiki: + type: prose + lexer: Text only + wrap: true + primary_extension: .mediawiki MiniD: # Legacy searchable: false @@ -884,6 +1187,12 @@ Nemerle: color: "#0d3c6e" primary_extension: .n +NetLogo: + type: programming + lexer: Common Lisp + color: "#ff2b2b" + primary_extension: .nlogo + Nginx: type: markup lexer: Nginx configuration file @@ -920,6 +1229,7 @@ OCaml: primary_extension: .ml extensions: - .eliomi + - .ml4 - .mli - .mll - .mly @@ -974,6 +1284,24 @@ OpenEdge ABL: - abl primary_extension: .p +Org: + type: prose + lexer: Text only + wrap: true + primary_extension: .org + +Oxygene: + type: programming + lexer: Text only + color: "#5a63a3" + primary_extension: .oxygene + +PAWN: + type: programming + lexer: C++ + color: "#dbb284" + primary_extension: .pwn + PHP: type: programming ace_mode: php @@ -1027,13 +1355,27 @@ Perl: primary_extension: .pl extensions: - .PL - - .nqp - .perl - .ph - .plx - - .pm6 + - .pm - .pod - .psgi + interpreters: + - perl + +Perl6: + type: programming + color: "#0298c3" + primary_extension: .p6 + extensions: + - .6pl + - .6pm + - .nqp + - .p6l + - .p6m + - .pl6 + - .pm6 Pike: type: programming @@ -1043,18 +1385,34 @@ Pike: extensions: - .pmod +Pod: + type: prose + lexer: Text only + ace_mode: perl + wrap: true + primary_extension: .pod + PogoScript: type: programming color: "#d80074" lexer: Text only primary_extension: .pogo +PostScript: + type: markup + primary_extension: .ps + extensions: + - .eps + PowerShell: type: programming ace_mode: powershell aliases: - posh primary_extension: .ps1 + extensions: + - .psd1 + - .psm1 Processing: type: programming @@ -1067,7 +1425,15 @@ Prolog: color: "#74283c" primary_extension: .prolog extensions: - - .pro + - .ecl + - .pl + +Protocol Buffer: + type: markup + aliases: + - protobuf + - Protocol Buffers + primary_extension: .proto Puppet: type: programming @@ -1091,12 +1457,17 @@ Python: primary_extension: .py extensions: - .gyp + - .lmi - .pyt - .pyw - .wsgi - .xpy filenames: - wscript + - SConstruct + - SConscript + interpreters: + - python Python traceback: type: data @@ -1105,19 +1476,58 @@ Python traceback: searchable: false primary_extension: .pytb +QML: + type: markup + color: "#44a51c" + primary_extension: .qml + R: type: programming color: "#198ce7" lexer: S + aliases: + - R primary_extension: .r + extensions: + - .R + - .rsx filenames: - .Rprofile + interpreters: + - Rscript + +RDoc: + type: prose + lexer: Text only + ace_mode: rdoc + wrap: true + primary_extension: .rdoc + +REALbasic: + type: programming + lexer: VB.net + primary_extension: .rbbas + extensions: + - .rbfrm + - .rbmnu + - .rbres + - .rbtbar + - .rbuistate RHTML: type: markup group: HTML primary_extension: .rhtml +RMarkdown: + type: prose + lexer: Text only + wrap: true + ace_mode: markdown + primary_extension: .rmd + extensions: + - .Rmd + Racket: type: programming lexer: Racket @@ -1151,6 +1561,12 @@ Rebol: Redcode: primary_extension: .cw +RobotFramework: + type: programming + primary_extension: .robot + # extensions: + # - .txt + Rouge: type: programming lexer: Clojure @@ -1174,6 +1590,7 @@ Ruby: - .gemspec - .god - .irbrc + - .mspec - .podspec - .rbuild - .rbw @@ -1181,9 +1598,13 @@ Ruby: - .ru - .thor - .watchr + interpreters: + - ruby filenames: + - Appraisals - Berksfile - Gemfile + - Gemfile.lock - Guardfile - Podfile - Thorfile @@ -1222,14 +1643,27 @@ Scala: ace_mode: scala color: "#7dd3b0" primary_extension: .scala + extensions: + - .sc + +Scaml: + group: HTML + type: markup + primary_extension: .scaml Scheme: type: programming color: "#1e4aec" primary_extension: .scm extensions: + - .sld - .sls - .ss + interpreters: + - guile + - racket + - bigloo + - chicken Scilab: type: programming @@ -1252,10 +1686,21 @@ Shell: - zsh primary_extension: .sh extensions: + - .bats - .tmux + interpreters: + - bash + - sh + - zsh filenames: - Dockerfile +Shen: + type: programming + color: "#120F14" + lexer: Text only + primary_extension: .shen + Slash: type: programming color: "#007eff" @@ -1280,12 +1725,29 @@ Standard ML: aliases: - sml primary_extension: .sml + extensions: + - .fun + +Stylus: + type: markup + group: CSS + lexer: Text only + primary_extension: .styl SuperCollider: type: programming color: "#46390b" lexer: Text only - primary_extension: .sc + primary_extension: .scd + +SystemVerilog: + type: programming + color: "#343761" + lexer: systemverilog + primary_extension: .sv + extensions: + - .svh + - .vh TOML: type: data @@ -1300,6 +1762,9 @@ Tcl: type: programming color: "#e4cc98" primary_extension: .tcl + extensions: + - .adp + - .tm Tcsh: type: programming @@ -1310,15 +1775,22 @@ Tcsh: TeX: type: markup + color: "#3D6117" ace_mode: latex + wrap: true aliases: - latex primary_extension: .tex extensions: - .aux + - .bib + - .cls - .dtx - .ins - .ltx + - .mkii + - .mkiv + - .mkvi - .sty - .toc @@ -1327,7 +1799,7 @@ Tea: primary_extension: .tea Textile: - type: markup + type: prose lexer: Text only ace_mode: textile wrap: true @@ -1362,11 +1834,25 @@ Unified Parallel C: color: "#755223" primary_extension: .upc +UnrealScript: + type: programming + color: "#a54c4d" + lexer: Java + primary_extension: .uc + VHDL: type: programming lexer: vhdl color: "#543978" primary_extension: .vhdl + extensions: + - .vhd + - .vhf + - .vhi + - .vho + - .vhs + - .vht + - .vhw Vala: type: programming @@ -1381,9 +1867,7 @@ Verilog: color: "#848bf3" primary_extension: .v extensions: - - .sv - - .svh - - .vh + - .veo VimL: type: programming @@ -1393,6 +1877,7 @@ VimL: - vim primary_extension: .vim filenames: + - .vimrc - vimrc - gvimrc @@ -1403,8 +1888,10 @@ Visual Basic: primary_extension: .vb extensions: - .bas + - .frm - .frx - .vba + - .vbhtml - .vbs Volt: @@ -1429,18 +1916,27 @@ XML: extensions: - .axml - .ccxml + - .clixml + - .cproject - .dita - .ditamap - .ditaval - .glade - .grxml + - .jelly - .kml + - .launch - .mxml + - .osm - .plist + - .pluginspec + - .ps1xml + - .psc1 - .pt - .rdf - .rss - .scxml + - .srdf - .svg - .tmCommand - .tmLanguage @@ -1449,12 +1945,14 @@ XML: - .tmTheme - .tml - .ui + - .urdf - .vxml - .wsdl - .wxi - .wxl - .wxs - .x3d + - .xacro - .xaml - .xlf - .xliff @@ -1465,6 +1963,7 @@ XML: filenames: - .classpath - .project + - phpunit.xml.dist XProc: type: programming @@ -1479,6 +1978,8 @@ XQuery: primary_extension: .xquery extensions: - .xq + - .xql + - .xqm - .xqy XS: @@ -1504,6 +2005,7 @@ YAML: primary_extension: .yml extensions: - .reek + - .rviz - .yaml eC: @@ -1530,6 +2032,11 @@ mupad: lexer: MuPAD primary_extension: .mu +nesC: + type: programming + color: "#ffce3b" + primary_extension: .nc + ooc: type: programming lexer: Ooc @@ -1537,7 +2044,7 @@ ooc: primary_extension: .ooc reStructuredText: - type: markup + type: prose wrap: true search_term: rst aliases: @@ -1552,3 +2059,9 @@ wisp: ace_mode: clojure color: "#7582D1" primary_extension: .wisp + +xBase: + type: programming + lexer: Text only + color: "#3a4040" + primary_extension: .prg diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 4b34be0a..a62bf281 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -29,6 +29,7 @@ module Linguist @computed_stats = false @language = @size = nil @sizes = Hash.new { 0 } + @file_breakdown = Hash.new { |h,k| h[k] = Array.new } end # Public: Returns a breakdown of language stats. @@ -60,6 +61,12 @@ module Linguist @size end + # Public: Return the language breakdown of this repository by file + def breakdown_by_file + compute_stats + @file_breakdown + end + # Internal: Compute language breakdown for each blob in the Repository. # # Returns nothing @@ -75,6 +82,10 @@ module Linguist # Only include programming languages and acceptable markup languages if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) + + # Build up the per-file breakdown stats + @file_breakdown[blob.language.group.name] << blob.name + @sizes[blob.language.group] += blob.size end end diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 56a3d875..5eaff50e 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -3,6 +3,9 @@ "ABAP": [ ".abap" ], + "Agda": [ + ".agda" + ], "Apex": [ ".cls" ], @@ -12,26 +15,65 @@ "Arduino": [ ".ino" ], + "AsciiDoc": [ + ".adoc", + ".asc", + ".asciidoc" + ], + "AspectJ": [ + ".aj" + ], + "ATS": [ + ".atxt", + ".dats", + ".hats", + ".sats" + ], "AutoHotkey": [ ".ahk" ], "Awk": [ ".awk" ], + "BlitzBasic": [ + ".bb" + ], + "Bluespec": [ + ".bsv" + ], + "Brightscript": [ + ".brs" + ], "C": [ ".c", + ".cats", ".h" ], + "C#": [ + ".cs", + ".cshtml" + ], "C++": [ ".cc", ".cpp", - ".cu", ".h", ".hpp" ], "Ceylon": [ ".ceylon" ], + "Cirru": [ + ".cirru" + ], + "Clojure": [ + ".cl2", + ".clj", + ".cljc", + ".cljs", + ".cljscm", + ".cljx", + ".hic" + ], "COBOL": [ ".cbl", ".ccp", @@ -41,19 +83,39 @@ "CoffeeScript": [ ".coffee" ], + "Common Lisp": [ + ".lisp" + ], "Coq": [ ".v" ], + "Creole": [ + ".creole" + ], "CSS": [ ".css" ], + "Cuda": [ + ".cu", + ".cuh" + ], "Dart": [ ".dart" ], "Diff": [ ".patch" ], - "Ecl": [ + "DM": [ + ".dm" + ], + "Dogescript": [ + ".djs" + ], + "Eagle": [ + ".brd", + ".sch" + ], + "ECL": [ ".ecl" ], "edn": [ @@ -77,6 +139,12 @@ ".forth", ".fth" ], + "Frege": [ + ".fr" + ], + "Game Maker Language": [ + ".gml" + ], "GAS": [ ".s" ], @@ -84,9 +152,12 @@ ".fp", ".glsl" ], + "Gnuplot": [ + ".gnu", + ".gp" + ], "Gosu": [ ".gs", - ".gsp", ".gst", ".gsx", ".vark" @@ -105,9 +176,22 @@ ".handlebars", ".hbs" ], + "Hy": [ + ".hy" + ], + "IDL": [ + ".dlm", + ".pro" + ], + "Idris": [ + ".idr" + ], "Ioke": [ ".ik" ], + "Jade": [ + ".jade" + ], "Java": [ ".java" ], @@ -117,8 +201,13 @@ ], "JSON": [ ".json", - ".maxhelp", - ".maxpat" + ".lock" + ], + "JSON5": [ + ".json5" + ], + "JSONLD": [ + ".jsonld" ], "Julia": [ ".jl" @@ -126,6 +215,9 @@ "Kotlin": [ ".kt" ], + "KRL": [ + ".krl" + ], "Lasso": [ ".las", ".lasso", @@ -135,6 +227,12 @@ "Less": [ ".less" ], + "LFE": [ + ".lfe" + ], + "Literate Agda": [ + ".lagda" + ], "Literate CoffeeScript": [ ".litcoffee" ], @@ -159,12 +257,23 @@ "Markdown": [ ".md" ], + "Mask": [ + ".mask" + ], + "Mathematica": [ + ".m" + ], "Matlab": [ ".m" ], "Max": [ + ".maxhelp", + ".maxpat", ".mxt" ], + "MediaWiki": [ + ".mediawiki" + ], "Monkey": [ ".monkey" ], @@ -174,6 +283,9 @@ "Nemerle": [ ".n" ], + "NetLogo": [ + ".nlogo" + ], "Nimrod": [ ".nim" ], @@ -206,6 +318,12 @@ ".cls", ".p" ], + "Org": [ + ".org" + ], + "Oxygene": [ + ".oxygene" + ], "Parrot Assembly": [ ".pasm" ], @@ -215,6 +333,9 @@ "Pascal": [ ".dpr" ], + "PAWN": [ + ".pwn" + ], "Perl": [ ".fcgi", ".pl", @@ -222,14 +343,24 @@ ".script!", ".t" ], + "Perl6": [ + ".p6", + ".pm6" + ], "PHP": [ ".module", ".php", ".script!" ], + "Pod": [ + ".pod" + ], "PogoScript": [ ".pogo" ], + "PostScript": [ + ".ps" + ], "PowerShell": [ ".ps1", ".psm1" @@ -238,7 +369,12 @@ ".pde" ], "Prolog": [ - ".pl" + ".ecl", + ".pl", + ".prolog" + ], + "Protocol Buffer": [ + ".proto" ], "Python": [ ".py", @@ -246,18 +382,27 @@ ], "R": [ ".R", + ".rsx", ".script!" ], "Racket": [ - ".scrbl", - ".script!" + ".scrbl" ], "Ragel in Ruby Host": [ ".rl" ], + "RDoc": [ + ".rdoc" + ], "Rebol": [ ".r" ], + "RMarkdown": [ + ".rmd" + ], + "RobotFramework": [ + ".robot" + ], "Ruby": [ ".pluginspec", ".rabl", @@ -274,9 +419,14 @@ ], "Scala": [ ".sbt", + ".sc", ".script!" ], + "Scaml": [ + ".scaml" + ], "Scheme": [ + ".sld", ".sps" ], "Scilab": [ @@ -293,17 +443,34 @@ ".sh", ".zsh" ], + "Shen": [ + ".shen" + ], "Slash": [ ".sl" ], + "Squirrel": [ + ".nut" + ], "Standard ML": [ + ".fun", ".sig", ".sml" ], + "Stylus": [ + ".styl" + ], "SuperCollider": [ - ".sc", ".scd" ], + "SystemVerilog": [ + ".sv", + ".svh", + ".vh" + ], + "Tcl": [ + ".tm" + ], "Tea": [ ".tea" ], @@ -319,6 +486,9 @@ "TypeScript": [ ".ts" ], + "UnrealScript": [ + ".uc" + ], "Verilog": [ ".v" ], @@ -326,7 +496,9 @@ ".vhd" ], "Visual Basic": [ - ".cls" + ".cls", + ".vb", + ".vbhtml" ], "Volt": [ ".volt" @@ -353,7 +525,13 @@ ], "Xtend": [ ".xtend" + ], + "YAML": [ + ".yml" ] + }, + "interpreters": { + }, "filenames": { "ApacheConf": [ @@ -375,6 +553,7 @@ "ack" ], "Ruby": [ + "Appraisals", "Capfile", "Rakefile" ], @@ -412,8 +591,8 @@ ".gemrc" ] }, - "tokens_total": 411886, - "languages_total": 447, + "tokens_total": 506816, + "languages_total": 591, "tokens": { "ABAP": { "*/**": 1, @@ -674,6 +853,64 @@ "pos": 2, "endclass.": 1 }, + "Agda": { + "module": 3, + "NatCat": 1, + "where": 2, + "open": 2, + "import": 2, + "Relation.Binary.PropositionalEquality": 1, + "-": 21, + "If": 1, + "you": 2, + "can": 1, + "show": 1, + "that": 1, + "a": 1, + "relation": 1, + "only": 1, + "ever": 1, + "has": 1, + "one": 1, + "inhabitant": 5, + "get": 1, + "the": 1, + "category": 1, + "laws": 1, + "for": 1, + "free": 1, + "EasyCategory": 3, + "(": 36, + "obj": 4, + "Set": 2, + ")": 36, + "_": 6, + "{": 10, + "x": 34, + "y": 28, + "z": 18, + "}": 10, + "id": 9, + "single": 4, + "r": 26, + "s": 29, + "assoc": 2, + "w": 4, + "t": 6, + "Data.Nat": 1, + "same": 5, + ".0": 2, + "n": 14, + "refl": 6, + ".": 5, + "suc": 6, + "m": 6, + "cong": 1, + "trans": 5, + ".n": 1, + "zero": 1, + "Nat": 1 + }, "ApacheConf": { "ServerSignature": 1, "Off": 1, @@ -1784,6 +2021,712 @@ "loop": 1, "Serial.print": 1 }, + "AsciiDoc": { + "Gregory": 2, + "Rom": 2, + "has": 2, + "written": 2, + "an": 2, + "AsciiDoc": 3, + "plugin": 2, + "for": 2, + "the": 2, + "Redmine": 2, + "project": 2, + "management": 2, + "application.": 2, + "https": 1, + "//github.com/foo": 1, + "-": 4, + "users/foo": 1, + "vicmd": 1, + "gif": 1, + "tag": 1, + "rom": 2, + "[": 2, + "]": 2, + "end": 1, + "berschrift": 1, + "*": 4, + "Codierungen": 1, + "sind": 1, + "verr": 1, + "ckt": 1, + "auf": 1, + "lteren": 1, + "Versionen": 1, + "von": 1, + "Ruby": 1, + "Home": 1, + "Page": 1, + "Example": 1, + "Articles": 1, + "Item": 6, + "Document": 1, + "Title": 1, + "Doc": 1, + "Writer": 1, + "": 1, + "idprefix": 1, + "id_": 1, + "Preamble": 1, + "paragraph.": 4, + "NOTE": 1, + "This": 1, + "is": 1, + "test": 1, + "only": 1, + "a": 1, + "test.": 1, + "Section": 3, + "A": 2, + "*Section": 3, + "A*": 2, + "Subsection": 1, + "B": 2, + "B*": 1, + ".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, + "staload": 25, + "_": 25, + "sortdef": 2, + "ftype": 13, + "type": 30, + "-": 49, + "infixr": 2, + "(": 562, + ")": 567, + "typedef": 10, + "a": 200, + "b": 26, + "": 2, + "functor": 12, + "F": 34, + "{": 142, + "}": 141, + "list0": 9, + "extern": 13, + "val": 95, + "functor_list0": 7, + "implement": 55, + "f": 22, + "lam": 20, + "xs": 82, + "list0_map": 2, + "": 14, + "": 3, + "datatype": 4, + "CoYoneda": 7, + "r": 25, + "of": 59, + "fun": 56, + "CoYoneda_phi": 2, + "CoYoneda_psi": 3, + "ftor": 9, + "fx": 8, + "x": 48, + "int0": 4, + "I": 8, + "int": 2, + "bool": 27, + "True": 7, + "|": 22, + "False": 8, + "boxed": 2, + "boolean": 2, + "bool2string": 4, + "string": 2, + "case": 9, + "+": 20, + "fprint_val": 2, + "": 2, + "out": 8, + "fprint": 3, + "int2bool": 2, + "i": 6, + "let": 34, + "in": 48, + "if": 7, + "then": 11, + "else": 7, + "end": 73, + "myintlist0": 2, + "g0ofg1": 1, + "list": 1, + "myboolist0": 9, + "fprintln": 3, + "stdout_ref": 4, + "main0": 3, + "UN": 3, + "phil_left": 3, + "n": 51, + "phil_right": 3, + "nmod": 1, + "NPHIL": 6, + "randsleep": 6, + "intGte": 1, + "void": 14, + "ignoret": 2, + "sleep": 2, + "UN.cast": 2, + "uInt": 1, + "rand": 1, + "mod": 1, + "phil_think": 3, + "println": 9, + "phil_dine": 3, + "lf": 5, + "rf": 5, + "phil_loop": 10, + "nl": 2, + "nr": 2, + "ch_lfork": 2, + "fork_changet": 5, + "ch_rfork": 2, + "channel_takeout": 4, + "HX": 1, + "try": 1, + "to": 16, + "actively": 1, + "induce": 1, + "deadlock": 2, + "ch_forktray": 3, + "forktray_changet": 4, + "channel_insert": 5, + "[": 49, + "]": 48, + "cleaner_wash": 3, + "fork_get_num": 4, + "cleaner_return": 4, + "ch": 7, + "cleaner_loop": 6, + "f0": 3, + "dynload": 3, + "local": 10, + "mythread_create_cloptr": 6, + "llam": 6, + "while": 1, + "true": 5, + "%": 7, + "#": 7, + "#define": 4, + "nphil": 13, + "natLt": 2, + "absvtype": 2, + "fork_vtype": 3, + "ptr": 2, + "vtypedef": 2, + "fork": 16, + "channel": 11, + "datavtype": 1, + "FORK": 3, + "assume": 2, + "the_forkarray": 2, + "t": 1, + "array_tabulate": 1, + "fopr": 1, + "": 2, + "where": 6, + "channel_create_exn": 2, + "": 2, + "i2sz": 4, + "arrayref_tabulate": 1, + "the_forktray": 2, + "set_vtype": 3, + "t@ype": 2, + "set": 34, + "t0p": 31, + "compare_elt_elt": 4, + "x1": 1, + "x2": 1, + "<": 14, + "linset_nil": 2, + "linset_make_nil": 2, + "linset_sing": 2, + "": 16, + "linset_make_sing": 2, + "linset_make_list": 1, + "List": 1, + "INV": 24, + "linset_is_nil": 2, + "linset_isnot_nil": 2, + "linset_size": 2, + "size_t": 1, + "linset_is_member": 3, + "x0": 22, + "linset_isnot_member": 1, + "linset_copy": 2, + "linset_free": 2, + "linset_insert": 3, + "&": 17, + "linset_takeout": 1, + "res": 9, + "opt": 6, + "endfun": 1, + "linset_takeout_opt": 1, + "Option_vt": 4, + "linset_remove": 2, + "linset_choose": 3, + "linset_choose_opt": 1, + "linset_takeoutmax": 1, + "linset_takeoutmax_opt": 1, + "linset_takeoutmin": 1, + "linset_takeoutmin_opt": 1, + "fprint_linset": 3, + "sep": 1, + "FILEref": 2, + "overload": 1, + "with": 1, + "env": 11, + "vt0p": 2, + "linset_foreach": 3, + "fwork": 3, + "linset_foreach_env": 3, + "linset_listize": 2, + "List0_vt": 5, + "linset_listize1": 2, + "code": 6, + "reuse": 2, + "elt": 2, + "list_vt_nil": 16, + "list_vt_cons": 17, + "list_vt_is_nil": 1, + "list_vt_is_cons": 1, + "list_vt_length": 1, + "aux": 4, + "nat": 4, + ".": 14, + "": 3, + "list_vt": 7, + "sgn": 9, + "false": 6, + "list_vt_copy": 2, + "list_vt_free": 1, + "mynode_cons": 4, + "nx": 22, + "mynode1": 6, + "xs1": 15, + "UN.castvwtp0": 8, + "List1_vt": 5, + "@list_vt_cons": 5, + "xs2": 3, + "prval": 20, + "UN.cast2void": 5, + ";": 4, + "fold@": 8, + "ins": 3, + "tail": 1, + "recursive": 1, + "n1": 4, + "<=>": 1, + "1": 3, + "mynode_make_elt": 4, + "ans": 2, + "is": 26, + "found": 1, + "effmask_all": 3, + "free@": 1, + "xs1_": 3, + "rem": 1, + "*": 2, + "opt_some": 1, + "opt_none": 1, + "list_vt_foreach": 1, + "": 3, + "list_vt_foreach_env": 1, + "mynode_null": 5, + "mynode": 3, + "null": 1, + "the_null_ptr": 1, + "mynode_free": 1, + "nx2": 4, + "mynode_get_elt": 1, + "nx1": 7, + "UN.castvwtp1": 2, + "mynode_set_elt": 1, + "l": 3, + "__assert": 2, + "praxi": 1, + "mynode_getfree_elt": 1, + "linset_takeout_ngc": 2, + "takeout": 3, + "mynode0": 1, + "pf_x": 6, + "view@x": 3, + "pf_xs1": 6, + "view@xs1": 3, + "linset_takeoutmax_ngc": 2, + "xs_": 4, + "@list_vt_nil": 1, + "linset_takeoutmin_ngc": 2, + "unsnoc": 4, + "pos": 1, + "and": 10, + "fold@xs": 1, + "ATS_PACKNAME": 1, + "ATS_STALOADFLAG": 1, + "no": 2, + "static": 1, + "loading": 1, + "at": 2, + "run": 1, + "time": 1, + "castfn": 1, + "linset2list": 1, + "": 1, + "html": 1, + "PUBLIC": 1, + "W3C": 1, + "DTD": 2, + "XHTML": 1, + "EN": 1, + "http": 2, + "www": 1, + "w3": 1, + "org": 1, + "TR": 1, + "xhtml11": 2, + "dtd": 1, + "": 1, + "xmlns=": 1, + "": 1, + "": 1, + "equiv=": 1, + "content=": 1, + "": 1, + "EFFECTIVATS": 1, + "DiningPhil2": 1, + "": 1, + "#patscode_style": 1, + "": 1, + "": 1, + "

": 1, + "Effective": 1, + "ATS": 2, + "Dining": 2, + "Philosophers": 2, + "

": 1, + "In": 2, + "this": 2, + "article": 2, + "present": 1, + "an": 6, + "implementation": 3, + "slight": 1, + "variant": 1, + "the": 30, + "famous": 1, + "problem": 1, + "by": 4, + "Dijkstra": 1, + "that": 8, + "makes": 1, + "simple": 1, + "but": 1, + "convincing": 1, + "use": 1, + "linear": 2, + "types.": 1, + "

": 8, + "The": 8, + "Original": 2, + "Problem": 2, + "

": 8, + "There": 3, + "are": 7, + "five": 1, + "philosophers": 1, + "sitting": 1, + "around": 1, + "table": 3, + "there": 3, + "also": 3, + "forks": 7, + "placed": 1, + "on": 8, + "such": 1, + "each": 2, + "located": 2, + "between": 1, + "left": 3, + "hand": 6, + "philosopher": 5, + "right": 3, + "another": 1, + "philosopher.": 1, + "Each": 4, + "does": 1, + "following": 6, + "routine": 1, + "repeatedly": 1, + "thinking": 1, + "dining.": 1, + "order": 1, + "dine": 1, + "needs": 2, + "first": 2, + "acquire": 1, + "two": 3, + "one": 3, + "his": 4, + "side": 2, + "other": 2, + "side.": 2, + "After": 2, + "finishing": 1, + "dining": 1, + "puts": 2, + "acquired": 1, + "onto": 1, + "A": 6, + "Variant": 1, + "twist": 1, + "added": 1, + "original": 1, + "version": 1, + "

": 1, + "used": 1, + "it": 2, + "becomes": 1, + "be": 9, + "put": 1, + "tray": 2, + "for": 15, + "dirty": 2, + "forks.": 1, + "cleaner": 2, + "who": 1, + "cleans": 1, + "them": 2, + "back": 1, + "table.": 1, + "Channels": 1, + "Communication": 1, + "just": 1, + "shared": 1, + "queue": 1, + "fixed": 1, + "capacity.": 1, + "functions": 1, + "inserting": 1, + "element": 5, + "into": 3, + "taking": 1, + "given": 4, + "

": 7,
+      "class=": 6,
+      "#pats2xhtml_sats": 3,
+      "
": 7, + "If": 2, + "called": 2, + "full": 4, + "caller": 2, + "blocked": 3, + "until": 2, + "taken": 1, + "channel.": 2, + "empty": 1, + "inserted": 1, + "Channel": 2, + "Fork": 3, + "Forks": 1, + "resources": 1, + "type.": 1, + "initially": 1, + "stored": 2, + "which": 2, + "can": 4, + "obtained": 2, + "calling": 2, + "function": 3, + "defined": 1, + "natural": 1, + "numbers": 1, + "less": 1, + "than": 1, + "channels": 4, + "storing": 3, + "chosen": 3, + "capacity": 3, + "reason": 1, + "store": 1, + "most": 1, + "guarantee": 1, + "these": 1, + "never": 2, + "so": 2, + "attempt": 1, + "made": 1, + "send": 1, + "signals": 1, + "awake": 1, + "callers": 1, + "supposedly": 1, + "being": 2, + "due": 1, + "Tray": 1, + "instead": 1, + "become": 1, + "as": 4, + "only": 1, + "total": 1, + "Philosopher": 1, + "Loop": 2, + "implemented": 2, + "loop": 2, + "#pats2xhtml_dats": 3, + "It": 2, + "should": 3, + "straighforward": 2, + "follow": 2, + "Cleaner": 1, + "finds": 1, + "number": 2, + "uses": 1, + "locate": 1, + "fork.": 1, + "Its": 1, + "actual": 1, + "follows": 1, + "now": 1, + "Testing": 1, + "entire": 1, + "files": 1, + "DiningPhil2.sats": 1, + "DiningPhil2.dats": 1, + "DiningPhil2_fork.dats": 1, + "DiningPhil2_thread.dats": 1, + "Makefile": 1, + "available": 1, + "compiling": 1, + "source": 1, + "excutable": 1, + "testing.": 1, + "One": 1, + "able": 1, + "encounter": 1, + "after": 1, + "running": 1, + "simulation": 1, + "while.": 1, + "
": 1, + "size=": 1, + "This": 1, + "written": 1, + "href=": 1, + "Hongwei": 1, + "Xi": 1, + "
": 1, + "": 1, + "": 1, + "main": 1, + "fprint_filsub": 1, + "option0": 3, + "functor_option0": 2, + "option0_map": 1, + "functor_homres": 2, + "c": 3, + "Yoneda_phi": 3, + "Yoneda_psi": 3, + "m": 4, + "mf": 4, + "natrans": 3, + "G": 2, + "Yoneda_phi_nat": 2, + "Yoneda_psi_nat": 2, + "list_t": 1, + "g0ofg1_list": 1, + "Yoneda_bool_list0": 3, + "myboolist1": 2 + }, "AutoHotkey": { "MsgBox": 1, "Hello": 1, @@ -1902,21 +2845,831 @@ "fragments": 1, "END": 1 }, + "BlitzBasic": { + "Local": 34, + "bk": 3, + "CreateBank": 5, + "(": 125, + ")": 126, + "PokeFloat": 3, + "-": 24, + "Print": 13, + "Bin": 4, + "PeekInt": 4, + "%": 6, + "Shl": 7, + "f": 5, + "ff": 1, + "+": 11, + "Hex": 2, + "FloatToHalf": 3, + "HalfToFloat": 1, + "FToI": 2, + "WaitKey": 2, + "End": 58, + ";": 57, + "Half": 1, + "precision": 2, + "bit": 2, + "arithmetic": 2, + "library": 2, + "Global": 2, + "Half_CBank_": 13, + "Function": 101, + "f#": 3, + "If": 25, + "Then": 18, + "Return": 36, + "HalfToFloat#": 1, + "h": 4, + "signBit": 6, + "exponent": 22, + "fraction": 9, + "fBits": 8, + "And": 8, + "<": 18, + "Shr": 3, + "F": 3, + "FF": 2, + "ElseIf": 1, + "Or": 4, + "PokeInt": 2, + "PeekFloat": 1, + "F800000": 1, + "FFFFF": 1, + "Abs": 1, + "*": 2, + "Sgn": 1, + "Else": 7, + "EndIf": 7, + "HalfAdd": 1, + "l": 84, + "r": 12, + "HalfSub": 1, + "HalfMul": 1, + "HalfDiv": 1, + "HalfLT": 1, + "HalfGT": 1, + "Double": 2, + "DoubleOut": 1, + "[": 2, + "]": 2, + "Double_CBank_": 1, + "DoubleToFloat#": 1, + "d": 1, + "FloatToDouble": 1, + "IntToDouble": 1, + "i": 49, + "SefToDouble": 1, + "s": 12, + "e": 4, + "DoubleAdd": 1, + "DoubleSub": 1, + "DoubleMul": 1, + "DoubleDiv": 1, + "DoubleLT": 1, + "DoubleGT": 1, + "IDEal": 3, + "Editor": 3, + "Parameters": 3, + "F#1A#20#2F": 1, + "C#Blitz3D": 3, + "linked": 2, + "list": 32, + "container": 1, + "class": 1, + "with": 3, + "thanks": 1, + "to": 11, + "MusicianKool": 3, + "for": 3, + "concept": 1, + "and": 9, + "issue": 1, + "fixes": 1, + "Type": 8, + "LList": 3, + "Field": 10, + "head_.ListNode": 1, + "tail_.ListNode": 1, + "ListNode": 8, + "pv_.ListNode": 1, + "nx_.ListNode": 1, + "Value": 37, + "Iterator": 2, + "l_.LList": 1, + "cn_.ListNode": 1, + "cni_": 8, + "Create": 4, + "a": 46, + "new": 4, + "object": 2, + "CreateList.LList": 1, + "l.LList": 20, + "New": 11, + "head_": 35, + "tail_": 34, + "nx_": 33, + "caps": 1, + "pv_": 27, + "These": 1, + "make": 1, + "it": 1, + "more": 1, + "or": 4, + "less": 1, + "safe": 1, + "iterate": 2, + "freely": 1, + "Free": 1, + "all": 3, + "elements": 4, + "not": 4, + "any": 1, + "values": 4, + "FreeList": 1, + "ClearList": 2, + "Delete": 6, + "Remove": 7, + "the": 52, + "from": 15, + "does": 1, + "free": 1, + "n.ListNode": 12, + "While": 7, + "n": 54, + "nx.ListNode": 1, + "nx": 1, + "Wend": 6, + "Count": 1, + "number": 1, + "of": 16, + "in": 4, + "slow": 3, + "ListLength": 2, + "i.Iterator": 6, + "GetIterator": 3, + "elems": 4, + "EachIn": 5, + "True": 4, + "if": 2, + "contains": 1, + "given": 7, + "value": 16, + "ListContains": 1, + "ListFindNode": 2, + "Null": 15, + "intvalues": 1, + "bank": 8, + "ListFromBank.LList": 1, + "CreateList": 2, + "size": 4, + "BankSize": 1, + "p": 7, + "For": 6, + "To": 6, + "Step": 2, + "ListAddLast": 2, + "Next": 7, + "containing": 3, + "ListToBank": 1, + "Swap": 1, + "contents": 1, + "two": 1, + "objects": 1, + "SwapLists": 1, + "l1.LList": 1, + "l2.LList": 1, + "tempH.ListNode": 1, + "l1": 4, + "tempT.ListNode": 1, + "l2": 4, + "tempH": 1, + "tempT": 1, + "same": 1, + "as": 2, + "first": 5, + "CopyList.LList": 1, + "lo.LList": 1, + "ln.LList": 1, + "lo": 1, + "ln": 2, + "Reverse": 1, + "order": 1, + "ReverseList": 1, + "n1.ListNode": 1, + "n2.ListNode": 1, + "tmp.ListNode": 1, + "n1": 5, + "n2": 6, + "tmp": 4, + "Search": 1, + "retrieve": 1, + "node": 8, + "ListFindNode.ListNode": 1, + "Append": 1, + "end": 5, + "fast": 2, + "return": 7, + "ListAddLast.ListNode": 1, + "Attach": 1, + "start": 13, + "ListAddFirst.ListNode": 1, + "occurence": 1, + "ListRemove": 1, + "RemoveListNode": 6, + "element": 4, + "at": 5, + "position": 4, + "backwards": 2, + "negative": 2, + "index": 13, + "ValueAtIndex": 1, + "ListNodeAtIndex": 3, + "invalid": 1, + "ListNodeAtIndex.ListNode": 1, + "Beyond": 1, + "valid": 2, + "Negative": 1, + "count": 1, + "backward": 1, + "Before": 3, + "Replace": 1, + "added": 2, + "by": 3, + "ReplaceValueAtIndex": 1, + "RemoveNodeAtIndex": 1, + "tval": 3, + "Retrieve": 2, + "ListFirst": 1, + "last": 2, + "ListLast": 1, + "its": 2, + "ListRemoveFirst": 1, + "val": 6, + "ListRemoveLast": 1, + "Insert": 3, + "into": 2, + "before": 2, + "specified": 2, + "InsertBeforeNode.ListNode": 1, + "bef.ListNode": 1, + "bef": 7, + "after": 1, + "then": 1, + "InsertAfterNode.ListNode": 1, + "aft.ListNode": 1, + "aft": 7, + "Get": 1, + "an": 4, + "iterator": 4, + "use": 1, + "loop": 2, + "This": 1, + "function": 1, + "means": 1, + "that": 1, + "most": 1, + "programs": 1, + "won": 1, + "available": 1, + "moment": 1, + "l_": 7, + "Exit": 1, + "there": 1, + "wasn": 1, + "t": 1, + "create": 1, + "one": 1, + "cn_": 12, + "No": 1, + "especial": 1, + "reason": 1, + "why": 1, + "this": 2, + "has": 1, + "be": 1, + "anything": 1, + "but": 1, + "meh": 1, + "Use": 1, + "argument": 1, + "over": 1, + "members": 1, + "Still": 1, + "items": 1, + "Disconnect": 1, + "having": 1, + "reached": 1, + "False": 3, + "currently": 1, + "pointed": 1, + "IteratorRemove": 1, + "temp.ListNode": 1, + "temp": 1, + "Call": 1, + "breaking": 1, + "out": 1, + "disconnect": 1, + "IteratorBreak": 1, + "F#5#A#10#18#2A#32#3E#47#4C#58#66#6F#78#8F#9B#A9#B7#BD#C5#CC": 1, + "F#E3#E9#EF#F4#F9#103#10D#11B#12B#13F#152#163": 1, + "result": 4, + "s.Sum3Obj": 2, + "Sum3Obj": 6, + "Handle": 2, + "MilliSecs": 4, + "Sum3_": 2, + "MakeSum3Obj": 2, + "Sum3": 2, + "b": 7, + "c": 7, + "isActive": 4, + "Last": 1, + "Restore": 1, + "label": 1, + "Read": 1, + "foo": 1, + ".label": 1, + "Data": 1, + "a_": 2, + "a.Sum3Obj": 1, + "Object.Sum3Obj": 1, + "return_": 2, + "First": 1 + }, + "Bluespec": { + "package": 2, + "TbTL": 1, + ";": 156, + "import": 1, + "TL": 6, + "*": 1, + "interface": 2, + "Lamp": 3, + "method": 42, + "Bool": 32, + "changed": 2, + "Action": 17, + "show_offs": 2, + "show_ons": 2, + "reset": 2, + "endinterface": 2, + "module": 3, + "mkLamp#": 1, + "(": 158, + "String": 1, + "name": 3, + "lamp": 5, + ")": 163, + "Reg#": 15, + "prev": 5, + "<": 44, + "-": 29, + "mkReg": 15, + "False": 9, + "if": 9, + "&&": 3, + "write": 2, + "+": 7, + "endmethod": 8, + "endmodule": 3, + "mkTest": 1, + "let": 1, + "dut": 2, + "sysTL": 3, + "Bit#": 1, + "ctr": 8, + "carN": 4, + "carS": 2, + "carE": 2, + "carW": 2, + "lamps": 15, + "[": 17, + "]": 17, + "mkLamp": 12, + "dut.lampRedNS": 1, + "dut.lampAmberNS": 1, + "dut.lampGreenNS": 1, + "dut.lampRedE": 1, + "dut.lampAmberE": 1, + "dut.lampGreenE": 1, + "dut.lampRedW": 1, + "dut.lampAmberW": 1, + "dut.lampGreenW": 1, + "dut.lampRedPed": 1, + "dut.lampAmberPed": 1, + "dut.lampGreenPed": 1, + "rule": 10, + "start": 1, + "dumpvars": 1, + "endrule": 10, + "detect_cars": 1, + "dut.set_car_state_N": 1, + "dut.set_car_state_S": 1, + "dut.set_car_state_E": 1, + "dut.set_car_state_W": 1, + "go": 1, + "True": 6, + "<=>": 3, + "12_000": 1, + "ped_button_push": 4, + "stop": 1, + "display": 2, + "finish": 1, + "function": 10, + "do_offs": 2, + "l": 3, + "l.show_offs": 1, + "do_ons": 2, + "l.show_ons": 1, + "do_reset": 2, + "l.reset": 1, + "do_it": 4, + "f": 2, + "action": 3, + "for": 3, + "Integer": 3, + "i": 15, + "endaction": 3, + "endfunction": 7, + "any_changes": 2, + "b": 12, + "||": 7, + ".changed": 1, + "return": 9, + "show": 1, + "time": 1, + "endpackage": 2, + "set_car_state_N": 2, + "x": 8, + "set_car_state_S": 2, + "set_car_state_E": 2, + "set_car_state_W": 2, + "lampRedNS": 2, + "lampAmberNS": 2, + "lampGreenNS": 2, + "lampRedE": 2, + "lampAmberE": 2, + "lampGreenE": 2, + "lampRedW": 2, + "lampAmberW": 2, + "lampGreenW": 2, + "lampRedPed": 2, + "lampAmberPed": 2, + "lampGreenPed": 2, + "typedef": 3, + "enum": 1, + "{": 1, + "AllRed": 4, + "GreenNS": 9, + "AmberNS": 5, + "GreenE": 8, + "AmberE": 5, + "GreenW": 8, + "AmberW": 5, + "GreenPed": 4, + "AmberPed": 3, + "}": 1, + "TLstates": 11, + "deriving": 1, + "Eq": 1, + "Bits": 1, + "UInt#": 2, + "Time32": 9, + "CtrSize": 3, + "allRedDelay": 2, + "amberDelay": 2, + "nsGreenDelay": 2, + "ewGreenDelay": 3, + "pedGreenDelay": 1, + "pedAmberDelay": 1, + "clocks_per_sec": 2, + "state": 21, + "next_green": 8, + "secs": 7, + "ped_button_pushed": 4, + "car_present_N": 3, + "car_present_S": 3, + "car_present_E": 4, + "car_present_W": 4, + "car_present_NS": 3, + "cycle_ctr": 6, + "dec_cycle_ctr": 1, + "Rules": 5, + "low_priority_rule": 2, + "rules": 4, + "inc_sec": 1, + "endrules": 4, + "next_state": 8, + "ns": 4, + "0": 2, + "green_seq": 7, + "case": 2, + "endcase": 2, + "car_present": 4, + "make_from_green_rule": 5, + "green_state": 2, + "delay": 2, + "car_is_present": 2, + "from_green": 1, + "make_from_amber_rule": 5, + "amber_state": 2, + "ng": 2, + "from_amber": 1, + "hprs": 10, + "7": 1, + "1": 1, + "2": 1, + "3": 1, + "4": 1, + "5": 1, + "6": 1, + "fromAllRed": 2, + "else": 4, + "noAction": 1, + "high_priority_rules": 4, + "rJoin": 1, + "addRules": 1, + "preempts": 1 + }, + "Brightscript": { + "**": 17, + "Simple": 1, + "Grid": 2, + "Screen": 2, + "Demonstration": 1, + "App": 1, + "Copyright": 1, + "(": 32, + "c": 1, + ")": 31, + "Roku": 1, + "Inc.": 1, + "All": 3, + "Rights": 1, + "Reserved.": 1, + "************************************************************": 2, + "Sub": 2, + "Main": 1, + "set": 2, + "to": 10, + "go": 1, + "time": 1, + "get": 1, + "started": 1, + "while": 4, + "gridstyle": 7, + "<": 1, + "print": 7, + ";": 10, + "screen": 5, + "preShowGridScreen": 2, + "showGridScreen": 2, + "end": 2, + "End": 4, + "Set": 1, + "the": 17, + "configurable": 1, + "theme": 3, + "attributes": 2, + "for": 10, + "application": 1, + "Configure": 1, + "custom": 1, + "overhang": 1, + "and": 4, + "Logo": 1, + "are": 2, + "artwork": 2, + "colors": 1, + "offsets": 1, + "specific": 1, + "app": 1, + "******************************************************": 4, + "Screens": 1, + "can": 2, + "make": 1, + "slight": 1, + "adjustments": 1, + "default": 1, + "individual": 1, + "attributes.": 1, + "these": 1, + "greyscales": 1, + "theme.GridScreenBackgroundColor": 1, + "theme.GridScreenMessageColor": 1, + "theme.GridScreenRetrievingColor": 1, + "theme.GridScreenListNameColor": 1, + "used": 1, + "in": 3, + "theme.CounterTextLeft": 1, + "theme.CounterSeparator": 1, + "theme.CounterTextRight": 1, + "theme.GridScreenLogoHD": 1, + "theme.GridScreenLogoOffsetHD_X": 1, + "theme.GridScreenLogoOffsetHD_Y": 1, + "theme.GridScreenOverhangHeightHD": 1, + "theme.GridScreenLogoSD": 1, + "theme.GridScreenOverhangHeightSD": 1, + "theme.GridScreenLogoOffsetSD_X": 1, + "theme.GridScreenLogoOffsetSD_Y": 1, + "theme.GridScreenFocusBorderSD": 1, + "theme.GridScreenFocusBorderHD": 1, + "use": 1, + "your": 1, + "own": 1, + "description": 1, + "background": 1, + "theme.GridScreenDescriptionOffsetSD": 1, + "theme.GridScreenDescriptionOffsetHD": 1, + "return": 5, + "Function": 5, + "Perform": 1, + "any": 1, + "startup/initialization": 1, + "stuff": 1, + "prior": 1, + "style": 6, + "as": 2, + "string": 3, + "As": 3, + "Object": 2, + "m.port": 3, + "CreateObject": 2, + "screen.SetMessagePort": 1, + "screen.": 1, + "The": 1, + "will": 3, + "show": 1, + "retreiving": 1, + "categoryList": 4, + "getCategoryList": 1, + "[": 3, + "]": 4, + "+": 1, + "screen.setupLists": 1, + "categoryList.count": 2, + "screen.SetListNames": 1, + "StyleButtons": 3, + "getGridControlButtons": 1, + "screen.SetContentList": 2, + "i": 3, + "-": 15, + "getShowsForCategoryItem": 1, + "screen.Show": 1, + "true": 1, + "msg": 3, + "wait": 1, + "getmessageport": 1, + "does": 1, + "not": 2, + "work": 1, + "on": 1, + "gridscreen": 1, + "type": 2, + "if": 3, + "then": 3, + "msg.GetMessage": 1, + "msg.GetIndex": 3, + "msg.getData": 2, + "msg.isListItemFocused": 1, + "else": 1, + "msg.isListItemSelected": 1, + "row": 2, + "selection": 3, + "yes": 1, + "so": 2, + "we": 3, + "come": 1, + "back": 1, + "with": 2, + "new": 1, + ".Title": 1, + "endif": 1, + "**********************************************************": 1, + "this": 3, + "function": 1, + "passing": 1, + "an": 1, + "roAssociativeArray": 2, + "be": 2, + "sufficient": 1, + "springboard": 2, + "display": 2, + "add": 1, + "code": 1, + "create": 1, + "now": 1, + "do": 1, + "nothing": 1, + "Return": 1, + "list": 1, + "of": 5, + "categories": 1, + "filter": 1, + "all": 1, + "categories.": 1, + "just": 2, + "static": 1, + "data": 2, + "example.": 1, + "********************************************************************": 1, + "ContentMetaData": 1, + "objects": 1, + "shows": 1, + "category.": 1, + "For": 1, + "example": 1, + "cheat": 1, + "but": 2, + "ideally": 1, + "you": 1, + "dynamically": 1, + "content": 2, + "each": 1, + "category": 1, + "is": 1, + "dynamic": 1, + "s": 1, + "one": 3, + "small": 1, + "step": 1, + "a": 4, + "man": 1, + "giant": 1, + "leap": 1, + "mankind.": 1, + "http": 14, + "//upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg": 2, + "I": 2, + "have": 2, + "Dream": 1, + "PG": 1, + "dream": 1, + "that": 1, + "my": 1, + "four": 1, + "little": 1, + "children": 1, + "day": 1, + "live": 1, + "nation": 1, + "where": 1, + "they": 1, + "judged": 1, + "by": 2, + "color": 1, + "their": 2, + "skin": 1, + "character.": 1, + "//upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_": 2, + "_March_on_Washington.jpg": 2, + "Flat": 6, + "Movie": 2, + "HD": 6, + "x2": 4, + "SD": 5, + "Netflix": 1, + "//upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif": 2, + "Landscape": 1, + "x3": 6, + "Channel": 1, + "Store": 1, + "//upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px": 2, + "Dunkery_Hill.jpg": 2, + "Portrait": 1, + "x4": 1, + "posters": 3, + "//upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg": 2, + "Square": 1, + "x1": 1, + "//upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px": 2, + "SQUARE_SHAPE.svg.png": 2, + "x9": 1, + "//upload.wikimedia.org/wikipedia/commons/thumb/2/22/": 2, + "%": 8, + "C3": 4, + "cran_TV_plat.svg/200px": 2, + "cran_TV_plat.svg.png": 2, + "}": 1, + "buttons": 1 + }, "C": { - "#include": 149, - "const": 357, - "char": 529, + "#include": 154, + "const": 358, + "char": 530, "*blob_type": 2, - ";": 5439, - "struct": 359, + ";": 5465, + "struct": 360, "blob": 6, "*lookup_blob": 2, - "(": 6213, + "(": 6243, "unsigned": 140, "*sha1": 16, - ")": 6215, - "{": 1528, - "object": 10, + ")": 6245, + "{": 1531, + "object": 41, "*obj": 9, "lookup_object": 2, "sha1": 20, @@ -1932,22 +3685,66 @@ "sha1_to_hex": 8, "typename": 2, "NULL": 330, - "}": 1544, - "*": 253, + "}": 1547, + "*": 261, "int": 446, "parse_blob_buffer": 2, "*item": 10, - "void": 279, + "void": 288, "*buffer": 6, "long": 105, "size": 120, "item": 24, "object.parsed": 4, - "#ifndef": 84, + "#ifndef": 89, "BLOB_H": 2, - "#define": 911, - "extern": 37, - "#endif": 236, + "#define": 920, + "extern": 38, + "#endif": 243, + "BOOTSTRAP_H": 2, + "": 8, + "__GNUC__": 8, + "typedef": 191, + "*true": 1, + "*false": 1, + "*eof": 1, + "*empty_list": 1, + "*global_enviroment": 1, + "enum": 30, + "obj_type": 1, + "scm_bool": 1, + "scm_empty_list": 1, + "scm_eof": 1, + "scm_char": 1, + "scm_int": 1, + "scm_pair": 1, + "scm_symbol": 1, + "scm_prim_fun": 1, + "scm_lambda": 1, + "scm_str": 1, + "scm_file": 1, + "*eval_proc": 1, + "*maybe_add_begin": 1, + "*code": 2, + "init_enviroment": 1, + "*env": 4, + "eval_err": 1, + "*msg": 7, + "__attribute__": 1, + "noreturn": 1, + "define_var": 1, + "*var": 4, + "*val": 6, + "set_var": 1, + "*get_var": 1, + "*cond2nested_if": 1, + "*cond": 1, + "*let2lambda": 1, + "*let": 1, + "*and2nested_if": 1, + "*and": 1, + "*or2nested_if": 1, + "*or": 1, "git_cache_init": 1, "git_cache": 4, "*cache": 4, @@ -1973,8 +3770,8 @@ "i": 410, "for": 88, "+": 551, - "[": 597, - "]": 597, + "[": 601, + "]": 601, "git_cached_obj_decref": 3, "git__free": 15, "*git_cache_get": 1, @@ -1984,7 +3781,7 @@ "hash": 12, "*node": 2, "*result": 1, - "memcpy": 34, + "memcpy": 35, "oid": 17, "id": 13, "git_mutex_lock": 2, @@ -2002,7 +3799,7 @@ "else": 190, "save_commit_buffer": 3, "*commit_type": 2, - "static": 454, + "static": 455, "commit": 59, "*check_commit": 1, "quiet": 5, @@ -2095,7 +3892,6 @@ "commit_list_insert": 2, "next": 8, "date": 5, - "enum": 29, "object_type": 1, "ret": 142, "read_sha1_file": 1, @@ -2177,7 +3973,6 @@ "*format_subject": 1, "strbuf": 12, "*sb": 7, - "*msg": 6, "*line_separator": 1, "userformat_find_requirements": 1, "*fmt": 2, @@ -2208,7 +4003,6 @@ "list": 1, "lifo": 1, "FLEX_ARRAY": 1, - "typedef": 189, "*read_graft_line": 1, "len": 30, "*lookup_commit_graft": 1, @@ -2280,7 +4074,7 @@ "": 1, "": 1, "": 1, - "#ifdef": 64, + "#ifdef": 66, "CONFIG_SMP": 1, "DEFINE_MUTEX": 1, "cpu_add_remove_lock": 3, @@ -2786,6 +4580,13 @@ "diff_delta__merge_like_cgit": 1, "git_vector_swap": 1, "git_pool_swap": 1, + "ATSHOME_LIBATS_DYNARRAY_CATS": 3, + "": 5, + "atslib_dynarray_memcpy": 1, + "atslib_dynarray_memmove": 1, + "memmove": 2, + "//": 262, + "ifndef": 2, "git_usage_string": 2, "git_more_info_string": 2, "N_": 1, @@ -2796,7 +4597,6 @@ "*cmd": 5, "want": 3, "pager_command_config": 2, - "*var": 1, "*data": 12, "data": 69, "prefixcmp": 3, @@ -3017,14 +4817,12 @@ "vec": 2, ".data": 1, ".len": 3, - "": 7, "HELLO_H": 2, "hello": 1, "": 5, "": 2, "": 3, "": 3, - "": 4, "": 2, "ULLONG_MAX": 10, "MIN": 3, @@ -3329,7 +5127,7 @@ "paused": 3, "HPE_PAUSED": 2, "http_parser_h": 2, - "__cplusplus": 18, + "__cplusplus": 20, "HTTP_PARSER_VERSION_MAJOR": 1, "HTTP_PARSER_VERSION_MINOR": 1, "": 2, @@ -3420,6 +5218,22 @@ "*http_method_str": 1, "*http_errno_name": 1, "*http_errno_description": 1, + "": 1, + "_Included_jni_JniLayer": 2, + "JNIEXPORT": 6, + "jlong": 6, + "JNICALL": 6, + "Java_jni_JniLayer_jni_1layer_1initialize": 1, + "JNIEnv": 6, + "jobject": 6, + "jintArray": 1, + "jint": 7, + "Java_jni_JniLayer_jni_1layer_1mainloop": 1, + "Java_jni_JniLayer_jni_1layer_1set_1button": 1, + "Java_jni_JniLayer_jni_1layer_1set_1analog": 1, + "jfloat": 1, + "Java_jni_JniLayer_jni_1layer_1report_1analog_1chg": 1, + "Java_jni_JniLayer_jni_1layer_1kill": 1, "strncasecmp": 2, "_strnicmp": 1, "REF_TABLE_SIZE": 1, @@ -3704,6 +5518,15 @@ "rb_define_class": 1, "rb_cObject": 1, "rb_define_method": 2, + "READLINE_READLINE_CATS": 3, + "": 1, + "atscntrb_readline_rl_library_version": 1, + "char*": 167, + "rl_library_version": 1, + "atscntrb_readline_rl_readline_version": 1, + "rl_readline_version": 1, + "atscntrb_readline_readline": 1, + "readline": 1, "": 1, "": 1, "": 1, @@ -3927,7 +5750,6 @@ "COVERAGE_TEST": 1, "dictVanillaFree": 1, "*privdata": 8, - "*val": 4, "DICT_NOTUSED": 6, "privdata": 8, "zfree": 2, @@ -3960,7 +5782,6 @@ "key": 9, "dictGenHashFunction": 5, "dictSdsHash": 4, - "char*": 166, "dictSdsCaseHash": 2, "dictGenCaseHashFunction": 1, "dictEncObjKeyCompare": 4, @@ -4453,7 +6274,6 @@ "name.release": 1, "name.machine": 1, "aeGetApiName": 1, - "__GNUC__": 7, "__GNUC_MINOR__": 2, "__GNUC_PATCHLEVEL__": 1, "uptime/": 1, @@ -4584,7 +6404,6 @@ "": 1, "": 2, "": 2, - "//": 257, "rfUTF8_IsContinuationbyte": 1, "e.t.c.": 1, "rfFReadLine_UTF8": 5, @@ -5061,7 +6880,6 @@ "use": 1, "determine": 1, "backs": 1, - "memmove": 1, "by": 1, "contiuing": 1, "make": 3, @@ -6455,6 +8273,13 @@ "__pyx_pf_7sklearn_12linear_model_8sgd_fast_10Regression_loss": 1, "__pyx_base.__pyx_vtab": 1, "__pyx_base.loss": 1, + "syscalldef": 1, + "syscalldefs": 1, + "SYSCALL_OR_NUM": 3, + "SYS_restart_syscall": 1, + "MAKE_UINT16": 3, + "SYS_exit": 1, + "SYS_fork": 1, "__wglew_h__": 2, "__WGLEW_H__": 1, "__wglext_h_": 2, @@ -7502,112 +9327,1827 @@ "yajl_get_bytes_consumed": 1, "yajl_free_error": 1 }, + "C#": { + "@": 1, + "{": 5, + "ViewBag.Title": 1, + ";": 8, + "}": 5, + "@section": 1, + "featured": 1, + "
": 1, + "class=": 7, + "
": 1, + "
": 1, + "

": 1, + "@ViewBag.Title.": 1, + "

": 1, + "

": 1, + "@ViewBag.Message": 1, + "

": 1, + "
": 1, + "

": 1, + "To": 1, + "learn": 1, + "more": 4, + "about": 2, + "ASP.NET": 5, + "MVC": 4, + "visit": 2, + "": 5, + "href=": 5, + "title=": 2, + "http": 1, + "//asp.net/mvc": 1, + "": 5, + ".": 2, + "The": 1, + "page": 1, + "features": 3, + "": 1, + "videos": 1, + "tutorials": 1, + "and": 6, + "samples": 1, + "": 1, + "to": 4, + "help": 1, + "you": 4, + "get": 1, + "the": 5, + "most": 1, + "from": 1, + "MVC.": 1, + "If": 1, + "have": 1, + "any": 1, + "questions": 1, + "our": 1, + "forums": 1, + "

": 1, + "
": 1, + "
": 1, + "

": 1, + "We": 1, + "suggest": 1, + "following": 1, + "

": 1, + "
    ": 1, + "
  1. ": 3, + "
    ": 3, + "Getting": 1, + "Started": 1, + "
    ": 3, + "gives": 2, + "a": 3, + "powerful": 1, + "patterns": 1, + "-": 3, + "based": 1, + "way": 1, + "build": 1, + "dynamic": 1, + "websites": 1, + "that": 5, + "enables": 1, + "clean": 1, + "separation": 1, + "of": 2, + "concerns": 1, + "full": 1, + "control": 1, + "over": 1, + "markup": 1, + "for": 4, + "enjoyable": 1, + "agile": 1, + "development.": 1, + "includes": 1, + "many": 1, + "enable": 1, + "fast": 1, + "TDD": 1, + "friendly": 1, + "development": 1, + "creating": 1, + "sophisticated": 1, + "applications": 1, + "use": 1, + "latest": 1, + "web": 2, + "standards.": 1, + "Learn": 3, + "
  2. ": 3, + "Add": 1, + "NuGet": 2, + "packages": 1, + "jump": 1, + "start": 1, + "your": 2, + "coding": 1, + "makes": 1, + "it": 2, + "easy": 1, + "install": 1, + "update": 1, + "free": 1, + "libraries": 1, + "tools.": 1, + "Find": 1, + "Web": 1, + "Hosting": 1, + "You": 1, + "can": 1, + "easily": 1, + "find": 1, + "hosting": 1, + "company": 1, + "offers": 1, + "right": 1, + "mix": 1, + "price": 1, + "applications.": 1, + "
": 1, + "using": 5, + "System": 1, + "System.Collections.Generic": 1, + "System.Linq": 1, + "System.Text": 1, + "System.Threading.Tasks": 1, + "namespace": 1, + "LittleSampleApp": 1, + "///": 4, + "": 1, + "Just": 1, + "what": 1, + "says": 1, + "on": 1, + "tin.": 1, + "A": 1, + "little": 1, + "sample": 1, + "application": 1, + "Linguist": 1, + "try": 1, + "out.": 1, + "": 1, + "class": 1, + "Program": 1, + "static": 1, + "void": 1, + "Main": 1, + "(": 3, + "string": 1, + "[": 1, + "]": 1, + "args": 1, + ")": 3, + "Console.WriteLine": 2 + }, "C++": { - "class": 34, + "class": 40, "Bar": 2, - "{": 553, + "{": 581, "protected": 4, - "char": 122, + "char": 127, "*name": 6, - ";": 2308, - "public": 27, - "void": 152, + ";": 2471, + "public": 33, + "void": 225, "hello": 2, - "(": 2438, - ")": 2440, - "}": 552, - "foo": 2, - "cudaArray*": 1, - "cu_array": 4, - "texture": 1, - "": 1, - "2": 1, - "cudaReadModeElementType": 1, - "tex": 4, - "cudaChannelFormatDesc": 1, - "description": 5, - "cudaCreateChannelDesc": 1, - "": 1, - "cudaMallocArray": 1, - "&": 148, - "width": 5, - "height": 5, - "cudaMemcpyToArray": 1, - "image": 1, - "width*height*sizeof": 1, - "float": 9, - "cudaMemcpyHostToDevice": 1, - "tex.addressMode": 2, - "[": 204, - "]": 204, - "cudaAddressModeClamp": 2, - "tex.filterMode": 1, - "cudaFilterModePoint": 1, - "tex.normalized": 1, - "false": 43, - "//": 239, - "do": 5, - "not": 2, - "normalize": 1, - "coordinates": 1, - "cudaBindTextureToArray": 1, - "dim3": 2, - "blockDim": 2, - "gridDim": 2, - "+": 55, - "blockDim.x": 2, - "-": 227, - "/": 15, - "blockDim.y": 2, - "kernel": 2, - "<<": 19, - "<": 56, - "d_data": 1, - "cudaUnbindTexture": 1, - "//end": 1, - "__global__": 1, - "float*": 1, - "odata": 2, - "int": 148, - "unsigned": 22, + "(": 2729, + ")": 2731, + "}": 581, + "//": 278, + "///": 843, + "mainpage": 1, + "C": 6, + "library": 14, + "for": 98, + "Broadcom": 3, + "BCM": 14, + "as": 28, + "used": 17, + "in": 165, + "Raspberry": 6, + "Pi": 5, + "This": 18, + "is": 100, + "a": 156, + "RPi": 17, + ".": 16, + "It": 7, + "provides": 3, + "access": 17, + "to": 253, + "GPIO": 87, + "and": 118, + "other": 17, + "IO": 2, + "functions": 19, + "on": 55, + "the": 537, + "chip": 9, + "allowing": 3, + "pins": 40, + "pin": 90, + "IDE": 4, + "plug": 3, + "board": 2, + "so": 2, + "you": 29, + "can": 21, + "control": 17, + "interface": 9, + "with": 32, + "various": 4, + "external": 3, + "devices.": 1, + "reading": 3, + "digital": 2, + "inputs": 2, + "setting": 2, + "outputs": 1, + "using": 11, + "SPI": 44, + "I2C": 29, + "accessing": 2, + "system": 9, + "timers.": 1, + "Pin": 65, + "event": 3, + "detection": 2, + "supported": 3, + "by": 53, + "polling": 1, + "interrupts": 1, + "are": 36, + "not": 26, + "+": 60, + "compatible": 1, + "installs": 1, + "header": 7, + "file": 31, + "non": 2, + "-": 349, + "shared": 2, + "any": 23, + "Linux": 2, + "based": 4, + "distro": 1, + "but": 5, + "clearly": 1, + "no": 7, + "use": 34, + "except": 2, + "or": 44, + "another": 1, + "The": 50, + "version": 38, + "of": 211, + "package": 1, + "that": 33, + "this": 52, + "documentation": 3, + "refers": 1, + "be": 35, + "downloaded": 1, + "from": 91, + "http": 11, + "//www.airspayce.com/mikem/bcm2835/bcm2835": 1, + "tar.gz": 1, + "You": 9, + "find": 2, + "latest": 2, + "at": 20, + "//www.airspayce.com/mikem/bcm2835": 1, + "Several": 1, + "example": 3, + "programs": 4, + "provided.": 1, + "Based": 1, + "data": 26, + "//elinux.org/RPi_Low": 1, + "level_peripherals": 1, + "//www.raspberrypi.org/wp": 1, + "content/uploads/2012/02/BCM2835": 1, + "ARM": 5, + "Peripherals.pdf": 1, + "//www.scribd.com/doc/101830961/GPIO": 2, + "Pads": 3, + "Control2": 2, + "also": 3, + "online": 1, + "help": 1, + "discussion": 1, + "//groups.google.com/group/bcm2835": 1, + "Please": 4, + "group": 23, + "all": 11, + "questions": 1, + "discussions": 1, + "topic.": 1, + "Do": 1, + "contact": 1, + "author": 3, + "directly": 2, + "unless": 1, + "it": 19, + "discuss": 1, + "commercial": 1, + "licensing.": 1, + "Tested": 1, + "debian6": 1, + "wheezy": 3, + "raspbian": 3, + "Occidentalisv01": 2, + "CAUTION": 1, + "has": 29, + "been": 14, + "observed": 1, + "when": 22, + "detect": 3, + "enables": 3, + "such": 4, + "bcm2835_gpio_len": 5, + "pulled": 1, + "LOW": 8, + "cause": 1, + "temporary": 1, + "hangs": 1, + "Occidentalisv01.": 1, + "Reason": 1, + "yet": 1, + "determined": 1, + "suspect": 1, + "an": 23, + "interrupt": 1, + "handler": 1, + "hitting": 1, + "hard": 1, + "loop": 2, + "those": 3, + "OSs.": 1, + "If": 11, + "must": 6, + "friends": 2, + "make": 6, + "sure": 3, + "disable": 2, + "bcm2835_gpio_cler_len": 1, + "after": 18, + "use.": 1, + "par": 9, + "Installation": 1, + "consists": 1, + "single": 2, + "which": 14, + "will": 15, + "installed": 1, + "usual": 3, + "places": 1, + "install": 3, + "code": 12, + "#": 1, + "download": 2, + "say": 1, + "bcm2835": 7, + "xx.tar.gz": 2, + "then": 15, + "tar": 1, + "zxvf": 1, + "cd": 1, + "xx": 2, + "./configure": 1, + "sudo": 2, + "check": 3, + "endcode": 2, + "Physical": 21, + "Addresses": 6, + "bcm2835_peri_read": 3, + "bcm2835_peri_write": 3, + "bcm2835_peri_set_bits": 2, + "low": 2, + "level": 10, + "peripheral": 14, + "register": 17, + "functions.": 4, + "They": 1, + "designed": 3, + "physical": 4, + "addresses": 4, + "described": 1, + "section": 6, + "BCM2835": 2, + "Peripherals": 1, + "manual.": 1, + "range": 3, + "FFFFFF": 1, + "peripherals.": 1, + "bus": 4, + "peripherals": 2, + "set": 18, + "up": 18, + "map": 3, + "onto": 1, + "address": 13, + "starting": 1, + "E000000.": 1, + "Thus": 1, + "advertised": 1, + "manual": 8, + "Ennnnnn": 1, + "available": 6, + "nnnnnn.": 1, + "base": 4, + "registers": 12, + "following": 2, + "externals": 1, + "bcm2835_gpio": 2, + "bcm2835_pwm": 2, + "bcm2835_clk": 2, + "bcm2835_pads": 2, + "bcm2835_spio0": 1, + "bcm2835_st": 1, + "bcm2835_bsc0": 1, + "bcm2835_bsc1": 1, + "Numbering": 1, + "numbering": 1, + "different": 5, + "inconsistent": 1, + "underlying": 4, + "numbering.": 1, + "//elinux.org/RPi_BCM2835_GPIOs": 1, + "some": 4, + "well": 1, + "power": 1, + "ground": 1, + "pins.": 1, + "Not": 4, + "header.": 1, + "Version": 40, + "P5": 6, + "connector": 1, + "V": 2, + "Gnd.": 1, + "passed": 4, + "number": 52, + "_not_": 1, + "number.": 1, + "There": 1, + "symbolic": 1, + "definitions": 3, + "each": 7, + "should": 10, + "convenience.": 1, + "See": 7, + "ref": 32, + "RPiGPIOPin.": 22, + "Pins": 2, + "bcm2835_spi_*": 1, + "allow": 5, + "SPI0": 17, + "send": 3, + "received": 3, + "Serial": 3, + "Peripheral": 6, + "Interface": 2, + "For": 6, + "more": 4, + "information": 3, + "about": 6, + "see": 14, + "//en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus": 1, + "When": 12, + "bcm2835_spi_begin": 3, + "called": 13, + "changes": 2, + "bahaviour": 1, + "their": 6, + "default": 14, + "behaviour": 1, + "order": 14, + "support": 4, + "SPI.": 1, + "While": 1, + "able": 2, + "state": 22, + "through": 4, + "bcm2835_spi_gpio_write": 1, + "bcm2835_spi_end": 4, + "revert": 1, + "configured": 1, + "controled": 1, + "bcm2835_gpio_*": 1, + "calls.": 1, + "P1": 56, + "MOSI": 8, + "MISO": 6, + "CLK": 6, + "CE0": 5, + "CE1": 6, + "bcm2835_i2c_*": 2, + "BSC": 10, + "generically": 1, + "referred": 1, + "I": 4, + "//en.wikipedia.org/wiki/I": 1, + "%": 6, + "C2": 1, + "B2C": 1, + "V2": 2, + "SDA": 3, + "SLC": 1, + "Real": 1, + "Time": 1, + "performance": 2, + "constraints": 2, + "user": 3, + "i.e.": 1, + "they": 2, + "run": 1, + "Such": 1, + "part": 1, + "kernel": 4, + "usually": 2, + "subject": 1, + "paging": 1, + "swapping": 2, + "while": 12, + "does": 4, + "things": 1, + "besides": 1, + "running": 1, + "your": 12, + "program.": 1, + "means": 8, + "expect": 2, + "get": 5, + "real": 4, + "time": 10, + "timing": 3, + "programs.": 1, + "In": 2, + "particular": 1, + "there": 4, + "guarantee": 1, + "bcm2835_delay": 5, + "bcm2835_delayMicroseconds": 6, + "return": 164, + "exactly": 2, + "requested.": 1, + "fact": 2, + "depending": 1, + "activity": 1, + "host": 1, + "etc": 1, + "might": 1, + "significantly": 1, + "longer": 1, + "delay": 9, + "times": 2, + "than": 5, + "one": 73, + "asked": 1, + "for.": 1, + "So": 1, + "please": 2, + "dont": 1, + "request.": 1, + "Arjan": 2, + "reports": 1, + "prevent": 4, + "fragment": 2, + "struct": 12, + "sched_param": 1, + "sp": 4, + "memset": 3, + "&": 149, + "sizeof": 15, + "sp.sched_priority": 1, + "sched_get_priority_max": 1, + "SCHED_FIFO": 2, + "sched_setscheduler": 1, + "mlockall": 1, + "MCL_CURRENT": 1, + "|": 14, + "MCL_FUTURE": 1, + "Open": 2, + "Source": 2, + "Licensing": 2, + "GPL": 2, + "appropriate": 7, + "option": 1, + "if": 306, + "want": 5, + "share": 2, + "source": 12, + "application": 2, + "everyone": 1, + "distribute": 1, + "give": 2, + "them": 1, + "right": 9, + "who": 1, + "uses": 4, + "it.": 3, + "wish": 2, + "software": 1, + "under": 2, + "contribute": 1, + "open": 6, + "community": 1, + "accordance": 1, + "distributed.": 1, + "//www.gnu.org/copyleft/gpl.html": 1, + "COPYING": 1, + "Acknowledgements": 1, + "Some": 1, + "inspired": 2, + "Dom": 1, + "Gert.": 1, + "Alan": 1, + "Barr.": 1, + "Revision": 1, + "History": 1, + "Initial": 1, + "release": 1, + "Minor": 1, + "bug": 1, + "fixes": 1, + "Added": 11, + "bcm2835_spi_transfern": 3, + "Fixed": 4, + "problem": 2, + "prevented": 1, + "being": 4, + "used.": 2, + "Reported": 5, + "David": 1, + "Robinson.": 1, + "bcm2835_close": 4, + "deinit": 1, + "library.": 3, + "Suggested": 1, + "sar": 1, + "Ortiz": 1, + "Document": 1, + "testing": 1, + "Functions": 1, + "bcm2835_gpio_ren": 3, + "bcm2835_gpio_fen": 3, + "bcm2835_gpio_hen": 3, + "bcm2835_gpio_aren": 3, + "bcm2835_gpio_afen": 3, + "now": 4, + "only": 6, + "specified.": 1, + "Other": 1, + "were": 1, + "already": 1, + "previously": 10, + "enabled": 4, + "stay": 1, + "enabled.": 1, + "bcm2835_gpio_clr_ren": 2, + "bcm2835_gpio_clr_fen": 2, + "bcm2835_gpio_clr_hen": 2, + "bcm2835_gpio_clr_len": 2, + "bcm2835_gpio_clr_aren": 2, + "bcm2835_gpio_clr_afen": 2, + "clear": 3, + "enable": 3, + "individual": 1, + "suggested": 3, + "Andreas": 1, + "Sundstrom.": 1, + "bcm2835_spi_transfernb": 2, + "buffers": 3, + "read": 21, + "write.": 1, + "Improvements": 3, + "barrier": 3, + "maddin.": 1, + "contributed": 1, + "mikew": 1, + "noticed": 1, + "was": 6, + "mallocing": 1, + "memory": 14, + "mmaps": 1, + "/dev/mem.": 1, + "ve": 4, + "removed": 1, + "mallocs": 1, + "frees": 1, + "found": 1, + "calling": 8, + "nanosleep": 7, + "takes": 1, + "least": 2, + "us.": 1, + "need": 3, + "link": 3, + "version.": 1, + "s": 18, + "doc": 1, + "Also": 1, + "added": 2, + "define": 2, + "passwrd": 1, + "value": 50, + "Gert": 1, + "says": 1, + "needed": 3, + "change": 3, + "pad": 4, + "settings.": 1, + "Changed": 1, + "names": 3, + "collisions": 1, + "wiringPi.": 1, + "Macros": 2, + "delayMicroseconds": 3, + "disabled": 2, + "defining": 1, + "BCM2835_NO_DELAY_COMPATIBILITY": 2, + "incorrect": 2, + "New": 6, + "mapping": 3, + "Hardware": 1, + "pointers": 2, + "initialisation": 2, + "externally": 1, + "bcm2835_spi0.": 1, + "Now": 4, + "compiles": 1, + "even": 2, + "CLOCK_MONOTONIC_RAW": 1, + "CLOCK_MONOTONIC": 1, + "instead.": 1, + "errors": 1, + "divider": 15, + "frequencies": 2, + "MHz": 14, + "clock.": 6, + "Ben": 1, + "Simpson.": 1, + "end": 23, + "examples": 1, + "Mark": 5, + "Wolfe.": 1, + "bcm2835_gpio_set_multi": 2, + "bcm2835_gpio_clr_multi": 2, + "bcm2835_gpio_write_multi": 4, + "mask": 20, + "once.": 1, + "Requested": 2, + "Sebastian": 2, + "Loncar.": 2, + "bcm2835_gpio_write_mask.": 1, + "Changes": 1, + "timer": 2, + "counter": 1, + "instead": 1, + "clock_gettime": 1, + "improved": 1, + "accuracy.": 1, + "No": 2, + "lrt": 1, + "now.": 1, + "Contributed": 1, + "van": 1, + "Vught.": 1, + "Removed": 1, + "inlines": 1, + "previous": 6, + "patch": 1, + "since": 3, + "don": 1, + "t": 15, + "seem": 1, + "work": 1, + "everywhere.": 1, + "olly.": 1, + "Patch": 2, + "Dootson": 2, + "close": 3, + "/dev/mem": 4, + "granted.": 1, + "susceptible": 1, + "bit": 19, + "overruns.": 1, + "courtesy": 1, + "Jeremy": 1, + "Mortis.": 1, + "definition": 3, + "BCM2835_GPFEN0": 2, + "broke": 1, + "ability": 1, + "falling": 4, + "edge": 8, + "events.": 1, + "Dootson.": 2, + "bcm2835_i2c_set_baudrate": 2, + "bcm2835_i2c_read_register_rs.": 1, + "bcm2835_i2c_read": 4, + "bcm2835_i2c_write": 4, + "fix": 1, + "ocasional": 1, + "reads": 2, + "completing.": 1, + "Patched": 1, + "p": 6, + "[": 274, + "atched": 1, + "his": 1, + "submitted": 1, + "high": 1, + "load": 1, + "processes.": 1, + "Updated": 1, + "distribution": 1, + "location": 6, + "details": 1, + "airspayce.com": 1, + "missing": 1, + "unmapmem": 1, + "pads": 7, + "leak.": 1, + "Hartmut": 1, + "Henkel.": 1, + "Mike": 1, + "McCauley": 1, + "mikem@airspayce.com": 1, + "DO": 1, + "NOT": 3, + "CONTACT": 1, + "THE": 2, + "AUTHOR": 1, + "DIRECTLY": 1, + "USE": 1, + "LISTS": 1, + "#ifndef": 27, + "BCM2835_H": 3, + "#define": 341, + "#include": 121, + "": 2, + "defgroup": 7, + "constants": 1, + "Constants": 1, + "passing": 1, + "values": 3, + "here": 1, + "@": 14, + "HIGH": 12, + "true": 41, + "volts": 2, + "pin.": 21, + "false": 45, + "Speed": 1, + "core": 1, + "clock": 21, + "core_clk": 1, + "BCM2835_CORE_CLK_HZ": 1, + "<": 247, + "Base": 17, + "Address": 10, + "BCM2835_PERI_BASE": 9, + "System": 10, + "Timer": 9, + "BCM2835_ST_BASE": 1, + "BCM2835_GPIO_PADS": 2, + "Clock/timer": 1, + "BCM2835_CLOCK_BASE": 1, + "BCM2835_GPIO_BASE": 6, + "BCM2835_SPI0_BASE": 1, + "BSC0": 2, + "BCM2835_BSC0_BASE": 1, + "PWM": 2, + "BCM2835_GPIO_PWM": 1, + "C000": 1, + "BSC1": 2, + "BCM2835_BSC1_BASE": 1, + "ST": 1, + "registers.": 10, + "Available": 8, + "bcm2835_init": 11, + "extern": 72, + "volatile": 13, + "uint32_t": 37, + "*bcm2835_st": 1, + "*bcm2835_gpio": 1, + "*bcm2835_pwm": 1, + "*bcm2835_clk": 1, + "PADS": 1, + "*bcm2835_pads": 1, + "*bcm2835_spi0": 1, + "*bcm2835_bsc0": 1, + "*bcm2835_bsc1": 1, + "Size": 2, + "page": 5, + "BCM2835_PAGE_SIZE": 1, + "*1024": 2, + "block": 4, + "BCM2835_BLOCK_SIZE": 1, + "offsets": 2, + "BCM2835_GPIO_BASE.": 1, + "Offsets": 1, + "into": 6, + "bytes": 29, + "per": 3, + "Register": 1, + "View": 1, + "BCM2835_GPFSEL0": 1, + "Function": 8, + "Select": 49, + "BCM2835_GPFSEL1": 1, + "BCM2835_GPFSEL2": 1, + "BCM2835_GPFSEL3": 1, + "c": 62, + "BCM2835_GPFSEL4": 1, + "BCM2835_GPFSEL5": 1, + "BCM2835_GPSET0": 1, + "Output": 6, + "Set": 2, + "BCM2835_GPSET1": 1, + "BCM2835_GPCLR0": 1, + "Clear": 18, + "BCM2835_GPCLR1": 1, + "BCM2835_GPLEV0": 1, + "Level": 2, + "BCM2835_GPLEV1": 1, + "BCM2835_GPEDS0": 1, + "Event": 11, + "Detect": 35, + "Status": 6, + "BCM2835_GPEDS1": 1, + "BCM2835_GPREN0": 1, + "Rising": 8, + "Edge": 16, + "Enable": 38, + "BCM2835_GPREN1": 1, + "Falling": 8, + "BCM2835_GPFEN1": 1, + "BCM2835_GPHEN0": 1, + "High": 4, + "BCM2835_GPHEN1": 1, + "BCM2835_GPLEN0": 1, + "Low": 5, + "BCM2835_GPLEN1": 1, + "BCM2835_GPAREN0": 1, + "Async.": 4, + "BCM2835_GPAREN1": 1, + "BCM2835_GPAFEN0": 1, + "BCM2835_GPAFEN1": 1, + "BCM2835_GPPUD": 1, + "Pull": 11, + "up/down": 10, + "BCM2835_GPPUDCLK0": 1, + "Clock": 11, + "BCM2835_GPPUDCLK1": 1, + "brief": 12, + "bcm2835PortFunction": 1, + "Port": 1, + "function": 18, + "select": 9, + "modes": 1, + "bcm2835_gpio_fsel": 2, + "typedef": 50, + "enum": 17, + "BCM2835_GPIO_FSEL_INPT": 1, + "b000": 1, + "Input": 2, + "BCM2835_GPIO_FSEL_OUTP": 1, + "b001": 1, + "BCM2835_GPIO_FSEL_ALT0": 1, + "b100": 1, + "Alternate": 6, + "BCM2835_GPIO_FSEL_ALT1": 1, + "b101": 1, + "BCM2835_GPIO_FSEL_ALT2": 1, + "b110": 1, + "BCM2835_GPIO_FSEL_ALT3": 1, + "b111": 2, + "BCM2835_GPIO_FSEL_ALT4": 1, + "b011": 1, + "BCM2835_GPIO_FSEL_ALT5": 1, + "b010": 1, + "BCM2835_GPIO_FSEL_MASK": 1, + "bits": 11, + "bcm2835FunctionSelect": 2, + "bcm2835PUDControl": 4, + "Pullup/Pulldown": 1, + "defines": 3, + "bcm2835_gpio_pud": 5, + "BCM2835_GPIO_PUD_OFF": 1, + "b00": 1, + "Off": 3, + "pull": 1, + "BCM2835_GPIO_PUD_DOWN": 1, + "b01": 1, + "Down": 1, + "BCM2835_GPIO_PUD_UP": 1, + "b10": 1, + "Up": 1, + "Pad": 11, + "BCM2835_PADS_GPIO_0_27": 1, + "BCM2835_PADS_GPIO_28_45": 1, + "BCM2835_PADS_GPIO_46_53": 1, + "Control": 6, + "masks": 1, + "BCM2835_PAD_PASSWRD": 1, + "A": 7, + "<<": 29, + "Password": 1, + "BCM2835_PAD_SLEW_RATE_UNLIMITED": 1, + "Slew": 1, + "rate": 3, + "unlimited": 1, + "BCM2835_PAD_HYSTERESIS_ENABLED": 1, + "Hysteresis": 1, + "BCM2835_PAD_DRIVE_2mA": 1, + "mA": 8, + "drive": 8, + "current": 26, + "BCM2835_PAD_DRIVE_4mA": 1, + "BCM2835_PAD_DRIVE_6mA": 1, + "BCM2835_PAD_DRIVE_8mA": 1, + "BCM2835_PAD_DRIVE_10mA": 1, + "BCM2835_PAD_DRIVE_12mA": 1, + "BCM2835_PAD_DRIVE_14mA": 1, + "BCM2835_PAD_DRIVE_16mA": 1, + "bcm2835PadGroup": 4, + "specification": 1, + "bcm2835_gpio_pad": 2, + "BCM2835_PAD_GROUP_GPIO_0_27": 1, + "BCM2835_PAD_GROUP_GPIO_28_45": 1, + "BCM2835_PAD_GROUP_GPIO_46_53": 1, + "Numbers": 1, + "Here": 1, + "we": 4, + "terms": 4, + "numbers.": 1, + "These": 6, + "requiring": 1, + "bin": 1, + "connected": 1, + "adopt": 1, + "alternate": 7, + "function.": 3, + "slightly": 1, + "pinouts": 1, + "these": 1, + "RPI_V2_*.": 1, + "At": 1, + "bootup": 1, + "UART0_TXD": 3, + "UART0_RXD": 3, + "ie": 3, + "alt0": 1, + "respectively": 1, + "dedicated": 1, + "cant": 1, + "controlled": 1, + "independently": 1, + "RPI_GPIO_P1_03": 6, + "RPI_GPIO_P1_05": 6, + "RPI_GPIO_P1_07": 1, + "RPI_GPIO_P1_08": 1, + "defaults": 4, + "alt": 4, + "RPI_GPIO_P1_10": 1, + "RPI_GPIO_P1_11": 1, + "RPI_GPIO_P1_12": 1, + "RPI_GPIO_P1_13": 1, + "RPI_GPIO_P1_15": 1, + "RPI_GPIO_P1_16": 1, + "RPI_GPIO_P1_18": 1, + "RPI_GPIO_P1_19": 1, + "RPI_GPIO_P1_21": 1, + "RPI_GPIO_P1_22": 1, + "RPI_GPIO_P1_23": 1, + "RPI_GPIO_P1_24": 1, + "RPI_GPIO_P1_26": 1, + "RPI_V2_GPIO_P1_03": 1, + "RPI_V2_GPIO_P1_05": 1, + "RPI_V2_GPIO_P1_07": 1, + "RPI_V2_GPIO_P1_08": 1, + "RPI_V2_GPIO_P1_10": 1, + "RPI_V2_GPIO_P1_11": 1, + "RPI_V2_GPIO_P1_12": 1, + "RPI_V2_GPIO_P1_13": 1, + "RPI_V2_GPIO_P1_15": 1, + "RPI_V2_GPIO_P1_16": 1, + "RPI_V2_GPIO_P1_18": 1, + "RPI_V2_GPIO_P1_19": 1, + "RPI_V2_GPIO_P1_21": 1, + "RPI_V2_GPIO_P1_22": 1, + "RPI_V2_GPIO_P1_23": 1, + "RPI_V2_GPIO_P1_24": 1, + "RPI_V2_GPIO_P1_26": 1, + "RPI_V2_GPIO_P5_03": 1, + "RPI_V2_GPIO_P5_04": 1, + "RPI_V2_GPIO_P5_05": 1, + "RPI_V2_GPIO_P5_06": 1, + "RPiGPIOPin": 1, + "BCM2835_SPI0_CS": 1, + "Master": 12, + "BCM2835_SPI0_FIFO": 1, + "TX": 5, + "RX": 7, + "FIFOs": 1, + "BCM2835_SPI0_CLK": 1, + "Divider": 2, + "BCM2835_SPI0_DLEN": 1, + "Data": 9, + "Length": 2, + "BCM2835_SPI0_LTOH": 1, + "LOSSI": 1, + "mode": 24, + "TOH": 1, + "BCM2835_SPI0_DC": 1, + "DMA": 3, + "DREQ": 1, + "Controls": 1, + "BCM2835_SPI0_CS_LEN_LONG": 1, + "Long": 1, + "word": 7, + "Lossi": 2, + "DMA_LEN": 1, + "BCM2835_SPI0_CS_DMA_LEN": 1, + "BCM2835_SPI0_CS_CSPOL2": 1, + "Chip": 9, + "Polarity": 5, + "BCM2835_SPI0_CS_CSPOL1": 1, + "BCM2835_SPI0_CS_CSPOL0": 1, + "BCM2835_SPI0_CS_RXF": 1, + "RXF": 2, + "FIFO": 25, + "Full": 1, + "BCM2835_SPI0_CS_RXR": 1, + "RXR": 3, + "needs": 3, + "Reading": 1, + "full": 9, + "BCM2835_SPI0_CS_TXD": 1, + "TXD": 2, + "accept": 2, + "BCM2835_SPI0_CS_RXD": 1, + "RXD": 2, + "contains": 2, + "BCM2835_SPI0_CS_DONE": 1, + "Done": 3, + "transfer": 8, + "BCM2835_SPI0_CS_TE_EN": 1, + "Unused": 2, + "BCM2835_SPI0_CS_LMONO": 1, + "BCM2835_SPI0_CS_LEN": 1, + "LEN": 1, + "LoSSI": 1, + "BCM2835_SPI0_CS_REN": 1, + "REN": 1, + "Read": 3, + "BCM2835_SPI0_CS_ADCS": 1, + "ADCS": 1, + "Automatically": 1, + "Deassert": 1, + "BCM2835_SPI0_CS_INTR": 1, + "INTR": 1, + "Interrupt": 5, + "BCM2835_SPI0_CS_INTD": 1, + "INTD": 1, + "BCM2835_SPI0_CS_DMAEN": 1, + "DMAEN": 1, + "BCM2835_SPI0_CS_TA": 1, + "Transfer": 3, + "Active": 2, + "BCM2835_SPI0_CS_CSPOL": 1, + "BCM2835_SPI0_CS_CLEAR": 1, + "BCM2835_SPI0_CS_CLEAR_RX": 1, + "BCM2835_SPI0_CS_CLEAR_TX": 1, + "BCM2835_SPI0_CS_CPOL": 1, + "BCM2835_SPI0_CS_CPHA": 1, + "Phase": 1, + "BCM2835_SPI0_CS_CS": 1, + "bcm2835SPIBitOrder": 3, + "Bit": 1, + "Specifies": 5, + "ordering": 4, + "bcm2835_spi_setBitOrder": 2, + "BCM2835_SPI_BIT_ORDER_LSBFIRST": 1, + "LSB": 1, + "First": 2, + "BCM2835_SPI_BIT_ORDER_MSBFIRST": 1, + "MSB": 1, + "Specify": 2, + "bcm2835_spi_setDataMode": 2, + "BCM2835_SPI_MODE0": 1, + "CPOL": 4, + "CPHA": 4, + "BCM2835_SPI_MODE1": 1, + "BCM2835_SPI_MODE2": 1, + "BCM2835_SPI_MODE3": 1, + "bcm2835SPIMode": 2, + "bcm2835SPIChipSelect": 3, + "BCM2835_SPI_CS0": 1, + "BCM2835_SPI_CS1": 1, + "BCM2835_SPI_CS2": 1, + "CS1": 1, + "CS2": 1, + "asserted": 3, + "BCM2835_SPI_CS_NONE": 1, + "CS": 5, + "yourself": 1, + "bcm2835SPIClockDivider": 3, + "generate": 2, + "Figures": 1, + "below": 1, + "period": 1, + "frequency.": 1, + "divided": 2, + "nominal": 2, + "reported": 2, + "contrary": 1, + "may": 9, + "shown": 1, + "have": 4, + "confirmed": 1, + "measurement": 2, + "BCM2835_SPI_CLOCK_DIVIDER_65536": 1, + "us": 12, + "kHz": 10, + "BCM2835_SPI_CLOCK_DIVIDER_32768": 1, + "BCM2835_SPI_CLOCK_DIVIDER_16384": 1, + "BCM2835_SPI_CLOCK_DIVIDER_8192": 1, + "/51757813kHz": 1, + "BCM2835_SPI_CLOCK_DIVIDER_4096": 1, + "BCM2835_SPI_CLOCK_DIVIDER_2048": 1, + "BCM2835_SPI_CLOCK_DIVIDER_1024": 1, + "BCM2835_SPI_CLOCK_DIVIDER_512": 1, + "BCM2835_SPI_CLOCK_DIVIDER_256": 1, + "BCM2835_SPI_CLOCK_DIVIDER_128": 1, + "ns": 9, + "BCM2835_SPI_CLOCK_DIVIDER_64": 1, + "BCM2835_SPI_CLOCK_DIVIDER_32": 1, + "BCM2835_SPI_CLOCK_DIVIDER_16": 1, + "BCM2835_SPI_CLOCK_DIVIDER_8": 1, + "BCM2835_SPI_CLOCK_DIVIDER_4": 1, + "BCM2835_SPI_CLOCK_DIVIDER_2": 1, + "fastest": 1, + "BCM2835_SPI_CLOCK_DIVIDER_1": 1, + "same": 3, + "/65536": 1, + "BCM2835_BSC_C": 1, + "BCM2835_BSC_S": 1, + "BCM2835_BSC_DLEN": 1, + "BCM2835_BSC_A": 1, + "Slave": 1, + "BCM2835_BSC_FIFO": 1, + "BCM2835_BSC_DIV": 1, + "BCM2835_BSC_DEL": 1, + "Delay": 4, + "BCM2835_BSC_CLKT": 1, + "Stretch": 2, + "Timeout": 2, + "BCM2835_BSC_C_I2CEN": 1, + "BCM2835_BSC_C_INTR": 1, + "BCM2835_BSC_C_INTT": 1, + "BCM2835_BSC_C_INTD": 1, + "DONE": 2, + "BCM2835_BSC_C_ST": 1, + "Start": 4, + "new": 13, + "BCM2835_BSC_C_CLEAR_1": 1, + "BCM2835_BSC_C_CLEAR_2": 1, + "BCM2835_BSC_C_READ": 1, + "BCM2835_BSC_S_CLKT": 1, + "stretch": 1, + "timeout": 1, + "BCM2835_BSC_S_ERR": 1, + "ACK": 1, + "error": 2, + "BCM2835_BSC_S_RXF": 1, + "BCM2835_BSC_S_TXE": 1, + "TXE": 1, + "BCM2835_BSC_S_RXD": 1, + "BCM2835_BSC_S_TXD": 1, + "BCM2835_BSC_S_RXR": 1, + "BCM2835_BSC_S_TXW": 1, + "TXW": 1, + "writing": 2, + "BCM2835_BSC_S_DONE": 1, + "BCM2835_BSC_S_TA": 1, + "BCM2835_BSC_FIFO_SIZE": 1, + "size": 13, + "bcm2835I2CClockDivider": 3, + "BCM2835_I2C_CLOCK_DIVIDER_2500": 1, + "BCM2835_I2C_CLOCK_DIVIDER_626": 1, + "BCM2835_I2C_CLOCK_DIVIDER_150": 1, + "reset": 1, + "BCM2835_I2C_CLOCK_DIVIDER_148": 1, + "bcm2835I2CReasonCodes": 5, + "reason": 4, + "codes": 1, + "BCM2835_I2C_REASON_OK": 1, + "Success": 1, + "BCM2835_I2C_REASON_ERROR_NACK": 1, + "Received": 4, + "NACK": 1, + "BCM2835_I2C_REASON_ERROR_CLKT": 1, + "BCM2835_I2C_REASON_ERROR_DATA": 1, + "sent": 1, + "/": 14, + "BCM2835_ST_CS": 1, + "Control/Status": 1, + "BCM2835_ST_CLO": 1, + "Counter": 4, + "Lower": 2, + "BCM2835_ST_CHI": 1, + "Upper": 1, + "BCM2835_PWM_CONTROL": 1, + "BCM2835_PWM_STATUS": 1, + "BCM2835_PWM0_RANGE": 1, + "BCM2835_PWM0_DATA": 1, + "BCM2835_PWM1_RANGE": 1, + "BCM2835_PWM1_DATA": 1, + "BCM2835_PWMCLK_CNTL": 1, + "BCM2835_PWMCLK_DIV": 1, + "BCM2835_PWM1_MS_MODE": 1, + "Run": 4, + "MS": 2, + "BCM2835_PWM1_USEFIFO": 1, + "BCM2835_PWM1_REVPOLAR": 1, + "Reverse": 2, + "polarity": 3, + "BCM2835_PWM1_OFFSTATE": 1, + "Ouput": 2, + "BCM2835_PWM1_REPEATFF": 1, + "Repeat": 2, + "last": 6, + "empty": 2, + "BCM2835_PWM1_SERIAL": 1, + "serial": 2, + "BCM2835_PWM1_ENABLE": 1, + "Channel": 2, + "BCM2835_PWM0_MS_MODE": 1, + "BCM2835_PWM0_USEFIFO": 1, + "BCM2835_PWM0_REVPOLAR": 1, + "BCM2835_PWM0_OFFSTATE": 1, + "BCM2835_PWM0_REPEATFF": 1, + "BCM2835_PWM0_SERIAL": 1, + "BCM2835_PWM0_ENABLE": 1, "x": 48, - "blockIdx.x*blockDim.x": 1, - "threadIdx.x": 1, - "y": 16, - "blockIdx.y*blockDim.y": 1, - "threadIdx.y": 1, - "if": 296, - "&&": 24, - "c": 52, - "tex2D": 1, - "y*width": 1, - "#include": 106, + "#endif": 89, + "#ifdef": 19, + "__cplusplus": 12, + "init": 2, + "Library": 1, + "management": 1, + "intialise": 1, + "Initialise": 1, + "opening": 1, + "getting": 1, + "internal": 47, + "device": 7, + "call": 4, + "successfully": 1, + "before": 7, + "bcm2835_set_debug": 2, + "fails": 1, + "returning": 1, + "result": 2, + "crashes": 1, + "failures.": 1, + "Prints": 1, + "messages": 1, + "stderr": 1, + "case": 34, + "errors.": 1, + "successful": 2, + "else": 48, + "int": 161, + "Close": 1, + "deallocating": 1, + "allocated": 2, + "closing": 1, + "Sets": 24, + "debug": 6, + "prevents": 1, + "makes": 1, + "print": 5, + "out": 5, + "what": 2, + "would": 2, + "do": 9, + "rather": 2, + "causes": 1, + "normal": 1, + "operation.": 2, + "Call": 2, + "param": 72, + "]": 273, + "level.": 3, + "uint8_t": 43, + "lowlevel": 2, + "provide": 1, + "generally": 1, + "Reads": 5, + "done": 3, + "twice": 3, + "therefore": 6, + "always": 3, + "safe": 4, + "precautions": 3, + "correct": 3, + "paddr": 10, + "from.": 6, + "etc.": 5, + "sa": 30, + "uint32_t*": 7, + "without": 3, + "within": 4, + "occurred": 2, + "since.": 2, + "bcm2835_peri_read_nb": 1, + "Writes": 2, + "write": 8, + "bcm2835_peri_write_nb": 1, + "Alters": 1, + "regsiter.": 1, + "valu": 1, + "alters": 1, + "deines": 1, + "according": 1, + "value.": 2, + "All": 1, + "unaffected.": 1, + "Use": 8, + "alter": 2, + "subset": 1, + "register.": 3, + "masked": 2, + "mask.": 1, + "Bitmask": 1, + "altered": 1, + "gpio": 1, + "interface.": 3, + "input": 12, + "output": 21, + "state.": 1, + "given": 16, + "configures": 1, + "RPI_GPIO_P1_*": 21, + "Mode": 1, + "BCM2835_GPIO_FSEL_*": 1, + "specified": 27, + "HIGH.": 2, + "bcm2835_gpio_write": 3, + "bcm2835_gpio_set": 1, + "LOW.": 5, + "bcm2835_gpio_clr": 1, + "first": 13, + "Mask": 6, + "affect.": 4, + "eg": 5, + "returns": 4, + "either": 4, + "Works": 1, + "whether": 4, + "output.": 1, + "bcm2835_gpio_lev": 1, + "Status.": 7, + "Tests": 1, + "detected": 7, + "requested": 1, + "flag": 1, + "bcm2835_gpio_set_eds": 2, + "status": 1, + "th": 1, + "true.": 2, + "bcm2835_gpio_eds": 1, + "effect": 3, + "clearing": 1, + "flag.": 1, + "afer": 1, + "seeing": 1, + "rising": 3, + "sets": 8, + "GPRENn": 2, + "synchronous": 2, + "detection.": 2, + "signal": 4, + "sampled": 6, + "looking": 2, + "pattern": 2, + "signal.": 2, + "suppressing": 2, + "glitches.": 2, + "Disable": 6, + "Asynchronous": 6, + "incoming": 2, + "As": 2, + "edges": 2, + "very": 2, + "short": 5, + "duration": 2, + "detected.": 2, + "bcm2835_gpio_pudclk": 3, + "resistor": 1, + "However": 3, + "convenient": 2, + "bcm2835_gpio_set_pud": 4, + "pud": 4, + "desired": 7, + "mode.": 4, + "One": 3, + "BCM2835_GPIO_PUD_*": 2, + "Clocks": 3, + "earlier": 1, + "remove": 2, + "group.": 2, + "BCM2835_PAD_GROUP_GPIO_*": 2, + "BCM2835_PAD_*": 2, + "bcm2835_gpio_set_pad": 1, + "Delays": 3, + "milliseconds.": 1, + "Uses": 4, + "CPU": 5, + "until": 1, + "up.": 1, + "mercy": 2, + "From": 2, + "interval": 4, + "req": 2, + "exact": 2, + "multiple": 2, + "granularity": 2, + "rounded": 2, + "next": 9, + "multiple.": 2, + "Furthermore": 2, + "sleep": 2, + "completes": 2, + "still": 3, + "becomes": 2, + "free": 4, + "once": 5, + "again": 2, + "execute": 3, + "thread.": 2, + "millis": 2, + "milliseconds": 1, + "unsigned": 22, + "microseconds.": 2, + "combination": 2, + "busy": 2, + "wait": 2, + "timers": 1, + "less": 1, + "microseconds": 6, + "Timer.": 1, + "RaspberryPi": 1, + "Your": 1, + "mileage": 1, + "vary.": 1, + "micros": 5, + "uint64_t": 8, + "required": 2, + "bcm2835_gpio_write_mask": 1, + "clocking": 1, + "spi": 1, + "let": 2, + "device.": 2, + "operations.": 4, + "Forces": 2, + "ALT0": 2, + "funcitons": 1, + "complete": 2, + "End": 2, + "returned": 5, + "INPUT": 2, + "behaviour.": 2, + "NOTE": 1, + "effect.": 1, + "SPI0.": 1, + "Defaults": 1, + "BCM2835_SPI_BIT_ORDER_*": 1, + "speed.": 2, + "BCM2835_SPI_CLOCK_DIVIDER_*": 1, + "bcm2835_spi_setClockDivider": 1, + "uint16_t": 2, + "polariy": 1, + "phase": 1, + "BCM2835_SPI_MODE*": 1, + "bcm2835_spi_transfer": 5, + "made": 1, + "selected": 13, + "during": 4, + "transfer.": 4, + "cs": 4, + "activate": 1, + "slave.": 7, + "BCM2835_SPI_CS*": 1, + "bcm2835_spi_chipSelect": 4, + "occurs": 1, + "currently": 12, + "active.": 1, + "transfers": 1, + "happening": 1, + "complement": 1, + "inactive": 1, + "affect": 1, + "active": 3, + "Whether": 1, + "bcm2835_spi_setChipSelectPolarity": 1, + "Transfers": 6, + "byte": 6, + "Asserts": 3, + "simultaneously": 3, + "clocks": 2, + "MISO.": 2, + "Returns": 2, + "polled": 2, + "Peripherls": 2, + "len": 15, + "slave": 8, + "placed": 1, + "rbuf.": 1, + "rbuf": 3, + "long": 11, + "tbuf": 4, + "Buffer": 10, + "send.": 5, + "put": 1, + "buffer": 9, + "Number": 8, + "send/received": 2, + "char*": 24, + "bcm2835_spi_transfernb.": 1, + "replaces": 1, + "transmitted": 1, + "buffer.": 1, + "buf": 14, + "replace": 1, + "contents": 3, + "eh": 2, + "bcm2835_spi_writenb": 1, + "i2c": 1, + "Philips": 1, + "bus/interface": 1, + "January": 1, + "SCL": 2, + "bcm2835_i2c_end": 3, + "bcm2835_i2c_begin": 1, + "address.": 2, + "addr": 2, + "bcm2835_i2c_setSlaveAddress": 4, + "BCM2835_I2C_CLOCK_DIVIDER_*": 1, + "bcm2835_i2c_setClockDivider": 2, + "converting": 1, + "baudrate": 4, + "parameter": 1, + "equivalent": 1, + "divider.": 1, + "standard": 2, + "khz": 1, + "corresponds": 1, + "its": 1, + "driver.": 1, + "Of": 1, + "course": 2, + "nothing": 1, + "driver": 1, + "const": 170, + "*": 161, + "receive.": 2, + "received.": 2, + "Allows": 2, + "slaves": 1, + "require": 3, + "repeated": 1, + "start": 12, + "prior": 1, + "stop": 1, + "set.": 1, + "popular": 1, + "MPL3115A2": 1, + "pressure": 1, + "temperature": 1, + "sensor.": 1, + "Note": 1, + "combined": 1, + "better": 1, + "choice.": 1, + "Will": 1, + "regaddr": 2, + "containing": 2, + "bcm2835_i2c_read_register_rs": 1, + "st": 1, + "delays": 1, + "Counter.": 1, + "bcm2835_st_read": 1, + "offset.": 1, + "offset_micros": 2, + "Offset": 1, + "bcm2835_st_delay": 1, + "@example": 5, + "blink.c": 1, + "Blinks": 1, + "off": 1, + "input.c": 1, + "event.c": 1, + "Shows": 3, + "how": 3, + "spi.c": 1, + "spin.c": 1, + "#pragma": 3, + "": 4, + "": 4, + "": 2, + "namespace": 31, + "std": 52, + "DEFAULT_DELIMITER": 1, + "CsvStreamer": 5, + "private": 16, + "ofstream": 1, + "File": 1, + "stream": 6, + "vector": 16, + "row_buffer": 1, + "stores": 3, + "row": 12, + "flushed/written": 1, + "fields": 4, + "columns": 2, + "rows": 3, + "records": 2, + "including": 2, + "delimiter": 2, + "Delimiter": 1, + "character": 10, + "comma": 2, + "string": 24, + "sanitize": 1, + "ready": 1, + "Empty": 1, + "CSV": 4, + "streamer...": 1, + "Same": 1, + "...": 1, + "Opens": 3, + "path/name": 3, + "Ensures": 1, + "closed": 1, + "saved": 1, + "delimiting": 1, + "add_field": 1, + "line": 11, + "adds": 1, + "field": 5, + "save_fields": 1, + "save": 1, + "writes": 2, + "append": 8, + "Appends": 5, + "quoted": 1, + "leading/trailing": 1, + "spaces": 3, + "trimmed": 1, + "bool": 104, + "Like": 1, + "specify": 1, + "trim": 2, + "keep": 1, + "float": 8, + "double": 25, + "writeln": 1, + "Flushes": 1, + "Saves": 1, + "closes": 1, + "field_count": 1, + "Gets": 2, + "row_count": 1, "": 1, "": 1, "": 2, - "static": 260, + "static": 262, "Env": 13, "*env_instance": 1, - "*": 159, - "NULL": 108, + "NULL": 109, "*Env": 1, "instance": 4, "env_instance": 3, - "new": 9, - "return": 147, "QObject": 2, "QCoreApplication": 1, "parse": 3, - "const": 166, "**envp": 1, "**env": 1, "**": 2, "QString": 20, "envvar": 2, - "name": 21, - "value": 18, + "name": 25, "indexOfEquals": 5, - "for": 18, "env": 3, "envp": 4, "*env": 1, @@ -7619,19 +11159,19 @@ "QVariantMap": 3, "asVariantMap": 2, "m_map": 2, - "#ifndef": 23, "ENV_H": 3, - "#define": 190, "": 1, "Q_OBJECT": 1, "*instance": 1, - "private": 12, - "#endif": 82, + "Field": 2, + "Free": 1, + "Black": 1, + "White": 1, + "Illegal": 1, + "Player": 1, "GDSDBREADER_H": 3, "": 1, "GDS_DIR": 1, - "enum": 6, - "level": 1, "LEVEL_ONE": 1, "LEVEL_TWO": 1, "LEVEL_THREE": 1, @@ -7641,14 +11181,10 @@ "depth": 1, "userIndex": 1, "QByteArray": 1, - "data": 2, - "This": 6, - "is": 35, "COMPRESSED": 1, "optimize": 1, "ram": 1, - "and": 14, - "disk": 1, + "disk": 2, "space": 2, "decompressed": 1, "quint64": 1, @@ -7661,28 +11197,17 @@ "dbDataStructure*": 1, "father": 1, "fatherIndex": 1, - "bool": 99, "noFatherRoot": 1, - "Used": 1, - "to": 75, + "Used": 2, "tell": 1, - "this": 22, "node": 1, - "the": 178, "root": 1, - "so": 1, "hasn": 1, - "t": 13, - "in": 9, "argument": 1, - "list": 2, - "of": 48, - "an": 3, + "list": 3, "operator": 10, "overload.": 1, - "A": 1, "friend": 10, - "stream": 5, "myclass.label": 2, "myclass.depth": 2, "myclass.userIndex": 2, @@ -7698,16 +11223,10 @@ "QDataStream": 2, "myclass": 1, "//Don": 1, - "read": 1, - "it": 2, - "either": 1, "qUncompress": 2, - "": 1, - "using": 1, - "namespace": 26, - "std": 49, + "": 2, "main": 2, - "cout": 1, + "cout": 2, "endl": 1, "": 1, "": 1, @@ -7732,7 +11251,6 @@ "err": 26, "pub_key": 6, "EC_POINT_new": 4, - "group": 12, "EC_POINT_mul": 3, "priv_key": 2, "EC_KEY_set_private_key": 1, @@ -7745,7 +11263,6 @@ "*msg": 2, "msglen": 2, "recid": 3, - "check": 2, "ret": 24, "*x": 1, "*e": 1, @@ -7761,7 +11278,6 @@ "n": 28, "i": 47, "BN_CTX_start": 1, - "order": 8, "BN_CTX_get": 8, "EC_GROUP_get_order": 1, "BN_copy": 1, @@ -7769,29 +11285,26 @@ "BN_add": 1, "ecsig": 3, "r": 36, - "field": 3, "EC_GROUP_get_curve_GFp": 1, "BN_cmp": 1, "R": 6, "EC_POINT_set_compressed_coordinates_GFp": 1, - "%": 4, "O": 5, "EC_POINT_is_at_infinity": 1, "Q": 5, "EC_GROUP_get_degree": 1, - "e": 14, + "e": 15, "BN_bin2bn": 3, "msg": 1, "*msglen": 1, "BN_rshift": 1, - "zero": 3, + "zero": 5, "BN_zero": 1, "BN_mod_sub": 1, "rr": 4, "BN_mod_inverse": 1, "sor": 3, "BN_mod_mul": 2, - "s": 9, "eor": 3, "BN_CTX_end": 1, "CKey": 26, @@ -7800,7 +11313,6 @@ "pkey": 14, "POINT_CONVERSION_COMPRESSED": 1, "fCompressedPubKey": 5, - "true": 39, "Reset": 5, "EC_KEY_new_by_curve_name": 2, "NID_secp256k1": 2, @@ -7813,7 +11325,6 @@ "b.fSet": 2, "EC_KEY_copy": 1, "hash": 20, - "sizeof": 14, "vchSig": 18, "nSize": 2, "vchSig.clear": 2, @@ -7821,19 +11332,17 @@ "Shrink": 1, "fit": 1, "actual": 1, - "size": 9, "SignCompact": 2, "uint256": 10, - "vector": 14, "": 19, "fOk": 3, "*sig": 2, "ECDSA_do_sign": 1, - "char*": 14, "sig": 11, "nBitsR": 3, "BN_num_bits": 2, "nBitsS": 3, + "&&": 23, "nRecId": 4, "<4;>": 1, "keyRec": 5, @@ -7865,12 +11374,9 @@ "key2.GetPubKey": 1, "BITCOIN_KEY_H": 2, "": 1, - "": 2, "": 1, - "definition": 1, "runtime_error": 2, - "explicit": 3, - "string": 10, + "explicit": 4, "str": 2, "CKeyID": 5, "uint160": 8, @@ -7878,7 +11384,6 @@ "CPubKey": 11, "vchPubKey": 6, "vchPubKeyIn": 2, - "a": 84, "a.vchPubKey": 3, "b.vchPubKey": 3, "IMPLEMENT_SERIALIZE": 1, @@ -7893,7 +11398,6 @@ "||": 17, "IsCompressed": 2, "Raw": 1, - "typedef": 38, "secure_allocator": 2, "CPrivKey": 3, "EC_KEY*": 1, @@ -7907,7 +11411,141 @@ "GetPrivKey": 1, "SetPubKey": 1, "Sign": 1, - "#ifdef": 16, + "LIBCANIH": 2, + "": 1, + "": 1, + "int64": 1, + "//#define": 1, + "DEBUG": 5, + "dout": 2, + "#else": 25, + "cerr": 1, + "libcanister": 2, + "//the": 8, + "canmem": 22, + "object": 3, + "generic": 1, + "container": 2, + "commonly": 1, + "//throughout": 1, + "canister": 14, + "framework": 1, + "hold": 1, + "uncertain": 1, + "//length": 1, + "contain": 1, + "null": 3, + "bytes.": 1, + "raw": 2, + "absolute": 1, + "length": 10, + "//creates": 3, + "unallocated": 1, + "allocsize": 1, + "blank": 1, + "strdata": 1, + "//automates": 1, + "creation": 1, + "limited": 2, + "canmems": 1, + "//cleans": 1, + "zeromem": 1, + "//overwrites": 2, + "fragmem": 1, + "notation": 1, + "countlen": 1, + "//counts": 1, + "strings": 1, + "//removes": 1, + "nulls": 1, + "//returns": 2, + "singleton": 2, + "//contains": 2, + "caninfo": 2, + "path": 8, + "//physical": 1, + "internalname": 1, + "//a": 1, + "numfiles": 1, + "files": 6, + "//necessary": 1, + "type": 7, + "canfile": 7, + "//this": 1, + "holds": 2, + "//canister": 1, + "canister*": 1, + "parent": 1, + "//internal": 1, + "id": 1, + "//use": 1, + "own.": 1, + "newline": 2, + "delimited": 2, + "container.": 1, + "TOC": 1, + "info": 2, + "general": 1, + "canfiles": 1, + "recommended": 1, + "modify": 1, + "//these": 1, + "enforced.": 1, + "canfile*": 1, + "readonly": 3, + "//if": 1, + "routines": 1, + "anything": 1, + "//maximum": 1, + "//time": 1, + "whatever": 1, + "suits": 1, + "application.": 1, + "cachemax": 2, + "cachecnt": 1, + "//number": 1, + "cache": 2, + "modified": 3, + "//both": 1, + "initialize": 1, + "fspath": 3, + "//destroys": 1, + "flushing": 1, + "modded": 1, + "//open": 1, + "//does": 1, + "exist": 2, + "//close": 1, + "flush": 1, + "clean": 2, + "//deletes": 1, + "inside": 1, + "delFile": 1, + "//pulls": 1, + "getFile": 1, + "otherwise": 1, + "overwrites": 1, + "operation": 1, + "succeeded": 2, + "writeFile": 2, + "//get": 1, + "//list": 1, + "paths": 1, + "getTOC": 1, + "//brings": 1, + "back": 1, + "limit": 1, + "//important": 1, + "sCFID": 2, + "CFID": 2, + "avoid": 1, + "uncaching": 1, + "//really": 1, + "just": 1, + "internally": 1, + "harm.": 1, + "cacheclean": 1, + "dFlush": 1, "Q_OS_LINUX": 2, "": 1, "#if": 44, @@ -7916,17 +11554,14 @@ "#error": 9, "Something": 1, "wrong": 1, - "with": 6, "setup.": 1, - "Please": 3, - "report": 2, + "report": 3, "mailing": 1, "argc": 2, "char**": 2, "argv": 2, "google_breakpad": 1, "ExceptionHandler": 1, - "eh": 1, "Utils": 4, "exceptionHandler": 2, "qInstallMsgHandler": 1, @@ -7949,6 +11584,80 @@ "phantom.execute": 1, "app.exec": 1, "phantom.returnValue": 1, + "NINJA_METRICS_H_": 3, + "int64_t.": 1, + "Metrics": 2, + "module": 1, + "dumps": 1, + "stats": 2, + "actions.": 1, + "To": 1, + "METRIC_RECORD": 4, + "below.": 1, + "metrics": 2, + "hit": 1, + "path.": 2, + "count": 1, + "Total": 1, + "spent": 1, + "int64_t": 3, + "sum": 1, + "scoped": 1, + "recording": 1, + "metric": 2, + "across": 1, + "body": 1, + "macro.": 1, + "ScopedMetric": 4, + "Metric*": 4, + "metric_": 1, + "Timestamp": 1, + "started.": 1, + "Value": 24, + "platform": 2, + "dependent.": 1, + "start_": 1, + "prints": 1, + "report.": 1, + "NewMetric": 2, + "Print": 2, + "summary": 1, + "stdout.": 1, + "Report": 1, + "": 1, + "metrics_": 1, + "Get": 1, + "relative": 2, + "epoch.": 1, + "Epoch": 1, + "varies": 1, + "between": 1, + "platforms": 1, + "useful": 1, + "measuring": 1, + "elapsed": 1, + "time.": 1, + "GetTimeMillis": 1, + "simple": 1, + "stopwatch": 1, + "seconds": 1, + "Restart": 3, + "called.": 1, + "Stopwatch": 2, + "started_": 4, + "Seconds": 1, + "call.": 1, + "Elapsed": 1, + "static_cast": 8, + "": 1, + "primary": 1, + "metrics.": 1, + "top": 1, + "recorded": 1, + "metrics_h_metric": 2, + "g_metrics": 3, + "metrics_h_scoped": 1, + "Metrics*": 1, "INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION": 1, "": 1, "": 2, @@ -7964,13 +11673,11 @@ "protobuf": 72, "Descriptor*": 3, "Person_descriptor_": 6, - "internal": 46, "GeneratedMessageReflection*": 1, "Person_reflection_": 4, "protobuf_AssignDesc_protocol_2dbuffer_2eproto": 4, "protobuf_AddDesc_protocol_2dbuffer_2eproto": 6, "FileDescriptor*": 1, - "file": 6, "DescriptorPool": 3, "generated_pool": 2, "FindFileByName": 1, @@ -8002,20 +11709,17 @@ "InternalRegisterGeneratedFile": 1, "InitAsDefaultInstance": 3, "OnShutdown": 1, - "struct": 8, "StaticDescriptorInitializer_protocol_2dbuffer_2eproto": 2, "static_descriptor_initializer_protocol_2dbuffer_2eproto_": 1, "_MSC_VER": 3, "kNameFieldNumber": 2, "Message": 7, "SharedCtor": 4, - "from": 25, "MergeFrom": 9, "_cached_size_": 7, "const_cast": 3, "string*": 11, "kEmptyString": 12, - "memset": 2, "SharedDtor": 3, "SetCachedSize": 2, "GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN": 2, @@ -8023,26 +11727,20 @@ "descriptor": 2, "*default_instance_": 1, "Person*": 7, - "New": 4, - "Clear": 5, "xffu": 3, "has_name": 6, - "clear": 2, "mutable_unknown_fields": 4, "MergePartialFromCodedStream": 2, "io": 4, "CodedInputStream*": 2, - "input": 6, "DO_": 4, "EXPRESSION": 2, "uint32": 2, "tag": 6, - "while": 11, "ReadTag": 1, "switch": 3, "WireFormatLite": 9, "GetTagFieldNumber": 1, - "case": 33, "GetTagWireType": 2, "WIRETYPE_LENGTH_DELIMITED": 1, "ReadString": 1, @@ -8052,16 +11750,13 @@ ".data": 3, ".length": 3, "PARSE": 1, - "else": 46, "handle_uninterpreted": 2, "ExpectAtEnd": 1, - "default": 4, "WIRETYPE_END_GROUP": 1, "SkipField": 1, "#undef": 3, "SerializeWithCachedSizes": 2, "CodedOutputStream*": 2, - "output": 5, "SERIALIZE": 2, "WriteString": 1, "unknown_fields": 7, @@ -8077,7 +11772,6 @@ "StringSize": 1, "ComputeUnknownFieldsSize": 1, "GOOGLE_CHECK_NE": 2, - "source": 9, "dynamic_cast_if_available": 1, "": 12, "ReflectionOps": 1, @@ -8090,7 +11784,6 @@ "CopyFrom": 5, "IsInitialized": 3, "Swap": 2, - "other": 7, "swap": 3, "_unknown_fields_.Swap": 1, "Metadata": 3, @@ -8099,19 +11792,12 @@ "metadata.descriptor": 1, "metadata.reflection": 1, "PROTOBUF_protocol_2dbuffer_2eproto__INCLUDED": 3, - "": 1, "GOOGLE_PROTOBUF_VERSION": 1, - "was": 3, "generated": 2, - "by": 5, "newer": 2, - "version": 4, "protoc": 2, - "which": 2, "incompatible": 2, - "your": 3, "Protocol": 2, - "Buffer": 2, "headers.": 3, "update": 1, "GOOGLE_PROTOBUF_MIN_PROTOC_VERSION": 1, @@ -8136,7 +11822,6 @@ "clear_has_name": 5, "mutable": 1, "u": 9, - "|": 8, "*name_": 1, "assign": 3, "reinterpret_cast": 7, @@ -8144,45 +11829,26 @@ "SWIG": 2, "QSCICOMMAND_H": 2, "__APPLE__": 4, - "extern": 4, "": 1, "": 2, "": 1, "QsciScintilla": 7, - "brief": 2, - "The": 8, "QsciCommand": 7, "represents": 1, "editor": 1, "command": 9, - "that": 7, - "may": 2, - "have": 1, - "one": 42, - "or": 10, "two": 1, "keys": 3, "bound": 4, - "it.": 2, "Methods": 1, - "are": 3, "provided": 1, - "change": 1, - "remove": 1, "binding.": 1, "Each": 1, - "has": 2, - "user": 2, "friendly": 2, - "use": 1, - "mapping": 1, + "description": 3, "dialogs.": 1, "QSCINTILLA_EXPORT": 2, - "defines": 1, - "different": 1, "commands": 1, - "can": 3, - "be": 9, "assigned": 1, "key.": 1, "Command": 4, @@ -8203,7 +11869,6 @@ "view": 2, "LineScrollDown": 1, "SCI_LINESCROLLDOWN": 1, - "up": 13, "LineUp": 1, "SCI_LINEUP": 1, "LineUpExtend": 1, @@ -8212,16 +11877,13 @@ "SCI_LINEUPRECTEXTEND": 1, "LineScrollUp": 1, "SCI_LINESCROLLUP": 1, - "start": 11, "document.": 8, "ScrollToStart": 1, "SCI_SCROLLTOSTART": 1, - "end": 18, "ScrollToEnd": 1, "SCI_SCROLLTOEND": 1, "vertically": 1, "centre": 1, - "current": 9, "VerticalCentreCaret": 1, "SCI_VERTICALCENTRECARET": 1, "paragraph.": 4, @@ -8241,7 +11903,6 @@ "SCI_CHARLEFTEXTEND": 1, "CharLeftRectExtend": 1, "SCI_CHARLEFTRECTEXTEND": 1, - "right": 8, "CharRight": 1, "SCI_CHARRIGHT": 1, "CharRightExtend": 1, @@ -8257,17 +11918,14 @@ "SCI_WORDRIGHT": 1, "WordRightExtend": 1, "SCI_WORDRIGHTEXTEND": 1, - "previous": 5, "WordLeftEnd": 1, "SCI_WORDLEFTEND": 1, "WordLeftEndExtend": 1, "SCI_WORDLEFTENDEXTEND": 1, - "next": 6, "WordRightEnd": 1, "SCI_WORDRIGHTEND": 1, "WordRightEndExtend": 1, "SCI_WORDRIGHTENDEXTEND": 1, - "word": 6, "part.": 4, "WordPartLeft": 1, "SCI_WORDPARTLEFT": 1, @@ -8293,9 +11951,7 @@ "SCI_HOMEWRAP": 1, "HomeWrapExtend": 1, "SCI_HOMEWRAPEXTEND": 1, - "first": 8, "visible": 6, - "character": 8, "VCHome": 1, "SCI_VCHOME": 1, "VCHomeExtend": 1, @@ -8356,7 +12012,6 @@ "SCI_CLEAR": 1, "DeleteBack": 1, "SCI_DELETEBACK": 1, - "at": 4, "DeleteBackNotLine": 1, "SCI_DELETEBACKNOTLINE": 1, "left.": 2, @@ -8367,7 +12022,6 @@ "SCI_DELWORDRIGHT": 1, "DeleteWordRightEnd": 1, "SCI_DELWORDRIGHTEND": 1, - "line": 10, "DeleteLineLeft": 1, "SCI_DELLINELEFT": 1, "DeleteLineRight": 1, @@ -8388,11 +12042,9 @@ "Duplicate": 2, "LineDuplicate": 1, "SCI_LINEDUPLICATE": 1, - "Select": 33, "whole": 2, "SelectAll": 1, "SCI_SELECTALL": 1, - "selected": 2, "lines": 3, "MoveSelectedLinesUp": 1, "SCI_MOVESELECTEDLINESUP": 1, @@ -8420,7 +12072,6 @@ "EditToggleOvertype": 1, "SCI_EDITTOGGLEOVERTYPE": 1, "Insert": 2, - "platform": 1, "dependent": 1, "newline.": 1, "Newline": 1, @@ -8429,7 +12080,6 @@ "Formfeed": 1, "SCI_FORMFEED": 1, "Indent": 1, - "level.": 2, "Tab": 1, "SCI_TAB": 1, "De": 1, @@ -8437,11 +12087,8 @@ "Backtab": 1, "SCI_BACKTAB": 1, "Cancel": 2, - "any": 5, - "operation.": 1, "SCI_CANCEL": 1, "Undo": 2, - "last": 4, "command.": 5, "SCI_UNDO": 1, "Redo": 2, @@ -8454,21 +12101,16 @@ "ZoomOut": 1, "SCI_ZOOMOUT": 1, "Return": 3, - "will": 2, "executed": 1, "instance.": 2, "scicmd": 2, "Execute": 1, - "execute": 1, "Binds": 2, - "If": 4, - "then": 6, "binding": 3, "removed.": 2, "invalid": 5, "unchanged.": 1, "Valid": 1, - "control": 1, "Key_Down": 1, "Key_Up": 1, "Key_Left": 1, @@ -8484,20 +12126,15 @@ "Key_Tab": 1, "Key_Return.": 1, "Keys": 1, - "modified": 2, - "combination": 1, "SHIFT": 1, "CTRL": 1, "ALT": 1, "META.": 1, - "sa": 8, "setAlternateKey": 3, "validKey": 3, "setKey": 3, - "alternate": 3, "altkey": 3, "alternateKey": 3, - "currently": 2, "returned.": 4, "qkey": 2, "qaltkey": 2, @@ -8524,13 +12161,10 @@ "sub": 2, "Qt": 1, "QPrinter": 3, - "able": 1, - "print": 4, "text": 5, "Scintilla": 2, "further": 1, "classed": 1, - "alter": 1, "layout": 1, "adding": 2, "headers": 3, @@ -8539,75 +12173,45 @@ "Constructs": 1, "printer": 1, "paint": 1, - "device": 1, - "mode": 4, - "mode.": 1, "PrinterMode": 1, "ScreenResolution": 1, "Destroys": 1, "Format": 1, - "page": 4, - "example": 1, - "before": 1, "drawn": 2, - "on": 1, "painter": 4, - "used": 4, "add": 3, "customised": 2, "graphics.": 2, "drawing": 4, "actually": 1, - "being": 2, - "rather": 1, - "than": 1, "sized.": 1, "methods": 1, - "must": 1, - "only": 1, - "called": 1, - "when": 5, - "true.": 1, "area": 5, "draw": 1, "text.": 3, - "should": 1, "necessary": 1, "reserve": 1, "By": 1, - "relative": 1, "printable": 1, - "Use": 1, "setFullPage": 1, "because": 2, - "calling": 1, "printRange": 2, - "you": 1, - "want": 2, "try": 1, "over": 1, "pagenr": 2, - "number": 3, "numbered": 1, "formatPage": 1, "points": 2, - "each": 2, "font": 2, "printing.": 2, "setMagnification": 2, "magnification": 3, "mag": 2, - "Sets": 2, "printing": 2, "magnification.": 1, - "Print": 1, - "range": 1, "qsb.": 1, "negative": 2, "signifies": 2, - "returned": 2, - "there": 1, - "no": 1, "error.": 1, "*qsb": 1, "wrap": 4, @@ -8617,6 +12221,10 @@ "wrapMode": 2, "wmode.": 1, "wmode": 1, + "": 2, + "Gui": 1, + "rpc_init": 1, + "rpc_server_loop": 1, "v8": 9, "Scanner": 16, "UnicodeCache*": 4, @@ -8637,7 +12245,6 @@ "ScanHexNumber": 2, "expected_length": 4, "ASSERT": 17, - "prevent": 1, "overflow": 1, "digits": 3, "c0_": 64, @@ -8649,7 +12256,6 @@ "STATIC_ASSERT": 5, "Token": 212, "NUM_TOKENS": 1, - "byte": 1, "one_char_tokens": 2, "ILLEGAL": 120, "LPAREN": 2, @@ -8664,12 +12270,10 @@ "LBRACE": 2, "RBRACE": 2, "BIT_NOT": 2, - "Value": 23, "Next": 3, "current_": 2, "next_": 2, "has_multiline_comment_before_next_": 5, - "static_cast": 7, "token": 64, "": 1, "pos": 12, @@ -8707,7 +12311,6 @@ "ASSIGN": 1, "NE_STRICT": 1, "NE": 1, - "NOT": 1, "INC": 1, "ASSIGN_ADD": 1, "ADD": 1, @@ -8741,11 +12344,8 @@ "IsCarriageReturn": 2, "IsLineFeed": 2, "fall": 2, - "through": 2, "v": 3, - "xx": 1, "xxx": 1, - "error": 1, "immediately": 1, "octal": 1, "escape": 1, @@ -8753,12 +12353,11 @@ "consume": 2, "LiteralScope": 4, "literal": 2, - ".": 2, "X": 2, "E": 3, "l": 1, - "p": 5, "w": 1, + "y": 13, "keyword": 1, "Unescaped": 1, "in_character_class": 2, @@ -8775,7 +12374,6 @@ "CLASSIC_MODE": 2, "STRICT_MODE": 2, "EXTENDED_MODE": 2, - "detect": 1, "x16": 1, "x36.": 1, "Utf16CharacterStream": 3, @@ -8825,7 +12423,6 @@ "backing_store_.Dispose": 3, "INLINE": 2, "AddChar": 2, - "uint32_t": 8, "ExpandBuffer": 2, "kMaxAsciiCharCodeU": 1, "": 6, @@ -8840,7 +12437,6 @@ "utf16_literal": 3, "backing_store_.start": 5, "ascii_literal": 3, - "length": 8, "kInitialCapacity": 2, "kGrowthFactory": 2, "kMinConversionSlack": 1, @@ -8872,7 +12468,6 @@ "kNoOctalLocation": 1, "scanner_contants": 1, "current_token": 1, - "location": 4, "current_.location": 2, "literal_ascii_string": 1, "ASSERT_NOT_NULL": 9, @@ -8908,7 +12503,6 @@ "ScanRegExpFlags": 1, "IsIdentifier": 1, "CharacterStream*": 1, - "buffer": 1, "TokenDesc": 3, "LiteralBuffer*": 2, "literal_chars": 1, @@ -8924,9 +12518,9 @@ "LiteralScope*": 1, "ScanIdentifierUnicodeEscape": 1, "desc": 2, - "as": 1, "look": 1, "ahead": 1, + "smallPrime_t": 1, "UTILS_H": 3, "": 1, "": 1, @@ -8934,12 +12528,10 @@ "QTemporaryFile": 1, "showUsage": 1, "QtMsgType": 1, - "type": 6, "dump_path": 1, "minidump_id": 1, "void*": 1, "context": 8, - "succeeded": 1, "QVariant": 1, "coffee2js": 1, "script": 1, @@ -8965,10 +12557,6 @@ "QTemporaryFile*": 2, "m_tempHarness": 1, "We": 1, - "make": 1, - "sure": 1, - "clean": 1, - "after": 1, "ourselves": 1, "m_tempWrapper": 1, "V8_DECLARE_ONCE": 1, @@ -9012,8 +12600,6 @@ "UnregisterAll": 1, "OS": 3, "seed_random": 2, - "uint32_t*": 2, - "state": 15, "FLAG_random_seed": 2, "val": 3, "ScopedLock": 1, @@ -9057,9 +12643,7 @@ "IncrementCallDepth": 1, "DecrementCallDepth": 1, "union": 1, - "double": 23, "double_value": 1, - "uint64_t": 2, "uint64_t_value": 1, "double_int_union": 2, "Object*": 4, @@ -9076,8 +12660,6 @@ "SetUp": 4, "FLAG_crankshaft": 1, "Serializer": 1, - "enabled": 1, - "CPU": 2, "SupportsCrankshaft": 1, "PostSetUp": 1, "RuntimeProfiler": 1, @@ -9095,10 +12677,8 @@ "V8_V8_H_": 3, "defined": 21, "GOOGLE3": 2, - "DEBUG": 3, "NDEBUG": 4, "both": 1, - "set": 1, "Deserializer": 1, "AllStatic": 1, "IsRunning": 1, @@ -9114,15 +12694,10 @@ "PY_SSIZE_T_CLEAN": 1, "Py_PYTHON_H": 1, "Python": 1, - "needed": 1, "compile": 1, - "C": 1, "extensions": 1, - "please": 1, - "install": 1, "development": 1, "Python.": 1, - "#else": 24, "": 1, "offsetof": 2, "member": 2, @@ -9179,9 +12754,7 @@ "*buf": 1, "PyObject": 221, "*obj": 2, - "len": 1, "itemsize": 2, - "readonly": 2, "ndim": 2, "*format": 1, "*shape": 1, @@ -9306,7 +12879,6 @@ "PyObject_DelAttrString": 2, "__Pyx_NAMESTR": 3, "__Pyx_DOCSTR": 3, - "__cplusplus": 10, "__PYX_EXTERN_C": 2, "_USE_MATH_DEFINES": 1, "": 1, @@ -9323,7 +12895,6 @@ "CYTHON_UNUSED": 7, "**p": 1, "*s": 1, - "long": 5, "encoding": 1, "is_unicode": 1, "is_str": 1, @@ -9402,7 +12973,6 @@ "complex": 2, "__pyx_t_float_complex": 27, "_Complex": 2, - "real": 2, "imag": 2, "__pyx_t_double_complex": 27, "npy_cfloat": 1, @@ -9512,7 +13082,6 @@ "cabs": 1, "cpow": 1, "__Pyx_PyInt_AsUnsignedChar": 1, - "short": 3, "__Pyx_PyInt_AsUnsignedShort": 1, "__Pyx_PyInt_AsUnsignedInt": 1, "__Pyx_PyInt_AsChar": 1, @@ -9734,7 +13303,6 @@ "NPY_F_CONTIGUOUS": 1, "__pyx_k_tuple_8": 1, "__pyx_L7": 2, - "buf": 1, "PyArray_DATA": 1, "strides": 5, "malloc": 2, @@ -9781,7 +13349,6 @@ "__pyx_L2": 2, "__pyx_pf_5numpy_7ndarray_1__releasebuffer__": 2, "PyArray_HASFIELDS": 1, - "free": 2, "*__pyx_f_5numpy_PyArray_MultiIterNew1": 1, "*__pyx_v_a": 5, "PyArray_MultiIterNew": 5, @@ -9808,11 +13375,9 @@ "__pyx_v_fields": 7, "__pyx_v_childname": 4, "__pyx_v_new_offset": 5, - "names": 2, "PyTuple_GET_SIZE": 2, "PyTuple_GET_ITEM": 3, "PyObject_GetItem": 1, - "fields": 1, "PyTuple_CheckExact": 1, "tuple": 3, "__pyx_ptype_5numpy_dtype": 1, @@ -9857,6 +13422,173 @@ "<=>": 1, "other.name": 1 }, + "Cirru": { + "print": 38, + "array": 14, + "int": 36, + "string": 7, + "set": 12, + "f": 3, + "block": 1, + "(": 20, + "a": 22, + "b": 7, + "c": 9, + ")": 20, + "call": 1, + "bool": 6, + "true": 1, + "false": 1, + "yes": 1, + "no": 1, + "map": 8, + "m": 3, + "float": 1, + "require": 1, + "./stdio.cr": 1, + "self": 2, + "child": 1, + "under": 2, + "parent": 1, + "get": 4, + "x": 2, + "just": 4, + "-": 4, + "code": 4, + "eval": 2, + "nothing": 1, + "container": 3 + }, + "Clojure": { + "(": 83, + "defn": 4, + "prime": 2, + "[": 41, + "n": 9, + "]": 41, + "not": 3, + "-": 14, + "any": 1, + "zero": 1, + "map": 2, + "#": 1, + "rem": 2, + "%": 1, + ")": 84, + "range": 3, + ";": 8, + "while": 3, + "stops": 1, + "at": 1, + "the": 1, + "first": 2, + "collection": 1, + "element": 1, + "that": 1, + "evaluates": 1, + "to": 1, + "false": 2, + "like": 1, + "take": 1, + "for": 2, + "x": 6, + "html": 1, + "head": 1, + "meta": 1, + "{": 8, + "charset": 1, + "}": 8, + "link": 1, + "rel": 1, + "href": 1, + "script": 1, + "src": 1, + "body": 1, + "div.nav": 1, + "p": 1, + "into": 2, + "array": 3, + "aseq": 8, + "nil": 1, + "type": 2, + "let": 1, + "count": 3, + "a": 3, + "make": 1, + "loop": 1, + "seq": 1, + "i": 4, + "if": 1, + "<": 1, + "do": 1, + "aset": 1, + "recur": 1, + "next": 1, + "inc": 1, + "defprotocol": 1, + "ISound": 4, + "sound": 5, + "deftype": 2, + "Cat": 1, + "_": 3, + "Dog": 1, + "extend": 1, + "default": 1, + "rand": 2, + "scm*": 1, + "random": 1, + "real": 1, + "clj": 1, + "ns": 2, + "c2.svg": 2, + "use": 2, + "c2.core": 2, + "only": 4, + "unify": 2, + "c2.maths": 2, + "Pi": 2, + "Tau": 2, + "radians": 2, + "per": 2, + "degree": 2, + "sin": 2, + "cos": 2, + "mean": 2, + "cljs": 3, + "require": 1, + "c2.dom": 1, + "as": 1, + "dom": 1, + "Stub": 1, + "float": 2, + "fn": 2, + "which": 1, + "does": 1, + "exist": 1, + "on": 1, + "runtime": 1, + "def": 1, + "identity": 1, + "xy": 1, + "coordinates": 7, + "cond": 1, + "and": 1, + "vector": 1, + "y": 1, + "deftest": 1, + "function": 1, + "tests": 1, + "is": 7, + "true": 2, + "contains": 1, + "foo": 6, + "bar": 4, + "select": 1, + "keys": 2, + "baz": 4, + "vals": 1, + "filter": 1 + }, "COBOL": { "program": 1, "-": 19, @@ -10603,6 +14335,49 @@ "xFF": 1, "ip.join": 1 }, + "Common Lisp": { + ";": 10, + "-": 10, + "*": 2, + "lisp": 1, + "(": 14, + "in": 1, + "package": 1, + "foo": 2, + ")": 14, + "Header": 1, + "comment.": 4, + "defvar": 1, + "*foo*": 1, + "eval": 1, + "when": 1, + "execute": 1, + "compile": 1, + "toplevel": 2, + "load": 1, + "defun": 1, + "add": 1, + "x": 5, + "&": 3, + "optional": 1, + "y": 2, + "key": 1, + "z": 2, + "declare": 1, + "ignore": 1, + "Inline": 1, + "+": 2, + "or": 1, + "#": 2, + "|": 2, + "Multi": 1, + "line": 2, + "defmacro": 1, + "body": 1, + "b": 1, + "if": 1, + "After": 1 + }, "Coq": { "Inductive": 41, "day": 9, @@ -11941,6 +15716,95 @@ "IHhas_type1.": 1, "IHhas_type2.": 1 }, + "Creole": { + "Creole": 6, + "is": 3, + "a": 2, + "-": 5, + "to": 2, + "HTML": 1, + "converter": 2, + "for": 1, + "the": 5, + "lightweight": 1, + "markup": 1, + "language": 1, + "(": 5, + "http": 4, + "//wikicreole.org/": 1, + ")": 5, + ".": 1, + "Github": 1, + "uses": 1, + "this": 1, + "render": 1, + "*.creole": 1, + "files.": 1, + "Project": 1, + "page": 1, + "on": 2, + "github": 1, + "*": 5, + "//github.com/minad/creole": 1, + "Travis": 1, + "CI": 1, + "https": 1, + "//travis": 1, + "ci.org/minad/creole": 1, + "RDOC": 1, + "//rdoc.info/projects/minad/creole": 1, + "INSTALLATION": 1, + "{": 6, + "gem": 1, + "install": 1, + "creole": 1, + "}": 6, + "SYNOPSIS": 1, + "require": 1, + "html": 1, + "Creole.creolize": 1, + "BUGS": 1, + "If": 1, + "you": 1, + "found": 1, + "bug": 1, + "please": 1, + "report": 1, + "it": 1, + "at": 1, + "project": 1, + "s": 1, + "tracker": 1, + "GitHub": 1, + "//github.com/minad/creole/issues": 1, + "AUTHORS": 1, + "Lars": 2, + "Christensen": 2, + "larsch": 1, + "Daniel": 2, + "Mendler": 1, + "minad": 1, + "LICENSE": 1, + "Copyright": 1, + "c": 1, + "Mendler.": 1, + "It": 1, + "free": 1, + "software": 1, + "and": 1, + "may": 1, + "be": 1, + "redistributed": 1, + "under": 1, + "terms": 1, + "specified": 1, + "in": 1, + "README": 1, + "file": 1, + "of": 1, + "Ruby": 1, + "distribution.": 1 + }, "CSS": { ".clearfix": 8, "{": 1661, @@ -12689,30 +16553,113 @@ "backdrop.fade": 1, "backdrop.fade.in": 1 }, + "Cuda": { + "__global__": 2, + "void": 3, + "scalarProdGPU": 1, + "(": 20, + "float": 8, + "*d_C": 1, + "*d_A": 1, + "*d_B": 1, + "int": 14, + "vectorN": 2, + "elementN": 3, + ")": 20, + "{": 8, + "//Accumulators": 1, + "cache": 1, + "__shared__": 1, + "accumResult": 5, + "[": 11, + "ACCUM_N": 4, + "]": 11, + ";": 30, + "////////////////////////////////////////////////////////////////////////////": 2, + "for": 5, + "vec": 5, + "blockIdx.x": 2, + "<": 5, + "+": 12, + "gridDim.x": 1, + "vectorBase": 3, + "IMUL": 1, + "vectorEnd": 2, + "////////////////////////////////////////////////////////////////////////": 4, + "iAccum": 10, + "threadIdx.x": 4, + "blockDim.x": 3, + "sum": 3, + "pos": 5, + "d_A": 2, + "*": 2, + "d_B": 2, + "}": 8, + "stride": 5, + "/": 2, + "__syncthreads": 1, + "if": 3, + "d_C": 2, + "#include": 2, + "": 1, + "": 1, + "vectorAdd": 2, + "const": 2, + "*A": 1, + "*B": 1, + "*C": 1, + "numElements": 4, + "i": 5, + "C": 1, + "A": 1, + "B": 1, + "main": 1, + "cudaError_t": 1, + "err": 5, + "cudaSuccess": 2, + "threadsPerBlock": 4, + "blocksPerGrid": 1, + "-": 1, + "<<": 1, + "": 1, + "cudaGetLastError": 1, + "fprintf": 1, + "stderr": 1, + "cudaGetErrorString": 1, + "exit": 1, + "EXIT_FAILURE": 1, + "cudaDeviceReset": 1, + "return": 1 + }, "Dart": { + "import": 1, + "as": 1, + "math": 1, + ";": 9, "class": 1, - "Point": 7, + "Point": 5, "{": 3, + "num": 2, + "x": 2, + "y": 2, "(": 7, "this.x": 1, "this.y": 1, ")": 7, - ";": 8, "distanceTo": 1, "other": 1, - "var": 3, + "var": 4, "dx": 3, - "x": 2, "-": 2, "other.x": 1, "dy": 3, - "y": 2, "other.y": 1, "return": 1, - "Math.sqrt": 1, + "math.sqrt": 1, "*": 2, "+": 1, "}": 3, + "void": 1, "main": 1, "p": 1, "new": 2, @@ -12729,7 +16676,623 @@ "d472341..8ad9ffb": 1, "+": 3 }, - "Ecl": { + "DM": { + "#define": 4, + "PI": 6, + "#if": 1, + "G": 1, + "#elif": 1, + "I": 1, + "#else": 1, + "K": 1, + "#endif": 1, + "var/GlobalCounter": 1, + "var/const/CONST_VARIABLE": 1, + "var/list/MyList": 1, + "list": 3, + "(": 17, + "new": 1, + "/datum/entity": 2, + ")": 17, + "var/list/EmptyList": 1, + "[": 2, + "]": 2, + "//": 6, + "creates": 1, + "a": 1, + "of": 1, + "null": 2, + "entries": 1, + "var/list/NullList": 1, + "var/name": 1, + "var/number": 1, + "/datum/entity/proc/myFunction": 1, + "world.log": 5, + "<<": 5, + "/datum/entity/New": 1, + "number": 2, + "GlobalCounter": 1, + "+": 3, + "/datum/entity/unit": 1, + "name": 1, + "/datum/entity/unit/New": 1, + "..": 1, + "calls": 1, + "the": 2, + "parent": 1, + "s": 1, + "proc": 1, + ";": 3, + "equal": 1, + "to": 1, + "super": 1, + "and": 1, + "base": 1, + "in": 1, + "other": 1, + "languages": 1, + "rand": 1, + "/datum/entity/unit/myFunction": 1, + "/proc/ReverseList": 1, + "var/list/input": 1, + "var/list/output": 1, + "for": 1, + "var/i": 1, + "input.len": 1, + "i": 3, + "-": 2, + "IMPORTANT": 1, + "List": 1, + "Arrays": 1, + "count": 1, + "from": 1, + "output": 2, + "input": 1, + "is": 2, + "return": 3, + "/proc/DoStuff": 1, + "var/bitflag": 2, + "bitflag": 4, + "|": 1, + "/proc/DoOtherStuff": 1, + "bits": 1, + "maximum": 1, + "amount": 1, + "&": 1, + "/proc/DoNothing": 1, + "var/pi": 1, + "if": 2, + "pi": 2, + "else": 2, + "CONST_VARIABLE": 1, + "#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, "true": 1, @@ -14111,6 +18674,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, @@ -14652,10 +21531,180 @@ "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": { - "print": 4, - "(": 54, - ")": 55, "<%!-->": 1, "defined": 1, "in": 3, @@ -14665,9 +21714,11 @@ "%": 2, "@": 1, "params": 1, + "(": 53, "users": 2, "Collection": 1, "": 1, + ")": 54, "<%>": 2, "for": 2, "user": 1, @@ -14694,6 +21745,7 @@ "int": 2, "Relationship.valueOf": 2, "hello": 1, + "print": 3, "uses": 2, "java.util.*": 1, "java.io.File": 1, @@ -14903,6 +21955,240 @@ "": 1, "/each": 1 }, + "Hy": { + ";": 4, + "Fibonacci": 1, + "example": 2, + "in": 2, + "Hy.": 2, + "(": 28, + "defn": 2, + "fib": 4, + "[": 10, + "n": 5, + "]": 10, + "if": 2, + "<": 1, + ")": 28, + "+": 1, + "-": 10, + "__name__": 1, + "for": 2, + "x": 3, + "print": 1, + "The": 1, + "concurrent.futures": 2, + "import": 1, + "ThreadPoolExecutor": 2, + "as": 3, + "completed": 2, + "random": 1, + "randint": 2, + "sh": 1, + "sleep": 2, + "task": 2, + "to": 2, + "do": 2, + "with": 1, + "executor": 2, + "setv": 1, + "jobs": 2, + "list": 1, + "comp": 1, + ".submit": 1, + "range": 1, + "future": 2, + ".result": 1 + }, + "IDL": { + ";": 59, + "docformat": 3, + "+": 8, + "Inverse": 1, + "hyperbolic": 2, + "cosine.": 1, + "Uses": 1, + "the": 7, + "formula": 1, + "text": 1, + "{": 3, + "acosh": 1, + "}": 3, + "(": 26, + "z": 9, + ")": 26, + "ln": 1, + "sqrt": 4, + "-": 14, + "Examples": 2, + "The": 1, + "arc": 1, + "sine": 1, + "function": 4, + "looks": 1, + "like": 2, + "IDL": 5, + "x": 8, + "*": 2, + "findgen": 1, + "/": 1, + "plot": 1, + "mg_acosh": 2, + "xstyle": 1, + "This": 1, + "should": 1, + "look": 1, + "..": 1, + "image": 1, + "acosh.png": 1, + "Returns": 3, + "float": 1, + "double": 2, + "complex": 2, + "or": 1, + "depending": 1, + "on": 1, + "input": 2, + "Params": 3, + "in": 4, + "required": 4, + "type": 5, + "numeric": 1, + "compile_opt": 3, + "strictarr": 3, + "return": 5, + "alog": 1, + "end": 5, + "MODULE": 1, + "mg_analysis": 1, + "DESCRIPTION": 1, + "Tools": 1, + "for": 2, + "analysis": 1, + "VERSION": 1, + "SOURCE": 1, + "mgalloy": 1, + "BUILD_DATE": 1, + "January": 1, + "FUNCTION": 2, + "MG_ARRAY_EQUAL": 1, + "KEYWORDS": 1, + "MG_TOTAL": 1, + "Find": 1, + "greatest": 1, + "common": 1, + "denominator": 1, + "GCD": 1, + "two": 1, + "positive": 2, + "integers.": 1, + "integer": 5, + "a": 4, + "first": 1, + "b": 4, + "second": 1, + "mg_gcd": 2, + "on_error": 1, + "if": 5, + "n_params": 1, + "ne": 1, + "then": 5, + "message": 2, + "mg_isinteger": 2, + "||": 1, + "begin": 2, + "endif": 2, + "_a": 3, + "abs": 2, + "_b": 3, + "minArg": 5, + "<": 1, + "maxArg": 3, + "eq": 2, + "remainder": 3, + "mod": 1, + "Truncate": 1, + "argument": 2, + "towards": 1, + "i.e.": 1, + "takes": 1, + "FLOOR": 1, + "of": 4, + "values": 2, + "and": 1, + "CEIL": 1, + "negative": 1, + "values.": 1, + "Try": 1, + "main": 2, + "level": 2, + "program": 2, + "at": 1, + "this": 1, + "file.": 1, + "It": 1, + "does": 1, + "print": 4, + "mg_trunc": 3, + "[": 6, + "]": 6, + "floor": 2, + "ceil": 2, + "array": 2, + "same": 1, + "as": 1, + "float/double": 1, + "containing": 1, + "to": 1, + "truncate": 1, + "result": 3, + "posInd": 3, + "where": 1, + "gt": 2, + "nposInd": 2, + "L": 1, + "example": 1 + }, + "Idris": { + "module": 1, + "Prelude.Char": 1, + "import": 1, + "Builtins": 1, + "isUpper": 4, + "Char": 13, + "-": 8, + "Bool": 8, + "x": 36, + "&&": 3, + "<=>": 3, + "Z": 1, + "isLower": 4, + "z": 1, + "isAlpha": 3, + "||": 9, + "isDigit": 3, + "(": 8, + "9": 1, + "isAlphaNum": 2, + "isSpace": 2, + "isNL": 2, + "toUpper": 3, + "if": 2, + ")": 7, + "then": 2, + "prim__intToChar": 2, + "prim__charToInt": 2, + "else": 2, + "toLower": 2, + "+": 1, + "isHexDigit": 2, + "elem": 1, + "hexChars": 3, + "where": 1, + "List": 1, + "[": 1, + "]": 1 + }, "INI": { ";": 1, "editorconfig.org": 1, @@ -14932,6 +22218,11 @@ "SHEBANG#!ioke": 1, "println": 1 }, + "Jade": { + "p.": 1, + "Hello": 1, + "World": 1 + }, "Java": { "package": 6, "clojure.asm": 1, @@ -21883,12 +29174,63 @@ "logger": 2 }, "JSON": { - "{": 143, - "}": 143, - "[": 165, - "]": 165, + "{": 73, + "[": 17, + "]": 17, + "}": 73, "true": 3 }, + "JSON5": { + "{": 6, + "foo": 1, + "while": 1, + "true": 1, + "this": 1, + "here": 1, + "//": 2, + "inline": 1, + "comment": 1, + "hex": 1, + "xDEADbeef": 1, + "half": 1, + ".5": 1, + "delta": 1, + "+": 1, + "to": 1, + "Infinity": 1, + "and": 1, + "beyond": 1, + "finally": 1, + "oh": 1, + "[": 3, + "]": 3, + "}": 6, + "name": 1, + "version": 1, + "description": 1, + "keywords": 1, + "author": 1, + "contributors": 1, + "main": 1, + "bin": 1, + "dependencies": 1, + "devDependencies": 1, + "mocha": 1, + "scripts": 1, + "build": 1, + "test": 1, + "homepage": 1, + "repository": 1, + "type": 1, + "url": 1 + }, + "JSONLD": { + "{": 7, + "}": 7, + "[": 1, + "null": 2, + "]": 1 + }, "Julia": { "##": 5, "Test": 1, @@ -22051,6 +29393,29 @@ "true": 1, "return": 1 }, + "KRL": { + "ruleset": 1, + "sample": 1, + "{": 3, + "meta": 1, + "name": 1, + "description": 1, + "<<": 1, + "Hello": 1, + "world": 1, + "author": 1, + "}": 3, + "rule": 1, + "hello": 1, + "select": 1, + "when": 1, + "web": 1, + "pageview": 1, + "notify": 1, + "(": 1, + ")": 1, + ";": 1 + }, "Lasso": { "<": 7, "LassoScript": 1, @@ -22937,6 +30302,430 @@ "/": 2, "margin": 1 }, + "LFE": { + ";": 213, + "Copyright": 4, + "(": 217, + "c": 4, + ")": 231, + "Duncan": 4, + "McGreggor": 4, + "": 2, + "Licensed": 3, + "under": 9, + "the": 36, + "Apache": 3, + "License": 12, + "Version": 3, + "you": 3, + "may": 6, + "not": 5, + "use": 6, + "this": 3, + "file": 6, + "except": 3, + "in": 10, + "compliance": 3, + "with": 8, + "License.": 6, + "You": 3, + "obtain": 3, + "a": 8, + "copy": 3, + "of": 10, + "at": 4, + "http": 4, + "//www.apache.org/licenses/LICENSE": 3, + "-": 98, + "Unless": 3, + "required": 3, + "by": 4, + "applicable": 3, + "law": 3, + "or": 6, + "agreed": 3, + "to": 10, + "writing": 3, + "software": 3, + "distributed": 6, + "is": 5, + "on": 4, + "an": 5, + "BASIS": 3, + "WITHOUT": 3, + "WARRANTIES": 3, + "OR": 3, + "CONDITIONS": 3, + "OF": 3, + "ANY": 3, + "KIND": 3, + "either": 3, + "express": 3, + "implied.": 3, + "See": 3, + "for": 5, + "specific": 3, + "language": 3, + "governing": 3, + "permissions": 3, + "and": 7, + "limitations": 3, + "File": 4, + "church.lfe": 1, + "Author": 3, + "Purpose": 3, + "Demonstrating": 2, + "church": 20, + "numerals": 1, + "from": 2, + "lambda": 18, + "calculus": 1, + "The": 4, + "code": 2, + "below": 3, + "was": 1, + "used": 1, + "create": 4, + "section": 1, + "user": 1, + "guide": 1, + "here": 1, + "//lfe.github.io/user": 1, + "guide/recursion/5.html": 1, + "Here": 1, + "some": 2, + "example": 2, + "usage": 1, + "slurp": 2, + "five/0": 2, + "int2": 1, + "get": 21, + "defmodule": 2, + "export": 2, + "all": 1, + "defun": 20, + "zero": 2, + "s": 19, + "x": 12, + "one": 1, + "funcall": 23, + "two": 1, + "three": 1, + "four": 1, + "five": 1, + "int": 2, + "successor": 3, + "n": 4, + "+": 2, + "int1": 1, + "numeral": 8, + "#": 3, + "successor/1": 1, + "count": 7, + "limit": 4, + "cond": 1, + "/": 1, + "integer": 2, + "*": 6, + "Mode": 1, + "LFE": 4, + "Code": 1, + "Paradigms": 1, + "Artificial": 1, + "Intelligence": 1, + "Programming": 1, + "Peter": 1, + "Norvig": 1, + "gps1.lisp": 1, + "First": 1, + "version": 1, + "GPS": 1, + "General": 1, + "Problem": 1, + "Solver": 1, + "Converted": 1, + "Robert": 3, + "Virding": 3, + "Define": 1, + "macros": 1, + "global": 2, + "variable": 2, + "access.": 1, + "This": 2, + "hack": 1, + "very": 1, + "naughty": 1, + "defsyntax": 2, + "defvar": 2, + "[": 3, + "name": 8, + "val": 2, + "]": 3, + "let": 6, + "v": 3, + "put": 1, + "getvar": 3, + "solved": 1, + "gps": 1, + "state": 4, + "goals": 2, + "Set": 1, + "variables": 1, + "but": 1, + "existing": 1, + "*ops*": 1, + "*state*": 5, + "current": 1, + "list": 13, + "conditions.": 1, + "if": 1, + "every": 1, + "fun": 1, + "achieve": 1, + "op": 8, + "action": 3, + "setvar": 2, + "set": 1, + "difference": 1, + "del": 5, + "union": 1, + "add": 3, + "drive": 1, + "son": 2, + "school": 2, + "preconds": 4, + "shop": 6, + "installs": 1, + "battery": 1, + "car": 1, + "works": 1, + "make": 2, + "communication": 2, + "telephone": 1, + "have": 3, + "phone": 1, + "book": 1, + "give": 1, + "money": 3, + "has": 1, + "mnesia_demo.lfe": 1, + "A": 1, + "simple": 4, + "Mnesia": 2, + "demo": 2, + "LFE.": 1, + "contains": 1, + "using": 1, + "access": 1, + "tables.": 1, + "It": 1, + "shows": 2, + "how": 2, + "emp": 1, + "XXXX": 1, + "macro": 1, + "ETS": 1, + "match": 5, + "pattern": 1, + "together": 1, + "mnesia": 8, + "match_object": 1, + "specifications": 1, + "select": 1, + "Query": 2, + "List": 2, + "Comprehensions.": 1, + "mnesia_demo": 1, + "new": 2, + "by_place": 1, + "by_place_ms": 1, + "by_place_qlc": 2, + "defrecord": 1, + "person": 8, + "place": 7, + "job": 3, + "Start": 1, + "table": 2, + "we": 1, + "will": 1, + "memory": 1, + "only": 1, + "schema.": 1, + "start": 1, + "create_table": 1, + "attributes": 1, + "Initialise": 1, + "table.": 1, + "people": 1, + "spec": 1, + "p": 2, + "j": 2, + "when": 1, + "tuple": 1, + "transaction": 2, + "f": 3, + "Use": 1, + "Comprehensions": 1, + "records": 1, + "q": 2, + "qlc": 2, + "lc": 1, + "<": 1, + "e": 1, + "object.lfe": 1, + "OOP": 1, + "closures": 1, + "object": 16, + "system": 1, + "demonstrated": 1, + "do": 2, + "following": 2, + "objects": 2, + "call": 2, + "methods": 5, + "those": 1, + "which": 1, + "can": 1, + "other": 1, + "update": 1, + "instance": 2, + "Note": 1, + "however": 1, + "that": 1, + "his": 1, + "does": 1, + "demonstrate": 1, + "inheritance.": 1, + "To": 1, + "cd": 1, + "examples": 1, + "../bin/lfe": 1, + "pa": 1, + "../ebin": 1, + "Load": 1, + "fish": 6, + "class": 3, + "#Fun": 1, + "": 1, + "Execute": 1, + "basic": 1, + "species": 7, + "mommy": 3, + "move": 4, + "Carp": 1, + "swam": 1, + "feet": 1, + "ok": 1, + "id": 9, + "Now": 1, + "strictly": 1, + "necessary.": 1, + "When": 1, + "isn": 1, + "children": 10, + "formatted": 1, + "verb": 2, + "self": 6, + "distance": 2, + "erlang": 1, + "length": 1, + "method": 7, + "define": 1, + "info": 1, + "reproduce": 1 + }, + "Literate Agda": { + "documentclass": 1, + "{": 35, + "article": 1, + "}": 35, + "usepackage": 7, + "amssymb": 1, + "bbm": 1, + "[": 2, + "greek": 1, + "english": 1, + "]": 2, + "babel": 1, + "ucs": 1, + "utf8x": 1, + "inputenc": 1, + "autofe": 1, + "DeclareUnicodeCharacter": 3, + "ensuremath": 3, + "ulcorner": 1, + "urcorner": 1, + "overline": 1, + "equiv": 1, + "fancyvrb": 1, + "DefineVerbatimEnvironment": 1, + "code": 3, + "Verbatim": 1, + "%": 1, + "Add": 1, + "fancy": 1, + "options": 1, + "here": 1, + "if": 1, + "you": 3, + "like.": 1, + "begin": 2, + "document": 2, + "module": 3, + "NatCat": 1, + "where": 2, + "open": 2, + "import": 2, + "Relation.Binary.PropositionalEquality": 1, + "-": 21, + "If": 1, + "can": 1, + "show": 1, + "that": 1, + "a": 1, + "relation": 1, + "only": 1, + "ever": 1, + "has": 1, + "one": 1, + "inhabitant": 5, + "get": 1, + "the": 1, + "category": 1, + "laws": 1, + "for": 1, + "free": 1, + "EasyCategory": 3, + "(": 36, + "obj": 4, + "Set": 2, + ")": 36, + "_": 6, + "x": 34, + "y": 28, + "z": 18, + "id": 9, + "single": 4, + "r": 26, + "s": 29, + "assoc": 2, + "w": 4, + "t": 6, + "Data.Nat": 1, + "same": 5, + ".0": 2, + "n": 14, + "refl": 6, + ".": 5, + "suc": 6, + "m": 6, + "cong": 1, + "trans": 5, + ".n": 1, + "zero": 1, + "Nat": 1, + "end": 2 + }, "Literate CoffeeScript": { "The": 2, "**Scope**": 2, @@ -23379,27 +31168,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, @@ -23420,52 +31209,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, @@ -23479,21 +31268,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, @@ -23567,7 +31356,7 @@ "text": 6, "replaceAll": 11, "writeLine": 2, - "line": 9, + "line": 14, "CacheTempBuffer": 2, "j": 67, "increment": 11, @@ -23585,7 +31374,7 @@ "value": 72, "getSessionValue": 3, "tr": 13, - "+": 188, + "+": 189, "f": 93, "o": 51, "q": 244, @@ -23601,7 +31390,7 @@ "type": 2, "avoid": 1, "Cache": 3, - "bug": 1, + "bug": 2, "getPhraseIndex": 1, "zewdCompiler5": 1, "licensed": 1, @@ -23616,7 +31405,7 @@ "wldSessid": 1, "zzname": 1, "zv": 6, - "[": 53, + "[": 54, "extcErr": 1, "mess": 3, "namespace": 1, @@ -23724,7 +31513,7 @@ "char": 9, "len": 8, "create": 6, - "characters": 4, + "characters": 8, "str": 15, "convertDateToSeconds": 1, "hdate": 7, @@ -23769,12 +31558,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, @@ -23785,7 +31574,7 @@ "openNewFile": 2, "openFile": 2, "openDOM": 2, - "&": 27, + "&": 28, "#39": 1, "<\",\"<\")>": 1, "string=": 1, @@ -23794,7 +31583,7 @@ "HTML": 1, "quot": 2, "stop": 20, - "no": 53, + "no": 54, "no2": 1, "p1_c_p2": 1, "getIP": 2, @@ -23823,7 +31612,7 @@ "linkToParentSession": 2, "zewdCompiler20": 1, "exportToGTM": 1, - "routine": 4, + "routine": 6, "zewdDemo": 1, "Tutorial": 1, "Wed": 1, @@ -23872,10 +31661,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, @@ -23901,12 +31690,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, @@ -23937,7 +31805,6 @@ "digest.init": 3, "usually": 1, "when": 11, - "an": 11, "invalid": 4, "algorithm": 1, "was": 5, @@ -23952,9 +31819,7 @@ "contact": 2, "me": 2, "questions": 2, - "comments": 4, "returns": 7, - "ASCII": 1, "HEX": 1, "all": 8, "one": 5, @@ -24006,7 +31871,6 @@ "illustrate": 1, "dynamic": 1, "scope": 1, - "variables": 2, "triangle1": 1, "sum": 15, "main2": 1, @@ -24014,12 +31878,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, @@ -24131,7 +31993,6 @@ "modulo": 1, "division.": 1, "//en.wikipedia.org/wiki/MD5": 1, - "t": 11, "#64": 1, "msg_": 1, "_m_": 1, @@ -24173,9 +32034,7 @@ "keyId": 108, "been": 4, "tested": 1, - "valid": 1, "these": 1, - "are": 11, "called": 8, "To": 2, "Initialise": 2, @@ -24237,7 +32096,6 @@ "getAttributeId": 2, "domain": 1, "Not": 1, - "allowed": 17, "same": 2, "remove": 6, "existing": 2, @@ -24328,7 +32186,6 @@ "runSelect": 3, "count": 18, "select": 3, - "*": 5, "where": 6, "limit": 14, "asc": 1, @@ -24376,7 +32233,6 @@ ".itemStack": 1, "***": 2, "listCopy": 3, - "numeric": 6, "N.N": 12, "N.N1": 4, "externalSelect": 2, @@ -24587,7 +32443,6 @@ "protect": 11, "erropt": 6, "isstring": 5, - "code": 28, "pcre.config": 1, ".name": 1, ".erropt": 3, @@ -24611,7 +32466,6 @@ "LANG": 4, "LC_*": 1, "output": 49, - "command": 9, "Debian": 2, "tip": 1, "dpkg": 1, @@ -24685,7 +32539,6 @@ "begin_": 1, "_end": 1, "store": 6, - "above": 2, "stores": 1, "captured": 6, "key=": 2, @@ -24761,8 +32614,6 @@ "matched": 1, "back": 4, "th": 3, - "{": 4, - "}": 4, "replaced": 1, "substitution": 2, "begins": 1, @@ -24795,7 +32646,6 @@ "@ref": 2, "E": 12, "COMPILE": 2, - "has": 6, "meaning": 1, "zs": 2, "re": 2, @@ -24875,7 +32725,6 @@ "Run": 1, ".offset": 1, "used.": 2, - "always": 1, "strings": 1, "submitted": 1, "exact": 1, @@ -24884,8 +32733,6 @@ "way": 1, "i*2": 3, "what": 2, - "while": 3, - "/": 2, "/mg": 2, "aaa": 1, "nbb": 1, @@ -24908,7 +32755,6 @@ "listing": 1, "CHAR": 1, "different": 3, - "character": 2, "modes": 1, "In": 1, "probably": 1, @@ -24984,7 +32830,6 @@ "runs": 2, "especially": 1, "there": 2, - "would": 1, "paths": 2, "tree": 1, "checked.": 1, @@ -25089,7 +32934,6 @@ "false": 5, "post2": 1, "special": 2, - "after": 2, "post": 1, "condition": 1, "PRCAAPR": 1, @@ -25106,7 +32950,6 @@ "Accounts": 1, "Receivable": 1, "**198": 1, - "**": 2, "Mar": 1, "Per": 1, "VHA": 1, @@ -25116,7 +32959,6 @@ "PRCATY": 2, "NEW": 3, "DIC": 6, - "X": 18, "Y": 26, "DEBT": 10, "PRCADB": 5, @@ -25159,7 +33001,6 @@ "_PRCATY_": 1, "COMP1": 2, "RCY": 5, - "]": 14, "COMP2": 2, "_STAT_": 1, "_STAT": 1, @@ -25393,7 +33234,6 @@ "WVBEGDT1": 1, "NOTIFICATION": 1, "IS": 3, - "NOT": 1, "QUEUED.": 1, "WVB": 4, "OR": 2, @@ -25507,7 +33347,6 @@ "TODO": 1, "Caller": 1, "indentation": 1, - "comment": 1, "tab": 1, "space.": 1, "M/Wire": 4, @@ -25553,7 +33392,6 @@ "simply": 1, "Stop": 1, "RESJOB": 1, - "it.": 1, "mwireVersion": 4, "mwireDate": 2, "July": 1, @@ -25713,31 +33551,158 @@ "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": 32, - "[": 309, + "function": 34, + "[": 311, "dx": 6, - "y": 22, - "]": 309, + "y": 25, + "]": 311, "adapting_structural_model": 2, - "(": 1357, + "(": 1379, "t": 32, - "x": 42, + "x": 46, "u": 3, "varargin": 25, - ")": 1358, - "%": 552, - "size": 8, + ")": 1380, + "%": 554, + "size": 11, "aux": 3, "{": 157, - "end": 147, + "end": 150, "}": 157, - ";": 891, + ";": 909, "m": 44, - "zeros": 60, + "zeros": 61, "b": 12, - "for": 77, - "i": 334, + "for": 78, + "i": 338, "if": 52, "+": 169, "elseif": 14, @@ -25753,7 +33718,7 @@ "*": 46, "aux.b": 3, "e": 14, - "-": 672, + "-": 673, "c2": 5, "Yc": 5, "parallel": 2, @@ -25773,7 +33738,7 @@ "n": 102, "|": 2, "&": 4, - "error": 14, + "error": 16, "sum": 2, "/length": 1, "bicycle": 7, @@ -25951,7 +33916,7 @@ "num2str": 10, "bikeData.handlingMetric.num": 1, "bikeData.handlingMetric.den": 1, - "w": 3, + "w": 6, "mag": 4, "phase": 2, "bode": 5, @@ -26031,7 +33996,7 @@ "Lateral": 1, "Deviation": 1, "paths.eps": 1, - "d": 3, + "d": 12, "like": 1, "plot.": 1, "names": 6, @@ -26127,6 +34092,23 @@ "minLine": 4, "min": 1, "speedInd": 12, + "cross_validation": 1, + "hyper_parameter": 3, + "num_data": 2, + "K": 4, + "indices": 2, + "crossvalind": 1, + "errors": 4, + "test_idx": 4, + "train_idx": 3, + "x_train": 2, + "y_train": 2, + "train": 1, + "x_test": 3, + "y_test": 3, + "calc_cost": 1, + "calc_error": 2, + "mean": 2, "value": 2, "isterminal": 2, "direction": 2, @@ -26637,6 +34619,12 @@ "command": 2, "line.": 2, "value2": 4, + "d_mean": 3, + "d_std": 3, + "normalize": 1, + "repmat": 2, + "std": 1, + "d./": 1, "overrideSettings": 3, "overrideNames": 2, "defaultNames": 2, @@ -26748,6 +34736,10 @@ "contents.colheaders": 1 }, "Max": { + "{": 126, + "}": 126, + "[": 163, + "]": 163, "max": 1, "v2": 1, ";": 39, @@ -26784,6 +34776,283 @@ "fasten": 1, "pop": 1 }, + "MediaWiki": { + "Overview": 1, + "The": 17, + "GDB": 15, + "Tracepoint": 4, + "Analysis": 1, + "feature": 3, + "is": 9, + "an": 3, + "extension": 1, + "to": 12, + "the": 72, + "Tracing": 3, + "and": 20, + "Monitoring": 1, + "Framework": 1, + "that": 4, + "allows": 2, + "visualization": 1, + "analysis": 1, + "of": 8, + "C/C": 10, + "+": 20, + "tracepoint": 5, + "data": 5, + "collected": 2, + "by": 10, + "stored": 1, + "a": 12, + "log": 1, + "file.": 1, + "Getting": 1, + "Started": 1, + "can": 9, + "be": 18, + "installed": 2, + "from": 8, + "Eclipse": 1, + "update": 2, + "site": 1, + "selecting": 1, + ".": 8, + "requires": 1, + "version": 1, + "or": 8, + "later": 1, + "on": 3, + "local": 1, + "host.": 1, + "executable": 3, + "program": 1, + "must": 3, + "found": 1, + "in": 15, + "path.": 1, + "Trace": 9, + "Perspective": 1, + "To": 1, + "open": 1, + "perspective": 2, + "select": 5, + "includes": 1, + "following": 1, + "views": 2, + "default": 2, + "*": 6, + "This": 7, + "view": 7, + "shows": 7, + "projects": 1, + "workspace": 2, + "used": 1, + "create": 1, + "manage": 1, + "projects.": 1, + "running": 1, + "Postmortem": 5, + "Debugger": 4, + "instances": 1, + "displays": 2, + "thread": 1, + "stack": 2, + "trace": 17, + "associated": 1, + "with": 4, + "tracepoint.": 3, + "status": 1, + "debugger": 1, + "navigation": 1, + "records.": 1, + "console": 1, + "output": 1, + "Debugger.": 1, + "editor": 7, + "area": 2, + "contains": 1, + "editors": 1, + "when": 1, + "opened.": 1, + "[": 11, + "Image": 2, + "images/GDBTracePerspective.png": 1, + "]": 11, + "Collecting": 2, + "Data": 4, + "outside": 2, + "scope": 1, + "this": 5, + "feature.": 1, + "It": 1, + "done": 2, + "command": 1, + "line": 2, + "using": 3, + "CDT": 3, + "debug": 1, + "component": 1, + "within": 1, + "Eclipse.": 1, + "See": 1, + "FAQ": 2, + "entry": 2, + "#References": 2, + "|": 2, + "References": 3, + "section.": 2, + "Importing": 2, + "Some": 1, + "information": 1, + "section": 1, + "redundant": 1, + "LTTng": 3, + "User": 3, + "Guide.": 1, + "For": 1, + "further": 1, + "details": 1, + "see": 1, + "Guide": 2, + "Creating": 1, + "Project": 1, + "In": 5, + "right": 3, + "-": 8, + "click": 8, + "context": 4, + "menu.": 4, + "dialog": 1, + "name": 2, + "your": 2, + "project": 2, + "tracing": 1, + "folder": 5, + "Browse": 2, + "enter": 2, + "source": 2, + "directory.": 1, + "Select": 1, + "file": 6, + "tree.": 1, + "Optionally": 1, + "set": 1, + "type": 2, + "Click": 1, + "Alternatively": 1, + "drag": 1, + "&": 1, + "dropped": 1, + "any": 2, + "external": 1, + "manager.": 1, + "Selecting": 2, + "Type": 1, + "Right": 2, + "imported": 1, + "choose": 2, + "step": 1, + "omitted": 1, + "if": 1, + "was": 2, + "selected": 3, + "at": 3, + "import.": 1, + "will": 6, + "updated": 2, + "icon": 1, + "images/gdb_icon16.png": 1, + "Executable": 1, + "created": 1, + "identified": 1, + "so": 2, + "launched": 1, + "properly.": 1, + "path": 1, + "press": 1, + "recognized": 1, + "as": 1, + "executable.": 1, + "Visualizing": 1, + "Opening": 1, + "double": 1, + "it": 3, + "opened": 2, + "Events": 5, + "instance": 1, + "launched.": 1, + "If": 2, + "available": 1, + "code": 1, + "corresponding": 1, + "first": 1, + "record": 2, + "also": 2, + "editor.": 2, + "At": 1, + "point": 1, + "recommended": 1, + "relocate": 1, + "not": 1, + "hidden": 1, + "Viewing": 1, + "table": 1, + "shown": 1, + "one": 1, + "row": 1, + "for": 2, + "each": 1, + "record.": 2, + "column": 6, + "sequential": 1, + "number.": 1, + "number": 2, + "assigned": 1, + "collection": 1, + "time": 2, + "method": 1, + "where": 1, + "set.": 1, + "run": 1, + "Searching": 1, + "filtering": 1, + "entering": 1, + "regular": 1, + "expression": 1, + "header.": 1, + "Navigating": 1, + "records": 1, + "keyboard": 1, + "mouse.": 1, + "show": 1, + "current": 1, + "navigated": 1, + "clicking": 1, + "buttons.": 1, + "updated.": 1, + "http": 4, + "//wiki.eclipse.org/index.php/Linux_Tools_Project/LTTng2/User_Guide": 1, + "//wiki.eclipse.org/CDT/User/FAQ#How_can_I_trace_my_application_using_C.2FC.2B.2B_Tracepoints.3F": 1, + "How": 1, + "I": 1, + "my": 1, + "application": 1, + "Tracepoints": 1, + "Updating": 1, + "Document": 1, + "document": 2, + "maintained": 1, + "collaborative": 1, + "wiki.": 1, + "you": 1, + "wish": 1, + "modify": 1, + "please": 1, + "visit": 1, + "//wiki.eclipse.org/index.php/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide": 1, + "//wiki.eclipse.org/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide": 1 + }, "Monkey": { "Strict": 1, "sample": 1, @@ -27186,6 +35455,96 @@ "WriteLine": 1, "}": 2 }, + "NetLogo": { + "patches": 7, + "-": 28, + "own": 1, + "[": 17, + "living": 6, + ";": 12, + "indicates": 1, + "if": 2, + "the": 6, + "cell": 10, + "is": 1, + "live": 4, + "neighbors": 5, + "counts": 1, + "how": 1, + "many": 1, + "neighboring": 1, + "cells": 2, + "are": 1, + "alive": 1, + "]": 17, + "to": 6, + "setup": 2, + "blank": 1, + "clear": 2, + "all": 5, + "ask": 6, + "death": 5, + "reset": 2, + "ticks": 2, + "end": 6, + "random": 2, + "ifelse": 3, + "float": 1, + "<": 1, + "initial": 1, + "density": 1, + "birth": 4, + "set": 5, + "true": 1, + "pcolor": 2, + "fgcolor": 1, + "false": 1, + "bgcolor": 1, + "go": 1, + "count": 1, + "with": 2, + "Starting": 1, + "a": 1, + "new": 1, + "here": 1, + "ensures": 1, + "that": 1, + "finish": 1, + "executing": 2, + "first": 1, + "before": 1, + "any": 1, + "of": 2, + "them": 1, + "start": 1, + "second": 1, + "ask.": 1, + "This": 1, + "keeps": 1, + "in": 2, + "synch": 1, + "each": 2, + "other": 1, + "so": 1, + "births": 1, + "and": 1, + "deaths": 1, + "at": 1, + "generation": 1, + "happen": 1, + "lockstep.": 1, + "tick": 1, + "draw": 1, + "let": 1, + "erasing": 2, + "patch": 2, + "mouse": 5, + "xcor": 2, + "ycor": 2, + "while": 1, + "down": 1, + "display": 1 + }, "Nginx": { "user": 1, "www": 2, @@ -30546,23 +38905,23 @@ "OpenCL": { "double": 3, "run_fftw": 1, - "(": 11, + "(": 18, "int": 3, - "n": 2, - "const": 2, - "float": 2, - "*": 4, - "x": 2, - "y": 2, - ")": 11, - "{": 2, + "n": 4, + "const": 4, + "float": 3, + "*": 5, + "x": 5, + "y": 4, + ")": 18, + "{": 4, "fftwf_plan": 1, "p1": 3, "fftwf_plan_dft_1d": 1, "fftwf_complex": 2, "FFTW_FORWARD": 1, "FFTW_ESTIMATE": 1, - ";": 9, + ";": 12, "nops": 3, "t": 4, "cl": 2, @@ -30570,13 +38929,30 @@ "for": 1, "op": 3, "<": 1, - "+": 2, + "+": 4, "fftwf_execute": 1, - "}": 2, + "}": 4, "-": 1, "/": 1, "fftwf_destroy_plan": 1, - "return": 1 + "return": 1, + "typedef": 1, + "foo_t": 3, + "#ifndef": 1, + "ZERO": 3, + "#define": 2, + "#endif": 1, + "FOO": 1, + "__kernel": 1, + "void": 1, + "foo": 1, + "__global": 1, + "__local": 1, + "uint": 1, + "barrier": 1, + "CLK_LOCAL_MEM_FENCE": 1, + "if": 1, + "*x": 1 }, "OpenEdge ABL": { "USING": 3, @@ -30797,6 +39173,298 @@ "CHR": 2, "lcPostBase64Data.": 1 }, + "Org": { + "#": 13, + "+": 13, + "OPTIONS": 1, + "H": 1, + "num": 1, + "nil": 4, + "toc": 2, + "n": 1, + "@": 1, + "t": 10, + "|": 4, + "-": 30, + "f": 2, + "*": 3, + "TeX": 1, + "LaTeX": 1, + "skip": 1, + "d": 2, + "(": 11, + "HIDE": 1, + ")": 11, + "tags": 2, + "not": 1, + "in": 2, + "STARTUP": 1, + "align": 1, + "fold": 1, + "nodlcheck": 1, + "hidestars": 1, + "oddeven": 1, + "lognotestate": 1, + "SEQ_TODO": 1, + "TODO": 1, + "INPROGRESS": 1, + "i": 1, + "WAITING": 1, + "w@": 1, + "DONE": 1, + "CANCELED": 1, + "c@": 1, + "TAGS": 1, + "Write": 1, + "w": 1, + "Update": 1, + "u": 1, + "Fix": 1, + "Check": 1, + "c": 1, + "TITLE": 1, + "org": 10, + "ruby": 6, + "AUTHOR": 1, + "Brian": 1, + "Dewey": 1, + "EMAIL": 1, + "bdewey@gmail.com": 1, + "LANGUAGE": 1, + "en": 1, + "PRIORITIES": 1, + "A": 1, + "C": 1, + "B": 1, + "CATEGORY": 1, + "worg": 1, + "{": 1, + "Back": 1, + "to": 8, + "Worg": 1, + "rubygems": 2, + "ve": 1, + "already": 1, + "created": 1, + "a": 4, + "site.": 1, + "Make": 1, + "sure": 1, + "you": 2, + "have": 1, + "installed": 1, + "sudo": 1, + "gem": 1, + "install": 1, + ".": 1, + "You": 1, + "need": 1, + "register": 1, + "new": 2, + "Webby": 3, + "filter": 3, + "handle": 1, + "mode": 2, + "content.": 2, + "makes": 1, + "this": 2, + "easy.": 1, + "In": 1, + "the": 6, + "lib/": 1, + "folder": 1, + "of": 2, + "your": 2, + "site": 1, + "create": 1, + "file": 1, + "orgmode.rb": 1, + "BEGIN_EXAMPLE": 2, + "require": 1, + "Filters.register": 1, + "do": 2, + "input": 3, + "Orgmode": 2, + "Parser.new": 1, + ".to_html": 1, + "end": 1, + "END_EXAMPLE": 1, + "This": 2, + "code": 1, + "creates": 1, + "that": 1, + "will": 1, + "use": 1, + "parser": 1, + "translate": 1, + "into": 1, + "HTML.": 1, + "Create": 1, + "For": 1, + "example": 1, + "title": 2, + "Parser": 1, + "created_at": 1, + "status": 2, + "Under": 1, + "development": 1, + "erb": 1, + "orgmode": 3, + "<%=>": 2, + "page": 2, + "Status": 1, + "Description": 1, + "Helpful": 1, + "Ruby": 1, + "routines": 1, + "for": 3, + "parsing": 1, + "files.": 1, + "The": 3, + "most": 1, + "significant": 1, + "thing": 2, + "library": 1, + "does": 1, + "today": 1, + "is": 5, + "convert": 1, + "files": 1, + "textile.": 1, + "Currently": 1, + "cannot": 1, + "much": 1, + "customize": 1, + "conversion.": 1, + "supplied": 1, + "textile": 1, + "conversion": 1, + "optimized": 1, + "extracting": 1, + "from": 1, + "orgfile": 1, + "as": 1, + "opposed": 1, + "History": 1, + "**": 1, + "Version": 1, + "first": 1, + "output": 2, + "HTML": 2, + "gets": 1, + "class": 1, + "now": 1, + "indented": 1, + "Proper": 1, + "support": 1, + "multi": 1, + "paragraph": 2, + "list": 1, + "items.": 1, + "See": 1, + "part": 1, + "last": 1, + "bullet.": 1, + "Fixed": 1, + "bugs": 1, + "wouldn": 1, + "s": 1, + "all": 1, + "there": 1, + "it": 1 + }, + "Oxygene": { + "": 1, + "DefaultTargets=": 1, + "xmlns=": 1, + "": 3, + "": 1, + "Loops": 2, + "": 1, + "": 1, + "exe": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "False": 4, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "Properties": 1, + "App.ico": 1, + "": 1, + "": 1, + "Condition=": 3, + "Release": 2, + "": 1, + "": 1, + "{": 1, + "BD89C": 1, + "-": 4, + "B610": 1, + "CEE": 1, + "CAF": 1, + "C515D88E2C94": 1, + "}": 1, + "": 1, + "": 3, + "": 1, + "DEBUG": 1, + ";": 2, + "TRACE": 1, + "": 1, + "": 2, + ".": 2, + "bin": 2, + "Debug": 1, + "": 2, + "": 1, + "True": 3, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "": 1, + "Project=": 1, + "": 2, + "": 5, + "Include=": 12, + "": 5, + "(": 5, + "Framework": 5, + ")": 5, + "mscorlib.dll": 1, + "": 5, + "": 5, + "System.dll": 1, + "ProgramFiles": 1, + "Reference": 1, + "Assemblies": 1, + "Microsoft": 1, + "v3.5": 1, + "System.Core.dll": 1, + "": 1, + "": 1, + "System.Data.dll": 1, + "System.Xml.dll": 1, + "": 2, + "": 4, + "": 1, + "": 1, + "": 2, + "ResXFileCodeGenerator": 1, + "": 2, + "": 1, + "": 1, + "SettingsSingleFileGenerator": 1, + "": 1, + "": 1 + }, "Parrot Assembly": { "SHEBANG#!parrot": 1, ".pcc_sub": 1, @@ -30835,6 +39503,165 @@ "Application.Run": 1, "end.": 1 }, + "PAWN": { + "//": 22, + "-": 1551, + "#include": 5, + "": 1, + "": 1, + "": 1, + "#pragma": 1, + "tabsize": 1, + "#define": 5, + "COLOR_WHITE": 2, + "xFFFFFFFF": 2, + "COLOR_NORMAL_PLAYER": 3, + "xFFBB7777": 1, + "CITY_LOS_SANTOS": 7, + "CITY_SAN_FIERRO": 4, + "CITY_LAS_VENTURAS": 6, + "new": 13, + "total_vehicles_from_files": 19, + ";": 257, + "gPlayerCitySelection": 21, + "[": 56, + "MAX_PLAYERS": 3, + "]": 56, + "gPlayerHasCitySelected": 6, + "gPlayerLastCitySelectionTick": 5, + "Text": 5, + "txtClassSelHelper": 14, + "txtLosSantos": 7, + "txtSanFierro": 7, + "txtLasVenturas": 7, + "thisanimid": 1, + "lastanimid": 1, + "main": 1, + "(": 273, + ")": 273, + "{": 39, + "print": 3, + "}": 39, + "public": 6, + "OnPlayerConnect": 1, + "playerid": 132, + "GameTextForPlayer": 1, + "SendClientMessage": 1, + "GetTickCount": 4, + "//SetPlayerColor": 2, + "//Kick": 1, + "return": 17, + "OnPlayerSpawn": 1, + "if": 28, + "IsPlayerNPC": 3, + "randSpawn": 16, + "SetPlayerInterior": 7, + "TogglePlayerClock": 2, + "ResetPlayerMoney": 3, + "GivePlayerMoney": 2, + "random": 3, + "sizeof": 3, + "gRandomSpawns_LosSantos": 5, + "SetPlayerPos": 6, + "SetPlayerFacingAngle": 6, + "else": 9, + "gRandomSpawns_SanFierro": 5, + "gRandomSpawns_LasVenturas": 5, + "SetPlayerSkillLevel": 11, + "WEAPONSKILL_PISTOL": 1, + "WEAPONSKILL_PISTOL_SILENCED": 1, + "WEAPONSKILL_DESERT_EAGLE": 1, + "WEAPONSKILL_SHOTGUN": 1, + "WEAPONSKILL_SAWNOFF_SHOTGUN": 1, + "WEAPONSKILL_SPAS12_SHOTGUN": 1, + "WEAPONSKILL_MICRO_UZI": 1, + "WEAPONSKILL_MP5": 1, + "WEAPONSKILL_AK47": 1, + "WEAPONSKILL_M4": 1, + "WEAPONSKILL_SNIPERRIFLE": 1, + "GivePlayerWeapon": 1, + "WEAPON_COLT45": 1, + "//GivePlayerWeapon": 1, + "WEAPON_MP5": 1, + "OnPlayerDeath": 1, + "killerid": 3, + "reason": 1, + "playercash": 4, + "INVALID_PLAYER_ID": 1, + "GetPlayerMoney": 1, + "ClassSel_SetupCharSelection": 2, + "SetPlayerCameraPos": 6, + "SetPlayerCameraLookAt": 6, + "ClassSel_InitCityNameText": 4, + "txtInit": 7, + "TextDrawUseBox": 2, + "TextDrawLetterSize": 2, + "TextDrawFont": 2, + "TextDrawSetShadow": 2, + "TextDrawSetOutline": 2, + "TextDrawColor": 2, + "xEEEEEEFF": 1, + "TextDrawBackgroundColor": 2, + "FF": 2, + "ClassSel_InitTextDraws": 2, + "TextDrawCreate": 4, + "TextDrawBoxColor": 1, + "BB": 1, + "TextDrawTextSize": 1, + "ClassSel_SetupSelectedCity": 3, + "TextDrawShowForPlayer": 4, + "TextDrawHideForPlayer": 10, + "ClassSel_SwitchToNextCity": 3, + "+": 19, + "PlayerPlaySound": 2, + "ClassSel_SwitchToPreviousCity": 2, + "<": 3, + "ClassSel_HandleCitySelection": 2, + "Keys": 3, + "ud": 2, + "lr": 4, + "GetPlayerKeys": 1, + "&": 1, + "KEY_FIRE": 1, + "TogglePlayerSpectating": 2, + "OnPlayerRequestClass": 1, + "classid": 1, + "GetPlayerState": 2, + "PLAYER_STATE_SPECTATING": 2, + "OnGameModeInit": 1, + "SetGameModeText": 1, + "ShowPlayerMarkers": 1, + "PLAYER_MARKERS_MODE_GLOBAL": 1, + "ShowNameTags": 1, + "SetNameTagDrawDistance": 1, + "EnableStuntBonusForAll": 1, + "DisableInteriorEnterExits": 1, + "SetWeather": 1, + "SetWorldTime": 1, + "//UsePlayerPedAnims": 1, + "//ManualVehicleEngineAndLights": 1, + "//LimitGlobalChatRadius": 1, + "AddPlayerClass": 69, + "//AddPlayerClass": 1, + "LoadStaticVehiclesFromFile": 17, + "printf": 1, + "OnPlayerUpdate": 1, + "IsPlayerConnected": 1, + "&&": 2, + "GetPlayerInterior": 1, + "GetPlayerWeapon": 2, + "SetPlayerArmedWeapon": 1, + "fists": 1, + "no": 1, + "syncing": 1, + "until": 1, + "they": 1, + "change": 1, + "their": 1, + "weapon": 1, + "WEAPON_MINIGUN": 1, + "Kick": 1 + }, "Perl": { "package": 14, "App": 131, @@ -32550,6 +41377,131 @@ "reference.": 1, "AUTHOR": 1 }, + "Perl6": { + "token": 6, + "pod_formatting_code": 1, + "{": 29, + "": 1, + "<[A..Z]>": 1, + "*POD_IN_FORMATTINGCODE": 1, + "}": 27, + "": 1, + "[": 1, + "": 1, + "#": 13, + "N*": 1, + "role": 10, + "q": 5, + "stopper": 2, + "MAIN": 1, + "quote": 1, + ")": 19, + "backslash": 3, + "sym": 3, + "<\\\\>": 1, + "": 1, + "": 1, + "": 1, + "": 1, + ".": 1, + "method": 2, + "tweak_q": 1, + "(": 16, + "v": 2, + "self.panic": 2, + "tweak_qq": 1, + "qq": 5, + "does": 7, + "b1": 1, + "c1": 1, + "s1": 1, + "a1": 1, + "h1": 1, + "f1": 1, + "Too": 2, + "late": 2, + "for": 2, + "SHEBANG#!perl": 1, + "use": 1, + "v6": 1, + ";": 19, + "my": 10, + "string": 7, + "if": 1, + "eq": 1, + "say": 10, + "regex": 2, + "http": 1, + "-": 3, + "verb": 1, + "|": 9, + "multi": 2, + "line": 5, + "comment": 2, + "I": 1, + "there": 1, + "m": 2, + "even": 1, + "specialer": 1, + "nesting": 1, + "work": 1, + "<": 3, + "trying": 1, + "mixed": 1, + "delimiters": 1, + "": 1, + "arbitrary": 2, + "delimiter": 2, + "Hooray": 1, + "": 1, + "with": 9, + "whitespace": 1, + "<<": 1, + "more": 1, + "strings": 1, + "%": 1, + "hash": 1, + "Hash.new": 1, + "begin": 1, + "pod": 1, + "Here": 1, + "t": 2, + "highlighted": 1, + "table": 1, + "Of": 1, + "things": 1, + "A": 3, + "single": 3, + "declarator": 7, + "a": 8, + "keyword": 7, + "like": 7, + "Another": 2, + "block": 2, + "brace": 1, + "More": 2, + "blocks": 2, + "don": 2, + "x": 2, + "foo": 3, + "Rob": 1, + "food": 1, + "match": 1, + "sub": 1, + "something": 1, + "Str": 1, + "D": 1, + "value": 1, + "...": 1, + "s": 1, + "some": 2, + "stuff": 1, + "chars": 1, + "/": 1, + "": 1, + "": 1, + "roleq": 1 + }, "PHP": { "<": 11, "php": 12, @@ -33598,6 +42550,253 @@ "config": 3, "application": 2 }, + "Pod": { + "Id": 1, + "contents.pod": 1, + "v": 1, + "/05/04": 1, + "tower": 1, + "Exp": 1, + "begin": 3, + "html": 7, + "": 1, + "end": 4, + "head1": 2, + "Net": 12, + "Z3950": 12, + "AsyncZ": 16, + "head2": 3, + "Intro": 1, + "adds": 1, + "an": 3, + "additional": 1, + "layer": 1, + "of": 19, + "asynchronous": 4, + "support": 1, + "for": 11, + "the": 29, + "module": 6, + "through": 1, + "use": 1, + "multiple": 1, + "forked": 1, + "processes.": 1, + "I": 8, + "hope": 1, + "that": 9, + "users": 1, + "will": 1, + "also": 2, + "find": 1, + "it": 3, + "provides": 1, + "a": 8, + "convenient": 2, + "front": 1, + "to": 9, + "C": 13, + "": 1, + ".": 5, + "My": 1, + "initial": 1, + "idea": 1, + "was": 1, + "write": 1, + "something": 2, + "would": 1, + "provide": 1, + "means": 1, + "processing": 1, + "and": 14, + "formatting": 2, + "Z39.50": 1, + "records": 4, + "which": 3, + "did": 1, + "using": 1, + "": 2, + "synchronous": 1, + "code.": 1, + "But": 3, + "wanted": 1, + "could": 1, + "handle": 1, + "queries": 1, + "large": 1, + "numbers": 1, + "servers": 1, + "at": 1, + "one": 1, + "session.": 1, + "Working": 1, + "on": 1, + "this": 3, + "part": 3, + "my": 1, + "project": 1, + "found": 1, + "had": 1, + "trouble": 1, + "with": 6, + "features": 1, + "so": 1, + "ended": 1, + "up": 1, + "what": 1, + "have": 3, + "here.": 1, + "give": 2, + "more": 4, + "detailed": 4, + "account": 2, + "in": 9, + "": 4, + "href=": 5, + "": 1, + "DESCRIPTION": 1, + "": 1, + "": 5, + "section": 2, + "": 5, + "AsyncZ.html": 2, + "": 6, + "pod": 3, + "B": 1, + "": 1, + "": 1, + "cut": 3, + "Documentation": 1, + "over": 2, + "item": 10, + "AsyncZ.pod": 1, + "This": 4, + "is": 8, + "starting": 2, + "point": 2, + "gives": 2, + "overview": 2, + "describes": 2, + "basic": 4, + "mechanics": 2, + "its": 2, + "workings": 2, + "details": 5, + "particulars": 2, + "objects": 2, + "methods.": 2, + "see": 2, + "L": 1, + "": 1, + "explanations": 2, + "sample": 2, + "scripts": 2, + "come": 2, + "": 2, + "distribution.": 2, + "Options.pod": 1, + "document": 2, + "various": 2, + "options": 2, + "can": 4, + "be": 2, + "set": 2, + "modify": 2, + "behavior": 2, + "Index": 1, + "Report.pod": 2, + "deals": 2, + "how": 4, + "are": 7, + "treated": 2, + "line": 4, + "by": 2, + "you": 4, + "affect": 2, + "apearance": 2, + "record": 2, + "s": 2, + "HOW": 2, + "TO.": 2, + "back": 2, + "": 1, + "The": 6, + "Modules": 1, + "There": 2, + "modules": 5, + "than": 2, + "there": 2, + "documentation.": 2, + "reason": 2, + "only": 2, + "full": 2, + "complete": 2, + "access": 9, + "other": 2, + "either": 2, + "internal": 2, + "": 1, + "or": 4, + "accessed": 2, + "indirectly": 2, + "indirectly.": 2, + "head3": 1, + "Here": 1, + "main": 1, + "direct": 2, + "documented": 7, + "": 4, + "": 2, + "documentation": 4, + "ErrMsg": 1, + "User": 1, + "error": 1, + "message": 1, + "handling": 2, + "indirect": 2, + "Errors": 1, + "Error": 1, + "debugging": 1, + "limited": 2, + "Report": 1, + "Module": 1, + "reponsible": 1, + "fetching": 1, + "ZLoop": 1, + "Event": 1, + "loop": 1, + "child": 3, + "processes": 3, + "no": 2, + "not": 2, + "ZSend": 1, + "Connection": 1, + "Options": 2, + "_params": 1, + "INDEX": 1 + }, "PogoScript": { "httpism": 1, "require": 3, @@ -33680,6 +42879,60 @@ "href": 1, "m.1": 1 }, + "PostScript": { + "%": 23, + "PS": 1, + "-": 4, + "Adobe": 1, + "Creator": 1, + "Aaron": 1, + "Puchert": 1, + "Title": 1, + "The": 1, + "Sierpinski": 1, + "triangle": 1, + "Pages": 1, + "PageOrder": 1, + "Ascend": 1, + "BeginProlog": 1, + "/pageset": 1, + "{": 4, + "scale": 1, + "set": 1, + "cm": 1, + "translate": 1, + "setlinewidth": 1, + "}": 4, + "def": 2, + "/sierpinski": 1, + "dup": 4, + "gt": 1, + "[": 6, + "]": 6, + "concat": 5, + "sub": 3, + "sierpinski": 4, + "newpath": 1, + "moveto": 1, + "lineto": 2, + "closepath": 1, + "fill": 1, + "ifelse": 1, + "pop": 1, + "EndProlog": 1, + "BeginSetup": 1, + "<<": 1, + "/PageSize": 1, + "setpagedevice": 1, + "A4": 1, + "EndSetup": 1, + "Page": 1, + "Test": 1, + "pageset": 1, + "sqrt": 1, + "showpage": 1, + "EOF": 1 + }, "PowerShell": { "Write": 2, "-": 2, @@ -33713,332 +42966,54 @@ "TWO_PI": 1 }, "Prolog": { - "action_module": 1, - "(": 585, - "calculator": 1, - ")": 584, - ".": 210, - "%": 334, - "[": 110, - "-": 276, - "d1": 1, - "]": 109, - "push": 20, - "D": 37, - "if": 2, - "mode": 22, - "init": 11, - "<": 11, - "deny": 10, - "displayed": 17, - "D1": 5, - "affirm": 10, - "cont": 3, - "*D1": 2, - "+": 32, - "New": 2, - "a": 31, - "op": 28, - "d": 27, - "m": 16, - "clear": 4, - "nop": 6, - "accumulator": 10, - "A": 40, - "O": 14, - "memory": 5, - "M": 14, - "X": 62, - "mem_rec": 2, - "plus": 6, - "eval": 7, - "V": 16, - ";": 9, - "use": 3, - "normal": 3, - "arithmetic": 3, - "i.e.": 3, - "minus": 5, - "lt": 1, - "times": 4, - "equal": 2, - "mem_plus": 2, - "v": 3, - "where": 3, - "V1": 2, - "plus_minus": 1, - "normalize": 2, - "Wff": 3, - "NormalClauses": 3, - "conVert": 1, - "S": 26, - "cnF": 1, - "T": 6, - "flatten_and": 5, - "U": 2, - "make_clauses": 5, - "make": 2, - "sequence": 2, - "out": 4, - "of": 5, - "conjunction": 1, - "/": 2, - "Y": 34, - "F": 31, - "B": 30, - "sequence_append": 5, - "disjunction": 1, - "flatten_or": 6, - "append": 2, - "two": 1, - "sequences": 1, - "R": 32, - "separate": 7, - "into": 1, - "positive": 1, - "and": 3, - "negative": 1, - "literals": 1, - "P": 37, - "N": 20, - "|": 36, - "N1": 2, - "P1": 2, - "tautology": 4, - "some_occurs": 3, - "occurs": 4, - "_": 21, - "C": 21, - "make_clause": 5, - "false": 1, - "make_sequence": 9, - "H": 11, - "write_list": 3, - "write": 13, - "nl": 8, - "A*": 1, - "Algorithm": 1, - "Nodes": 1, - "have": 2, - "form": 2, - "S#D#F#A": 1, - "describes": 1, - "the": 15, - "state": 1, + "-": 52, + "lib": 1, + "(": 49, + "ic": 1, + ")": 49, + ".": 25, + "vabs": 2, + "Val": 8, + "AbsVal": 10, + "#": 9, + ";": 1, + "labeling": 2, + "[": 21, + "]": 21, + "vabsIC": 1, "or": 1, - "configuration": 1, - "is": 22, - "depth": 1, - "node": 2, - "evaluation": 1, - "function": 4, - "value": 1, - "ancestor": 1, - "list": 1, - "for": 1, - "yfx": 1, - "solve": 2, - "State": 7, - "Soln": 3, - "f_function": 3, - "search": 4, - "State#0#F#": 1, - "reverse": 2, - "h_function": 2, - "H.": 1, - "State#_#_#Soln": 1, - "goal": 2, - "expand": 2, - "Children": 2, - "insert_all": 4, - "Open": 7, - "Open1": 2, - "Open3": 2, - "insert": 6, - "Open2": 2, - "repeat_node": 2, - "cheaper": 2, - "B1": 2, - "P#_#_#_": 2, - "_#_#F1#_": 1, - "_#_#F2#_": 1, - "F1": 1, - "F2.": 1, - "State#D#_#S": 1, - "All_My_Children": 2, - "bagof": 1, - "Child#D1#F#": 1, - "Move": 3, - "move": 7, - "Child": 2, - "puzzle": 4, - "solver": 1, - "A/B/C/D/E/F/G/H/I": 3, - "{": 3, - "...": 3, - "I": 5, - "}": 3, - "represents": 1, - "empty": 2, - "tile": 5, - "/2/3/8/0/4/7/6/5": 1, - "The": 1, - "moves": 1, - "left": 26, - "A/0/C/D/E/F/H/I/J": 3, - "/A/C/D/E/F/H/I/J": 1, - "A/B/C/D/0/F/H/I/J": 4, - "A/B/C/0/D/F/H/I/J": 1, - "A/B/C/D/E/F/H/0/J": 3, - "A/B/C/D/E/F/0/H/J": 1, - "A/B/0/D/E/F/H/I/J": 2, - "A/0/B/D/E/F/H/I/J": 1, - "A/B/C/D/E/0/H/I/J": 3, - "A/B/C/D/0/E/H/I/J": 1, - "A/B/C/D/E/F/H/I/0": 2, - "A/B/C/D/E/F/H/0/I": 1, - "up": 17, - "A/B/C/0/E/F/H/I/J": 3, - "/B/C/A/E/F/H/I/J": 1, - "A/0/C/D/B/F/H/I/J": 1, - "A/B/0/D/E/C/H/I/J": 1, - "A/B/C/D/E/F/0/I/J": 2, - "A/B/C/0/E/F/D/I/J": 1, - "A/B/C/D/0/F/H/E/J": 1, - "A/B/C/D/E/0/H/I/F": 1, - "right": 22, - "A/C/0/D/E/F/H/I/J": 1, - "A/B/C/D/F/0/H/I/J": 1, - "A/B/C/D/E/F/H/J/0": 1, - "/B/C/D/E/F/H/I/J": 2, - "B/0/C/D/E/F/H/I/J": 1, - "A/B/C/E/0/F/H/I/J": 1, - "A/B/C/D/E/F/I/0/J": 1, - "down": 15, - "A/B/C/H/E/F/0/I/J": 1, - "A/B/C/D/I/F/H/0/J": 1, - "A/B/C/D/E/J/H/I/0": 1, - "D/B/C/0/E/F/H/I/J": 1, - "A/E/C/D/0/F/H/I/J": 1, - "A/B/F/D/E/0/H/I/J": 1, - "heuristic": 1, - "Puzz": 3, - "p_fcn": 2, - "s_fcn": 2, - "*S.": 1, - "Manhattan": 1, - "distance": 1, - "Pa": 2, - "b": 12, - "Pb": 2, - "c": 10, - "Pc": 2, - "Pd": 2, - "e": 10, - "E": 3, - "Pe": 2, - "f": 10, - "Pf": 2, - "g": 10, - "G": 7, - "Pg": 3, - "h": 10, - "Ph": 2, - "i": 10, - "Pi": 1, - "Pi.": 1, - "cycle": 1, - "s_aux": 14, - "S1": 2, - "S2": 2, - "S3": 2, - "S4": 2, - "S5": 2, - "S6": 2, - "S7": 2, - "S8": 2, - "S9": 1, - "S9.": 1, - "animation": 1, - "using": 2, - "VT100": 1, - "character": 3, - "graphics": 1, - "animate": 2, - "message.": 2, - "initialize": 2, - "cursor": 7, - "get0": 2, - "_X": 2, - "play_back": 5, - "dynamic": 1, - "location/3.": 1, - "A/B/C/D/E/F/H/I/J": 1, - "cls": 2, - "retractall": 1, - "location": 32, - "assert": 17, - "J": 1, - "draw_all.": 1, - "draw_all": 1, - "draw": 18, - "call": 1, - "Put": 1, - "way": 1, - "message": 1, - "nl.": 1, - "put": 16, - "ESC": 1, - "screen": 1, - "quickly": 1, - "video": 1, - "attributes": 1, - "bold": 1, - "blink": 1, - "not": 1, - "working": 1, - "plain": 1, - "reverse_video": 2, - "Tile": 35, - "objects": 1, - "map": 2, - "s": 1, - "Each": 1, - "should": 1, - "be": 1, - "drawn": 2, - "at": 1, - "which": 1, - "asserted": 1, - "retracted": 1, - "by": 1, - "character_map": 3, - "spot": 1, - "to": 1, - "retract": 8, - "X0": 10, - "Y0": 10, - "Xnew": 6, - "Ynew": 6, - "Obj": 26, - "plain.": 1, - "hide": 10, - "hide_row": 4, - "Y1": 8, - "X1": 8, - "draw_row": 4, - "an": 1, - "Object": 1, - "partition": 5, - "Xs": 5, - "Pivot": 4, - "Smalls": 3, - "Bigs": 3, - "@": 1, - "Rest": 4, - "quicksort": 4, - "Smaller": 2, - "Bigger": 2, + "faitListe": 3, + "_": 2, + "First": 2, + "|": 12, + "Rest": 6, + "Taille": 2, + "Min": 2, + "Max": 2, + "Min..Max": 1, + "Taille1": 2, + "suite": 3, + "Xi": 5, + "Xi1": 7, + "Xi2": 7, + "checkRelation": 3, + "VabsXi1": 2, + "Xi.": 1, + "checkPeriode": 3, + "ListVar": 2, + "length": 1, + "Length": 2, + "<": 1, + "X1": 2, + "X2": 2, + "X3": 2, + "X4": 2, + "X5": 2, + "X6": 2, + "X7": 2, + "X8": 2, + "X9": 2, + "X10": 3, "male": 3, "john": 2, "peter": 3, @@ -34047,6 +43022,10 @@ "christie": 3, "parents": 4, "brother": 1, + "X": 3, + "Y": 2, + "F": 2, + "M": 2, "turing": 1, "Tape0": 2, "Tape": 2, @@ -34054,7 +43033,9 @@ "q0": 1, "Ls": 12, "Rs": 16, + "reverse": 1, "Ls1": 4, + "append": 1, "qf": 1, "Q0": 2, "Ls0": 6, @@ -34069,9 +43050,46 @@ "Action": 2, "action": 4, "Rs1": 2, + "b": 2, + "left": 4, "stay": 1, + "right": 1, "L": 2 }, + "Protocol Buffer": { + "package": 1, + "tutorial": 1, + ";": 13, + "option": 2, + "java_package": 1, + "java_outer_classname": 1, + "message": 3, + "Person": 2, + "{": 4, + "required": 3, + "string": 3, + "name": 1, + "int32": 1, + "id": 1, + "optional": 2, + "email": 1, + "enum": 1, + "PhoneType": 2, + "MOBILE": 1, + "HOME": 2, + "WORK": 1, + "}": 4, + "PhoneNumber": 2, + "number": 1, + "type": 1, + "[": 1, + "default": 1, + "]": 1, + "repeated": 2, + "phone": 1, + "AddressBook": 1, + "person": 1 + }, "Python": { "from": 34, "__future__": 2, @@ -35033,9 +44051,9 @@ "<": 12, "-": 12, "function": 3, - "(": 28, + "(": 29, "lines": 4, - ")": 28, + ")": 29, "{": 3, "dates": 3, "matrix": 2, @@ -35045,8 +44063,8 @@ "byrow": 2, "TRUE": 3, "days": 2, - "[": 3, - "]": 3, + "[": 4, + "]": 4, "times": 2, "hours": 2, "all.days": 2, @@ -35081,7 +44099,22 @@ "width": 1, "height": 1, "hello": 2, - "print": 1 + "print": 1, + "##polyg": 1, + "vector": 2, + "##numpoints": 1, + "number": 1, + "##output": 1, + "output": 1, + "##": 1, + "Example": 1, + "scripts": 1, + "group": 1, + "pts": 1, + "spsample": 1, + "polyg": 1, + "numpoints": 1, + "type": 1 }, "Racket": { ";": 3, @@ -35090,7 +44123,7 @@ "and": 1, "efficient": 1, "code": 1, - "-": 100, + "-": 94, "that": 2, "s": 1, "the": 3, @@ -35100,41 +44133,27 @@ "http": 1, "//racket": 1, "lang.org/": 1, - "(": 25, + "(": 23, "define": 1, "bottles": 4, "n": 8, "more": 2, - ")": 25, + ")": 23, "printf": 2, "case": 1, "[": 16, "]": 16, "else": 1, "if": 1, - "for": 3, + "for": 2, "in": 3, "range": 1, "sub1": 1, "displayln": 2, - "SHEBANG#!sh": 1, - "#": 2, - "|": 2, - "*": 2, - "scheme": 1, - "exec": 1, - "racket": 1, - "um": 1, - "require": 2, - "racket/file": 1, - "racket/path": 1, - "racket/list": 1, - "racket/string": 1, - "syntax": 1, - "racket/base": 1, "#lang": 1, "scribble/manual": 1, "@": 3, + "require": 1, "scribble/bnf": 1, "@title": 1, "{": 2, @@ -35342,6 +44361,177 @@ "my_ts..": 1, "SimpleTokenizer.new": 1 }, + "RDoc": { + "RDoc": 7, + "-": 9, + "Ruby": 4, + "Documentation": 2, + "System": 1, + "home": 1, + "https": 3, + "//github.com/rdoc/rdoc": 1, + "rdoc": 7, + "http": 1, + "//docs.seattlerb.org/rdoc": 1, + "bugs": 1, + "//github.com/rdoc/rdoc/issues": 1, + "code": 1, + "quality": 1, + "{": 1, + "": 1, + "src=": 1, + "alt=": 1, + "}": 1, + "[": 3, + "//codeclimate.com/github/rdoc/rdoc": 1, + "]": 3, + "Description": 1, + "produces": 1, + "HTML": 1, + "and": 9, + "command": 4, + "line": 1, + "documentation": 8, + "for": 9, + "projects.": 1, + "includes": 1, + "the": 12, + "+": 8, + "ri": 1, + "tools": 1, + "generating": 1, + "displaying": 1, + "from": 1, + "line.": 1, + "Generating": 1, + "Once": 1, + "installed": 1, + "you": 3, + "can": 2, + "create": 1, + "using": 1, + "options": 1, + "names...": 1, + "For": 1, + "an": 1, + "up": 1, + "to": 4, + "date": 1, + "option": 1, + "summary": 1, + "type": 2, + "help": 1, + "A": 1, + "typical": 1, + "use": 1, + "might": 1, + "be": 3, + "generate": 1, + "a": 5, + "package": 1, + "of": 2, + "source": 2, + "(": 3, + "such": 1, + "as": 1, + "itself": 1, + ")": 3, + ".": 2, + "This": 2, + "generates": 1, + "all": 1, + "C": 1, + "files": 2, + "in": 4, + "below": 1, + "current": 1, + "directory.": 1, + "These": 1, + "will": 1, + "stored": 1, + "tree": 1, + "starting": 1, + "subdirectory": 1, + "doc": 1, + "You": 2, + "make": 2, + "this": 1, + "slightly": 1, + "more": 1, + "useful": 1, + "your": 1, + "readers": 1, + "by": 1, + "having": 1, + "index": 1, + "page": 1, + "contain": 1, + "primary": 1, + "file.": 1, + "In": 1, + "our": 1, + "case": 1, + "we": 1, + "could": 1, + "#": 1, + "rdoc/rdoc": 1, + "s": 1, + "OK": 1, + "file": 1, + "bug": 1, + "report": 1, + "anything": 1, + "t": 1, + "figure": 1, + "out": 1, + "how": 1, + "produce": 1, + "output": 1, + "like": 1, + "that": 1, + "is": 4, + "probably": 1, + "bug.": 1, + "License": 1, + "Copyright": 1, + "c": 2, + "Dave": 1, + "Thomas": 1, + "The": 1, + "Pragmatic": 1, + "Programmers.": 1, + "Portions": 2, + "Eric": 1, + "Hodel.": 1, + "copyright": 1, + "others": 1, + "see": 1, + "individual": 1, + "LEGAL.rdoc": 1, + "details.": 1, + "free": 1, + "software": 2, + "may": 1, + "redistributed": 1, + "under": 1, + "terms": 1, + "specified": 1, + "LICENSE.rdoc.": 1, + "Warranty": 1, + "provided": 1, + "without": 2, + "any": 1, + "express": 1, + "or": 1, + "implied": 2, + "warranties": 2, + "including": 1, + "limitation": 1, + "merchantability": 1, + "fitness": 1, + "particular": 1, + "purpose.": 1 + }, "Rebol": { "REBOL": 1, "[": 3, @@ -35350,7 +44540,215 @@ "func": 1, "print": 1 }, + "RMarkdown": { + "Some": 1, + "text.": 1, + "##": 1, + "A": 1, + "graphic": 1, + "in": 1, + "R": 1, + "{": 1, + "r": 1, + "}": 1, + "plot": 1, + "(": 3, + ")": 3, + "hist": 1, + "rnorm": 1 + }, + "RobotFramework": { + "***": 16, + "Settings": 3, + "Documentation": 3, + "Example": 3, + "test": 6, + "cases": 2, + "using": 4, + "the": 9, + "data": 2, + "-": 16, + "driven": 4, + "testing": 2, + "approach.": 2, + "...": 28, + "Tests": 1, + "use": 2, + "Calculate": 3, + "keyword": 5, + "created": 1, + "in": 5, + "this": 1, + "file": 1, + "that": 5, + "turn": 1, + "uses": 1, + "keywords": 3, + "CalculatorLibrary": 5, + ".": 4, + "An": 1, + "exception": 1, + "is": 6, + "last": 1, + "has": 5, + "a": 4, + "custom": 1, + "_template": 1, + "keyword_.": 1, + "The": 2, + "style": 3, + "works": 3, + "well": 3, + "when": 2, + "you": 1, + "need": 3, + "to": 5, + "repeat": 1, + "same": 1, + "workflow": 3, + "multiple": 2, + "times.": 1, + "Notice": 1, + "one": 1, + "of": 3, + "these": 1, + "tests": 5, + "fails": 1, + "on": 1, + "purpose": 1, + "show": 1, + "how": 1, + "failures": 1, + "look": 1, + "like.": 1, + "Test": 4, + "Template": 2, + "Library": 3, + "Cases": 3, + "Expression": 1, + "Expected": 1, + "Addition": 2, + "+": 6, + "Subtraction": 1, + "Multiplication": 1, + "*": 4, + "Division": 2, + "/": 5, + "Failing": 1, + "Calculation": 3, + "error": 4, + "[": 4, + "]": 4, + "should": 9, + "fail": 2, + "kekkonen": 1, + "Invalid": 2, + "button": 13, + "{": 15, + "EMPTY": 3, + "}": 15, + "expression.": 1, + "by": 3, + "zero.": 1, + "Keywords": 2, + "Arguments": 2, + "expression": 5, + "expected": 4, + "Push": 16, + "buttons": 4, + "C": 4, + "Result": 8, + "be": 9, + "Should": 2, + "cause": 1, + "equal": 1, + "#": 2, + "Using": 1, + "BuiltIn": 1, + "case": 1, + "gherkin": 1, + "syntax.": 1, + "This": 3, + "similar": 1, + "examples.": 1, + "difference": 1, + "higher": 1, + "abstraction": 1, + "level": 1, + "and": 2, + "their": 1, + "arguments": 1, + "are": 1, + "embedded": 1, + "into": 1, + "names.": 1, + "kind": 2, + "_gherkin_": 2, + "syntax": 1, + "been": 3, + "made": 1, + "popular": 1, + "http": 1, + "//cukes.info": 1, + "|": 1, + "Cucumber": 1, + "It": 1, + "especially": 1, + "act": 1, + "as": 1, + "examples": 1, + "easily": 1, + "understood": 1, + "also": 2, + "business": 2, + "people.": 1, + "Given": 1, + "calculator": 1, + "cleared": 2, + "When": 1, + "user": 2, + "types": 2, + "pushes": 2, + "equals": 2, + "Then": 1, + "result": 2, + "Calculator": 1, + "User": 2, + "All": 1, + "contain": 1, + "constructed": 1, + "from": 1, + "Creating": 1, + "new": 1, + "or": 1, + "editing": 1, + "existing": 1, + "easy": 1, + "even": 1, + "for": 2, + "people": 2, + "without": 1, + "programming": 1, + "skills.": 1, + "normal": 1, + "automation.": 1, + "If": 1, + "understand": 1, + "may": 1, + "work": 1, + "better.": 1, + "Simple": 1, + "calculation": 2, + "Longer": 1, + "Clear": 1, + "built": 1, + "variable": 1 + }, "Ruby": { + "appraise": 2, + "do": 37, + "gem": 3, + "end": 238, "load": 3, "Dir": 4, "[": 56, @@ -35364,9 +44762,7 @@ "}": 68, "task": 2, "default": 2, - "do": 35, "puts": 12, - "end": 236, "module": 8, "Foo": 1, "require": 58, @@ -35964,7 +45360,6 @@ "For": 1, "use/testing": 1, "no": 1, - "gem": 1, "require_all": 4, "glob": 2, "File.join": 6, @@ -36787,29 +46182,29 @@ "exec": 2, "scala": 2, "#": 2, - "object": 2, + "object": 3, "Beers": 1, "extends": 1, "Application": 1, - "{": 10, - "def": 7, + "{": 21, + "def": 10, "bottles": 3, - "(": 34, + "(": 67, "qty": 12, - "Int": 3, + "Int": 11, "f": 4, "String": 5, - ")": 34, - "//": 4, + ")": 67, + "//": 29, "higher": 1, - "-": 4, + "-": 5, "order": 1, "functions": 2, "match": 2, - "case": 5, - "+": 29, + "case": 8, + "+": 49, "x": 3, - "}": 11, + "}": 22, "beers": 3, "sing": 3, "implicit": 3, @@ -36823,9 +46218,9 @@ ".capitalize": 1, "tail": 1, "recursion": 1, - "val": 2, + "val": 6, "headOfSong": 1, - "println": 2, + "println": 8, "parameter": 1, "name": 4, "version": 1, @@ -36852,10 +46247,10 @@ "<+=>": 1, "baseDirectory": 1, "map": 1, - "_": 1, + "_": 2, "input": 1, "add": 2, - "a": 2, + "a": 4, "maven": 2, "style": 2, "repository": 2, @@ -36866,8 +46261,8 @@ "of": 1, "repositories": 1, "define": 1, - "the": 4, - "to": 4, + "the": 5, + "to": 7, "publish": 1, "publishTo": 1, "set": 2, @@ -36905,7 +46300,7 @@ "false": 7, "showSuccess": 1, "timingFormat": 1, - "import": 1, + "import": 9, "java.text.DateFormat": 1, "DateFormat.getDateTimeInstance": 1, "DateFormat.SHORT": 2, @@ -36934,34 +46329,100 @@ "Credentials": 2, "Path.userHome": 1, "/": 2, + "math.random": 1, + "scala.language.postfixOps": 1, + "scala.util._": 1, + "scala.util.": 1, + "Try": 1, + "Success": 2, + "Failure": 2, + "scala.concurrent._": 1, + "duration._": 1, + "ExecutionContext.Implicits.global": 1, + "scala.concurrent.": 1, + "ExecutionContext": 1, + "CanAwait": 1, + "OnCompleteRunnable": 1, + "TimeoutException": 1, + "ExecutionException": 1, + "blocking": 3, + "node11": 1, + "Welcome": 1, + "Scala": 1, + "worksheet": 1, + "retry": 3, + "[": 11, + "T": 8, + "]": 11, + "n": 3, + "block": 8, + "Future": 5, + "ns": 1, + "Iterator": 2, + ".iterator": 1, + "attempts": 1, + "ns.map": 1, + "failed": 2, + "Future.failed": 1, + "new": 1, + "Exception": 2, + "attempts.foldLeft": 1, + "fallbackTo": 1, + "scala.concurrent.Future": 1, + "scala.concurrent.Fut": 1, + "|": 19, + "ure": 1, + "rb": 3, + "i": 9, + "Thread.sleep": 2, + "*random.toInt": 1, + "i.toString": 5, + "ri": 2, + "onComplete": 1, + "s": 1, + "s.toString": 1, + "t": 1, + "t.toString": 1, + "r": 1, + "r.toString": 1, + "Unit": 1, + "toList": 1, + ".foreach": 1, + "Iteration": 5, + "java.lang.Exception": 1, + "Hi": 10, "HelloWorld": 1, "main": 1, "args": 1, - "Array": 1, - "[": 1, - "]": 1 + "Array": 1 + }, + "Scaml": { + "%": 1, + "p": 1, + "Hello": 1, + "World": 1 }, "Scheme": { - "(": 359, + "(": 366, "import": 1, "rnrs": 1, - ")": 373, + ")": 380, "only": 1, "surfage": 4, "s1": 1, "lists": 1, "filter": 4, - "-": 188, + "-": 192, "map": 4, "gl": 12, "glut": 2, "dharmalab": 2, "records": 1, - "define": 27, + "define": 30, "record": 5, "type": 5, "math": 1, - "basic": 1, + "basic": 2, "agave": 4, "glu": 1, "compat": 1, @@ -36981,7 +46442,7 @@ ";": 1684, "utilities": 1, "say": 9, - ".": 1, + ".": 2, "args": 2, "for": 7, "each": 7, @@ -36990,7 +46451,7 @@ "translate": 6, "p": 6, "glTranslated": 1, - "x": 8, + "x": 10, "y": 3, "radians": 8, "/": 7, @@ -37103,7 +46564,7 @@ "when": 5, "<=>": 3, "distance": 3, - "begin": 1, + "begin": 2, "1": 2, "f": 1, "append": 4, @@ -37128,7 +46589,16 @@ "s": 1, "space": 1, "cons": 1, - "glutMainLoop": 1 + "glutMainLoop": 1, + "library": 1, + "libs": 1, + "export": 1, + "list2": 2, + "objs": 2, + "should": 1, + "not": 1, + "be": 1, + "exported": 1 }, "Scilab": { "function": 1, @@ -37920,6 +47390,440 @@ "foodforthought.jpg": 1, "name##*fo": 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, @@ -37994,128 +47898,714 @@ "ast.eval": 1, "Env.new": 1 }, + "Squirrel": { + "//example": 1, + "from": 1, + "http": 1, + "//www.squirrel": 1, + "-": 1, + "lang.org/#documentation": 1, + "local": 3, + "table": 1, + "{": 10, + "a": 2, + "subtable": 1, + "array": 3, + "[": 3, + "]": 3, + "}": 10, + "+": 2, + "b": 1, + ";": 15, + "foreach": 1, + "(": 10, + "i": 1, + "val": 2, + "in": 1, + ")": 10, + "print": 2, + "typeof": 1, + "/////////////////////////////////////////////": 1, + "class": 2, + "Entity": 3, + "constructor": 2, + "etype": 2, + "entityname": 4, + "name": 2, + "type": 2, + "x": 2, + "y": 2, + "z": 2, + "null": 2, + "function": 2, + "MoveTo": 1, + "newx": 2, + "newy": 2, + "newz": 2, + "Player": 2, + "extends": 1, + "base.constructor": 1, + "DoDomething": 1, + "newplayer": 1, + "newplayer.MoveTo": 1 + }, "Standard ML": { "signature": 2, "LAZY_BASE": 3, "sig": 2, - "type": 2, - "a": 18, + "type": 5, + "a": 74, "lazy": 12, - "-": 13, - ")": 23, - "end": 6, + "-": 19, + ")": 826, + "end": 52, "LAZY": 1, - "bool": 4, - "val": 12, + "bool": 9, + "val": 143, "inject": 3, - "toString": 2, - "(": 22, - "string": 1, + "toString": 3, + "(": 822, + "string": 14, "eq": 2, - "*": 1, + "*": 9, "eqBy": 3, - "compare": 2, + "compare": 7, "order": 2, "map": 2, - "b": 2, - "structure": 6, + "b": 58, + "structure": 10, "Ops": 2, "LazyBase": 2, - "struct": 4, + "struct": 9, "exception": 1, "Undefined": 3, - "fun": 9, + "fun": 51, "delay": 3, - "f": 9, + "f": 37, "force": 9, "undefined": 1, - "fn": 3, - "raise": 1, + "fn": 124, + "raise": 5, "LazyMemoBase": 2, - "datatype": 1, - "|": 1, + "datatype": 28, + "|": 225, "Done": 1, - "of": 1, - "unit": 1, - "let": 1, - "open": 1, + "of": 90, + "unit": 6, + "let": 43, + "open": 8, "B": 1, - "x": 15, + "x": 59, "isUndefined": 2, - "ignore": 1, - ";": 1, - "false": 1, - "handle": 1, - "true": 1, - "if": 1, - "then": 1, - "else": 1, - "p": 4, - "y": 6, + "ignore": 2, + ";": 20, + "false": 31, + "handle": 3, + "true": 35, + "if": 50, + "then": 50, + "else": 50, + "p": 6, + "y": 44, "op": 1, "Lazy": 1, "LazyFn": 2, - "LazyMemo": 1 + "LazyMemo": 1, + "functor": 2, + "Main": 1, + "S": 2, + "MAIN_STRUCTS": 1, + "MAIN": 1, + "Compile": 3, + "Place": 1, + "t": 23, + "Files": 3, + "Generated": 4, + "MLB": 4, + "O": 4, + "OUT": 3, + "SML": 6, + "TypeCheck": 3, + "toInt": 1, + "int": 1, + "OptPred": 1, + "Target": 1, + "Yes": 1, + "Show": 1, + "Anns": 1, + "PathMap": 1, + "gcc": 5, + "ref": 45, + "arScript": 3, + "asOpts": 6, + "{": 79, + "opt": 34, + "pred": 15, + "OptPred.t": 3, + "}": 79, + "list": 10, + "[": 104, + "]": 108, + "ccOpts": 6, + "linkOpts": 6, + "buildConstants": 2, + "debugRuntime": 3, + "debugFormat": 5, + "Dwarf": 3, + "DwarfPlus": 3, + "Dwarf2": 3, + "Stabs": 3, + "StabsPlus": 3, + "option": 6, + "NONE": 47, + "expert": 3, + "explicitAlign": 3, + "Control.align": 1, + "explicitChunk": 2, + "Control.chunk": 1, + "explicitCodegen": 5, + "Native": 5, + "Explicit": 5, + "Control.codegen": 3, + "keepGenerated": 3, + "keepO": 3, + "output": 16, + "profileSet": 3, + "profileTimeSet": 3, + "runtimeArgs": 3, + "show": 2, + "Show.t": 1, + "stop": 10, + "Place.OUT": 1, + "parseMlbPathVar": 3, + "line": 9, + "String.t": 1, + "case": 83, + "String.tokens": 7, + "Char.isSpace": 8, + "var": 3, + "path": 7, + "SOME": 68, + "_": 83, + "readMlbPathMap": 2, + "file": 14, + "File.t": 12, + "not": 1, + "File.canRead": 1, + "Error.bug": 14, + "concat": 52, + "List.keepAllMap": 4, + "File.lines": 2, + "String.forall": 4, + "v": 4, + "targetMap": 5, + "arch": 11, + "MLton.Platform.Arch.t": 3, + "os": 13, + "MLton.Platform.OS.t": 3, + "target": 28, + "Promise.lazy": 1, + "targetsDir": 5, + "OS.Path.mkAbsolute": 4, + "relativeTo": 4, + "Control.libDir": 1, + "potentialTargets": 2, + "Dir.lsDirs": 1, + "targetDir": 5, + "osFile": 2, + "OS.Path.joinDirFile": 3, + "dir": 4, + "archFile": 2, + "File.contents": 2, + "List.first": 2, + "MLton.Platform.OS.fromString": 1, + "MLton.Platform.Arch.fromString": 1, + "in": 40, + "setTargetType": 3, + "usage": 48, + "List.peek": 7, + "...": 23, + "Control": 3, + "Target.arch": 2, + "Target.os": 2, + "hasCodegen": 8, + "cg": 21, + "z": 73, + "Control.Target.arch": 4, + "Control.Target.os": 2, + "Control.Format.t": 1, + "AMD64": 2, + "x86Codegen": 9, + "X86": 3, + "amd64Codegen": 8, + "<": 3, + "Darwin": 6, + "orelse": 7, + "Control.format": 3, + "Executable": 5, + "Archive": 4, + "hasNativeCodegen": 2, + "defaultAlignIs8": 3, + "Alpha": 1, + "ARM": 1, + "HPPA": 1, + "IA64": 1, + "MIPS": 1, + "Sparc": 1, + "S390": 1, + "makeOptions": 3, + "s": 168, + "Fail": 2, + "reportAnnotation": 4, + "flag": 12, + "e": 18, + "Control.Elaborate.Bad": 1, + "Control.Elaborate.Deprecated": 1, + "ids": 2, + "Control.warnDeprecated": 1, + "Out.output": 2, + "Out.error": 3, + "List.toString": 1, + "Control.Elaborate.Id.name": 1, + "Control.Elaborate.Good": 1, + "Control.Elaborate.Other": 1, + "Popt": 1, + "tokenizeOpt": 4, + "opts": 4, + "List.foreach": 5, + "tokenizeTargetOpt": 4, + "List.map": 3, + "Normal": 29, + "SpaceString": 48, + "Align4": 2, + "Align8": 2, + "Expert": 72, + "o": 8, + "List.push": 22, + "OptPred.Yes": 6, + "boolRef": 20, + "ChunkPerFunc": 1, + "OneChunk": 1, + "String.hasPrefix": 2, + "prefix": 3, + "String.dropPrefix": 1, + "Char.isDigit": 3, + "Int.fromString": 4, + "n": 4, + "Coalesce": 1, + "limit": 1, + "Bool": 10, + "closureConvertGlobalize": 1, + "closureConvertShrink": 1, + "String.concatWith": 2, + "Control.Codegen.all": 2, + "Control.Codegen.toString": 2, + "name": 7, + "value": 4, + "Compile.setCommandLineConstant": 2, + "contifyIntoMain": 1, + "debug": 4, + "Control.Elaborate.processDefault": 1, + "Control.defaultChar": 1, + "Control.defaultInt": 5, + "Control.defaultReal": 2, + "Control.defaultWideChar": 2, + "Control.defaultWord": 4, + "Regexp.fromString": 7, + "re": 34, + "Regexp.compileDFA": 4, + "diagPasses": 1, + "Control.Elaborate.processEnabled": 2, + "dropPasses": 1, + "intRef": 8, + "errorThreshhold": 1, + "emitMain": 1, + "exportHeader": 3, + "Control.Format.all": 2, + "Control.Format.toString": 2, + "gcCheck": 1, + "Limit": 1, + "First": 1, + "Every": 1, + "Native.IEEEFP": 1, + "indentation": 1, + "Int": 8, + "i": 8, + "inlineNonRec": 6, + "small": 19, + "product": 19, + "#product": 1, + "inlineIntoMain": 1, + "loops": 18, + "inlineLeafA": 6, + "repeat": 18, + "size": 19, + "inlineLeafB": 6, + "keepCoreML": 1, + "keepDot": 1, + "keepMachine": 1, + "keepRSSA": 1, + "keepSSA": 1, + "keepSSA2": 1, + "keepSXML": 1, + "keepXML": 1, + "keepPasses": 1, + "libname": 9, + "loopPasses": 1, + "Int.toString": 3, + "markCards": 1, + "maxFunctionSize": 1, + "mlbPathVars": 4, + "@": 3, + "Native.commented": 1, + "Native.copyProp": 1, + "Native.cutoff": 1, + "Native.liveTransfer": 1, + "Native.liveStack": 1, + "Native.moveHoist": 1, + "Native.optimize": 1, + "Native.split": 1, + "Native.shuffle": 1, + "err": 1, + "optimizationPasses": 1, + "il": 10, + "set": 10, + "Result.Yes": 6, + "Result.No": 5, + "polyvariance": 9, + "hofo": 12, + "rounds": 12, + "preferAbsPaths": 1, + "profPasses": 1, + "profile": 6, + "ProfileNone": 2, + "ProfileAlloc": 1, + "ProfileCallStack": 3, + "ProfileCount": 1, + "ProfileDrop": 1, + "ProfileLabel": 1, + "ProfileTimeLabel": 4, + "ProfileTimeField": 2, + "profileBranch": 1, + "Regexp": 3, + "seq": 3, + "anys": 6, + "compileDFA": 3, + "profileC": 1, + "profileInclExcl": 2, + "profileIL": 3, + "ProfileSource": 1, + "ProfileSSA": 1, + "ProfileSSA2": 1, + "profileRaise": 2, + "profileStack": 1, + "profileVal": 1, + "Show.Anns": 1, + "Show.PathMap": 1, + "showBasis": 1, + "showDefUse": 1, + "showTypes": 1, + "Control.optimizationPasses": 4, + "String.equals": 4, + "Place.Files": 2, + "Place.Generated": 2, + "Place.O": 3, + "Place.TypeCheck": 1, + "#target": 2, + "Self": 2, + "Cross": 2, + "SpaceString2": 6, + "OptPred.Target": 6, + "#1": 1, + "trace": 4, + "#2": 2, + "typeCheck": 1, + "verbosity": 4, + "Silent": 3, + "Top": 5, + "Pass": 1, + "Detail": 1, + "warnAnn": 1, + "warnDeprecated": 1, + "zoneCutDepth": 1, + "style": 6, + "arg": 3, + "desc": 3, + "mainUsage": 3, + "parse": 2, + "Popt.makeUsage": 1, + "showExpert": 1, + "commandLine": 5, + "args": 8, + "lib": 2, + "libDir": 2, + "OS.Path.mkCanonical": 1, + "result": 1, + "targetStr": 3, + "libTargetDir": 1, + "targetArch": 4, + "archStr": 1, + "String.toLower": 2, + "MLton.Platform.Arch.toString": 2, + "targetOS": 5, + "OSStr": 2, + "MLton.Platform.OS.toString": 1, + "positionIndependent": 3, + "format": 7, + "MinGW": 4, + "Cygwin": 4, + "Library": 6, + "LibArchive": 3, + "Control.positionIndependent": 1, + "align": 1, + "codegen": 4, + "CCodegen": 1, + "MLton.Rusage.measureGC": 1, + "exnHistory": 1, + "Bool.toString": 1, + "Control.profile": 1, + "Control.ProfileCallStack": 1, + "sizeMap": 1, + "Control.libTargetDir": 1, + "ty": 4, + "Bytes.toBits": 1, + "Bytes.fromInt": 1, + "lookup": 4, + "use": 2, + "on": 1, + "must": 1, + "x86": 1, + "with": 1, + "ieee": 1, + "fp": 1, + "can": 1, + "No": 1, + "Out.standard": 1, + "input": 22, + "rest": 3, + "inputFile": 1, + "File.base": 5, + "File.fileOf": 1, + "start": 6, + "base": 3, + "rec": 1, + "loop": 3, + "suf": 14, + "hasNum": 2, + "sufs": 2, + "String.hasSuffix": 2, + "suffix": 8, + "Place.t": 1, + "List.exists": 1, + "File.withIn": 1, + "csoFiles": 1, + "Place.compare": 1, + "GREATER": 5, + "Place.toString": 2, + "EQUAL": 5, + "LESS": 5, + "printVersion": 1, + "tempFiles": 3, + "tmpDir": 2, + "tmpVar": 2, + "default": 2, + "MLton.Platform.OS.host": 2, + "Process.getEnv": 1, + "d": 32, + "temp": 3, + "out": 9, + "File.temp": 1, + "OS.Path.concat": 1, + "Out.close": 2, + "maybeOut": 10, + "maybeOutBase": 4, + "File.extension": 3, + "outputBase": 2, + "ext": 1, + "OS.Path.splitBaseExt": 1, + "defLibname": 6, + "OS.Path.splitDirFile": 1, + "String.extract": 1, + "toAlNum": 2, + "c": 42, + "Char.isAlphaNum": 1, + "#": 3, + "CharVector.map": 1, + "atMLtons": 1, + "Vector.fromList": 1, + "tokenize": 1, + "rev": 2, + "gccDebug": 3, + "asDebug": 2, + "compileO": 3, + "inputs": 7, + "libOpts": 2, + "System.system": 4, + "List.concat": 4, + "linkArchives": 1, + "String.contains": 1, + "File.move": 1, + "from": 1, + "to": 1, + "mkOutputO": 3, + "Counter.t": 3, + "File.dirOf": 2, + "Counter.next": 1, + "compileC": 2, + "debugSwitches": 2, + "compileS": 2, + "compileCSO": 1, + "List.forall": 1, + "Counter.new": 1, + "oFiles": 2, + "List.fold": 1, + "ac": 4, + "extension": 6, + "Option.toString": 1, + "mkCompileSrc": 1, + "listFiles": 2, + "elaborate": 1, + "compile": 2, + "outputs": 2, + "r": 3, + "make": 1, + "Int.inc": 1, + "Out.openOut": 1, + "print": 4, + "outputHeader": 2, + "done": 3, + "Control.No": 1, + "l": 2, + "Layout.output": 1, + "Out.newline": 1, + "Vector.foreach": 1, + "String.translate": 1, + "/": 1, + "Type": 1, + "Check": 1, + ".c": 1, + ".s": 1, + "invalid": 1, + "MLton": 1, + "Exn.finally": 1, + "File.remove": 1, + "doit": 1, + "Process.makeCommandLine": 1, + "main": 1, + "mainWrapped": 1, + "OS.Process.exit": 1, + "CommandLine.arguments": 1, + "RedBlackTree": 1, + "key": 16, + "entry": 12, + "dict": 17, + "Empty": 15, + "Red": 41, + "local": 1, + "lk": 4, + "tree": 4, + "and": 2, + "zipper": 3, + "TOP": 5, + "LEFTB": 10, + "RIGHTB": 10, + "delete": 3, + "zip": 19, + "Black": 40, + "LEFTR": 8, + "RIGHTR": 9, + "bbZip": 28, + "w": 17, + "delMin": 8, + "Match": 1, + "joinRed": 3, + "needB": 2, + "del": 8, + "NotFound": 2, + "entry1": 16, + "as": 7, + "key1": 8, + "datum1": 4, + "joinBlack": 1, + "insertShadow": 3, + "datum": 1, + "oldEntry": 7, + "ins": 8, + "left": 10, + "right": 10, + "restore_left": 1, + "restore_right": 1, + "app": 3, + "ap": 7, + "new": 1, + "insert": 2, + "table": 14, + "clear": 1 + }, + "Stylus": { + "border": 6, + "-": 10, + "radius": 5, + "(": 1, + ")": 1, + "webkit": 1, + "arguments": 3, + "moz": 1, + "a.button": 1, + "px": 5, + "fonts": 2, + "helvetica": 1, + "arial": 1, + "sans": 1, + "serif": 1, + "body": 1, + "{": 1, + "padding": 3, + ";": 2, + "font": 1, + "px/1.4": 1, + "}": 1, + "form": 2, + "input": 2, + "[": 2, + "type": 2, + "text": 2, + "]": 2, + "solid": 1, + "#eee": 1, + "color": 2, + "#ddd": 1, + "textarea": 1, + "@extends": 2, + "foo": 2, + "#FFF": 1, + ".bar": 1, + "background": 1, + "#000": 1 }, "SuperCollider": { - "BCR2000": 1, - "{": 14, - "var": 2, - "controls": 2, - "controlBuses": 2, - "rangedControlBuses": 2, - "responders": 2, - ";": 32, - "*new": 1, - "super.new.init": 1, - "}": 14, - "init": 1, - "Dictionary.new": 3, - "(": 34, - ")": 34, - "this.createCCResponders": 1, - "createCCResponders": 1, - "Array.fill": 1, - "|": 4, - "i": 5, - "CCResponder": 1, - "src": 3, - "chan": 3, - "num": 3, - "val": 4, - "[": 3, - "]": 3, - ".postln": 1, - "controls.put": 1, - "+": 4, - "controlBuses.put": 1, - "Bus.control": 1, - "Server.default": 1, - "controlBuses.at": 2, - ".value": 1, - "/": 2, - "nil": 4, - "//": 4, - "value": 1, - "at": 1, - "arg": 4, - "controlNum": 6, - "controls.at": 2, - "scalarAt": 1, - "busAt": 1, "//boot": 1, "server": 1, "s.boot": 1, + ";": 18, + "(": 22, "SynthDef": 1, + "{": 5, + "var": 1, "sig": 7, "resfreq": 3, "Saw.ar": 1, + ")": 22, "SinOsc.kr": 1, "*": 3, + "+": 1, "RLPF.ar": 1, "Out.ar": 1, + "}": 5, ".play": 2, "do": 2, + "arg": 1, + "i": 1, "Pan2.ar": 1, "SinOsc.ar": 1, "exprand": 1, @@ -38132,6 +48622,8 @@ "a.test.plot": 1, "b.test.plot": 1, "Env": 1, + "[": 2, + "]": 2, ".plot": 2, "e": 1, "Env.sine.asStream": 1, @@ -38139,48 +48631,665 @@ "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, "foo": 1 }, "TeX": { - "%": 59, + "%": 135, + "ProvidesClass": 2, + "{": 463, + "problemset": 1, + "}": 469, + "DeclareOption*": 2, + "PassOptionsToClass": 2, + "final": 2, + "article": 2, + "DeclareOption": 2, + "worksheet": 1, + "providecommand": 45, + "@solutionvis": 3, + "expand": 1, + "@expand": 3, + "ProcessOptions": 2, + "relax": 3, + "LoadClass": 2, + "[": 81, + "pt": 5, + "letterpaper": 1, + "]": 80, + "RequirePackage": 20, + "top": 1, + "in": 20, + "bottom": 1, + "left": 15, + "right": 16, + "geometry": 1, + "pgfkeys": 1, + "For": 13, + "mathtable": 2, + "environment.": 3, + "tabularx": 1, + "pset": 1, + "heading": 2, + "float": 1, + "Used": 6, + "for": 21, + "floats": 1, + "(": 12, + "tables": 1, + "figures": 1, + "etc.": 1, + ")": 12, + "graphicx": 1, + "inserting": 3, + "images.": 1, + "enumerate": 2, + "the": 19, + "mathtools": 2, + "Required.": 7, + "Loads": 1, + "amsmath.": 1, + "amsthm": 1, + "theorem": 1, + "environments.": 1, + "amssymb": 1, + "booktabs": 1, + "esdiff": 1, + "derivatives": 4, + "and": 5, + "partial": 2, + "Optional.": 1, + "shortintertext.": 1, + "fancyhdr": 2, + "customizing": 1, + "headers/footers.": 1, + "lastpage": 1, + "page": 4, + "count": 1, + "header/footer.": 1, + "xcolor": 1, + "setting": 3, + "color": 3, + "of": 14, + "hyperlinks": 2, + "obeyFinal": 1, + "Disable": 1, + "todos": 1, + "by": 1, + "option": 1, + "class": 1, + "@todoclr": 2, + "linecolor": 1, + "red": 1, + "todonotes": 1, + "keeping": 1, + "track": 1, + "to": 16, + "-": 9, + "dos.": 1, + "colorlinks": 1, + "true": 1, + "linkcolor": 1, + "navy": 2, + "urlcolor": 1, + "black": 2, + "hyperref": 1, + "following": 2, + "urls": 2, + "references": 1, + "a": 2, + "document.": 1, + "url": 2, + "Enables": 1, + "with": 5, + "tag": 1, + "all": 2, + "hypcap": 1, + "definecolor": 2, + "gray": 1, + "To": 1, + "Dos.": 1, + "brightness": 1, + "RGB": 1, + "coloring": 1, + "setlength": 12, + "parskip": 1, + "ex": 2, + "Sets": 1, + "space": 8, + "between": 1, + "paragraphs.": 2, + "parindent": 2, + "Indent": 1, + "first": 1, + "line": 2, + "new": 1, + "let": 11, + "VERBATIM": 2, + "verbatim": 2, + "def": 18, + "verbatim@font": 1, + "small": 8, + "ttfamily": 1, + "usepackage": 2, + "caption": 1, + "footnotesize": 2, + "subcaption": 1, + "captionsetup": 4, + "table": 2, + "labelformat": 4, + "simple": 3, + "labelsep": 4, + "period": 3, + "labelfont": 4, + "bf": 4, + "figure": 2, + "subtable": 1, + "parens": 1, + "subfigure": 1, + "TRUE": 1, + "FALSE": 1, + "SHOW": 3, + "HIDE": 2, + "thispagestyle": 5, + "empty": 6, + "listoftodos": 1, + "clearpage": 4, + "pagenumbering": 1, + "arabic": 2, + "shortname": 2, + "#1": 40, + "authorname": 2, + "#2": 17, + "coursename": 3, + "#3": 8, + "assignment": 3, + "#4": 4, + "duedate": 2, + "#5": 2, + "begin": 11, + "minipage": 4, + "textwidth": 4, + "flushleft": 2, + "hypertarget": 1, + "@assignment": 2, + "textbf": 5, + "end": 12, + "flushright": 2, + "renewcommand": 10, + "headrulewidth": 1, + "footrulewidth": 1, + "pagestyle": 3, + "fancyplain": 4, + "fancyhf": 2, + "lfoot": 1, + "hyperlink": 1, + "cfoot": 1, + "rfoot": 1, + "thepage": 2, + "pageref": 1, + "LastPage": 1, + "newcounter": 1, + "theproblem": 3, + "Problem": 2, + "counter": 1, + "environment": 1, + "problem": 1, + "addtocounter": 2, + "setcounter": 5, + "equation": 1, + "noindent": 2, + ".": 3, + "textit": 1, + "Default": 2, + "is": 2, + "omit": 1, + "pagebreaks": 1, + "after": 1, + "solution": 2, + "qqed": 2, + "hfill": 3, + "rule": 1, + "mm": 2, + "ifnum": 3, + "pagebreak": 2, + "fi": 15, + "show": 1, + "solutions.": 1, + "vspace": 2, + "em": 8, + "Solution.": 1, + "ifnum#1": 2, + "else": 9, + "chap": 1, + "section": 2, + "Sum": 3, + "n": 4, + "ensuremath": 15, + "sum_": 2, + "from": 5, + "infsum": 2, + "infty": 2, + "Infinite": 1, + "sum": 1, + "Int": 1, + "x": 4, + "int_": 1, + "mathrm": 1, + "d": 1, + "Integrate": 1, + "respect": 1, + "Lim": 2, + "displaystyle": 2, + "lim_": 1, + "Take": 1, + "limit": 1, + "infinity": 1, + "f": 1, + "Frac": 1, + "/": 1, + "_": 1, + "Slanted": 1, + "fraction": 1, + "proper": 1, + "spacing.": 1, + "Usefule": 1, + "display": 2, + "fractions.": 1, + "eval": 1, + "vert_": 1, + "L": 1, + "hand": 2, + "sizing": 2, + "R": 1, + "D": 1, + "diff": 1, + "writing": 2, + "PD": 1, + "diffp": 1, + "full": 1, + "Forces": 1, + "style": 1, + "math": 4, + "mode": 4, + "Deg": 1, + "circ": 1, + "adding": 1, + "degree": 1, + "symbol": 4, + "even": 1, + "if": 1, + "not": 2, + "abs": 1, + "vert": 3, + "Absolute": 1, + "Value": 1, + "norm": 1, + "Vert": 2, + "Norm": 1, + "vector": 1, + "magnitude": 1, + "e": 1, + "times": 3, + "Scientific": 2, + "Notation": 2, + "E": 2, + "u": 1, + "text": 7, + "units": 1, + "Roman": 1, + "mc": 1, + "hspace": 3, + "comma": 1, + "into": 2, + "mtxt": 1, + "insterting": 1, + "on": 2, + "either": 1, + "side.": 1, + "Option": 1, + "preceding": 1, + "punctuation.": 1, + "prob": 1, + "P": 2, + "cndprb": 1, + "right.": 1, + "cov": 1, + "Cov": 1, + "twovector": 1, + "r": 3, + "array": 6, + "threevector": 1, + "fourvector": 1, + "vecs": 4, + "vec": 2, + "bm": 2, + "bolded": 2, + "arrow": 2, + "vect": 3, + "unitvecs": 1, + "hat": 2, + "unitvect": 1, + "Div": 1, + "del": 3, + "cdot": 1, + "Curl": 1, + "Grad": 1, "NeedsTeXFormat": 1, - "{": 180, "LaTeX2e": 1, - "}": 185, - "ProvidesClass": 1, "reedthesis": 1, - "[": 22, "/01/27": 1, "The": 4, "Reed": 5, "College": 5, "Thesis": 5, "Class": 4, - "]": 22, - "DeclareOption*": 1, - "PassOptionsToClass": 1, "CurrentOption": 1, "book": 2, - "ProcessOptions": 1, - "relax": 2, - "LoadClass": 1, - "RequirePackage": 1, - "fancyhdr": 1, "AtBeginDocument": 1, - "fancyhf": 1, "fancyhead": 5, "LE": 1, "RO": 1, - "thepage": 1, "above": 1, "makes": 2, "your": 1, "headers": 6, - "in": 10, - "all": 1, "caps.": 2, "If": 1, "you": 1, @@ -38189,28 +49298,16 @@ "different": 1, "choose": 1, "one": 1, - "of": 8, - "the": 14, - "following": 1, "options": 1, - "(": 3, "be": 3, "sure": 1, - "to": 8, "remove": 1, - "symbol": 1, - "from": 1, "both": 1, - "right": 1, - "and": 2, - "left": 1, - ")": 3, "RE": 2, "slshape": 2, "nouppercase": 2, "leftmark": 2, "This": 2, - "on": 1, "RIGHT": 2, "side": 2, "pages": 2, @@ -38230,25 +49327,19 @@ "or": 1, "scshape": 2, "will": 2, - "small": 2, "And": 1, "so": 1, - "pagestyle": 2, "fancy": 1, - "let": 10, "oldthebibliography": 2, "thebibliography": 2, "endoldthebibliography": 2, "endthebibliography": 1, "renewenvironment": 2, - "#1": 12, "addcontentsline": 5, "toc": 5, "chapter": 9, "bibname": 2, - "end": 5, "things": 1, - "for": 5, "psych": 1, "majors": 1, "comment": 1, @@ -38259,14 +49350,8 @@ "endtheindex": 1, "indexname": 1, "RToldchapter": 1, - "renewcommand": 6, "if@openright": 1, "RTcleardoublepage": 3, - "else": 7, - "clearpage": 3, - "fi": 13, - "thispagestyle": 3, - "empty": 4, "global": 2, "@topnum": 1, "z@": 2, @@ -38274,16 +49359,12 @@ "secdef": 1, "@chapter": 2, "@schapter": 1, - "def": 12, - "#2": 4, - "ifnum": 2, "c@secnumdepth": 1, "m@ne": 2, "if@mainmatter": 1, "refstepcounter": 1, "typeout": 1, "@chapapp": 2, - "space": 4, "thechapter.": 1, "thechapter": 1, "space#1": 1, @@ -38306,18 +49387,15 @@ "newpage": 3, "RToldcleardoublepage": 1, "cleardoublepage": 4, - "setlength": 10, "oddsidemargin": 2, ".5in": 3, "evensidemargin": 2, - "textwidth": 2, "textheight": 4, "topmargin": 6, "addtolength": 8, "headheight": 4, "headsep": 3, ".6in": 1, - "pt": 1, "division#1": 1, "gdef": 6, "@division": 3, @@ -38353,15 +49431,12 @@ "addpenalty": 1, "@highpenalty": 2, "vskip": 4, - "em": 3, "@plus": 1, "@tempdima": 2, "begingroup": 1, - "parindent": 1, "rightskip": 1, "@pnumwidth": 3, "parfillskip": 1, - "-": 2, "leavevmode": 1, "bfseries": 3, "advance": 1, @@ -38374,8 +49449,6 @@ "mkern": 2, "@dotsep": 2, "mu": 2, - ".": 1, - "hfill": 1, "hb@xt@": 1, "hss": 1, "par": 6, @@ -38387,7 +49460,6 @@ "onecolumn": 1, "@restonecolfalse": 1, "Abstract": 2, - "begin": 4, "center": 7, "fontsize": 7, "selectfont": 6, @@ -38409,7 +49481,6 @@ "/Creator": 1, "maketitle": 1, "titlepage": 2, - "footnotesize": 1, "footnoterule": 1, "footnote": 1, "thanks": 1, @@ -38417,8 +49488,6 @@ "setbox0": 2, "Requirements": 2, "Degree": 2, - "setcounter": 1, - "page": 3, "null": 3, "vfil": 8, "@title": 1, @@ -38444,7 +49513,6 @@ "just": 1, "below": 2, "cm": 2, - "not": 1, "copy0": 1, "approved": 1, "major": 1, @@ -38516,17 +49584,17 @@ "Animal": 4, "{": 9, "constructor": 3, - "(": 17, + "(": 18, "public": 1, "name": 5, - ")": 17, + ")": 18, "}": 9, "move": 3, "meters": 2, "alert": 3, "this.name": 1, "+": 3, - ";": 7, + ";": 8, "Snake": 2, "extends": 2, "super": 2, @@ -38540,6 +49608,431 @@ "tom.move": 1, "console.log": 1 }, + "UnrealScript": { + "//": 5, + "-": 220, + "class": 18, + "MutU2Weapons": 1, + "extends": 2, + "Mutator": 1, + "config": 18, + "(": 189, + "U2Weapons": 1, + ")": 189, + ";": 295, + "var": 30, + "string": 25, + "ReplacedWeaponClassNames0": 1, + "ReplacedWeaponClassNames1": 1, + "ReplacedWeaponClassNames2": 1, + "ReplacedWeaponClassNames3": 1, + "ReplacedWeaponClassNames4": 1, + "ReplacedWeaponClassNames5": 1, + "ReplacedWeaponClassNames6": 1, + "ReplacedWeaponClassNames7": 1, + "ReplacedWeaponClassNames8": 1, + "ReplacedWeaponClassNames9": 1, + "ReplacedWeaponClassNames10": 1, + "ReplacedWeaponClassNames11": 1, + "ReplacedWeaponClassNames12": 1, + "bool": 18, + "bConfigUseU2Weapon0": 1, + "bConfigUseU2Weapon1": 1, + "bConfigUseU2Weapon2": 1, + "bConfigUseU2Weapon3": 1, + "bConfigUseU2Weapon4": 1, + "bConfigUseU2Weapon5": 1, + "bConfigUseU2Weapon6": 1, + "bConfigUseU2Weapon7": 1, + "bConfigUseU2Weapon8": 1, + "bConfigUseU2Weapon9": 1, + "bConfigUseU2Weapon10": 1, + "bConfigUseU2Weapon11": 1, + "bConfigUseU2Weapon12": 1, + "//var": 8, + "byte": 4, + "bUseU2Weapon": 1, + "[": 125, + "]": 125, + "": 7, + "ReplacedWeaponClasses": 3, + "": 2, + "ReplacedWeaponPickupClasses": 1, + "": 3, + "ReplacedAmmoPickupClasses": 1, + "U2WeaponClasses": 2, + "//GE": 17, + "For": 3, + "default": 12, + "properties": 3, + "ONLY": 3, + "U2WeaponPickupClassNames": 1, + "U2AmmoPickupClassNames": 2, + "bIsVehicle": 4, + "bNotVehicle": 3, + "localized": 2, + "U2WeaponDisplayText": 1, + "U2WeaponDescText": 1, + "GUISelectOptions": 1, + "int": 10, + "FirePowerMode": 1, + "bExperimental": 3, + "bUseFieldGenerator": 2, + "bUseProximitySensor": 2, + "bIntegrateShieldReward": 2, + "IterationNum": 8, + "Weapons.Length": 1, + "const": 1, + "DamageMultiplier": 28, + "DamagePercentage": 3, + "bUseXMPFeel": 4, + "FlashbangModeString": 1, + "struct": 1, + "WeaponInfo": 2, + "{": 28, + "ReplacedWeaponClass": 1, + "Generated": 4, + "from": 6, + "ReplacedWeaponClassName.": 2, + "This": 3, + "is": 6, + "what": 1, + "we": 3, + "replace.": 1, + "ReplacedWeaponPickupClass": 1, + "UNUSED": 1, + "ReplacedAmmoPickupClass": 1, + "WeaponClass": 1, + "the": 31, + "weapon": 10, + "are": 1, + "going": 1, + "to": 4, + "put": 1, + "inside": 1, + "world.": 1, + "WeaponPickupClassName": 1, + "WeponClass.": 1, + "AmmoPickupClassName": 1, + "WeaponClass.": 1, + "bEnabled": 1, + "Structs": 1, + "can": 2, + "d": 1, + "thus": 1, + "still": 1, + "require": 1, + "bConfigUseU2WeaponX": 1, + "indicates": 1, + "that": 3, + "spawns": 1, + "a": 2, + "vehicle": 3, + "deployable": 1, + "turrets": 1, + ".": 2, + "These": 1, + "only": 2, + "work": 1, + "in": 4, + "gametypes": 1, + "duh.": 1, + "Opposite": 1, + "of": 1, + "works": 1, + "non": 1, + "gametypes.": 2, + "Think": 1, + "shotgun.": 1, + "}": 27, + "Weapons": 31, + "function": 5, + "PostBeginPlay": 1, + "local": 8, + "FireMode": 8, + "x": 65, + "//local": 3, + "ReplacedWeaponPickupClassName": 1, + "//IterationNum": 1, + "ArrayCount": 2, + "Level.Game.bAllowVehicles": 4, + "He": 1, + "he": 1, + "neat": 1, + "way": 1, + "get": 1, + "required": 1, + "number.": 1, + "for": 11, + "<": 9, + "+": 18, + ".bEnabled": 3, + "GetPropertyText": 5, + "needed": 1, + "use": 1, + "variables": 1, + "an": 1, + "array": 2, + "like": 1, + "fashion.": 1, + "//bUseU2Weapon": 1, + ".ReplacedWeaponClass": 5, + "DynamicLoadObject": 2, + "//ReplacedWeaponClasses": 1, + "//ReplacedWeaponPickupClassName": 1, + ".default.PickupClass": 1, + "if": 55, + ".ReplacedWeaponClass.default.FireModeClass": 4, + "None": 10, + "&&": 15, + ".default.AmmoClass": 1, + ".default.AmmoClass.default.PickupClass": 2, + ".ReplacedAmmoPickupClass": 2, + "break": 1, + ".WeaponClass": 7, + ".WeaponPickupClassName": 1, + ".WeaponClass.default.PickupClass": 1, + ".AmmoPickupClassName": 2, + ".bIsVehicle": 2, + ".bNotVehicle": 2, + "Super.PostBeginPlay": 1, + "ValidReplacement": 6, + "return": 47, + "CheckReplacement": 1, + "Actor": 1, + "Other": 23, + "out": 2, + "bSuperRelevant": 3, + "i": 12, + "WeaponLocker": 3, + "L": 2, + "xWeaponBase": 3, + ".WeaponType": 2, + "false": 3, + "true": 5, + "Weapon": 1, + "Other.IsA": 2, + "Other.Class": 2, + "Ammo": 1, + "ReplaceWith": 1, + "L.Weapons.Length": 1, + "L.Weapons": 2, + "//STARTING": 1, + "WEAPON": 1, + "xPawn": 6, + ".RequiredEquipment": 3, + "True": 2, + "Special": 1, + "handling": 1, + "Shield": 2, + "Reward": 2, + "integration": 1, + "ShieldPack": 7, + ".SetStaticMesh": 1, + "StaticMesh": 1, + ".Skins": 1, + "Shader": 2, + ".RepSkin": 1, + ".SetDrawScale": 1, + ".SetCollisionSize": 1, + ".PickupMessage": 1, + ".PickupSound": 1, + "Sound": 1, + "Super.CheckReplacement": 1, + "GetInventoryClassOverride": 1, + "InventoryClassName": 3, + "Super.GetInventoryClassOverride": 1, + "static": 2, + "FillPlayInfo": 1, + "PlayInfo": 3, + "": 1, + "Recs": 4, + "WeaponOptions": 17, + "Super.FillPlayInfo": 1, + ".static.GetWeaponList": 1, + "Recs.Length": 1, + ".ClassName": 1, + ".FriendlyName": 1, + "PlayInfo.AddSetting": 33, + "default.RulesGroup": 33, + "default.U2WeaponDisplayText": 33, + "event": 3, + "GetDescriptionText": 1, + "PropName": 35, + "default.U2WeaponDescText": 33, + "Super.GetDescriptionText": 1, + "PreBeginPlay": 1, + "float": 3, + "k": 29, + "Multiplier.": 1, + "Super.PreBeginPlay": 1, + "/100.0": 1, + "//log": 1, + "@k": 1, + "//Sets": 1, + "various": 1, + "settings": 1, + "match": 1, + "different": 1, + "games": 1, + ".default.DamagePercentage": 1, + "//Original": 1, + "U2": 3, + "compensate": 1, + "division": 1, + "errors": 1, + "Class": 105, + ".default.DamageMin": 12, + "*": 54, + ".default.DamageMax": 12, + ".default.Damage": 27, + ".default.myDamage": 4, + "//Dampened": 1, + "already": 1, + "no": 2, + "need": 1, + "rewrite": 1, + "else": 1, + "//General": 2, + "XMP": 4, + ".default.Spread": 1, + ".default.MaxAmmo": 7, + ".default.Speed": 8, + ".default.MomentumTransfer": 4, + ".default.ClipSize": 4, + ".default.FireLastReloadTime": 3, + ".default.DamageRadius": 4, + ".default.LifeSpan": 4, + ".default.ShakeRadius": 1, + ".default.ShakeMagnitude": 1, + ".default.MaxSpeed": 5, + ".default.FireRate": 3, + ".default.ReloadTime": 3, + "//3200": 1, + "too": 1, + "much": 1, + ".default.VehicleDamageScaling": 2, + "*k": 28, + "//Experimental": 1, + "options": 1, + "lets": 1, + "you": 2, + "Unuse": 1, + "EMPimp": 1, + "projectile": 1, + "and": 3, + "fire": 1, + "two": 1, + "CAR": 1, + "barrels": 1, + "//CAR": 1, + "nothing": 1, + "U2Weapons.U2AssaultRifleFire": 1, + "U2Weapons.U2AssaultRifleAltFire": 1, + "U2ProjectileConcussionGrenade": 1, + "U2Weapons.U2AssaultRifleInv": 1, + "U2Weapons.U2WeaponEnergyRifle": 1, + "U2Weapons.U2WeaponFlameThrower": 1, + "U2Weapons.U2WeaponPistol": 1, + "U2Weapons.U2AutoTurretDeploy": 1, + "U2Weapons.U2WeaponRocketLauncher": 1, + "U2Weapons.U2WeaponGrenadeLauncher": 1, + "U2Weapons.U2WeaponSniper": 2, + "U2Weapons.U2WeaponRocketTurret": 1, + "U2Weapons.U2WeaponLandMine": 1, + "U2Weapons.U2WeaponLaserTripMine": 1, + "U2Weapons.U2WeaponShotgun": 1, + "s": 7, + "Minigun.": 1, + "Enable": 5, + "Shock": 1, + "Lance": 1, + "Energy": 2, + "Rifle": 3, + "What": 7, + "should": 7, + "be": 8, + "replaced": 8, + "with": 9, + "Rifle.": 3, + "By": 7, + "it": 7, + "Bio": 1, + "Magnum": 2, + "Pistol": 1, + "Pistol.": 1, + "Onslaught": 1, + "Grenade": 1, + "Launcher.": 2, + "Shark": 2, + "Rocket": 4, + "Launcher": 1, + "Flak": 1, + "Cannon.": 1, + "Should": 1, + "Lightning": 1, + "Gun": 2, + "Widowmaker": 2, + "Sniper": 3, + "Classic": 1, + "here.": 1, + "Turret": 2, + "delpoyable": 1, + "deployable.": 1, + "Redeemer.": 1, + "Laser": 2, + "Trip": 2, + "Mine": 1, + "Mine.": 1, + "t": 2, + "replace": 1, + "Link": 1, + "matches": 1, + "vehicles.": 1, + "Crowd": 1, + "Pleaser": 1, + "Shotgun.": 1, + "have": 1, + "shields": 1, + "or": 2, + "damage": 1, + "filtering.": 1, + "If": 1, + "checked": 1, + "mutator": 1, + "produces": 1, + "Unreal": 4, + "II": 4, + "shield": 1, + "pickups.": 1, + "Choose": 1, + "between": 2, + "white": 1, + "overlay": 3, + "depending": 2, + "on": 2, + "player": 2, + "view": 1, + "style": 1, + "distance": 1, + "foolproof": 1, + "FM_DistanceBased": 1, + "Arena": 1, + "Add": 1, + "weapons": 1, + "other": 1, + "Fully": 1, + "customisable": 1, + "choose": 1, + "behaviour.": 1, + "US3HelloWorld": 1, + "GameInfo": 1, + "InitGame": 1, + "Options": 1, + "Error": 1, + "log": 1, + "defaultproperties": 1 + }, "Verilog": { "////////////////////////////////////////////////////////////////////////////////": 14, "//": 117, @@ -39072,16 +50565,16 @@ "CLASS": 1, "BEGIN": 1, "MultiUse": 1, - "-": 6, + "-": 9, "NotPersistable": 1, "DataBindingBehavior": 1, "vbNone": 1, "MTSTransactionMode": 1, "*************************************************************************************************************************************************************************************************************************************************": 2, "Copyright": 1, - "(": 14, + "(": 20, "c": 1, - ")": 14, + ")": 20, "David": 1, "Briant": 1, "All": 1, @@ -39142,8 +50635,8 @@ "Release": 1, "hide": 1, "us": 1, - "from": 1, - "the": 3, + "from": 2, + "the": 7, "Applications": 1, "list": 1, "in": 1, @@ -39160,11 +50653,11 @@ "myMouseEventsForm.icon": 1, "make": 1, "myself": 1, - "easily": 1, + "easily": 2, "found": 1, "myMouseEventsForm.hwnd": 3, - "End": 7, - "Sub": 7, + "End": 11, + "Sub": 9, "shutdown": 1, "myAST.destroy": 1, "Nothing": 2, @@ -39180,17 +50673,17 @@ "MF_SEPARATOR": 1, "MF_CHECKED": 1, "route": 2, - "to": 1, - "a": 1, + "to": 4, + "a": 4, "remote": 1, "machine": 1, "Else": 1, - "for": 1, + "for": 4, "moment": 1, "just": 1, "between": 1, "MMFileTransports": 1, - "If": 3, + "If": 4, "myMMTransportIDsByRouterID.Exists": 1, "message.toAddress.RouterID": 2, "Then": 1, @@ -39210,7 +50703,141 @@ "id": 1, "oReceived": 2, "Boolean": 1, - "True": 1 + "True": 1, + "@Code": 1, + "ViewData": 1, + "Code": 1, + "@section": 1, + "featured": 1, + "": 1, + "Section": 1, + "

": 1, + "We": 1, + "suggest": 1, + "following": 1, + "

": 1, + "
    ": 1, + "
  1. ": 3, + "
    ": 3, + "Getting": 1, + "Started": 1, + "
    ": 3, + "gives": 2, + "powerful": 1, + "patterns": 1, + "based": 1, + "way": 1, + "build": 1, + "dynamic": 1, + "websites": 1, + "that": 5, + "enables": 1, + "clean": 1, + "separation": 1, + "of": 2, + "concerns": 1, + "full": 1, + "control": 1, + "over": 1, + "markup": 1, + "enjoyable": 1, + "agile": 1, + "development.": 1, + "includes": 1, + "many": 1, + "enable": 1, + "fast": 1, + "TDD": 1, + "friendly": 1, + "development": 1, + "creating": 1, + "sophisticated": 1, + "applications": 1, + "use": 1, + "latest": 1, + "web": 2, + "standards.": 1, + "Learn": 3, + "
  2. ": 3, + "Add": 1, + "NuGet": 2, + "packages": 1, + "jump": 1, + "start": 1, + "your": 2, + "coding": 1, + "makes": 1, + "it": 1, + "easy": 1, + "install": 1, + "update": 1, + "free": 1, + "libraries": 1, + "tools.": 1, + "Find": 1, + "Web": 1, + "Hosting": 1, + "You": 1, + "can": 1, + "find": 1, + "hosting": 1, + "company": 1, + "offers": 1, + "right": 1, + "mix": 1, + "price": 1, + "applications.": 1, + "
": 1, + "Module": 2, + "Module1": 1, + "Main": 1, + "Console.Out.WriteLine": 2 }, "Volt": { "module": 1, @@ -39739,8 +51366,8 @@ "return": 1 }, "XML": { - "": 3, - "version=": 4, + "": 4, + "version=": 6, "": 1, "name=": 223, "xmlns": 2, @@ -39790,7 +51417,7 @@ "revision=": 3, "status=": 1, "this": 77, - "a": 127, + "a": 128, "module.ivy": 1, "for": 59, "java": 1, @@ -39821,9 +51448,9 @@ "": 1, "": 1, "": 1, - "": 1, + "": 2, "ReactiveUI": 2, - "": 1, + "": 2, "": 1, "": 1, "": 120, @@ -39833,7 +51460,7 @@ "interface": 4, "that": 94, "replaces": 1, - "the": 260, + "the": 261, "non": 1, "PropertyChangedEventArgs.": 1, "Note": 7, @@ -40168,7 +51795,7 @@ "object.": 3, "ViewModel": 8, "another": 3, - "s": 1, + "s": 3, "Return": 1, "instance": 2, "type.": 3, @@ -40291,7 +51918,7 @@ "manage": 1, "disk": 1, "download": 1, - "save": 1, + "save": 2, "temporary": 1, "folder": 1, "onRelease": 1, @@ -40522,7 +52149,49 @@ "need": 12, "setup.": 12, "": 1, - "": 1 + "": 1, + "encoding=": 1, + "": 1, + "TS": 1, + "": 1, + "language=": 1, + "": 1, + "MainWindow": 1, + "": 8, + "": 8, + "filename=": 8, + "line=": 8, + "": 8, + "United": 1, + "Kingdom": 1, + "": 8, + "": 8, + "Reino": 1, + "Unido": 1, + "": 8, + "": 8, + "God": 1, + "Queen": 1, + "Deus": 1, + "salve": 1, + "Rainha": 1, + "England": 1, + "Inglaterra": 1, + "Wales": 1, + "Gales": 1, + "Scotland": 1, + "Esc": 1, + "cia": 1, + "Northern": 1, + "Ireland": 1, + "Irlanda": 1, + "Norte": 1, + "Portuguese": 1, + "Portugu": 1, + "English": 1, + "Ingl": 1, + "": 1, + "": 1 }, "XProc": { "": 1, @@ -40831,7 +52500,7 @@ }, "YAML": { "gem": 1, - "-": 16, + "-": 25, "local": 1, "gen": 1, "rdoc": 2, @@ -40843,62 +52512,127 @@ "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 } }, "language_tokens": { "ABAP": 1500, + "Agda": 376, "ApacheConf": 1449, "Apex": 4408, "AppleScript": 1862, "Arduino": 20, + "AsciiDoc": 103, + "AspectJ": 324, + "ATS": 4558, "AutoHotkey": 3, "Awk": 544, - "C": 58732, - "C++": 21480, + "BlitzBasic": 2065, + "Bluespec": 1298, + "Brightscript": 579, + "C": 59053, + "C#": 278, + "C++": 31181, "Ceylon": 50, + "Cirru": 244, + "Clojure": 510, "COBOL": 90, "CoffeeScript": 2951, + "Common Lisp": 103, "Coq": 18259, + "Creole": 134, "CSS": 43867, - "Dart": 68, + "Cuda": 290, + "Dart": 74, "Diff": 16, - "Ecl": 281, + "DM": 169, + "Dogescript": 30, + "Eagle": 30089, + "ECL": 281, "edn": 227, "Elm": 628, "Emacs Lisp": 1756, "Erlang": 2928, "fish": 636, "Forth": 1516, + "Frege": 5564, + "Game Maker Language": 13310, "GAS": 133, "GLSL": 3766, - "Gosu": 413, + "Gnuplot": 1023, + "Gosu": 410, "Groovy": 69, "Groovy Server Pages": 91, "Haml": 4, "Handlebars": 69, + "Hy": 155, + "IDL": 418, + "Idris": 148, "INI": 27, "Ioke": 2, + "Jade": 3, "Java": 8987, "JavaScript": 76934, - "JSON": 619, + "JSON": 183, + "JSON5": 57, + "JSONLD": 18, "Julia": 247, "Kotlin": 155, + "KRL": 25, "Lasso": 9849, "Less": 39, + "LFE": 1711, + "Literate Agda": 478, "Literate CoffeeScript": 275, "LiveScript": 123, "Logos": 93, "Logtalk": 36, "Lua": 724, - "M": 23373, + "M": 23615, "Makefile": 50, "Markdown": 1, - "Matlab": 11787, - "Max": 136, + "Mask": 74, + "Mathematica": 411, + "Matlab": 11942, + "Max": 714, + "MediaWiki": 766, "Monkey": 207, "MoonScript": 1718, "Nemerle": 17, + "NetLogo": 243, "Nginx": 179, "Nimrod": 1, "NSIS": 725, @@ -40907,105 +52641,154 @@ "OCaml": 382, "Omgrofl": 57, "Opa": 28, - "OpenCL": 88, + "OpenCL": 144, "OpenEdge ABL": 762, + "Org": 358, + "Oxygene": 157, "Parrot Assembly": 6, "Parrot Internal Representation": 5, "Pascal": 30, + "PAWN": 3263, "Perl": 17497, + "Perl6": 372, "PHP": 20724, + "Pod": 658, "PogoScript": 250, + "PostScript": 107, "PowerShell": 12, "Processing": 74, - "Prolog": 4040, + "Prolog": 468, + "Protocol Buffer": 63, "Python": 5715, - "R": 175, - "Racket": 360, + "R": 195, + "Racket": 331, "Ragel in Ruby Host": 593, + "RDoc": 279, "Rebol": 11, - "Ruby": 3854, + "RMarkdown": 19, + "RobotFramework": 483, + "Ruby": 3862, "Rust": 3566, "Sass": 56, - "Scala": 420, - "Scheme": 3478, + "Scala": 750, + "Scaml": 4, + "Scheme": 3515, "Scilab": 69, "SCSS": 39, "Shell": 3744, + "Shen": 3472, "Slash": 187, - "Standard ML": 243, - "SuperCollider": 268, + "Squirrel": 130, + "Standard ML": 6405, + "Stylus": 76, + "SuperCollider": 133, + "SystemVerilog": 541, + "Tcl": 1133, "Tea": 3, - "TeX": 1155, + "TeX": 2701, "Turing": 44, "TXL": 213, - "TypeScript": 106, + "TypeScript": 109, + "UnrealScript": 2873, "Verilog": 3778, "VHDL": 42, "VimL": 20, - "Visual Basic": 345, + "Visual Basic": 581, "Volt": 388, "wisp": 1363, "XC": 24, - "XML": 5622, + "XML": 5737, "XProc": 22, "XQuery": 801, "XSLT": 44, "Xtend": 399, - "YAML": 30 + "YAML": 77 }, "languages": { "ABAP": 1, + "Agda": 1, "ApacheConf": 3, "Apex": 6, "AppleScript": 7, "Arduino": 1, + "AsciiDoc": 3, + "AspectJ": 2, + "ATS": 10, "AutoHotkey": 1, "Awk": 1, - "C": 24, - "C++": 20, + "BlitzBasic": 3, + "Bluespec": 2, + "Brightscript": 1, + "C": 29, + "C#": 2, + "C++": 27, "Ceylon": 1, + "Cirru": 9, + "Clojure": 7, "COBOL": 4, "CoffeeScript": 9, + "Common Lisp": 1, "Coq": 12, + "Creole": 1, "CSS": 2, + "Cuda": 2, "Dart": 1, "Diff": 1, - "Ecl": 1, + "DM": 1, + "Dogescript": 1, + "Eagle": 2, + "ECL": 1, "edn": 1, "Elm": 3, "Emacs Lisp": 2, "Erlang": 5, "fish": 3, "Forth": 7, + "Frege": 4, + "Game Maker Language": 13, "GAS": 1, "GLSL": 3, - "Gosu": 5, + "Gnuplot": 6, + "Gosu": 4, "Groovy": 2, "Groovy Server Pages": 4, "Haml": 1, "Handlebars": 2, + "Hy": 2, + "IDL": 4, + "Idris": 1, "INI": 2, "Ioke": 1, + "Jade": 1, "Java": 6, "JavaScript": 20, - "JSON": 5, + "JSON": 4, + "JSON5": 2, + "JSONLD": 1, "Julia": 1, "Kotlin": 1, + "KRL": 1, "Lasso": 4, "Less": 1, + "LFE": 4, + "Literate Agda": 1, "Literate CoffeeScript": 1, "LiveScript": 1, "Logos": 1, "Logtalk": 1, "Lua": 3, - "M": 28, + "M": 29, "Makefile": 2, "Markdown": 1, - "Matlab": 37, - "Max": 1, + "Mask": 1, + "Mathematica": 3, + "Matlab": 39, + "Max": 3, + "MediaWiki": 1, "Monkey": 1, "MoonScript": 1, "Nemerle": 1, + "NetLogo": 1, "Nginx": 1, "Nimrod": 1, "NSIS": 2, @@ -41014,51 +52797,68 @@ "OCaml": 2, "Omgrofl": 1, "Opa": 2, - "OpenCL": 1, + "OpenCL": 2, "OpenEdge ABL": 5, + "Org": 1, + "Oxygene": 1, "Parrot Assembly": 1, "Parrot Internal Representation": 1, "Pascal": 1, + "PAWN": 1, "Perl": 14, + "Perl6": 3, "PHP": 9, + "Pod": 1, "PogoScript": 1, + "PostScript": 1, "PowerShell": 2, "Processing": 1, - "Prolog": 6, + "Prolog": 3, + "Protocol Buffer": 1, "Python": 7, - "R": 2, - "Racket": 3, + "R": 3, + "Racket": 2, "Ragel in Ruby Host": 3, + "RDoc": 1, "Rebol": 1, - "Ruby": 16, + "RMarkdown": 1, + "RobotFramework": 3, + "Ruby": 17, "Rust": 1, "Sass": 2, - "Scala": 3, - "Scheme": 1, + "Scala": 4, + "Scaml": 1, + "Scheme": 2, "Scilab": 3, "SCSS": 1, "Shell": 37, + "Shen": 3, "Slash": 1, - "Standard ML": 2, - "SuperCollider": 2, + "Squirrel": 1, + "Standard ML": 4, + "Stylus": 1, + "SuperCollider": 1, + "SystemVerilog": 4, + "Tcl": 2, "Tea": 1, - "TeX": 1, + "TeX": 2, "Turing": 1, "TXL": 1, "TypeScript": 3, + "UnrealScript": 2, "Verilog": 13, "VHDL": 1, "VimL": 2, - "Visual Basic": 1, + "Visual Basic": 3, "Volt": 1, "wisp": 1, "XC": 1, - "XML": 3, + "XML": 4, "XProc": 1, "XQuery": 1, "XSLT": 1, "Xtend": 2, - "YAML": 1 + "YAML": 2 }, - "md5": "04aab6477c2dc5ef1be1c9de1886c3f3" + "md5": "0c653c413ad8572c59974462a5ae4dab" } \ No newline at end of file diff --git a/lib/linguist/samples.rb b/lib/linguist/samples.rb index d9099385..2bd5212e 100644 --- a/lib/linguist/samples.rb +++ b/lib/linguist/samples.rb @@ -1,4 +1,8 @@ -require 'yaml' +begin + require 'json' +rescue LoadError + require 'yaml' +end require 'linguist/md5' require 'linguist/classifier' @@ -14,7 +18,8 @@ module Linguist # Hash of serialized samples object if File.exist?(PATH) - DATA = YAML.load_file(PATH) + serializer = defined?(JSON) ? JSON : YAML + DATA = serializer.load(File.read(PATH)) end # Public: Iterate over each sample. @@ -52,6 +57,7 @@ module Linguist yield({ :path => File.join(dirname, filename), :language => category, + :interpreter => File.exist?(filename) ? Linguist.interpreter_from_shebang(File.read(filename)) : nil, :extname => File.extname(filename) }) end @@ -67,6 +73,7 @@ module Linguist def self.data db = {} db['extnames'] = {} + db['interpreters'] = {} db['filenames'] = {} each do |sample| @@ -80,6 +87,14 @@ module Linguist end end + if sample[:interpreter] + db['interpreters'][language_name] ||= [] + if !db['interpreters'][language_name].include?(sample[:interpreter]) + db['interpreters'][language_name] << sample[:interpreter] + db['interpreters'][language_name].sort! + end + end + if sample[:filename] db['filenames'][language_name] ||= [] db['filenames'][language_name] << sample[:filename] @@ -95,4 +110,40 @@ module Linguist db end end + + # Used to retrieve the interpreter from the shebang line of a file's + # data. + def self.interpreter_from_shebang(data) + lines = data.lines.to_a + + if lines.any? && (match = lines[0].match(/(.+)\n?/)) && (bang = match[0]) =~ /^#!/ + bang.sub!(/^#! /, '#!') + tokens = bang.split(' ') + pieces = tokens.first.split('/') + + if pieces.size > 1 + script = pieces.last + else + script = pieces.first.sub('#!', '') + end + + script = script == 'env' ? tokens[1] : script + + # "python2.6" -> "python" + if script =~ /((?:\d+\.?)+)/ + script.sub! $1, '' + end + + # Check for multiline shebang hacks that call `exec` + if script == 'sh' && + lines[0...5].any? { |l| l.match(/exec (\w+).+\$0.+\$@/) } + script = $1 + end + + script + else + nil + end + end + end diff --git a/lib/linguist/vendor.yml b/lib/linguist/vendor.yml index 8967c266..5d870de5 100644 --- a/lib/linguist/vendor.yml +++ b/lib/linguist/vendor.yml @@ -10,7 +10,10 @@ ## Vendor Conventions ## # Caches -- cache/ +- (^|/)cache/ + +# Dependencies +- ^[Dd]ependencies/ # C deps # https://github.com/joyent/node @@ -24,20 +27,34 @@ # Node dependencies - node_modules/ +# Bower Components +- bower_components/ + # Erlang bundles - ^rebar$ +# Bootstrap minified css and js +- (^|/)bootstrap([^.]*)(\.min)?\.(js|css)$ + +# Foundation css +- foundation.min.css +- foundation.css + # Vendored dependencies -- vendor/ +- thirdparty/ +- vendors?/ # Debian packaging - ^debian/ +# Haxelib projects often contain a neko bytecode file named run.n +- run.n$ + ## Commonly Bundled JavaScript frameworks ## # jQuery - (^|/)jquery([^.]*)(\.min)?\.js$ -- (^|/)jquery\-\d\.\d(\.\d)?(\.min)?\.js$ +- (^|/)jquery\-\d\.\d+(\.\d+)?(\.min)?\.js$ # jQuery UI - (^|/)jquery\-ui(\-\d\.\d+(\.\d+)?)?(\.\w+)?(\.min)?\.(js|css)$ @@ -49,6 +66,9 @@ - (^|/)controls\.js$ - (^|/)dragdrop\.js$ +# Typescript definition files +- (.*?)\.d\.ts$ + # MooTools - (^|/)mootools([^.]*)\d+\.\d+.\d+([^.]*)\.js$ @@ -75,6 +95,12 @@ - (^|/)shCore\.js$ - (^|/)shLegacy\.js$ +# AngularJS +- (^|/)angular([^.]*)(\.min)?\.js$ + +# React +- (^|/)react(-[^.]*)?(\.min)?\.js$ + ## Python ## # django @@ -86,12 +112,21 @@ # WAF - ^waf$ +# .osx +- ^.osx$ ## Obj-C ## # Sparkle - (^|/)Sparkle/ +## Groovy ## + +# Gradle +- (^|/)gradlew$ +- (^|/)gradlew\.bat$ +- (^|/)gradle/wrapper/ + ## .NET ## # Visual Studio IntelliSense @@ -108,14 +143,30 @@ - ^[Pp]ackages/ # ExtJS -- (^|/)extjs/ +- (^|/)extjs/.*?\.js$ +- (^|/)extjs/.*?\.xml$ +- (^|/)extjs/.*?\.txt$ +- (^|/)extjs/.*?\.html$ +- (^|/)extjs/.*?\.properties$ +- (^|/)extjs/.sencha/ +- (^|/)extjs/docs/ +- (^|/)extjs/builds/ +- (^|/)extjs/cmd/ +- (^|/)extjs/examples/ +- (^|/)extjs/locale/ +- (^|/)extjs/packages/ +- (^|/)extjs/plugins/ +- (^|/)extjs/resources/ +- (^|/)extjs/src/ +- (^|/)extjs/welcome/ # Samples folders - ^[Ss]amples/ # LICENSE, README, git config files - ^COPYING$ -- ^LICENSE$ +- LICENSE$ +- License$ - gitattributes$ - gitignore$ - gitmodules$ @@ -125,5 +176,12 @@ # Test fixtures - ^[Tt]est/fixtures/ +# PhoneGap/Cordova +- (^|/)cordova([^.]*)(\.min)?\.js$ +- (^|/)cordova\-\d\.\d(\.\d)?(\.min)?\.js$ + +# Vagrant +- ^Vagrantfile$ + # .DS_Store's - .[Dd][Ss]_[Ss]tore$ diff --git a/samples/ATS/CoYonedaLemma.dats b/samples/ATS/CoYonedaLemma.dats new file mode 100644 index 00000000..aeac8bb1 --- /dev/null +++ b/samples/ATS/CoYonedaLemma.dats @@ -0,0 +1,110 @@ +(* ****** ****** *) +// +// HX-2014-01 +// CoYoneda Lemma: +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +"libats/ML/SATS/basis.sats" +staload +"libats/ML/SATS/list0.sats" + +(* ****** ****** *) + +staload _ = "libats/ML/DATS/list0.dats" + +(* ****** ****** *) + +sortdef ftype = type -> type + +(* ****** ****** *) + +infixr (->) ->> +typedef ->> (a:type, b:type) = a - b + +(* ****** ****** *) + +typedef +functor(F:ftype) = + {a,b:type} (a ->> b) ->> F(a) ->> F(b) + +(* ****** ****** *) + +typedef +list0 (a:type) = list0 (a) +extern +val functor_list0 : functor (list0) + +(* ****** ****** *) + +implement +functor_list0{a,b} + (f) = lam xs => list0_map (xs, f) + +(* ****** ****** *) + +datatype +CoYoneda + (F:ftype, r:type) = {a:type} CoYoneda of (a ->> r, F(a)) +// end of [CoYoneda] + +(* ****** ****** *) +// +extern +fun CoYoneda_phi + : {F:ftype}functor(F) -> {r:type} (F (r) ->> CoYoneda (F, r)) +extern +fun CoYoneda_psi + : {F:ftype}functor(F) -> {r:type} (CoYoneda (F, r) ->> F (r)) +// +(* ****** ****** *) + +implement +CoYoneda_phi(ftor) = lam (fx) => CoYoneda (lam x => x, fx) +implement +CoYoneda_psi(ftor) = lam (CoYoneda(f, fx)) => ftor (f) (fx) + +(* ****** ****** *) + +datatype int0 = I of (int) +datatype bool = True | False // boxed boolean + +(* ****** ****** *) +// +fun bool2string + (x:bool): string = +( + case+ x of True() => "True" | False() => "False" +) +// +implement +fprint_val (out, x) = fprint (out, bool2string(x)) +// +(* ****** ****** *) + +fun int2bool (i: int0): bool = + let val+I(i) = i in if i > 0 then True else False end + +(* ****** ****** *) + +val myintlist0 = g0ofg1($list{int0}((I)1, (I)0, (I)1, (I)0, (I)0)) +val myboolist0 = CoYoneda{list0,bool}{int0}(lam (i) => int2bool(i), myintlist0) +val myboolist0 = CoYoneda_psi{list0}(functor_list0){bool}(myboolist0) + +(* ****** ****** *) + +val ((*void*)) = fprintln! (stdout_ref, "myboolist0 = ", myboolist0) + +(* ****** ****** *) + +implement main0 () = () + +(* ****** ****** *) + +(* end of [CoYonedaLemma.dats] *) diff --git a/samples/ATS/DiningPhil2.dats b/samples/ATS/DiningPhil2.dats new file mode 100644 index 00000000..55c39654 --- /dev/null +++ b/samples/ATS/DiningPhil2.dats @@ -0,0 +1,178 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include +"share/atspre_define.hats" +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "libc/SATS/stdlib.sats" +staload "libc/SATS/unistd.sats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +staload _ = "libats/DATS/deqarray.dats" +staload _ = "{$LIBATSHWXI}/teaching/mythread/DATS/channel.dats" + +(* ****** ****** *) + +staload "./DiningPhil2.sats" + +(* ****** ****** *) + +implement phil_left (n) = n +implement phil_right (n) = (n+1) \nmod NPHIL + +(* ****** ****** *) +// +extern +fun randsleep (n: intGte(1)): void +// +implement +randsleep (n) = + ignoret (sleep($UN.cast{uInt}(rand() mod n + 1))) +// end of [randsleep] +// +(* ****** ****** *) + +implement +phil_think (n) = +{ +val () = println! ("phil_think(", n, ") starts") +val () = randsleep (6) +val () = println! ("phil_think(", n, ") finishes") +} + +(* ****** ****** *) + +implement +phil_dine (n, lf, rf) = +{ +val () = println! ("phil_dine(", n, ") starts") +val () = randsleep (3) +val () = println! ("phil_dine(", n, ") finishes") +} + +(* ****** ****** *) + +implement +phil_loop (n) = let +// +val () = phil_think (n) +// +val nl = phil_left (n) +val nr = phil_right (n) +// +val ch_lfork = fork_changet (nl) +val ch_rfork = fork_changet (nr) +// +val lf = channel_takeout (ch_lfork) +val () = println! ("phil_loop(", n, ") picks left fork") +// +val () = randsleep (2) // HX: try to actively induce deadlock +// +val rf = channel_takeout (ch_rfork) +val () = println! ("phil_loop(", n, ") picks right fork") +// +val () = phil_dine (n, lf, rf) +// +val ch_forktray = forktray_changet () +val () = channel_insert (ch_forktray, lf) +val () = channel_insert (ch_forktray, rf) +// +in + phil_loop (n) +end // end of [phil_loop] + +(* ****** ****** *) + +implement +cleaner_wash (f) = +{ +val f = fork_get_num (f) +val () = println! ("cleaner_wash(", f, ") starts") +val () = randsleep (1) +val () = println! ("cleaner_wash(", f, ") finishes") +} + +(* ****** ****** *) + +implement +cleaner_return (f) = +{ + val n = fork_get_num (f) + val ch = fork_changet (n) + val () = channel_insert (ch, f) +} + +(* ****** ****** *) + +implement +cleaner_loop () = let +// +val ch = forktray_changet () +val f0 = channel_takeout (ch) +// +val () = cleaner_wash (f0) +val () = cleaner_return (f0) +// +in + cleaner_loop () +end // end of [cleaner_loop] + +(* ****** ****** *) + +dynload "DiningPhil2.sats" +dynload "DiningPhil2_fork.dats" +dynload "DiningPhil2_thread.dats" + +(* ****** ****** *) + +local +// +staload +"{$LIBATSHWXI}/teaching/mythread/SATS/mythread.sats" +// +in (* in of [local] *) +// +val () = mythread_create_cloptr (llam () => phil_loop (0)) +val () = mythread_create_cloptr (llam () => phil_loop (1)) +val () = mythread_create_cloptr (llam () => phil_loop (2)) +val () = mythread_create_cloptr (llam () => phil_loop (3)) +val () = mythread_create_cloptr (llam () => phil_loop (4)) +// +val () = mythread_create_cloptr (llam () => cleaner_loop ()) +// +end // end of [local] + +(* ****** ****** *) + +implement +main0 () = +{ +// +val () = println! ("DiningPhil2: starting") +val ((*void*)) = while (true) ignoret (sleep(1)) +// +} (* end of [main0] *) + +(* ****** ****** *) + +(* end of [DiningPhil2.dats] *) diff --git a/samples/ATS/DiningPhil2.sats b/samples/ATS/DiningPhil2.sats new file mode 100644 index 00000000..bc7e96be --- /dev/null +++ b/samples/ATS/DiningPhil2.sats @@ -0,0 +1,71 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) + +#include +"share/atspre_define.hats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +%{# +#define NPHIL 5 +%} // end of [%{#] +#define NPHIL 5 + +(* ****** ****** *) + +typedef nphil = natLt(NPHIL) + +(* ****** ****** *) + +fun phil_left (n: nphil): nphil +fun phil_right (n: nphil): nphil + +(* ****** ****** *) +// +fun phil_loop (n: nphil): void +// +(* ****** ****** *) + +fun cleaner_loop ((*void*)): void + +(* ****** ****** *) + +absvtype fork_vtype = ptr +vtypedef fork = fork_vtype + +(* ****** ****** *) + +fun fork_get_num (!fork): nphil + +(* ****** ****** *) + +fun phil_dine + (n: nphil, lf: !fork, rf: !fork): void +// end of [phil_dine] + +fun phil_think (n: nphil): void + +(* ****** ****** *) + +fun cleaner_wash (f: !fork): void +fun cleaner_return (f: fork): void + +(* ****** ****** *) +// +fun fork_changet (n: nphil): channel(fork) +// +fun forktray_changet ((*void*)): channel(fork) +// +(* ****** ****** *) + +(* end of [DiningPhil2.sats] *) diff --git a/samples/ATS/DiningPhil2_fork.dats b/samples/ATS/DiningPhil2_fork.dats new file mode 100644 index 00000000..a6a8d4df --- /dev/null +++ b/samples/ATS/DiningPhil2_fork.dats @@ -0,0 +1,89 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include +"share/atspre_define.hats" +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/channel.sats" + +(* ****** ****** *) + +staload _ = "libats/DATS/deqarray.dats" +staload _ = "{$LIBATSHWXI}/teaching/mythread/DATS/channel.dats" + +(* ****** ****** *) + +staload "./DiningPhil2.sats" + +(* ****** ****** *) + +datavtype fork = FORK of (nphil) + +(* ****** ****** *) + +assume fork_vtype = fork + +(* ****** ****** *) + +implement +fork_get_num (f) = let val FORK(n) = f in n end + +(* ****** ****** *) + +local + +val +the_forkarray = let +// +typedef t = channel(fork) +// +implement +array_tabulate$fopr + (n) = ch where +{ + val n = $UN.cast{nphil}(n) + val ch = channel_create_exn (i2sz(2)) + val () = channel_insert (ch, FORK (n)) +} +// +in + arrayref_tabulate (i2sz(NPHIL)) +end // end of [val] + +in (* in of [local] *) + +implement fork_changet (n) = the_forkarray[n] + +end // end of [local] + +(* ****** ****** *) + +local + +val the_forktray = + channel_create_exn (i2sz(NPHIL+1)) + +in (* in of [local] *) + +implement forktray_changet () = the_forktray + +end // end of [local] + +(* ****** ****** *) + +(* end of [DiningPhil2_fork.dats] *) diff --git a/samples/ATS/DiningPhil2_thread.dats b/samples/ATS/DiningPhil2_thread.dats new file mode 100644 index 00000000..be73840b --- /dev/null +++ b/samples/ATS/DiningPhil2_thread.dats @@ -0,0 +1,43 @@ +(* ****** ****** *) +// +// HX-2013-11 +// +// Implementing a variant of +// the problem of Dining Philosophers +// +(* ****** ****** *) +// +#include "share/atspre_define.hats" +#include "share/atspre_staload.hats" +// +(* ****** ****** *) + +staload "{$LIBATSHWXI}/teaching/mythread/SATS/mythread.sats" + +(* ****** ****** *) + +local +// +#include "{$LIBATSHWXI}/teaching/mythread/DATS/mythread.dats" +// +in (* in of [local] *) +// +// HX: it is intentionally left to be empty +// +end // end of [local] + +(* ****** ****** *) + +local +// +#include "{$LIBATSHWXI}/teaching/mythread/DATS/mythread_posix.dats" +// +in (* in of [local] *) +// +// HX: it is intentionally left to be empty +// +end // end of [local] + +(* ****** ****** *) + +(* end of [DiningPhil2_thread.dats] *) diff --git a/samples/ATS/YonedaLemma.dats b/samples/ATS/YonedaLemma.dats new file mode 100644 index 00000000..cd3c31e6 --- /dev/null +++ b/samples/ATS/YonedaLemma.dats @@ -0,0 +1,178 @@ +(* ****** ****** *) +// +// HX-2014-01 +// Yoneda Lemma: +// The hardest "trivial" theorem :) +// +(* ****** ****** *) +// +#include +"share/atspre_staload.hats" +// +(* ****** ****** *) + +staload +"libats/ML/SATS/basis.sats" +staload +"libats/ML/SATS/list0.sats" +staload +"libats/ML/SATS/option0.sats" + +(* ****** ****** *) + +staload _ = "libats/ML/DATS/list0.dats" +staload _ = "libats/ML/DATS/option0.dats" + +(* ****** ****** *) + +sortdef ftype = type -> type + +(* ****** ****** *) + +infixr (->) ->> +typedef ->> (a:type, b:type) = a - b + +(* ****** ****** *) + +typedef +functor(F:ftype) = + {a,b:type} (a ->> b) ->> F(a) ->> F(b) + +(* ****** ****** *) + +typedef +list0 (a:type) = list0 (a) +extern +val functor_list0 : functor (list0) + +(* ****** ****** *) + +implement +functor_list0{a,b} + (f) = lam xs => list0_map (xs, f) + +(* ****** ****** *) + +typedef +option0 (a:type) = option0 (a) +extern +val functor_option0 : functor (option0) + +(* ****** ****** *) + +implement +functor_option0{a,b} + (f) = lam opt => option0_map (opt, f) + +(* ****** ****** *) + +extern +val functor_homres + : {c:type} functor (lam(r:type) => c ->> r) + +(* ****** ****** *) + +implement +functor_homres{c}{a,b} (f) = lam (r) => lam (x) => f (r(x)) + +(* ****** ****** *) +// +extern +fun Yoneda_phi : {F:ftype}functor(F) -> + {a:type}F(a) ->> ({r:type}(a ->> r) ->> F(r)) +extern +fun Yoneda_psi : {F:ftype}functor(F) -> + {a:type}({r:type}(a ->> r) ->> F(r)) ->> F(a) +// +(* ****** ****** *) +// +implement +Yoneda_phi + (ftor) = lam(fx) => lam (m) => ftor(m)(fx) +// +implement +Yoneda_psi (ftor) = lam(mf) => mf(lam x => x) +// +(* ****** ****** *) + +(* + +(* ****** ****** *) +// +// HX-2014-01-05: +// Another version based on Natural Transformation +// +(* ****** ****** *) + +typedef +natrans(F:ftype, G:ftype) = {x:type} (F(x) ->> G(x)) + +(* ****** ****** *) +// +extern +fun Yoneda_phi_nat : {F:ftype}functor(F) -> + {a:type} F(a) ->> natrans(lam (r:type) => (a ->> r), F) +extern +fun Yoneda_psi_nat : {F:ftype}functor(F) -> + {a:type} natrans(lam (r:type) => (a ->> r), F) ->> F(a) +// +(* ****** ****** *) +// +implement +Yoneda_phi_nat + (ftor) = lam(fx) => lam (m) => ftor(m)(fx) +// +implement +Yoneda_psi_nat (ftor) = lam(mf) => mf(lam x => x) +// +(* ****** ****** *) + +*) + +(* ****** ****** *) + +datatype bool = True | False // boxed boolean + +(* ****** ****** *) +// +fun bool2string + (x:bool): string = +( + case+ x of True() => "True" | False() => "False" +) +// +implement +fprint_val (out, x) = fprint (out, bool2string(x)) +// +(* ****** ****** *) +// +val myboolist0 = + $list_t{bool}(True, False, True, False, False) +val myboolist0 = g0ofg1_list (myboolist0) +// +(* ****** ****** *) +// +extern +val Yoneda_bool_list0 : {r:type} (bool ->> r) ->> list0(r) +// +implement +Yoneda_bool_list0 = + Yoneda_phi(functor_list0){bool}(myboolist0) +// +(* ****** ****** *) +// +val myboolist1 = + Yoneda_psi(functor_list0){bool}(Yoneda_bool_list0) +// +(* ****** ****** *) + +val () = fprintln! (stdout_ref, "myboolist0 = ", myboolist0) +val () = fprintln! (stdout_ref, "myboolist1 = ", myboolist1) + +(* ****** ****** *) + +implement main0 () = () + +(* ****** ****** *) + +(* end of [YonedaLemma.dats] *) diff --git a/samples/ATS/linset.hats b/samples/ATS/linset.hats new file mode 100644 index 00000000..29e44c44 --- /dev/null +++ b/samples/ATS/linset.hats @@ -0,0 +1,187 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS 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 ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) + +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: December, 2012 *) + +(* ****** ****** *) +// +// HX: shared by linset_listord (* ordered list *) +// HX: shared by linset_avltree (* AVL-tree-based *) +// +(* ****** ****** *) +// +// HX-2013-02: +// for sets of nonlinear elements +// +absvtype set_vtype (a:t@ype+) = ptr +// +(* ****** ****** *) + +vtypedef set (a:t0p) = set_vtype (a) + +(* ****** ****** *) + +fun{a:t0p} +compare_elt_elt (x1: a, x2: a):<> int + +(* ****** ****** *) + +fun{} linset_nil{a:t0p} ():<> set(a) +fun{} linset_make_nil{a:t0p} ():<> set(a) + +(* ****** ****** *) + +fun{a:t0p} linset_sing (x: a): set(a) +fun{a:t0p} linset_make_sing (x: a): set(a) + +(* ****** ****** *) + +fun{a:t0p} +linset_make_list (xs: List(INV(a))): set(a) + +(* ****** ****** *) + +fun{} +linset_is_nil {a:t0p} (xs: !set(INV(a))):<> bool +fun{} +linset_isnot_nil {a:t0p} (xs: !set(INV(a))):<> bool + +(* ****** ****** *) + +fun{a:t0p} linset_size (!set(INV(a))): size_t + +(* ****** ****** *) + +fun{a:t0p} +linset_is_member (xs: !set(INV(a)), x0: a):<> bool +fun{a:t0p} +linset_isnot_member (xs: !set(INV(a)), x0: a):<> bool + +(* ****** ****** *) + +fun{a:t0p} +linset_copy (!set(INV(a))): set(a) +fun{a:t0p} +linset_free (xs: set(INV(a))): void + +(* ****** ****** *) +// +fun{a:t0p} +linset_insert + (xs: &set(INV(a)) >> _, x0: a): bool +// +(* ****** ****** *) +// +fun{a:t0p} +linset_takeout +( + &set(INV(a)) >> _, a, res: &(a?) >> opt(a, b) +) : #[b:bool] bool(b) // endfun +fun{a:t0p} +linset_takeout_opt (&set(INV(a)) >> _, a): Option_vt(a) +// +(* ****** ****** *) +// +fun{a:t0p} +linset_remove + (xs: &set(INV(a)) >> _, x0: a): bool +// +(* ****** ****** *) +// +// HX: choosing an element in an unspecified manner +// +fun{a:t0p} +linset_choose +( + xs: !set(INV(a)), x: &a? >> opt (a, b) +) : #[b:bool] bool(b) +// +fun{a:t0p} +linset_choose_opt (xs: !set(INV(a))): Option_vt(a) +// +(* ****** ****** *) + +fun{a:t0p} +linset_takeoutmax +( + xs: &set(INV(a)) >> _, res: &a? >> opt(a, b) +) : #[b:bool] bool (b) +fun{a:t0p} +linset_takeoutmax_opt (xs: &set(INV(a)) >> _): Option_vt(a) + +(* ****** ****** *) + +fun{a:t0p} +linset_takeoutmin +( + xs: &set(INV(a)) >> _, res: &a? >> opt(a, b) +) : #[b:bool] bool (b) +fun{a:t0p} +linset_takeoutmin_opt (xs: &set(INV(a)) >> _): Option_vt(a) + +(* ****** ****** *) +// +fun{} +fprint_linset$sep (FILEref): void // ", " +// +fun{a:t0p} +fprint_linset (out: FILEref, xs: !set(INV(a))): void +// +overload fprint with fprint_linset +// +(* ****** ****** *) +// +fun{ +a:t0p}{env:vt0p +} linset_foreach$fwork + (x: a, env: &(env) >> _): void +// +fun{a:t0p} +linset_foreach (set: !set(INV(a))): void +fun{ +a:t0p}{env:vt0p +} linset_foreach_env + (set: !set(INV(a)), env: &(env) >> _): void +// end of [linset_foreach_env] +// +(* ****** ****** *) + +fun{a:t0p} +linset_listize (xs: set(INV(a))): List0_vt (a) + +(* ****** ****** *) + +fun{a:t0p} +linset_listize1 (xs: !set(INV(a))): List0_vt (a) + +(* ****** ****** *) + +(* end of [linset.hats] *) diff --git a/samples/ATS/linset_listord.dats b/samples/ATS/linset_listord.dats new file mode 100644 index 00000000..eb7dd642 --- /dev/null +++ b/samples/ATS/linset_listord.dats @@ -0,0 +1,504 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS 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 ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) + +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: February, 2013 *) + +(* ****** ****** *) +// +// HX-2013-08: +// a set is represented as a sorted list in descending order; +// note that descending order is chosen to faciliate set comparison +// +(* ****** ****** *) + +staload +UN = "prelude/SATS/unsafe.sats" + +(* ****** ****** *) + +staload "libats/SATS/linset_listord.sats" + +(* ****** ****** *) + +#include "./SHARE/linset.hats" // code reuse +#include "./SHARE/linset_node.hats" // code reuse + +(* ****** ****** *) + +assume +set_vtype (elt:t@ype) = List0_vt (elt) + +(* ****** ****** *) + +implement{} +linset_nil () = list_vt_nil () +implement{} +linset_make_nil () = list_vt_nil () + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_sing + (x) = list_vt_cons{a}(x, list_vt_nil) +// end of [linset_sing] +implement{a} +linset_make_sing + (x) = list_vt_cons{a}(x, list_vt_nil) +// end of [linset_make_sing] + +(* ****** ****** *) + +implement{} +linset_is_nil (xs) = list_vt_is_nil (xs) +implement{} +linset_isnot_nil (xs) = list_vt_is_cons (xs) + +(* ****** ****** *) + +implement{a} +linset_size (xs) = + let val n = list_vt_length(xs) in i2sz(n) end +// end of [linset_size] + +(* ****** ****** *) + +implement{a} +linset_is_member + (xs, x0) = let +// +fun aux + {n:nat} .. +( + xs: !list_vt (a, n) +) :<> bool = let +in +// +case+ xs of +| list_vt_cons (x, xs) => let + val sgn = compare_elt_elt (x0, x) in + if sgn > 0 then false else (if sgn < 0 then aux (xs) else true) + end // end of [list_vt_cons] +| list_vt_nil ((*void*)) => false +// +end // end of [aux] +// +in + aux (xs) +end // end of [linset_is_member] + +(* ****** ****** *) + +implement{a} +linset_copy (xs) = list_vt_copy (xs) +implement{a} +linset_free (xs) = list_vt_free (xs) + +(* ****** ****** *) + +implement{a} +linset_insert + (xs, x0) = let +// +fun +mynode_cons + {n:nat} .<>. +( + nx: mynode1 (a), xs: list_vt (a, n) +) : list_vt (a, n+1) = let +// +val xs1 = +$UN.castvwtp0{List1_vt(a)}(nx) +val+@list_vt_cons (_, xs2) = xs1 +prval () = $UN.cast2void (xs2); val () = (xs2 := xs) +// +in + fold@ (xs1); xs1 +end // end of [mynode_cons] +// +fun ins + {n:nat} .. // tail-recursive +( + xs: &list_vt (a, n) >> list_vt (a, n1) +) : #[n1:nat | n <= n1; n1 <= n+1] bool = +( +case+ xs of +| @list_vt_cons + (x, xs1) => let + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + val nx = mynode_make_elt (x0) + val ((*void*)) = xs := mynode_cons (nx, xs) + in + false + end else if sgn < 0 then let + val ans = ins (xs1) + prval () = fold@ (xs) + in + ans + end else let // [x0] is found + prval () = fold@ (xs) + in + true (* [x0] in [xs] *) + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => let + val nx = mynode_make_elt (x0) + val ((*void*)) = xs := mynode_cons (nx, xs) + in + false + end // end of [list_vt_nil] +) (* end of [ins] *) +// +in + $effmask_all (ins (xs)) +end // end of [linset_insert] + +(* ****** ****** *) + +(* +// +HX-2013-08: +[linset_remove] moved up +// +implement{a} +linset_remove + (xs, x0) = let +// +fun rem + {n:nat} .. // tail-recursive +( + xs: &list_vt (a, n) >> list_vt (a, n1) +) : #[n1:nat | n1 <= n; n <= n1+1] bool = +( +case+ xs of +| @list_vt_cons + (x, xs1) => let + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + in + false + end else if sgn < 0 then let + val ans = rem (xs1) + prval () = fold@ (xs) + in + ans + end else let // x0 = x + val xs1_ = xs1 + val ((*void*)) = free@{a}{0}(xs) + val () = xs := xs1_ + in + true // [x0] in [xs] + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => false +) (* end of [rem] *) +// +in + $effmask_all (rem (xs)) +end // end of [linset_remove] +*) + +(* ****** ****** *) +(* +** By Brandon Barker +*) +implement +{a}(*tmp*) +linset_choose + (xs, x0) = let +in +// +case+ xs of +| list_vt_cons + (x, xs1) => let + val () = x0 := x + prval () = opt_some{a}(x0) + in + true + end // end of [list_vt_cons] +| list_vt_nil () => let + prval () = opt_none{a}(x0) + in + false + end // end of [list_vt_nil] +// +end // end of [linset_choose] + +(* ****** ****** *) + +implement +{a}{env} +linset_foreach_env (xs, env) = let +// +implement +list_vt_foreach$fwork + (x, env) = linset_foreach$fwork (x, env) +// +in + list_vt_foreach_env (xs, env) +end // end of [linset_foreach_env] + +(* ****** ****** *) + +implement{a} +linset_listize (xs) = xs + +(* ****** ****** *) + +implement{a} +linset_listize1 (xs) = list_vt_copy (xs) + +(* ****** ****** *) +// +// HX: functions for processing mynodes +// +(* ****** ****** *) + +implement{ +} mynode_null{a} () = + $UN.castvwtp0{mynode(a,null)}(the_null_ptr) +// end of [mynode_null] + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_make_elt + (x) = let +// +val nx = list_vt_cons{a}{0}(x, _ ) +// +in + $UN.castvwtp0{mynode1(a)}(nx) +end // end of [mynode_make_elt] + +(* ****** ****** *) + +implement{ +} mynode_free + {a}(nx) = () where { +val nx = + $UN.castvwtp0{List1_vt(a)}(nx) +// +val+~list_vt_cons (_, nx2) = nx +// +prval ((*void*)) = $UN.cast2void (nx2) +// +} (* end of [mynode_free] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_get_elt + (nx) = (x) where { +// +val nx1 = + $UN.castvwtp1{List1_vt(a)}(nx) +// +val+list_vt_cons (x, _) = nx1 +// +prval ((*void*)) = $UN.cast2void (nx1) +// +} (* end of [mynode_get_elt] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_set_elt + {l} (nx, x0) = +{ +// +val nx1 = + $UN.castvwtp1{List1_vt(a)}(nx) +// +val+@list_vt_cons (x, _) = nx1 +// +val () = x := x0 +// +prval () = fold@ (nx1) +prval () = $UN.cast2void (nx1) +// +prval () = __assert (nx) where +{ + extern praxi __assert (nx: !mynode(a?, l) >> mynode (a, l)): void +} (* end of [prval] *) +// +} (* end of [mynode_set_elt] *) + +(* ****** ****** *) + +implement +{a}(*tmp*) +mynode_getfree_elt + (nx) = (x) where { +// +val nx = + $UN.castvwtp0{List1_vt(a)}(nx) +// +val+~list_vt_cons (x, nx2) = nx +// +prval ((*void*)) = $UN.cast2void (nx2) +// +} (* end of [mynode_getfree_elt] *) + +(* ****** ****** *) + +(* +fun{a:t0p} +linset_takeout_ngc + (set: &set(INV(a)) >> _, x0: a): mynode0 (a) +// end of [linset_takeout_ngc] +*) +implement +{a}(*tmp*) +linset_takeout_ngc + (set, x0) = let +// +fun takeout +( + xs: &List0_vt (a) >> _ +) : mynode0(a) = let +in +// +case+ xs of +| @list_vt_cons + (x, xs1) => let + prval pf_x = view@x + prval pf_xs1 = view@xs1 + val sgn = + compare_elt_elt (x0, x) + // end of [val] + in + if sgn > 0 then let + prval () = fold@ (xs) + in + mynode_null{a}((*void*)) + end else if sgn < 0 then let + val res = takeout (xs1) + prval ((*void*)) = fold@ (xs) + in + res + end else let // x0 = x + val xs1_ = xs1 + val res = $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs)) + val () = xs := xs1_ + in + res // [x0] in [xs] + end (* end of [if] *) + end // end of [list_vt_cons] +| list_vt_nil () => mynode_null{a}((*void*)) +// +end (* end of [takeout] *) +// +in + $effmask_all (takeout (set)) +end // end of [linset_takeout_ngc] + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_takeoutmax_ngc + (xs) = let +in +// +case+ xs of +| @list_vt_cons + (x, xs1) => let + prval pf_x = view@x + prval pf_xs1 = view@xs1 + val xs_ = xs + val () = xs := xs1 + in + $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs_)) + end // end of [list_vt_cons] +| @list_vt_nil () => let + prval () = fold@ (xs) + in + mynode_null{a}((*void*)) + end // end of [list_vt_nil] +// +end // end of [linset_takeoutmax_ngc] + +(* ****** ****** *) + +implement +{a}(*tmp*) +linset_takeoutmin_ngc + (xs) = let +// +fun unsnoc + {n:pos} .. +( + xs: &list_vt (a, n) >> list_vt (a, n-1) +) : mynode1 (a) = let +// +val+@list_vt_cons (x, xs1) = xs +// +prval pf_x = view@x and pf_xs1 = view@xs1 +// +in +// +case+ xs1 of +| list_vt_cons _ => + let val res = unsnoc(xs1) in fold@xs; res end + // end of [list_vt_cons] +| list_vt_nil () => let + val xs_ = xs + val () = xs := list_vt_nil{a}() + in + $UN.castvwtp0{mynode1(a)}((pf_x, pf_xs1 | xs_)) + end // end of [list_vt_nil] +// +end // end of [unsnoc] +// +in +// +case+ xs of +| list_vt_cons _ => unsnoc (xs) +| list_vt_nil () => mynode_null{a}((*void*)) +// +end // end of [linset_takeoutmin_ngc] + +(* ****** ****** *) + +(* end of [linset_listord.dats] *) diff --git a/samples/ATS/linset_listord.sats b/samples/ATS/linset_listord.sats new file mode 100644 index 00000000..468a534f --- /dev/null +++ b/samples/ATS/linset_listord.sats @@ -0,0 +1,51 @@ +(***********************************************************************) +(* *) +(* Applied Type System *) +(* *) +(***********************************************************************) + +(* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-2013 Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS 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 ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*) + +(* ****** ****** *) +// +// Author: Hongwei Xi +// Authoremail: hwxiATcsDOTbuDOTedu +// Time: October, 2010 +// +(* ****** ****** *) + +#define ATS_PACKNAME "ATSLIB.libats.linset_listord" +#define ATS_STALOADFLAG 0 // no static loading at run-time + +(* ****** ****** *) + +#include "./SHARE/linset.hats" +#include "./SHARE/linset_node.hats" + +(* ****** ****** *) + +castfn +linset2list {a:t0p} (xs: set (INV(a))):<> List0_vt (a) + +(* ****** ****** *) + +(* end of [linset_listord.sats] *) diff --git a/samples/ATS/main.atxt b/samples/ATS/main.atxt new file mode 100644 index 00000000..3bba35f0 --- /dev/null +++ b/samples/ATS/main.atxt @@ -0,0 +1,215 @@ +%{ +#include "./../ATEXT/atextfun.hats" +%} + + + + + + +EFFECTIVATS-DiningPhil2 +#patscode_style() + + + + +

+Effective ATS: Dining Philosophers +

+ +In this article, I present an implementation of a slight variant of the +famous problem of 5-Dining-Philosophers by Dijkstra that makes simple but +convincing use of linear types. + +

+The Original Problem +

+ +There are five philosophers sitting around a table and there are also 5 +forks placed on the table such that each fork is located between the left +hand of a philosopher and the right hand of another philosopher. Each +philosopher does the following routine repeatedly: thinking and dining. In +order to dine, a philosopher needs to first acquire two forks: one located +on his left-hand side and the other on his right-hand side. After +finishing dining, a philosopher puts the two acquired forks onto the table: +one on his left-hand side and the other on his right-hand side. + +

+A Variant of the Original Problem +

+ +The following twist is added to the original version: + +

+ +After a fork is used, it becomes a "dirty" fork and needs to be put in a +tray for dirty forks. There is a cleaner who cleans dirty forks and then +puts them back on the table. + +

+Channels for Communication +

+ +A channel is just a shared queue of fixed capacity. The following two +functions are for inserting an element into and taking an element out of a +given channel: + +
+#pats2xhtml_sats("\
+fun{a:vt0p} channel_insert (channel (a), a): void
+fun{a:vt0p} channel_takeout (chan: channel (a)): (a) 
+")
+ +If [channel_insert] is called on a channel that is full, then the caller is +blocked until an element is taken out of the channel. If [channel_takeout] +is called on a channel that is empty, then the caller is blocked until an +element is inserted into the channel. + +

+A Channel for Each Fork +

+ +Forks are resources given a linear type. Each fork is initially stored in a +channel, which can be obtained by calling the following function: + +
+#pats2xhtml_sats("\
+fun fork_changet (n: nphil): channel(fork)
+")
+ +where the type [nphil] is defined to be [natLt(5)] (for natural numbers +less than 5). The channels for storing forks are chosen to be of capacity +2. The reason that channels of capacity 2 are chosen to store at most one +element (in each of them) is to guarantee that these channels can never be +full (so that there is no attempt made to send signals to awake callers +supposedly being blocked due to channels being full). + + +

+A Channel for the Fork Tray +

+ +A tray for storing "dirty" forks is also a channel, which can be obtained +by calling the following function: + +
+#pats2xhtml_sats("\
+fun forktray_changet ((*void*)): channel(fork)
+")
+ +The capacity chosen for the channel is 6 (instead of 5) so that it can +never become full (as there are only 5 forks in total). + +

+Philosopher Loop +

+ +Each philosopher is implemented as a loop: + +
+#pats2xhtml_dats('\
+implement
+phil_loop (n) = let
+//
+val () = phil_think (n)
+//
+val nl = phil_left (n) // = n
+val nr = phil_right (n) // = (n+1) % 5
+//
+val ch_lfork = fork_changet (nl)
+val ch_rfork = fork_changet (nr)
+//
+val lf = channel_takeout (ch_lfork)
+val () = println! ("phil_loop(", n, ") picks left fork")
+//
+val () = randsleep (2) // sleep up to 2 seconds
+//
+val rf = channel_takeout (ch_rfork)
+val () = println! ("phil_loop(", n, ") picks right fork")
+//
+val () = phil_dine (n, lf, rf)
+//
+val ch_forktray = forktray_changet ()
+val () = channel_insert (ch_forktray, lf) // left fork to dirty tray
+val () = channel_insert (ch_forktray, rf) // right fork to dirty tray
+//
+in
+  phil_loop (n)
+end // end of [phil_loop]
+')
+ +It should be straighforward to follow the code for [phil_loop]. + +

+Fork Cleaner Loop +

+ +A cleaner is implemented as a loop: + +
+#pats2xhtml_dats('\
+implement
+cleaner_loop () = let
+//
+val ch = forktray_changet ()
+val f0 = channel_takeout (ch) // [f0] is dirty
+//
+val () = cleaner_wash (f0) // washes dirty [f0]
+val () = cleaner_return (f0) // puts back cleaned [f0]
+//
+in
+  cleaner_loop ()
+end // end of [cleaner_loop]
+')
+ +The function [cleaner_return] first finds out the number of a given fork +and then uses the number to locate the channel for storing the fork. Its +actual implementation is given as follows: + +
+#pats2xhtml_dats('\
+implement
+cleaner_return (f) =
+{
+  val n = fork_get_num (f)
+  val ch = fork_changet (n)
+  val () = channel_insert (ch, f)
+}
+')
+ +It should now be straighforward to follow the code for [cleaner_loop]. + +

+Testing +

+ +The entire code of this implementation is stored in the following files: + +
+DiningPhil2.sats
+DiningPhil2.dats
+DiningPhil2_fork.dats
+DiningPhil2_thread.dats
+
+ +There is also a Makefile available for compiling the ATS source code into +an excutable for testing. One should be able to encounter a deadlock after +running the simulation for a while. + +
+ +This article is written by
Hongwei Xi. + + + + +%{ +implement main () = fprint_filsub (stdout_ref, "main_atxt.txt") +%} diff --git a/samples/Agda/NatCat.agda b/samples/Agda/NatCat.agda new file mode 100644 index 00000000..6169a085 --- /dev/null +++ b/samples/Agda/NatCat.agda @@ -0,0 +1,39 @@ +module NatCat where + +open import Relation.Binary.PropositionalEquality + +-- If you can show that a relation only ever has one inhabitant +-- you get the category laws for free +module + EasyCategory + (obj : Set) + (_⟶_ : obj → obj → Set) + (_∘_ : ∀ {x y z} → x ⟶ y → y ⟶ z → x ⟶ z) + (id : ∀ x → x ⟶ x) + (single-inhabitant : (x y : obj) (r s : x ⟶ y) → r ≡ s) + where + + idʳ : ∀ x y (r : x ⟶ y) → r ∘ id y ≡ r + idʳ x y r = single-inhabitant x y (r ∘ id y) r + + idˡ : ∀ x y (r : x ⟶ y) → id x ∘ r ≡ r + idˡ x y r = single-inhabitant x y (id x ∘ r) r + + ∘-assoc : ∀ w x y z (r : w ⟶ x) (s : x ⟶ y) (t : y ⟶ z) → (r ∘ s) ∘ t ≡ r ∘ (s ∘ t) + ∘-assoc w x y z r s t = single-inhabitant w z ((r ∘ s) ∘ t) (r ∘ (s ∘ t)) + +open import Data.Nat + +same : (x y : ℕ) (r s : x ≤ y) → r ≡ s +same .0 y z≤n z≤n = refl +same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s) + +≤-trans : ∀ x y z → x ≤ y → y ≤ z → x ≤ z +≤-trans .0 y z z≤n s = z≤n +≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s) + +≤-refl : ∀ x → x ≤ x +≤-refl zero = z≤n +≤-refl (suc x) = s≤s (≤-refl x) + +module Nat-EasyCategory = EasyCategory ℕ _≤_ (λ {x}{y}{z} → ≤-trans x y z) ≤-refl same diff --git a/samples/AsciiDoc/encoding.asciidoc b/samples/AsciiDoc/encoding.asciidoc new file mode 100644 index 00000000..8cf1b761 --- /dev/null +++ b/samples/AsciiDoc/encoding.asciidoc @@ -0,0 +1,13 @@ +Gregory Romé has written an AsciiDoc plugin for the Redmine project management application. + +https://github.com/foo-users/foo +へと `vicmd` キーマップを足してみている試み、 +アニメーションgifです。 + +tag::romé[] +Gregory Romé has written an AsciiDoc plugin for the Redmine project management application. +end::romé[] + +== Überschrift + +* Codierungen sind verrückt auf älteren Versionen von Ruby \ No newline at end of file diff --git a/samples/AsciiDoc/list.asc b/samples/AsciiDoc/list.asc new file mode 100644 index 00000000..066d14fc --- /dev/null +++ b/samples/AsciiDoc/list.asc @@ -0,0 +1,10 @@ +AsciiDoc Home Page +================== + +Example Articles +~~~~~~~~~~~~~~~~ +- Item 1 + +- Item 2 + +- Item 3 diff --git a/samples/AsciiDoc/sample.adoc b/samples/AsciiDoc/sample.adoc new file mode 100644 index 00000000..51e1e45e --- /dev/null +++ b/samples/AsciiDoc/sample.adoc @@ -0,0 +1,25 @@ +Document Title +============== +Doc Writer +:idprefix: id_ + +Preamble paragraph. + +NOTE: This is test, only a test. + +== Section A + +*Section A* paragraph. + +=== Section A Subsection + +*Section A* 'subsection' paragraph. + +== Section B + +*Section B* paragraph. + +.Section B list +* Item 1 +* Item 2 +* Item 3 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/BlitzBasic/HalfAndDouble.bb b/samples/BlitzBasic/HalfAndDouble.bb new file mode 100644 index 00000000..6b8aa0d3 --- /dev/null +++ b/samples/BlitzBasic/HalfAndDouble.bb @@ -0,0 +1,147 @@ + +Local bk = CreateBank(8) +PokeFloat bk, 0, -1 +Print Bin(PeekInt(bk, 0)) +Print %1000000000000000 +Print Bin(1 Shl 31) +Print $1f +Print $ff +Print $1f + (127 - 15) +Print Hex(%01111111100000000000000000000000) +Print Hex(~%11111111100000000000000000000000) + +Print Bin(FloatToHalf(-2.5)) +Print HalfToFloat(FloatToHalf(-200000000000.0)) + +Print Bin(FToI(-2.5)) + +WaitKey +End + + +; Half-precision (16-bit) arithmetic library +;============================================ + +Global Half_CBank_ + +Function FToI(f#) + If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4) + PokeFloat Half_CBank_, 0, f + Return PeekInt(Half_CBank_, 0) +End Function + +Function HalfToFloat#(h) + Local signBit, exponent, fraction, fBits + + signBit = (h And 32768) <> 0 + exponent = (h And %0111110000000000) Shr 10 + fraction = (h And %0000001111111111) + + If exponent = $1F Then exponent = $FF : ElseIf exponent Then exponent = (exponent - 15) + 127 + fBits = (signBit Shl 31) Or (exponent Shl 23) Or (fraction Shl 13) + + If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4) + PokeInt Half_CBank_, 0, fBits + Return PeekFloat(Half_CBank_, 0) +End Function + +Function FloatToHalf(f#) + Local signBit, exponent, fraction, fBits + + If Half_CBank_ = 0 Then Half_CBank_ = CreateBank(4) + PokeFloat Half_CBank_, 0, f + fBits = PeekInt(Half_CBank_, 0) + + signBit = (fBits And (1 Shl 31)) <> 0 + exponent = (fBits And $7F800000) Shr 23 + fraction = fBits And $007FFFFF + + If exponent + exponent = exponent - 127 + If Abs(exponent) > $1F + If exponent <> ($FF - 127) Then fraction = 0 + exponent = $1F * Sgn(exponent) + Else + exponent = exponent + 15 + EndIf + exponent = exponent And %11111 + EndIf + fraction = fraction Shr 13 + + Return (signBit Shl 15) Or (exponent Shl 10) Or fraction +End Function + +Function HalfAdd(l, r) + +End Function + +Function HalfSub(l, r) + +End Function + +Function HalfMul(l, r) + +End Function + +Function HalfDiv(l, r) + +End Function + +Function HalfLT(l, r) + +End Function + +Function HalfGT(l, r) + +End Function + + +; Double-precision (64-bit) arithmetic library) +;=============================================== + +Global DoubleOut[1], Double_CBank_ + +Function DoubleToFloat#(d[1]) + +End Function + +Function FloatToDouble(f#) + +End Function + +Function IntToDouble(i) + +End Function + +Function SefToDouble(s, e, f) + +End Function + +Function DoubleAdd(l, r) + +End Function + +Function DoubleSub(l, r) + +End Function + +Function DoubleMul(l, r) + +End Function + +Function DoubleDiv(l, r) + +End Function + +Function DoubleLT(l, r) + +End Function + +Function DoubleGT(l, r) + +End Function + + +;~IDEal Editor Parameters: +;~F#1A#20#2F +;~C#Blitz3D \ No newline at end of file diff --git a/samples/BlitzBasic/LList.bb b/samples/BlitzBasic/LList.bb new file mode 100644 index 00000000..49bf4eaa --- /dev/null +++ b/samples/BlitzBasic/LList.bb @@ -0,0 +1,369 @@ + +; Double-linked list container class +;==================================== + +; with thanks to MusicianKool, for concept and issue fixes + + +Type LList + Field head_.ListNode + Field tail_.ListNode +End Type + +Type ListNode + Field pv_.ListNode + Field nx_.ListNode + Field Value +End Type + +Type Iterator + Field Value + Field l_.LList + Field cn_.ListNode, cni_ +End Type + + +;Create a new LList object +Function CreateList.LList() + Local l.LList = New LList + + l\head_ = New ListNode + l\tail_ = New ListNode + + l\head_\nx_ = l\tail_ ;End caps + l\head_\pv_ = l\head_ ;These make it more or less safe to iterate freely + l\head_\Value = 0 + + l\tail_\nx_ = l\tail_ + l\tail_\pv_ = l\head_ + l\tail_\Value = 0 + + Return l +End Function + +;Free a list and all elements (not any values) +Function FreeList(l.LList) + ClearList l + Delete l\head_ + Delete l\tail_ + Delete l +End Function + +;Remove all the elements from a list (does not free values) +Function ClearList(l.LList) + Local n.ListNode = l\head_\nx_ + While n <> l\tail_ + Local nx.ListNode = n\nx_ + Delete n + n = nx + Wend + l\head_\nx_ = l\tail_ + l\tail_\pv_ = l\head_ +End Function + +;Count the number of elements in a list (slow) +Function ListLength(l.LList) + Local i.Iterator = GetIterator(l), elems + While EachIn(i) + elems = elems + 1 + Wend + Return elems +End Function + +;Return True if a list contains a given value +Function ListContains(l.LList, Value) + Return (ListFindNode(l, Value) <> Null) +End Function + +;Create a linked list from the intvalues in a bank (slow) +Function ListFromBank.LList(bank) + Local l.LList = CreateList() + Local size = BankSize(bank), p + + For p = 0 To size - 4 Step 4 + ListAddLast l, PeekInt(bank, p) + Next + + Return l +End Function + +;Create a bank containing all the values in a list (slow) +Function ListToBank(l.LList) + Local size = ListLength(l) * 4 + Local bank = CreateBank(size) + + Local i.Iterator = GetIterator(l), p = 0 + While EachIn(i) + PokeInt bank, p, i\Value + p = p + 4 + Wend + + Return bank +End Function + +;Swap the contents of two list objects +Function SwapLists(l1.LList, l2.LList) + Local tempH.ListNode = l1\head_, tempT.ListNode = l1\tail_ + l1\head_ = l2\head_ + l1\tail_ = l2\tail_ + l2\head_ = tempH + l2\tail_ = tempT +End Function + +;Create a new list containing the same values as the first +Function CopyList.LList(lo.LList) + Local ln.LList = CreateList() + Local i.Iterator = GetIterator(lo) : While EachIn(i) + ListAddLast ln, i\Value + Wend + Return ln +End Function + +;Reverse the order of elements of a list +Function ReverseList(l.LList) + Local n1.ListNode, n2.ListNode, tmp.ListNode + + n1 = l\head_ + n2 = l\head_\nx_ + + While n1 <> l\tail_ + n1\pv_ = n2 + tmp = n2\nx_ + n2\nx_ = n1 + n1 = n2 + n2 = tmp + Wend + + tmp = l\head_ + l\head_ = l\tail_ + l\tail_ = tmp + + l\head_\pv_ = l\head_ + l\tail_\nx_ = l\tail_ +End Function + +;Search a list to retrieve the first node with the given value +Function ListFindNode.ListNode(l.LList, Value) + Local n.ListNode = l\head_\nx_ + + While n <> l\tail_ + If n\Value = Value Then Return n + n = n\nx_ + Wend + + Return Null +End Function + +;Append a value to the end of a list (fast) and return the node +Function ListAddLast.ListNode(l.LList, Value) + Local n.ListNode = New ListNode + + n\pv_ = l\tail_\pv_ + n\nx_ = l\tail_ + n\Value = Value + + l\tail_\pv_ = n + n\pv_\nx_ = n + + Return n +End Function + +;Attach a value to the start of a list (fast) and return the node +Function ListAddFirst.ListNode(l.LList, Value) + Local n.ListNode = New ListNode + + n\pv_ = l\head_ + n\nx_ = l\head_\nx_ + n\Value = Value + + l\head_\nx_ = n + n\nx_\pv_ = n + + Return n +End Function + +;Remove the first occurence of the given value from a list +Function ListRemove(l.LList, Value) + Local n.ListNode = ListFindNode(l, Value) + If n <> Null Then RemoveListNode n +End Function + +;Remove a node from a list +Function RemoveListNode(n.ListNode) + n\pv_\nx_ = n\nx_ + n\nx_\pv_ = n\pv_ + Delete n +End Function + +;Return the value of the element at the given position from the start of the list, +;or backwards from the end of the list for a negative index +Function ValueAtIndex(l.LList, index) + Local n.ListNode = ListNodeAtIndex(l, index) + If n <> Null Then Return n\Value : Else Return 0 +End Function + +;Return the ListNode at the given position from the start of the list, or backwards +;from the end of the list for a negative index, or Null if invalid +Function ListNodeAtIndex.ListNode(l.LList, index) + Local e, n.ListNode + + If index >= 0 + n = l\head_ + For e = 0 To index + n = n\nx_ + Next + If n = l\tail_ Then n = Null ;Beyond the end of the list - not valid + + Else ;Negative index - count backward + n = l\tail_ + For e = 0 To index Step -1 + n = n\pv_ + Next + If n = l\head_ Then n = Null ;Before the start of the list - not valid + + EndIf + + Return n +End Function + +;Replace a value at the given position (added by MusicianKool) +Function ReplaceValueAtIndex(l.LList,index,value) + Local n.ListNode = ListNodeAtIndex(l,index) + If n <> Null Then n\Value = value:Else Return 0 +End Function + +;Remove and return a value at the given position (added by MusicianKool) +Function RemoveNodeAtIndex(l.LList,index) + Local n.ListNode = ListNodeAtIndex(l,index),tval + If n <> Null Then tval = n\Value:RemoveListNode(n):Return tval:Else Return 0 +End Function + +;Retrieve the first value from a list +Function ListFirst(l.LList) + If l\head_\nx_ <> l\tail_ Then Return l\head_\nx_\Value +End Function + +;Retrieve the last value from a list +Function ListLast(l.LList) + If l\tail_\pv_ <> l\head_ Then Return l\tail_\pv_\Value +End Function + +;Remove the first element from a list, and return its value +Function ListRemoveFirst(l.LList) + Local val + If l\head_\nx_ <> l\tail_ + val = l\head_\nx_\Value + RemoveListNode l\head_\nx_ + EndIf + Return val +End Function + +;Remove the last element from a list, and return its value +Function ListRemoveLast(l.LList) + Local val + If l\tail_\pv_ <> l\head_ + val = l\tail_\pv_\Value + RemoveListNode l\tail_\pv_ + EndIf + Return val +End Function + +;Insert a value into a list before the specified node, and return the new node +Function InsertBeforeNode.ListNode(Value, n.ListNode) + Local bef.ListNode = New ListNode + + bef\pv_ = n\pv_ + bef\nx_ = n + bef\Value = Value + + n\pv_ = bef + bef\pv_\nx_ = bef + + Return bef +End Function + +;Insert a value into a list after the specified node, and return then new node +Function InsertAfterNode.ListNode(Value, n.ListNode) + Local aft.ListNode = New ListNode + + aft\nx_ = n\nx_ + aft\pv_ = n + aft\Value = Value + + n\nx_ = aft + aft\nx_\pv_ = aft + + Return aft +End Function + +;Get an iterator object to use with a loop +;This function means that most programs won't have to think about deleting iterators manually +;(in general only a small, constant number will be created) +Function GetIterator.Iterator(l.LList) + Local i.Iterator + + If l = Null Then RuntimeError "Cannot create Iterator for Null" + + For i = Each Iterator ;See if there's an available iterator at the moment + If i\l_ = Null Then Exit + Next + + If i = Null Then i = New Iterator ;If there wasn't, create one + + i\l_ = l + i\cn_ = l\head_ + i\cni_ = -1 + i\Value = 0 ;No especial reason why this has to be anything, but meh + + Return i +End Function + +;Use as the argument to While to iterate over the members of a list +Function EachIn(i.Iterator) + + i\cn_ = i\cn_\nx_ + + If i\cn_ <> i\l_\tail_ ;Still items in the list + i\Value = i\cn_\Value + i\cni_ = i\cni_ + 1 + Return True + + Else + i\l_ = Null ;Disconnect from the list, having reached the end + i\cn_ = Null + i\cni_ = -1 + Return False + + EndIf +End Function + +;Remove from the containing list the element currently pointed to by an iterator +Function IteratorRemove(i.Iterator) + If (i\cn_ <> i\l_\head_) And (i\cn_ <> i\l_\tail_) + Local temp.ListNode = i\cn_ + + i\cn_ = i\cn_\pv_ + i\cni_ = i\cni_ - 1 + i\Value = 0 + + RemoveListNode temp + + Return True + Else + Return False + EndIf +End Function + +;Call this before breaking out of an EachIn loop, to disconnect the iterator from the list +Function IteratorBreak(i.Iterator) + i\l_ = Null + i\cn_ = Null + i\cni_ = -1 + i\Value = 0 +End Function + + +;~IDEal Editor Parameters: +;~F#5#A#10#18#2A#32#3E#47#4C#58#66#6F#78#8F#9B#A9#B7#BD#C5#CC +;~F#E3#E9#EF#F4#F9#103#10D#11B#12B#13F#152#163 +;~C#Blitz3D \ No newline at end of file diff --git a/samples/BlitzBasic/PObj.bb b/samples/BlitzBasic/PObj.bb new file mode 100644 index 00000000..2989f98e --- /dev/null +++ b/samples/BlitzBasic/PObj.bb @@ -0,0 +1,66 @@ + +Local i, start, result + +Local s.Sum3Obj = New Sum3Obj + +For i = 1 To 100000 + s = New Sum3Obj + result = Handle Before s + Delete s +Next + +start = MilliSecs() +For i = 1 To 1000000 + result = Sum3_(MakeSum3Obj(i, i, i)) +Next +start = MilliSecs() - start +Print start + +start = MilliSecs() +For i = 1 To 1000000 + result = Sum3(i, i, i) +Next +start = MilliSecs() - start +Print start + +WaitKey +End + + +Function Sum3(a, b, c) + Return a + b + c +End Function + + +Type Sum3Obj + Field isActive + Field a, b, c +End Type + +Function MakeSum3Obj(a, b, c) + Local s.Sum3Obj = Last Sum3Obj + If s\isActive Then s = New Sum3Obj + s\isActive = True + s\a = a + s\b = b + s\c = c + + Restore label + Read foo + + Return Handle(s) +End Function + +.label +Data (10 + 2), 12, 14 +: +Function Sum3_(a_) + Local a.Sum3Obj = Object.Sum3Obj a_ + Local return_ = a\a + a\b + a\c + Insert a Before First Sum3Obj :: a\isActive = False + Return return_ +End Function + + +;~IDEal Editor Parameters: +;~C#Blitz3D \ No newline at end of file diff --git a/samples/Bluespec/TL.bsv b/samples/Bluespec/TL.bsv new file mode 100644 index 00000000..2d6af5c1 --- /dev/null +++ b/samples/Bluespec/TL.bsv @@ -0,0 +1,167 @@ +package TL; + +interface TL; + method Action ped_button_push(); + + (* always_enabled *) + method Action set_car_state_N(Bool x); + (* always_enabled *) + method Action set_car_state_S(Bool x); + (* always_enabled *) + method Action set_car_state_E(Bool x); + (* always_enabled *) + method Action set_car_state_W(Bool x); + + method Bool lampRedNS(); + method Bool lampAmberNS(); + method Bool lampGreenNS(); + + method Bool lampRedE(); + method Bool lampAmberE(); + method Bool lampGreenE(); + + method Bool lampRedW(); + method Bool lampAmberW(); + method Bool lampGreenW(); + + method Bool lampRedPed(); + method Bool lampAmberPed(); + method Bool lampGreenPed(); +endinterface: TL + +typedef enum { + AllRed, + GreenNS, AmberNS, + GreenE, AmberE, + GreenW, AmberW, + GreenPed, AmberPed} TLstates deriving (Eq, Bits); + +typedef UInt#(5) Time32; +typedef UInt#(20) CtrSize; + +(* synthesize *) +module sysTL(TL); + Time32 allRedDelay = 2; + Time32 amberDelay = 4; + Time32 nsGreenDelay = 20; + Time32 ewGreenDelay = 10; + Time32 pedGreenDelay = 10; + Time32 pedAmberDelay = 6; + + CtrSize clocks_per_sec = 100; + + Reg#(TLstates) state <- mkReg(AllRed); + Reg#(TLstates) next_green <- mkReg(GreenNS); + Reg#(Time32) secs <- mkReg(0); + Reg#(Bool) ped_button_pushed <- mkReg(False); + Reg#(Bool) car_present_N <- mkReg(True); + Reg#(Bool) car_present_S <- mkReg(True); + Reg#(Bool) car_present_E <- mkReg(True); + Reg#(Bool) car_present_W <- mkReg(True); + Bool car_present_NS = car_present_N || car_present_S; + Reg#(CtrSize) cycle_ctr <- mkReg(0); + + rule dec_cycle_ctr (cycle_ctr != 0); + cycle_ctr <= cycle_ctr - 1; + endrule + + Rules low_priority_rule = (rules + rule inc_sec (cycle_ctr == 0); + secs <= secs + 1; + cycle_ctr <= clocks_per_sec; + endrule endrules); + + function Action next_state(TLstates ns); + action + state <= ns; + secs <= 0; + endaction + endfunction: next_state + + function TLstates green_seq(TLstates x); + case (x) + GreenNS: return (GreenE); + GreenE: return (GreenW); + GreenW: return (GreenNS); + endcase + endfunction + + function Bool car_present(TLstates x); + case (x) + GreenNS: return (car_present_NS); + GreenE: return (car_present_E); + GreenW: return (car_present_W); + endcase + endfunction + + function Rules make_from_green_rule(TLstates green_state, Time32 delay, Bool car_is_present, TLstates ns); + return (rules + rule from_green (state == green_state && (secs >= delay || !car_is_present)); + next_state(ns); + endrule endrules); + endfunction: make_from_green_rule + + function Rules make_from_amber_rule(TLstates amber_state, TLstates ng); + return (rules + rule from_amber (state == amber_state && secs >= amberDelay); + next_state(AllRed); + next_green <= ng; + endrule endrules); + endfunction: make_from_amber_rule + + Rules hprs[7]; + + hprs[1] = make_from_green_rule(GreenNS, nsGreenDelay, car_present_NS, AmberNS); + hprs[2] = make_from_amber_rule(AmberNS, GreenE); + hprs[3] = make_from_green_rule(GreenE, ewGreenDelay, car_present_E, AmberE); + hprs[4] = make_from_amber_rule(AmberE, GreenW); + hprs[5] = make_from_green_rule(GreenW, ewGreenDelay, car_present_W, AmberW); + hprs[6] = make_from_amber_rule(AmberW, GreenNS); + + hprs[0] = (rules + rule fromAllRed (state == AllRed && secs >= allRedDelay); + if (ped_button_pushed) action + ped_button_pushed <= False; + next_state(GreenPed); + endaction else if (car_present(next_green)) + next_state(next_green); + else if (car_present(green_seq(next_green))) + next_state(green_seq(next_green)); + else if (car_present(green_seq(green_seq(next_green)))) + next_state(green_seq(green_seq(next_green))); + else + noAction; + endrule: fromAllRed endrules); + + Rules high_priority_rules = hprs[0]; + for (Integer i = 1; i<7; i=i+1) + high_priority_rules = rJoin(hprs[i], high_priority_rules); + + addRules(preempts(high_priority_rules, low_priority_rule)); + + method Action ped_button_push(); + ped_button_pushed <= True; + endmethod: ped_button_push + + method Action set_car_state_N(b) ; car_present_N <= b; endmethod + method Action set_car_state_S(b) ; car_present_S <= b; endmethod + method Action set_car_state_E(b) ; car_present_E <= b; endmethod + method Action set_car_state_W(b) ; car_present_W <= b; endmethod + + method lampRedNS() = (!(state == GreenNS || state == AmberNS)); + method lampAmberNS() = (state == AmberNS); + method lampGreenNS() = (state == GreenNS); + method lampRedE() = (!(state == GreenE || state == AmberE)); + method lampAmberE() = (state == AmberE); + method lampGreenE() = (state == GreenE); + method lampRedW() = (!(state == GreenW || state == AmberW)); + method lampAmberW() = (state == AmberW); + method lampGreenW() = (state == GreenW); + + method lampRedPed() = (!(state == GreenPed || state == AmberPed)); + method lampAmberPed() = (state == AmberPed); + method lampGreenPed() = (state == GreenPed); + +endmodule: sysTL + +endpackage: TL diff --git a/samples/Bluespec/TbTL.bsv b/samples/Bluespec/TbTL.bsv new file mode 100644 index 00000000..d5dbabf0 --- /dev/null +++ b/samples/Bluespec/TbTL.bsv @@ -0,0 +1,109 @@ +package TbTL; + +import TL::*; + +interface Lamp; + method Bool changed; + method Action show_offs; + method Action show_ons; + method Action reset; +endinterface + +module mkLamp#(String name, Bool lamp)(Lamp); + Reg#(Bool) prev <- mkReg(False); + + method changed = (prev != lamp); + + method Action show_offs; + if (prev && !lamp) + $write (name + " off, "); + endmethod + + method Action show_ons; + if (!prev && lamp) + $write (name + " on, "); + endmethod + + method Action reset; + prev <= lamp; + endmethod +endmodule + + +(* synthesize *) +module mkTest(); + let dut <- sysTL; + + Reg#(Bit#(16)) ctr <- mkReg(0); + + Reg#(Bool) carN <- mkReg(False); + Reg#(Bool) carS <- mkReg(False); + Reg#(Bool) carE <- mkReg(False); + Reg#(Bool) carW <- mkReg(False); + + Lamp lamps[12]; + + lamps[0] <- mkLamp("0: NS red ", dut.lampRedNS); + lamps[1] <- mkLamp("1: NS amber", dut.lampAmberNS); + lamps[2] <- mkLamp("2: NS green", dut.lampGreenNS); + lamps[3] <- mkLamp("3: E red ", dut.lampRedE); + lamps[4] <- mkLamp("4: E amber", dut.lampAmberE); + lamps[5] <- mkLamp("5: E green", dut.lampGreenE); + lamps[6] <- mkLamp("6: W red ", dut.lampRedW); + lamps[7] <- mkLamp("7: W amber", dut.lampAmberW); + lamps[8] <- mkLamp("8: W green", dut.lampGreenW); + + lamps[9] <- mkLamp("9: Ped red ", dut.lampRedPed); + lamps[10] <- mkLamp("10: Ped amber", dut.lampAmberPed); + lamps[11] <- mkLamp("11: Ped green", dut.lampGreenPed); + + rule start (ctr == 0); + $dumpvars; + endrule + + rule detect_cars; + dut.set_car_state_N(carN); + dut.set_car_state_S(carS); + dut.set_car_state_E(carE); + dut.set_car_state_W(carW); + endrule + + rule go; + ctr <= ctr + 1; + if (ctr == 5000) carN <= True; + if (ctr == 6500) carN <= False; + if (ctr == 12_000) dut.ped_button_push; + endrule + + rule stop (ctr > 32768); + $display("TESTS FINISHED"); + $finish(0); + endrule + + function do_offs(l) = l.show_offs; + function do_ons(l) = l.show_ons; + function do_reset(l) = l.reset; + + function do_it(f); + action + for (Integer i=0; i<12; i=i+1) + f(lamps[i]); + endaction + endfunction + + function any_changes(); + Bool b = False; + for (Integer i=0; i<12; i=i+1) + b = b || lamps[i].changed; + return b; + endfunction + + rule show (any_changes()); + do_it(do_offs); + do_it(do_ons); + do_it(do_reset); + $display("(at time %d)", $time); + endrule +endmodule + +endpackage diff --git a/samples/Brightscript/SimpleGrid.brs b/samples/Brightscript/SimpleGrid.brs new file mode 100644 index 00000000..b205d69a --- /dev/null +++ b/samples/Brightscript/SimpleGrid.brs @@ -0,0 +1,305 @@ +' ********************************************************* +' ** Simple Grid Screen Demonstration App +' ** Jun 2010 +' ** Copyright (c) 2010 Roku Inc. All Rights Reserved. +' ********************************************************* + +'************************************************************ +'** Application startup +'************************************************************ +Sub Main() + + 'initialize theme attributes like titles, logos and overhang color + initTheme() + + gridstyle = "Flat-Movie" + + 'set to go, time to get started + while gridstyle <> "" + print "starting grid style= ";gridstyle + screen=preShowGridScreen(gridstyle) + gridstyle = showGridScreen(screen, gridstyle) + end while + +End Sub + + +'************************************************************* +'** Set the configurable theme attributes for the application +'** +'** Configure the custom overhang and Logo attributes +'** These attributes affect the branding of the application +'** and are artwork, colors and offsets specific to the app +'************************************************************* + +Sub initTheme() + app = CreateObject("roAppManager") + app.SetTheme(CreateDefaultTheme()) +End Sub + +'****************************************************** +'** @return The default application theme. +'** Screens can make slight adjustments to the default +'** theme by getting it from here and then overriding +'** individual theme attributes. +'****************************************************** +Function CreateDefaultTheme() as Object + theme = CreateObject("roAssociativeArray") + + theme.ThemeType = "generic-dark" + + ' All these are greyscales + theme.GridScreenBackgroundColor = "#363636" + theme.GridScreenMessageColor = "#808080" + theme.GridScreenRetrievingColor = "#CCCCCC" + theme.GridScreenListNameColor = "#FFFFFF" + + ' Color values work here + theme.GridScreenDescriptionTitleColor = "#001090" + theme.GridScreenDescriptionDateColor = "#FF005B" + theme.GridScreenDescriptionRuntimeColor = "#5B005B" + theme.GridScreenDescriptionSynopsisColor = "#606000" + + 'used in the Grid Screen + theme.CounterTextLeft = "#FF0000" + theme.CounterSeparator = "#00FF00" + theme.CounterTextRight = "#0000FF" + + theme.GridScreenLogoHD = "pkg:/images/Overhang_Test_HD.png" + + theme.GridScreenLogoOffsetHD_X = "0" + theme.GridScreenLogoOffsetHD_Y = "0" + theme.GridScreenOverhangHeightHD = "99" + + theme.GridScreenLogoSD = "pkg:/images/Overhang_Test_SD43.png" + theme.GridScreenOverhangHeightSD = "66" + theme.GridScreenLogoOffsetSD_X = "0" + theme.GridScreenLogoOffsetSD_Y = "0" + + ' to use your own focus ring artwork + 'theme.GridScreenFocusBorderSD = "pkg:/images/GridCenter_Border_Movies_SD43.png" + 'theme.GridScreenBorderOffsetSD = "(-26,-25)" + 'theme.GridScreenFocusBorderHD = "pkg:/images/GridCenter_Border_Movies_HD.png" + 'theme.GridScreenBorderOffsetHD = "(-28,-20)" + + ' to use your own description background artwork + 'theme.GridScreenDescriptionImageSD = "pkg:/images/Grid_Description_Background_SD43.png" + 'theme.GridScreenDescriptionOffsetSD = "(125,170)" + 'theme.GridScreenDescriptionImageHD = "pkg:/images/Grid_Description_Background_HD.png" + 'theme.GridScreenDescriptionOffsetHD = "(190,255)" + + + return theme +End Function + +'****************************************************** +'** Perform any startup/initialization stuff prior to +'** initially showing the screen. +'****************************************************** +Function preShowGridScreen(style as string) As Object + + m.port=CreateObject("roMessagePort") + screen = CreateObject("roGridScreen") + screen.SetMessagePort(m.port) +' screen.SetDisplayMode("best-fit") + screen.SetDisplayMode("scale-to-fill") + + screen.SetGridStyle(style) + return screen + +End Function + + +'****************************************************** +'** Display the gird screen and wait for events from +'** the screen. The screen will show retreiving while +'** we fetch and parse the feeds for the show posters +'****************************************************** +Function showGridScreen(screen As Object, gridstyle as string) As string + + print "enter showGridScreen" + + categoryList = getCategoryList() + categoryList[0] = "GridStyle: " + gridstyle + screen.setupLists(categoryList.count()) + screen.SetListNames(categoryList) + StyleButtons = getGridControlButtons() + screen.SetContentList(0, StyleButtons) + for i = 1 to categoryList.count()-1 + screen.SetContentList(i, getShowsForCategoryItem(categoryList[i])) + end for + screen.Show() + + while true + print "Waiting for message" + msg = wait(0, m.port) + 'msg = wait(0, screen.GetMessagePort()) ' getmessageport does not work on gridscreen + print "Got Message:";type(msg) + if type(msg) = "roGridScreenEvent" then + print "msg= "; msg.GetMessage() " , index= "; msg.GetIndex(); " data= "; msg.getData() + if msg.isListItemFocused() then + print"list item focused | current show = "; msg.GetIndex() + else if msg.isListItemSelected() then + row = msg.GetIndex() + selection = msg.getData() + print "list item selected row= "; row; " selection= "; selection + + ' Did we get a selection from the gridstyle selection row? + if (row = 0) + ' yes, return so we can come back with new style + return StyleButtons[selection].Title + endif + + 'm.curShow = displayShowDetailScreen(showList[msg.GetIndex()]) + else if msg.isScreenClosed() then + return "" + end if + end If + end while + + +End Function + +'********************************************************** +'** When a poster on the home screen is selected, we call +'** this function passing an roAssociativeArray with the +'** ContentMetaData for the selected show. This data should +'** be sufficient for the springboard to display +'********************************************************** +Function displayShowDetailScreen(category as Object, showIndex as Integer) As Integer + + 'add code to create springboard, for now we do nothing + return 1 + +End Function + + +'************************************************************** +'** Return the list of categories to display in the filter +'** banner. The result is an roArray containing the names of +'** all of the categories. All just static data for the example. +'*************************************************************** +Function getCategoryList() As Object + + categoryList = [ "GridStyle", "Reality", "History", "News", "Comedy", "Drama"] + return categoryList + +End Function + + +'******************************************************************** +'** Given the category from the filter banner, return an array +'** of ContentMetaData objects (roAssociativeArray's) representing +'** the shows for the category. For this example, we just cheat and +'** create and return a static array with just the minimal items +'** set, but ideally, you'd go to a feed service, fetch and parse +'** this data dynamically, so content for each category is dynamic +'******************************************************************** +Function getShowsForCategoryItem(category As Object) As Object + + print "getting shows for category "; category + + showList = [ + { + Title: category + ": Header", + releaseDate: "1976", + length: 3600-600, + Description:"This row is category " + category, + hdBranded: true, + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif", + Description:"Short Synopsis #1", + Synopsis:"Length", + StarRating:10, + } + { + Title: category + ": Beverly Hillbillies", + releaseDate: "1969", + rating: "PG", + Description:"Come and listen to a story about a man named Jed: Poor mountaineer, barely kept his family fed. Then one day he was shootin at some food, and up through the ground came a bubblin crude. Oil that is, black gold, Texas tea.", + numEpisodes:42, + contentType:"season", + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/4/4e/The_Beverly_Hillbillies.jpg", + StarRating:80, + UserStarRating:40 + } + { + Title: category + ": Babylon 5", + releaseDate: "1996", + rating: "PG", + Description:"The show centers on the Babylon 5 space station: a focal point for politics, diplomacy, and conflict during the years 2257-2262.", + numEpisodes:102, + contentType:"season", + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/9/9d/Smb5-s4.jpg", + StarRating:80, + UserStarRating:40 + } + { + Title: category + ": John F. Kennedy", + releaseDate: "1961", + rating: "PG", + Description:"My fellow citizens of the world: ask not what America will do for you, but what together we can do for the freedom of man.", + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/en/5/52/Jfk_happy_birthday_1.jpg", + StarRating:100 + } + { + Title: category + ": Man on the Moon", + releaseDate: "1969", + rating: "PG", + Description:"That's one small step for a man, one giant leap for mankind.", + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg", + StarRating:100 + } + { + Title: category + ": I have a Dream", + releaseDate: "1963", + rating: "PG", + Description:"I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin, but by the content of their character.", + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/8/81/Martin_Luther_King_-_March_on_Washington.jpg", + StarRating:100 + } + ] + + return showList +End Function + +function getGridControlButtons() as object + buttons = [ + { Title: "Flat-Movie" + ReleaseDate: "HD:5x2 SD:5x2" + Description: "Flat-Movie (Netflix) style" + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif" + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/4/43/Gold_star_on_blue.gif" + } + { Title: "Flat-Landscape" + ReleaseDate: "HD:5x3 SD:4x3" + Description: "Channel Store" + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/9/96/Dunkery_Hill.jpg/800px-Dunkery_Hill.jpg", + } + { Title: "Flat-Portrait" + ReleaseDate: "HD:5x2 SD:5x2" + Description: "3x4 style posters" + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/9/9f/Kane_George_Gurnett.jpg", + } + { Title: "Flat-Square" + ReleaseDate: "HD:7x3 SD:6x3" + Description: "1x1 style posters" + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/d/de/SQUARE_SHAPE.svg/536px-SQUARE_SHAPE.svg.png", + } + { Title: "Flat-16x9" + ReleaseDate: "HD:5x3 SD:4x3" + Description: "HD style posters" + HDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png", + SDPosterUrl:"http://upload.wikimedia.org/wikipedia/commons/thumb/2/22/%C3%89cran_TV_plat.svg/200px-%C3%89cran_TV_plat.svg.png", + } + ] + return buttons +End Function diff --git a/samples/C#/Index.cshtml b/samples/C#/Index.cshtml new file mode 100644 index 00000000..f7aa29c6 --- /dev/null +++ b/samples/C#/Index.cshtml @@ -0,0 +1,45 @@ +@{ + ViewBag.Title = "Home Page"; +} +@section featured { + +} +

We suggest the following:

+
    +
  1. +
    Getting Started
    + ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that + enables a clean separation of concerns and that gives you full control over markup + for enjoyable, agile development. ASP.NET MVC includes many features that enable + fast, TDD-friendly development for creating sophisticated applications that use + the latest web standards. + Learn more… +
  2. + +
  3. +
    Add NuGet packages and jump-start your coding
    + NuGet makes it easy to install and update free libraries and tools. + Learn more… +
  4. + +
  5. +
    Find Web Hosting
    + You can easily find a web hosting company that offers the right mix of features + and price for your applications. + Learn more… +
  6. +
diff --git a/samples/C#/Program.cs b/samples/C#/Program.cs new file mode 100644 index 00000000..20e24850 --- /dev/null +++ b/samples/C#/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LittleSampleApp +{ + /// + /// Just what it says on the tin. A little sample application for Linguist to try out. + /// + /// + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Hello, I am a little sample application to test GitHub's Linguist module."); + Console.WriteLine("I also include a Razor MVC file just to prove it handles cshtml files now."); + } + } +} diff --git a/samples/C++/CsvStreamer.h b/samples/C++/CsvStreamer.h new file mode 100644 index 00000000..b15e648d --- /dev/null +++ b/samples/C++/CsvStreamer.h @@ -0,0 +1,42 @@ +#pragma once +#include +#include +#include +#include "util.h" + +using namespace std; + + +#define DEFAULT_DELIMITER ',' + + +class CsvStreamer +{ + private: + ofstream file; // File output stream + vector row_buffer; // Buffer which stores a row's data before being flushed/written + int fields; // Number of fields (columns) + long rows; // Number of rows (records) including header row + char delimiter; // Delimiter character; comma by default + string sanitize(string); // Returns a string ready for output into the file + + public: + CsvStreamer(); // Empty CSV streamer... be sure to open the file before writing! + CsvStreamer(string, char); // Same as open(string, char)... + CsvStreamer(string); // Opens an output CSV file given a file path/name + ~CsvStreamer(); // Ensures the output file is closed and saved + void open(string); // Opens an output CSV file given a file path/name (default delimiter) + void open(string, char); // Opens an output CSV file given a file path/name and a delimiting character (default comma) + void add_field(string); // If still on first line, adds a new field to the header row + void save_fields(); // Call this to save the header row; all new writes should be through append() + void append(string); // Appends the current row with this data for the next field; quoted only if needed (leading/trailing spaces are trimmed) + void append(string, bool); // Like append(string) but can specify whether to trim spaces at either end of the data (false to keep spaces) + void append(float); // Appends the current row with this number + void append(double); // Appends the current row with this number + void append(long); // Appends the current row with this number + void append(int); // Appends the current row with this number + void writeln(); // Flushes what was in the row buffer into the file (writes the row) + void close(); // Saves and closes the file + int field_count(); // Gets the number of fields (columns) + long row_count(); // Gets the number of records (rows) -- NOT including the header row +}; diff --git a/samples/C++/Field.h b/samples/C++/Field.h new file mode 100644 index 00000000..201be118 --- /dev/null +++ b/samples/C++/Field.h @@ -0,0 +1,32 @@ +/***************************************************************************** +* Dwarf Mine - The 13-11 Benchmark +* +* Copyright (c) 2013 Bünger, Thomas; Kieschnick, Christian; Kusber, +* Michael; Lohse, Henning; Wuttke, Nikolai; Xylander, Oliver; Yao, Gary; +* Zimmermann, Florian +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*****************************************************************************/ + +#pragma once + +enum Field { Free, Black, White, Illegal }; + +typedef Field Player; diff --git a/samples/C++/Types.h b/samples/C++/Types.h new file mode 100644 index 00000000..e2675538 --- /dev/null +++ b/samples/C++/Types.h @@ -0,0 +1,32 @@ +/***************************************************************************** +* Dwarf Mine - The 13-11 Benchmark +* +* Copyright (c) 2013 Bünger, Thomas; Kieschnick, Christian; Kusber, +* Michael; Lohse, Henning; Wuttke, Nikolai; Xylander, Oliver; Yao, Gary; +* Zimmermann, Florian +* +* Permission is hereby granted, free of charge, to any person obtaining +* a copy of this software and associated documentation files (the +* "Software"), to deal in the Software without restriction, including +* without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to +* permit persons to whom the Software is furnished to do so, subject to +* the following conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*****************************************************************************/ + +#pragma once + +#include + +typedef uint32_t smallPrime_t; diff --git a/samples/C++/bcm2835.h b/samples/C++/bcm2835.h new file mode 100644 index 00000000..e5330933 --- /dev/null +++ b/samples/C++/bcm2835.h @@ -0,0 +1,1129 @@ +// bcm2835.h +// +// C and C++ support for Broadcom BCM 2835 as used in Raspberry Pi +// +// Author: Mike McCauley +// Copyright (C) 2011-2013 Mike McCauley +// $Id: bcm2835.h,v 1.8 2013/02/15 22:06:09 mikem Exp mikem $ +// +/// \mainpage C library for Broadcom BCM 2835 as used in Raspberry Pi +/// +/// This is a C library for Raspberry Pi (RPi). It provides access to +/// GPIO and other IO functions on the Broadcom BCM 2835 chip, +/// allowing access to the GPIO pins on the +/// 26 pin IDE plug on the RPi board so you can control and interface with various external devices. +/// +/// It provides functions for reading digital inputs and setting digital outputs, using SPI and I2C, +/// and for accessing the system timers. +/// Pin event detection is supported by polling (interrupts are not supported). +/// +/// It is C++ compatible, and installs as a header file and non-shared library on +/// any Linux-based distro (but clearly is no use except on Raspberry Pi or another board with +/// BCM 2835). +/// +/// The version of the package that this documentation refers to can be downloaded +/// from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.26.tar.gz +/// You can find the latest version at http://www.airspayce.com/mikem/bcm2835 +/// +/// Several example programs are provided. +/// +/// Based on data in http://elinux.org/RPi_Low-level_peripherals and +/// http://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf +/// and http://www.scribd.com/doc/101830961/GPIO-Pads-Control2 +/// +/// You can also find online help and discussion at http://groups.google.com/group/bcm2835 +/// Please use that group for all questions and discussions on this topic. +/// Do not contact the author directly, unless it is to discuss commercial licensing. +/// +/// Tested on debian6-19-04-2012, 2012-07-15-wheezy-raspbian and Occidentalisv01 +/// CAUTION: it has been observed that when detect enables such as bcm2835_gpio_len() +/// are used and the pin is pulled LOW +/// it can cause temporary hangs on 2012-07-15-wheezy-raspbian and Occidentalisv01. +/// Reason for this is not yet determined, but suspect that an interrupt handler is +/// hitting a hard loop on those OSs. +/// If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with +/// bcm2835_gpio_cler_len() and friends after use. +/// +/// \par Installation +/// +/// This library consists of a single non-shared library and header file, which will be +/// installed in the usual places by make install +/// +/// \code +/// # download the latest version of the library, say bcm2835-1.xx.tar.gz, then: +/// tar zxvf bcm2835-1.xx.tar.gz +/// cd bcm2835-1.xx +/// ./configure +/// make +/// sudo make check +/// sudo make install +/// \endcode +/// +/// \par Physical Addresses +/// +/// The functions bcm2835_peri_read(), bcm2835_peri_write() and bcm2835_peri_set_bits() +/// are low level peripheral register access functions. They are designed to use +/// physical addresses as described in section 1.2.3 ARM physical addresses +/// of the BCM2835 ARM Peripherals manual. +/// Physical addresses range from 0x20000000 to 0x20FFFFFF for peripherals. The bus +/// addresses for peripherals are set up to map onto the peripheral bus address range starting at +/// 0x7E000000. Thus a peripheral advertised in the manual at bus address 0x7Ennnnnn is available at +/// physical address 0x20nnnnnn. +/// +/// The base address of the various peripheral registers are available with the following +/// externals: +/// bcm2835_gpio +/// bcm2835_pwm +/// bcm2835_clk +/// bcm2835_pads +/// bcm2835_spio0 +/// bcm2835_st +/// bcm2835_bsc0 +/// bcm2835_bsc1 +/// +/// \par Pin Numbering +/// +/// The GPIO pin numbering as used by RPi is different to and inconsistent with the underlying +/// BCM 2835 chip pin numbering. http://elinux.org/RPi_BCM2835_GPIOs +/// +/// RPi has a 26 pin IDE header that provides access to some of the GPIO pins on the BCM 2835, +/// as well as power and ground pins. Not all GPIO pins on the BCM 2835 are available on the +/// IDE header. +/// +/// RPi Version 2 also has a P5 connector with 4 GPIO pins, 5V, 3.3V and Gnd. +/// +/// The functions in this library are designed to be passed the BCM 2835 GPIO pin number and _not_ +/// the RPi pin number. There are symbolic definitions for each of the available pins +/// that you should use for convenience. See \ref RPiGPIOPin. +/// +/// \par SPI Pins +/// +/// The bcm2835_spi_* functions allow you to control the BCM 2835 SPI0 interface, +/// allowing you to send and received data by SPI (Serial Peripheral Interface). +/// For more information about SPI, see http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus +/// +/// When bcm2835_spi_begin() is called it changes the bahaviour of the SPI interface pins from their +/// default GPIO behaviour in order to support SPI. While SPI is in use, you will not be able +/// to control the state of the SPI pins through the usual bcm2835_spi_gpio_write(). +/// When bcm2835_spi_end() is called, the SPI pins will all revert to inputs, and can then be +/// configured and controled with the usual bcm2835_gpio_* calls. +/// +/// The Raspberry Pi GPIO pins used for SPI are: +/// +/// - P1-19 (MOSI) +/// - P1-21 (MISO) +/// - P1-23 (CLK) +/// - P1-24 (CE0) +/// - P1-26 (CE1) +/// +/// \par I2C Pins +/// +/// The bcm2835_i2c_* functions allow you to control the BCM 2835 BSC interface, +/// allowing you to send and received data by I2C ("eye-squared cee"; generically referred to as "two-wire interface") . +/// For more information about I?C, see http://en.wikipedia.org/wiki/I%C2%B2C +/// +/// The Raspberry Pi V2 GPIO pins used for I2C are: +/// +/// - P1-03 (SDA) +/// - P1-05 (SLC) +/// +/// \par Real Time performance constraints +/// +/// The bcm2835 is a library for user programs (i.e. they run in 'userland'). +/// Such programs are not part of the kernel and are usually +/// subject to paging and swapping by the kernel while it does other things besides running your program. +/// This means that you should not expect to get real-time performance or +/// real-time timing constraints from such programs. In particular, there is no guarantee that the +/// bcm2835_delay() and bcm2835_delayMicroseconds() will return after exactly the time requested. +/// In fact, depending on other activity on the host, IO etc, you might get significantly longer delay times +/// than the one you asked for. So please dont expect to get exactly the time delay you request. +/// +/// Arjan reports that you can prevent swapping on Linux with the following code fragment: +/// +/// \code +/// struct sched_param sp; +/// memset(&sp, 0, sizeof(sp)); +/// sp.sched_priority = sched_get_priority_max(SCHED_FIFO); +/// sched_setscheduler(0, SCHED_FIFO, &sp); +/// mlockall(MCL_CURRENT | MCL_FUTURE); +/// \endcode +/// +/// \par Open Source Licensing GPL V2 +/// +/// This is the appropriate option if you want to share the source code of your +/// application with everyone you distribute it to, and you also want to give them +/// the right to share who uses it. If you wish to use this software under Open +/// Source Licensing, you must contribute all your source code to the open source +/// community in accordance with the GPL Version 2 when your application is +/// distributed. See http://www.gnu.org/copyleft/gpl.html and COPYING +/// +/// \par Acknowledgements +/// +/// Some of this code has been inspired by Dom and Gert. +/// The I2C code has been inspired by Alan Barr. +/// +/// \par Revision History +/// +/// \version 1.0 Initial release +/// \version 1.1 Minor bug fixes +/// \version 1.2 Added support for SPI +/// \version 1.3 Added bcm2835_spi_transfern() +/// \version 1.4 Fixed a problem that prevented SPI CE1 being used. Reported by David Robinson. +/// \version 1.5 Added bcm2835_close() to deinit the library. Suggested by C?sar Ortiz +/// \version 1.6 Document testing on 2012-07-15-wheezy-raspbian and Occidentalisv01 +/// Functions bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen() +/// bcm2835_gpio_len(), bcm2835_gpio_aren() and bcm2835_gpio_afen() now +/// changes only the pin specified. Other pins that were already previously +/// enabled stay enabled. +/// Added bcm2835_gpio_clr_ren(), bcm2835_gpio_clr_fen(), bcm2835_gpio_clr_hen() +/// bcm2835_gpio_clr_len(), bcm2835_gpio_clr_aren(), bcm2835_gpio_clr_afen() +/// to clear the enable for individual pins, suggested by Andreas Sundstrom. +/// \version 1.7 Added bcm2835_spi_transfernb to support different buffers for read and write. +/// \version 1.8 Improvements to read barrier, as suggested by maddin. +/// \version 1.9 Improvements contributed by mikew: +/// I noticed that it was mallocing memory for the mmaps on /dev/mem. +/// It's not necessary to do that, you can just mmap the file directly, +/// so I've removed the mallocs (and frees). +/// I've also modified delayMicroseconds() to use nanosleep() for long waits, +/// and a busy wait on a high resolution timer for the rest. This is because +/// I've found that calling nanosleep() takes at least 100-200 us. +/// You need to link using '-lrt' using this version. +/// I've added some unsigned casts to the debug prints to silence compiler +/// warnings I was getting, fixed some typos, and changed the value of +/// BCM2835_PAD_HYSTERESIS_ENABLED to 0x08 as per Gert van Loo's doc at +/// http://www.scribd.com/doc/101830961/GPIO-Pads-Control2 +/// Also added a define for the passwrd value that Gert says is needed to +/// change pad control settings. +/// \version 1.10 Changed the names of the delay functions to bcm2835_delay() +/// and bcm2835_delayMicroseconds() to prevent collisions with wiringPi. +/// Macros to map delay()-> bcm2835_delay() and +/// Macros to map delayMicroseconds()-> bcm2835_delayMicroseconds(), which +/// can be disabled by defining BCM2835_NO_DELAY_COMPATIBILITY +/// \version 1.11 Fixed incorrect link to download file +/// \version 1.12 New GPIO pin definitions for RPi version 2 (which has a different GPIO mapping) +/// \version 1.13 New GPIO pin definitions for RPi version 2 plug P5 +/// Hardware base pointers are now available (after initialisation) externally as bcm2835_gpio +/// bcm2835_pwm bcm2835_clk bcm2835_pads bcm2835_spi0. +/// \version 1.14 Now compiles even if CLOCK_MONOTONIC_RAW is not available, uses CLOCK_MONOTONIC instead. +/// Fixed errors in documentation of SPI divider frequencies based on 250MHz clock. +/// Reported by Ben Simpson. +/// \version 1.15 Added bcm2835_close() to end of examples as suggested by Mark Wolfe. +/// \version 1.16 Added bcm2835_gpio_set_multi, bcm2835_gpio_clr_multi and bcm2835_gpio_write_multi +/// to allow a mask of pins to be set all at once. Requested by Sebastian Loncar. +/// \version 1.17 Added bcm2835_gpio_write_mask. Requested by Sebastian Loncar. +/// \version 1.18 Added bcm2835_i2c_* functions. Changes to bcm2835_delayMicroseconds: +/// now uses the RPi system timer counter, instead of clock_gettime, for improved accuracy. +/// No need to link with -lrt now. Contributed by Arjan van Vught. +/// \version 1.19 Removed inlines added by previous patch since they don't seem to work everywhere. +/// Reported by olly. +/// \version 1.20 Patch from Mark Dootson to close /dev/mem after access to the peripherals has been granted. +/// \version 1.21 delayMicroseconds is now not susceptible to 32 bit timer overruns. +/// Patch courtesy Jeremy Mortis. +/// \version 1.22 Fixed incorrect definition of BCM2835_GPFEN0 which broke the ability to set +/// falling edge events. Reported by Mark Dootson. +/// \version 1.23 Added bcm2835_i2c_set_baudrate and bcm2835_i2c_read_register_rs. +/// Improvements to bcm2835_i2c_read and bcm2835_i2c_write functions +/// to fix ocasional reads not completing. Patched by Mark Dootson. +/// \version 1.24 Mark Dootson p[atched a problem with his previously submitted code +/// under high load from other processes. +/// \version 1.25 Updated author and distribution location details to airspayce.com +/// \version 1.26 Added missing unmapmem for pads in bcm2835_close to prevent a memory leak. +/// Reported by Hartmut Henkel. +/// \author Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS + + + +// Defines for BCM2835 +#ifndef BCM2835_H +#define BCM2835_H + +#include + +/// \defgroup constants Constants for passing to and from library functions +/// The values here are designed to be passed to various functions in the bcm2835 library. +/// @{ + + +/// This means pin HIGH, true, 3.3volts on a pin. +#define HIGH 0x1 +/// This means pin LOW, false, 0volts on a pin. +#define LOW 0x0 + +/// Speed of the core clock core_clk +#define BCM2835_CORE_CLK_HZ 250000000 ///< 250 MHz + +// Physical addresses for various peripheral register sets +/// Base Physical Address of the BCM 2835 peripheral registers +#define BCM2835_PERI_BASE 0x20000000 +/// Base Physical Address of the System Timer registers +#define BCM2835_ST_BASE (BCM2835_PERI_BASE + 0x3000) +/// Base Physical Address of the Pads registers +#define BCM2835_GPIO_PADS (BCM2835_PERI_BASE + 0x100000) +/// Base Physical Address of the Clock/timer registers +#define BCM2835_CLOCK_BASE (BCM2835_PERI_BASE + 0x101000) +/// Base Physical Address of the GPIO registers +#define BCM2835_GPIO_BASE (BCM2835_PERI_BASE + 0x200000) +/// Base Physical Address of the SPI0 registers +#define BCM2835_SPI0_BASE (BCM2835_PERI_BASE + 0x204000) +/// Base Physical Address of the BSC0 registers +#define BCM2835_BSC0_BASE (BCM2835_PERI_BASE + 0x205000) +/// Base Physical Address of the PWM registers +#define BCM2835_GPIO_PWM (BCM2835_PERI_BASE + 0x20C000) + /// Base Physical Address of the BSC1 registers +#define BCM2835_BSC1_BASE (BCM2835_PERI_BASE + 0x804000) + + +/// Base of the ST (System Timer) registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_st; + +/// Base of the GPIO registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_gpio; + +/// Base of the PWM registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_pwm; + +/// Base of the CLK registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_clk; + +/// Base of the PADS registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_pads; + +/// Base of the SPI0 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_spi0; + +/// Base of the BSC0 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_bsc0; + +/// Base of the BSC1 registers. +/// Available after bcm2835_init has been called +extern volatile uint32_t *bcm2835_bsc1; + +/// Size of memory page on RPi +#define BCM2835_PAGE_SIZE (4*1024) +/// Size of memory block on RPi +#define BCM2835_BLOCK_SIZE (4*1024) + + +// Defines for GPIO +// The BCM2835 has 54 GPIO pins. +// BCM2835 data sheet, Page 90 onwards. +/// GPIO register offsets from BCM2835_GPIO_BASE. Offsets into the GPIO Peripheral block in bytes per 6.1 Register View +#define BCM2835_GPFSEL0 0x0000 ///< GPIO Function Select 0 +#define BCM2835_GPFSEL1 0x0004 ///< GPIO Function Select 1 +#define BCM2835_GPFSEL2 0x0008 ///< GPIO Function Select 2 +#define BCM2835_GPFSEL3 0x000c ///< GPIO Function Select 3 +#define BCM2835_GPFSEL4 0x0010 ///< GPIO Function Select 4 +#define BCM2835_GPFSEL5 0x0014 ///< GPIO Function Select 5 +#define BCM2835_GPSET0 0x001c ///< GPIO Pin Output Set 0 +#define BCM2835_GPSET1 0x0020 ///< GPIO Pin Output Set 1 +#define BCM2835_GPCLR0 0x0028 ///< GPIO Pin Output Clear 0 +#define BCM2835_GPCLR1 0x002c ///< GPIO Pin Output Clear 1 +#define BCM2835_GPLEV0 0x0034 ///< GPIO Pin Level 0 +#define BCM2835_GPLEV1 0x0038 ///< GPIO Pin Level 1 +#define BCM2835_GPEDS0 0x0040 ///< GPIO Pin Event Detect Status 0 +#define BCM2835_GPEDS1 0x0044 ///< GPIO Pin Event Detect Status 1 +#define BCM2835_GPREN0 0x004c ///< GPIO Pin Rising Edge Detect Enable 0 +#define BCM2835_GPREN1 0x0050 ///< GPIO Pin Rising Edge Detect Enable 1 +#define BCM2835_GPFEN0 0x0058 ///< GPIO Pin Falling Edge Detect Enable 0 +#define BCM2835_GPFEN1 0x005c ///< GPIO Pin Falling Edge Detect Enable 1 +#define BCM2835_GPHEN0 0x0064 ///< GPIO Pin High Detect Enable 0 +#define BCM2835_GPHEN1 0x0068 ///< GPIO Pin High Detect Enable 1 +#define BCM2835_GPLEN0 0x0070 ///< GPIO Pin Low Detect Enable 0 +#define BCM2835_GPLEN1 0x0074 ///< GPIO Pin Low Detect Enable 1 +#define BCM2835_GPAREN0 0x007c ///< GPIO Pin Async. Rising Edge Detect 0 +#define BCM2835_GPAREN1 0x0080 ///< GPIO Pin Async. Rising Edge Detect 1 +#define BCM2835_GPAFEN0 0x0088 ///< GPIO Pin Async. Falling Edge Detect 0 +#define BCM2835_GPAFEN1 0x008c ///< GPIO Pin Async. Falling Edge Detect 1 +#define BCM2835_GPPUD 0x0094 ///< GPIO Pin Pull-up/down Enable +#define BCM2835_GPPUDCLK0 0x0098 ///< GPIO Pin Pull-up/down Enable Clock 0 +#define BCM2835_GPPUDCLK1 0x009c ///< GPIO Pin Pull-up/down Enable Clock 1 + +/// \brief bcm2835PortFunction +/// Port function select modes for bcm2835_gpio_fsel() +typedef enum +{ + BCM2835_GPIO_FSEL_INPT = 0b000, ///< Input + BCM2835_GPIO_FSEL_OUTP = 0b001, ///< Output + BCM2835_GPIO_FSEL_ALT0 = 0b100, ///< Alternate function 0 + BCM2835_GPIO_FSEL_ALT1 = 0b101, ///< Alternate function 1 + BCM2835_GPIO_FSEL_ALT2 = 0b110, ///< Alternate function 2 + BCM2835_GPIO_FSEL_ALT3 = 0b111, ///< Alternate function 3 + BCM2835_GPIO_FSEL_ALT4 = 0b011, ///< Alternate function 4 + BCM2835_GPIO_FSEL_ALT5 = 0b010, ///< Alternate function 5 + BCM2835_GPIO_FSEL_MASK = 0b111 ///< Function select bits mask +} bcm2835FunctionSelect; + +/// \brief bcm2835PUDControl +/// Pullup/Pulldown defines for bcm2835_gpio_pud() +typedef enum +{ + BCM2835_GPIO_PUD_OFF = 0b00, ///< Off ? disable pull-up/down + BCM2835_GPIO_PUD_DOWN = 0b01, ///< Enable Pull Down control + BCM2835_GPIO_PUD_UP = 0b10 ///< Enable Pull Up control +} bcm2835PUDControl; + +/// Pad control register offsets from BCM2835_GPIO_PADS +#define BCM2835_PADS_GPIO_0_27 0x002c ///< Pad control register for pads 0 to 27 +#define BCM2835_PADS_GPIO_28_45 0x0030 ///< Pad control register for pads 28 to 45 +#define BCM2835_PADS_GPIO_46_53 0x0034 ///< Pad control register for pads 46 to 53 + +/// Pad Control masks +#define BCM2835_PAD_PASSWRD (0x5A << 24) ///< Password to enable setting pad mask +#define BCM2835_PAD_SLEW_RATE_UNLIMITED 0x10 ///< Slew rate unlimited +#define BCM2835_PAD_HYSTERESIS_ENABLED 0x08 ///< Hysteresis enabled +#define BCM2835_PAD_DRIVE_2mA 0x00 ///< 2mA drive current +#define BCM2835_PAD_DRIVE_4mA 0x01 ///< 4mA drive current +#define BCM2835_PAD_DRIVE_6mA 0x02 ///< 6mA drive current +#define BCM2835_PAD_DRIVE_8mA 0x03 ///< 8mA drive current +#define BCM2835_PAD_DRIVE_10mA 0x04 ///< 10mA drive current +#define BCM2835_PAD_DRIVE_12mA 0x05 ///< 12mA drive current +#define BCM2835_PAD_DRIVE_14mA 0x06 ///< 14mA drive current +#define BCM2835_PAD_DRIVE_16mA 0x07 ///< 16mA drive current + +/// \brief bcm2835PadGroup +/// Pad group specification for bcm2835_gpio_pad() +typedef enum +{ + BCM2835_PAD_GROUP_GPIO_0_27 = 0, ///< Pad group for GPIO pads 0 to 27 + BCM2835_PAD_GROUP_GPIO_28_45 = 1, ///< Pad group for GPIO pads 28 to 45 + BCM2835_PAD_GROUP_GPIO_46_53 = 2 ///< Pad group for GPIO pads 46 to 53 +} bcm2835PadGroup; + +/// \brief GPIO Pin Numbers +/// +/// Here we define Raspberry Pin GPIO pins on P1 in terms of the underlying BCM GPIO pin numbers. +/// These can be passed as a pin number to any function requiring a pin. +/// Not all pins on the RPi 26 bin IDE plug are connected to GPIO pins +/// and some can adopt an alternate function. +/// RPi version 2 has some slightly different pinouts, and these are values RPI_V2_*. +/// At bootup, pins 8 and 10 are set to UART0_TXD, UART0_RXD (ie the alt0 function) respectively +/// When SPI0 is in use (ie after bcm2835_spi_begin()), pins 19, 21, 23, 24, 26 are dedicated to SPI +/// and cant be controlled independently +typedef enum +{ + RPI_GPIO_P1_03 = 0, ///< Version 1, Pin P1-03 + RPI_GPIO_P1_05 = 1, ///< Version 1, Pin P1-05 + RPI_GPIO_P1_07 = 4, ///< Version 1, Pin P1-07 + RPI_GPIO_P1_08 = 14, ///< Version 1, Pin P1-08, defaults to alt function 0 UART0_TXD + RPI_GPIO_P1_10 = 15, ///< Version 1, Pin P1-10, defaults to alt function 0 UART0_RXD + RPI_GPIO_P1_11 = 17, ///< Version 1, Pin P1-11 + RPI_GPIO_P1_12 = 18, ///< Version 1, Pin P1-12 + RPI_GPIO_P1_13 = 21, ///< Version 1, Pin P1-13 + RPI_GPIO_P1_15 = 22, ///< Version 1, Pin P1-15 + RPI_GPIO_P1_16 = 23, ///< Version 1, Pin P1-16 + RPI_GPIO_P1_18 = 24, ///< Version 1, Pin P1-18 + RPI_GPIO_P1_19 = 10, ///< Version 1, Pin P1-19, MOSI when SPI0 in use + RPI_GPIO_P1_21 = 9, ///< Version 1, Pin P1-21, MISO when SPI0 in use + RPI_GPIO_P1_22 = 25, ///< Version 1, Pin P1-22 + RPI_GPIO_P1_23 = 11, ///< Version 1, Pin P1-23, CLK when SPI0 in use + RPI_GPIO_P1_24 = 8, ///< Version 1, Pin P1-24, CE0 when SPI0 in use + RPI_GPIO_P1_26 = 7, ///< Version 1, Pin P1-26, CE1 when SPI0 in use + + // RPi Version 2 + RPI_V2_GPIO_P1_03 = 2, ///< Version 2, Pin P1-03 + RPI_V2_GPIO_P1_05 = 3, ///< Version 2, Pin P1-05 + RPI_V2_GPIO_P1_07 = 4, ///< Version 2, Pin P1-07 + RPI_V2_GPIO_P1_08 = 14, ///< Version 2, Pin P1-08, defaults to alt function 0 UART0_TXD + RPI_V2_GPIO_P1_10 = 15, ///< Version 2, Pin P1-10, defaults to alt function 0 UART0_RXD + RPI_V2_GPIO_P1_11 = 17, ///< Version 2, Pin P1-11 + RPI_V2_GPIO_P1_12 = 18, ///< Version 2, Pin P1-12 + RPI_V2_GPIO_P1_13 = 27, ///< Version 2, Pin P1-13 + RPI_V2_GPIO_P1_15 = 22, ///< Version 2, Pin P1-15 + RPI_V2_GPIO_P1_16 = 23, ///< Version 2, Pin P1-16 + RPI_V2_GPIO_P1_18 = 24, ///< Version 2, Pin P1-18 + RPI_V2_GPIO_P1_19 = 10, ///< Version 2, Pin P1-19, MOSI when SPI0 in use + RPI_V2_GPIO_P1_21 = 9, ///< Version 2, Pin P1-21, MISO when SPI0 in use + RPI_V2_GPIO_P1_22 = 25, ///< Version 2, Pin P1-22 + RPI_V2_GPIO_P1_23 = 11, ///< Version 2, Pin P1-23, CLK when SPI0 in use + RPI_V2_GPIO_P1_24 = 8, ///< Version 2, Pin P1-24, CE0 when SPI0 in use + RPI_V2_GPIO_P1_26 = 7, ///< Version 2, Pin P1-26, CE1 when SPI0 in use + + // RPi Version 2, new plug P5 + RPI_V2_GPIO_P5_03 = 28, ///< Version 2, Pin P5-03 + RPI_V2_GPIO_P5_04 = 29, ///< Version 2, Pin P5-04 + RPI_V2_GPIO_P5_05 = 30, ///< Version 2, Pin P5-05 + RPI_V2_GPIO_P5_06 = 31, ///< Version 2, Pin P5-06 + +} RPiGPIOPin; + +// Defines for SPI +// GPIO register offsets from BCM2835_SPI0_BASE. +// Offsets into the SPI Peripheral block in bytes per 10.5 SPI Register Map +#define BCM2835_SPI0_CS 0x0000 ///< SPI Master Control and Status +#define BCM2835_SPI0_FIFO 0x0004 ///< SPI Master TX and RX FIFOs +#define BCM2835_SPI0_CLK 0x0008 ///< SPI Master Clock Divider +#define BCM2835_SPI0_DLEN 0x000c ///< SPI Master Data Length +#define BCM2835_SPI0_LTOH 0x0010 ///< SPI LOSSI mode TOH +#define BCM2835_SPI0_DC 0x0014 ///< SPI DMA DREQ Controls + +// Register masks for SPI0_CS +#define BCM2835_SPI0_CS_LEN_LONG 0x02000000 ///< Enable Long data word in Lossi mode if DMA_LEN is set +#define BCM2835_SPI0_CS_DMA_LEN 0x01000000 ///< Enable DMA mode in Lossi mode +#define BCM2835_SPI0_CS_CSPOL2 0x00800000 ///< Chip Select 2 Polarity +#define BCM2835_SPI0_CS_CSPOL1 0x00400000 ///< Chip Select 1 Polarity +#define BCM2835_SPI0_CS_CSPOL0 0x00200000 ///< Chip Select 0 Polarity +#define BCM2835_SPI0_CS_RXF 0x00100000 ///< RXF - RX FIFO Full +#define BCM2835_SPI0_CS_RXR 0x00080000 ///< RXR RX FIFO needs Reading ( full) +#define BCM2835_SPI0_CS_TXD 0x00040000 ///< TXD TX FIFO can accept Data +#define BCM2835_SPI0_CS_RXD 0x00020000 ///< RXD RX FIFO contains Data +#define BCM2835_SPI0_CS_DONE 0x00010000 ///< Done transfer Done +#define BCM2835_SPI0_CS_TE_EN 0x00008000 ///< Unused +#define BCM2835_SPI0_CS_LMONO 0x00004000 ///< Unused +#define BCM2835_SPI0_CS_LEN 0x00002000 ///< LEN LoSSI enable +#define BCM2835_SPI0_CS_REN 0x00001000 ///< REN Read Enable +#define BCM2835_SPI0_CS_ADCS 0x00000800 ///< ADCS Automatically Deassert Chip Select +#define BCM2835_SPI0_CS_INTR 0x00000400 ///< INTR Interrupt on RXR +#define BCM2835_SPI0_CS_INTD 0x00000200 ///< INTD Interrupt on Done +#define BCM2835_SPI0_CS_DMAEN 0x00000100 ///< DMAEN DMA Enable +#define BCM2835_SPI0_CS_TA 0x00000080 ///< Transfer Active +#define BCM2835_SPI0_CS_CSPOL 0x00000040 ///< Chip Select Polarity +#define BCM2835_SPI0_CS_CLEAR 0x00000030 ///< Clear FIFO Clear RX and TX +#define BCM2835_SPI0_CS_CLEAR_RX 0x00000020 ///< Clear FIFO Clear RX +#define BCM2835_SPI0_CS_CLEAR_TX 0x00000010 ///< Clear FIFO Clear TX +#define BCM2835_SPI0_CS_CPOL 0x00000008 ///< Clock Polarity +#define BCM2835_SPI0_CS_CPHA 0x00000004 ///< Clock Phase +#define BCM2835_SPI0_CS_CS 0x00000003 ///< Chip Select + +/// \brief bcm2835SPIBitOrder SPI Bit order +/// Specifies the SPI data bit ordering for bcm2835_spi_setBitOrder() +typedef enum +{ + BCM2835_SPI_BIT_ORDER_LSBFIRST = 0, ///< LSB First + BCM2835_SPI_BIT_ORDER_MSBFIRST = 1 ///< MSB First +}bcm2835SPIBitOrder; + +/// \brief SPI Data mode +/// Specify the SPI data mode to be passed to bcm2835_spi_setDataMode() +typedef enum +{ + BCM2835_SPI_MODE0 = 0, ///< CPOL = 0, CPHA = 0 + BCM2835_SPI_MODE1 = 1, ///< CPOL = 0, CPHA = 1 + BCM2835_SPI_MODE2 = 2, ///< CPOL = 1, CPHA = 0 + BCM2835_SPI_MODE3 = 3, ///< CPOL = 1, CPHA = 1 +}bcm2835SPIMode; + +/// \brief bcm2835SPIChipSelect +/// Specify the SPI chip select pin(s) +typedef enum +{ + BCM2835_SPI_CS0 = 0, ///< Chip Select 0 + BCM2835_SPI_CS1 = 1, ///< Chip Select 1 + BCM2835_SPI_CS2 = 2, ///< Chip Select 2 (ie pins CS1 and CS2 are asserted) + BCM2835_SPI_CS_NONE = 3, ///< No CS, control it yourself +} bcm2835SPIChipSelect; + +/// \brief bcm2835SPIClockDivider +/// Specifies the divider used to generate the SPI clock from the system clock. +/// Figures below give the divider, clock period and clock frequency. +/// Clock divided is based on nominal base clock rate of 250MHz +/// It is reported that (contrary to the documentation) any even divider may used. +/// The frequencies shown for each divider have been confirmed by measurement +typedef enum +{ + BCM2835_SPI_CLOCK_DIVIDER_65536 = 0, ///< 65536 = 262.144us = 3.814697260kHz + BCM2835_SPI_CLOCK_DIVIDER_32768 = 32768, ///< 32768 = 131.072us = 7.629394531kHz + BCM2835_SPI_CLOCK_DIVIDER_16384 = 16384, ///< 16384 = 65.536us = 15.25878906kHz + BCM2835_SPI_CLOCK_DIVIDER_8192 = 8192, ///< 8192 = 32.768us = 30/51757813kHz + BCM2835_SPI_CLOCK_DIVIDER_4096 = 4096, ///< 4096 = 16.384us = 61.03515625kHz + BCM2835_SPI_CLOCK_DIVIDER_2048 = 2048, ///< 2048 = 8.192us = 122.0703125kHz + BCM2835_SPI_CLOCK_DIVIDER_1024 = 1024, ///< 1024 = 4.096us = 244.140625kHz + BCM2835_SPI_CLOCK_DIVIDER_512 = 512, ///< 512 = 2.048us = 488.28125kHz + BCM2835_SPI_CLOCK_DIVIDER_256 = 256, ///< 256 = 1.024us = 976.5625MHz + BCM2835_SPI_CLOCK_DIVIDER_128 = 128, ///< 128 = 512ns = = 1.953125MHz + BCM2835_SPI_CLOCK_DIVIDER_64 = 64, ///< 64 = 256ns = 3.90625MHz + BCM2835_SPI_CLOCK_DIVIDER_32 = 32, ///< 32 = 128ns = 7.8125MHz + BCM2835_SPI_CLOCK_DIVIDER_16 = 16, ///< 16 = 64ns = 15.625MHz + BCM2835_SPI_CLOCK_DIVIDER_8 = 8, ///< 8 = 32ns = 31.25MHz + BCM2835_SPI_CLOCK_DIVIDER_4 = 4, ///< 4 = 16ns = 62.5MHz + BCM2835_SPI_CLOCK_DIVIDER_2 = 2, ///< 2 = 8ns = 125MHz, fastest you can get + BCM2835_SPI_CLOCK_DIVIDER_1 = 1, ///< 0 = 262.144us = 3.814697260kHz, same as 0/65536 +} bcm2835SPIClockDivider; + +// Defines for I2C +// GPIO register offsets from BCM2835_BSC*_BASE. +// Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map +#define BCM2835_BSC_C 0x0000 ///< BSC Master Control +#define BCM2835_BSC_S 0x0004 ///< BSC Master Status +#define BCM2835_BSC_DLEN 0x0008 ///< BSC Master Data Length +#define BCM2835_BSC_A 0x000c ///< BSC Master Slave Address +#define BCM2835_BSC_FIFO 0x0010 ///< BSC Master Data FIFO +#define BCM2835_BSC_DIV 0x0014 ///< BSC Master Clock Divider +#define BCM2835_BSC_DEL 0x0018 ///< BSC Master Data Delay +#define BCM2835_BSC_CLKT 0x001c ///< BSC Master Clock Stretch Timeout + +// Register masks for BSC_C +#define BCM2835_BSC_C_I2CEN 0x00008000 ///< I2C Enable, 0 = disabled, 1 = enabled +#define BCM2835_BSC_C_INTR 0x00000400 ///< Interrupt on RX +#define BCM2835_BSC_C_INTT 0x00000200 ///< Interrupt on TX +#define BCM2835_BSC_C_INTD 0x00000100 ///< Interrupt on DONE +#define BCM2835_BSC_C_ST 0x00000080 ///< Start transfer, 1 = Start a new transfer +#define BCM2835_BSC_C_CLEAR_1 0x00000020 ///< Clear FIFO Clear +#define BCM2835_BSC_C_CLEAR_2 0x00000010 ///< Clear FIFO Clear +#define BCM2835_BSC_C_READ 0x00000001 ///< Read transfer + +// Register masks for BSC_S +#define BCM2835_BSC_S_CLKT 0x00000200 ///< Clock stretch timeout +#define BCM2835_BSC_S_ERR 0x00000100 ///< ACK error +#define BCM2835_BSC_S_RXF 0x00000080 ///< RXF FIFO full, 0 = FIFO is not full, 1 = FIFO is full +#define BCM2835_BSC_S_TXE 0x00000040 ///< TXE FIFO full, 0 = FIFO is not full, 1 = FIFO is full +#define BCM2835_BSC_S_RXD 0x00000020 ///< RXD FIFO contains data +#define BCM2835_BSC_S_TXD 0x00000010 ///< TXD FIFO can accept data +#define BCM2835_BSC_S_RXR 0x00000008 ///< RXR FIFO needs reading (full) +#define BCM2835_BSC_S_TXW 0x00000004 ///< TXW FIFO needs writing (full) +#define BCM2835_BSC_S_DONE 0x00000002 ///< Transfer DONE +#define BCM2835_BSC_S_TA 0x00000001 ///< Transfer Active + +#define BCM2835_BSC_FIFO_SIZE 16 ///< BSC FIFO size + +/// \brief bcm2835I2CClockDivider +/// Specifies the divider used to generate the I2C clock from the system clock. +/// Clock divided is based on nominal base clock rate of 250MHz +typedef enum +{ + BCM2835_I2C_CLOCK_DIVIDER_2500 = 2500, ///< 2500 = 10us = 100 kHz + BCM2835_I2C_CLOCK_DIVIDER_626 = 626, ///< 622 = 2.504us = 399.3610 kHz + BCM2835_I2C_CLOCK_DIVIDER_150 = 150, ///< 150 = 60ns = 1.666 MHz (default at reset) + BCM2835_I2C_CLOCK_DIVIDER_148 = 148, ///< 148 = 59ns = 1.689 MHz +} bcm2835I2CClockDivider; + +/// \brief bcm2835I2CReasonCodes +/// Specifies the reason codes for the bcm2835_i2c_write and bcm2835_i2c_read functions. +typedef enum +{ + BCM2835_I2C_REASON_OK = 0x00, ///< Success + BCM2835_I2C_REASON_ERROR_NACK = 0x01, ///< Received a NACK + BCM2835_I2C_REASON_ERROR_CLKT = 0x02, ///< Received Clock Stretch Timeout + BCM2835_I2C_REASON_ERROR_DATA = 0x04, ///< Not all data is sent / received +} bcm2835I2CReasonCodes; + +// Defines for ST +// GPIO register offsets from BCM2835_ST_BASE. +// Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers +// The System Timer peripheral provides four 32-bit timer channels and a single 64-bit free running counter. +// BCM2835_ST_CLO is the System Timer Counter Lower bits register. +// The system timer free-running counter lower register is a read-only register that returns the current value +// of the lower 32-bits of the free running counter. +// BCM2835_ST_CHI is the System Timer Counter Upper bits register. +// The system timer free-running counter upper register is a read-only register that returns the current value +// of the upper 32-bits of the free running counter. +#define BCM2835_ST_CS 0x0000 ///< System Timer Control/Status +#define BCM2835_ST_CLO 0x0004 ///< System Timer Counter Lower 32 bits +#define BCM2835_ST_CHI 0x0008 ///< System Timer Counter Upper 32 bits + +/// @} + + +// Defines for PWM +#define BCM2835_PWM_CONTROL 0 +#define BCM2835_PWM_STATUS 1 +#define BCM2835_PWM0_RANGE 4 +#define BCM2835_PWM0_DATA 5 +#define BCM2835_PWM1_RANGE 8 +#define BCM2835_PWM1_DATA 9 + +#define BCM2835_PWMCLK_CNTL 40 +#define BCM2835_PWMCLK_DIV 41 + +#define BCM2835_PWM1_MS_MODE 0x8000 /// Run in MS mode +#define BCM2835_PWM1_USEFIFO 0x2000 /// Data from FIFO +#define BCM2835_PWM1_REVPOLAR 0x1000 /// Reverse polarity +#define BCM2835_PWM1_OFFSTATE 0x0800 /// Ouput Off state +#define BCM2835_PWM1_REPEATFF 0x0400 /// Repeat last value if FIFO empty +#define BCM2835_PWM1_SERIAL 0x0200 /// Run in serial mode +#define BCM2835_PWM1_ENABLE 0x0100 /// Channel Enable + +#define BCM2835_PWM0_MS_MODE 0x0080 /// Run in MS mode +#define BCM2835_PWM0_USEFIFO 0x0020 /// Data from FIFO +#define BCM2835_PWM0_REVPOLAR 0x0010 /// Reverse polarity +#define BCM2835_PWM0_OFFSTATE 0x0008 /// Ouput Off state +#define BCM2835_PWM0_REPEATFF 0x0004 /// Repeat last value if FIFO empty +#define BCM2835_PWM0_SERIAL 0x0002 /// Run in serial mode +#define BCM2835_PWM0_ENABLE 0x0001 /// Channel Enable + +// Historical name compatibility +#ifndef BCM2835_NO_DELAY_COMPATIBILITY +#define delay(x) bcm2835_delay(x) +#define delayMicroseconds(x) bcm2835_delayMicroseconds(x) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /// \defgroup init Library initialisation and management + /// These functions allow you to intialise and control the bcm2835 library + /// @{ + + /// Initialise the library by opening /dev/mem and getting pointers to the + /// internal memory for BCM 2835 device registers. You must call this (successfully) + /// before calling any other + /// functions in this library (except bcm2835_set_debug). + /// If bcm2835_init() fails by returning 0, + /// calling any other function may result in crashes or other failures. + /// Prints messages to stderr in case of errors. + /// \return 1 if successful else 0 + extern int bcm2835_init(void); + + /// Close the library, deallocating any allocated memory and closing /dev/mem + /// \return 1 if successful else 0 + extern int bcm2835_close(void); + + /// Sets the debug level of the library. + /// A value of 1 prevents mapping to /dev/mem, and makes the library print out + /// what it would do, rather than accessing the GPIO registers. + /// A value of 0, the default, causes normal operation. + /// Call this before calling bcm2835_init(); + /// \param[in] debug The new debug level. 1 means debug + extern void bcm2835_set_debug(uint8_t debug); + + /// @} // end of init + + /// \defgroup lowlevel Low level register access + /// These functions provide low level register access, and should not generally + /// need to be used + /// + /// @{ + + /// Reads 32 bit value from a peripheral address + /// The read is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \return the value read from the 32 bit register + /// \sa Physical Addresses + extern uint32_t bcm2835_peri_read(volatile uint32_t* paddr); + + + /// Reads 32 bit value from a peripheral address without the read barrier + /// You should only use this when your code has previously called bcm2835_peri_read() + /// within the same peripheral, and no other peripheral access has occurred since. + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \return the value read from the 32 bit register + /// \sa Physical Addresses + extern uint32_t bcm2835_peri_read_nb(volatile uint32_t* paddr); + + + /// Writes 32 bit value from a peripheral address + /// The write is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write + /// \sa Physical Addresses + extern void bcm2835_peri_write(volatile uint32_t* paddr, uint32_t value); + + /// Writes 32 bit value from a peripheral address without the write barrier + /// You should only use this when your code has previously called bcm2835_peri_write() + /// within the same peripheral, and no other peripheral access has occurred since. + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write + /// \sa Physical Addresses + extern void bcm2835_peri_write_nb(volatile uint32_t* paddr, uint32_t value); + + /// Alters a number of bits in a 32 peripheral regsiter. + /// It reads the current valu and then alters the bits deines as 1 in mask, + /// according to the bit value in value. + /// All other bits that are 0 in the mask are unaffected. + /// Use this to alter a subset of the bits in a register. + /// The write is done twice, and is therefore always safe in terms of + /// manual section 1.3 Peripheral access precautions for correct memory ordering + /// \param[in] paddr Physical address to read from. See BCM2835_GPIO_BASE etc. + /// \param[in] value The 32 bit value to write, masked in by mask. + /// \param[in] mask Bitmask that defines the bits that will be altered in the register. + /// \sa Physical Addresses + extern void bcm2835_peri_set_bits(volatile uint32_t* paddr, uint32_t value, uint32_t mask); + /// @} // end of lowlevel + + /// \defgroup gpio GPIO register access + /// These functions allow you to control the GPIO interface. You can set the + /// function of each GPIO pin, read the input state and set the output state. + /// @{ + + /// Sets the Function Select register for the given pin, which configures + /// the pin as Input, Output or one of the 6 alternate functions. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from RPiGPIOPin. + /// \param[in] mode Mode to set the pin to, one of BCM2835_GPIO_FSEL_* from \ref bcm2835FunctionSelect + extern void bcm2835_gpio_fsel(uint8_t pin, uint8_t mode); + + /// Sets the specified pin output to + /// HIGH. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \sa bcm2835_gpio_write() + extern void bcm2835_gpio_set(uint8_t pin); + + /// Sets the specified pin output to + /// LOW. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \sa bcm2835_gpio_write() + extern void bcm2835_gpio_clr(uint8_t pin); + + /// Sets any of the first 32 GPIO output pins specified in the mask to + /// HIGH. + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \sa bcm2835_gpio_write_multi() + extern void bcm2835_gpio_set_multi(uint32_t mask); + + /// Sets any of the first 32 GPIO output pins specified in the mask to + /// LOW. + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \sa bcm2835_gpio_write_multi() + extern void bcm2835_gpio_clr_multi(uint32_t mask); + + /// Reads the current level on the specified + /// pin and returns either HIGH or LOW. Works whether or not the pin + /// is an input or an output. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \return the current level either HIGH or LOW + extern uint8_t bcm2835_gpio_lev(uint8_t pin); + + /// Event Detect Status. + /// Tests whether the specified pin has detected a level or edge + /// as requested by bcm2835_gpio_ren(), bcm2835_gpio_fen(), bcm2835_gpio_hen(), + /// bcm2835_gpio_len(), bcm2835_gpio_aren(), bcm2835_gpio_afen(). + /// Clear the flag for a given pin by calling bcm2835_gpio_set_eds(pin); + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \return HIGH if the event detect status for th given pin is true. + extern uint8_t bcm2835_gpio_eds(uint8_t pin); + + /// Sets the Event Detect Status register for a given pin to 1, + /// which has the effect of clearing the flag. Use this afer seeing + /// an Event Detect Status on the pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_set_eds(uint8_t pin); + + /// Enable Rising Edge Detect Enable for the specified pin. + /// When a rising edge is detected, sets the appropriate pin in Event Detect Status. + /// The GPRENn registers use + /// synchronous edge detection. This means the input signal is sampled using the + /// system clock and then it is looking for a ?011? pattern on the sampled signal. This + /// has the effect of suppressing glitches. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_ren(uint8_t pin); + + /// Disable Rising Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_ren(uint8_t pin); + + /// Enable Falling Edge Detect Enable for the specified pin. + /// When a falling edge is detected, sets the appropriate pin in Event Detect Status. + /// The GPRENn registers use + /// synchronous edge detection. This means the input signal is sampled using the + /// system clock and then it is looking for a ?100? pattern on the sampled signal. This + /// has the effect of suppressing glitches. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_fen(uint8_t pin); + + /// Disable Falling Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_fen(uint8_t pin); + + /// Enable High Detect Enable for the specified pin. + /// When a HIGH level is detected on the pin, sets the appropriate pin in Event Detect Status. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_hen(uint8_t pin); + + /// Disable High Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_hen(uint8_t pin); + + /// Enable Low Detect Enable for the specified pin. + /// When a LOW level is detected on the pin, sets the appropriate pin in Event Detect Status. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_len(uint8_t pin); + + /// Disable Low Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_len(uint8_t pin); + + /// Enable Asynchronous Rising Edge Detect Enable for the specified pin. + /// When a rising edge is detected, sets the appropriate pin in Event Detect Status. + /// Asynchronous means the incoming signal is not sampled by the system clock. As such + /// rising edges of very short duration can be detected. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_aren(uint8_t pin); + + /// Disable Asynchronous Rising Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_aren(uint8_t pin); + + /// Enable Asynchronous Falling Edge Detect Enable for the specified pin. + /// When a falling edge is detected, sets the appropriate pin in Event Detect Status. + /// Asynchronous means the incoming signal is not sampled by the system clock. As such + /// falling edges of very short duration can be detected. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_afen(uint8_t pin); + + /// Disable Asynchronous Falling Edge Detect Enable for the specified pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + extern void bcm2835_gpio_clr_afen(uint8_t pin); + + /// Sets the Pull-up/down register for the given pin. This is + /// used with bcm2835_gpio_pudclk() to set the Pull-up/down resistor for the given pin. + /// However, it is usually more convenient to use bcm2835_gpio_set_pud(). + /// \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl + /// \sa bcm2835_gpio_set_pud() + extern void bcm2835_gpio_pud(uint8_t pud); + + /// Clocks the Pull-up/down value set earlier by bcm2835_gpio_pud() into the pin. + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] on HIGH to clock the value from bcm2835_gpio_pud() into the pin. + /// LOW to remove the clock. + /// \sa bcm2835_gpio_set_pud() + extern void bcm2835_gpio_pudclk(uint8_t pin, uint8_t on); + + /// Reads and returns the Pad Control for the given GPIO group. + /// \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_* + /// \return Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup + extern uint32_t bcm2835_gpio_pad(uint8_t group); + + /// Sets the Pad Control for the given GPIO group. + /// \param[in] group The GPIO pad group number, one of BCM2835_PAD_GROUP_GPIO_* + /// \param[in] control Mask of bits from BCM2835_PAD_* from \ref bcm2835PadGroup + extern void bcm2835_gpio_set_pad(uint8_t group, uint32_t control); + + /// Delays for the specified number of milliseconds. + /// Uses nanosleep(), and therefore does not use CPU until the time is up. + /// However, you are at the mercy of nanosleep(). From the manual for nanosleep(): + /// If the interval specified in req is not an exact multiple of the granularity + /// underlying clock (see time(7)), then the interval will be + /// rounded up to the next multiple. Furthermore, after the sleep completes, + /// there may still be a delay before the CPU becomes free to once + /// again execute the calling thread. + /// \param[in] millis Delay in milliseconds + extern void bcm2835_delay (unsigned int millis); + + /// Delays for the specified number of microseconds. + /// Uses a combination of nanosleep() and a busy wait loop on the BCM2835 system timers, + /// However, you are at the mercy of nanosleep(). From the manual for nanosleep(): + /// If the interval specified in req is not an exact multiple of the granularity + /// underlying clock (see time(7)), then the interval will be + /// rounded up to the next multiple. Furthermore, after the sleep completes, + /// there may still be a delay before the CPU becomes free to once + /// again execute the calling thread. + /// For times less than about 450 microseconds, uses a busy wait on the System Timer. + /// It is reported that a delay of 0 microseconds on RaspberryPi will in fact + /// result in a delay of about 80 microseconds. Your mileage may vary. + /// \param[in] micros Delay in microseconds + extern void bcm2835_delayMicroseconds (uint64_t micros); + + /// Sets the output state of the specified pin + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] on HIGH sets the output to HIGH and LOW to LOW. + extern void bcm2835_gpio_write(uint8_t pin, uint8_t on); + + /// Sets any of the first 32 GPIO output pins specified in the mask to the state given by on + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \param[in] on HIGH sets the output to HIGH and LOW to LOW. + extern void bcm2835_gpio_write_multi(uint32_t mask, uint8_t on); + + /// Sets the first 32 GPIO output pins specified in the mask to the value given by value + /// \param[in] value values required for each bit masked in by mask, eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + /// \param[in] mask Mask of pins to affect. Use eg: (1 << RPI_GPIO_P1_03) | (1 << RPI_GPIO_P1_05) + extern void bcm2835_gpio_write_mask(uint32_t value, uint32_t mask); + + /// Sets the Pull-up/down mode for the specified pin. This is more convenient than + /// clocking the mode in with bcm2835_gpio_pud() and bcm2835_gpio_pudclk(). + /// \param[in] pin GPIO number, or one of RPI_GPIO_P1_* from \ref RPiGPIOPin. + /// \param[in] pud The desired Pull-up/down mode. One of BCM2835_GPIO_PUD_* from bcm2835PUDControl + extern void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud); + + /// @} + + /// \defgroup spi SPI access + /// These functions let you use SPI0 (Serial Peripheral Interface) to + /// interface with an external SPI device. + /// @{ + + /// Start SPI operations. + /// Forces RPi SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) + /// to alternate function ALT0, which enables those pins for SPI interface. + /// You should call bcm2835_spi_end() when all SPI funcitons are complete to return the pins to + /// their default functions + /// \sa bcm2835_spi_end() + extern void bcm2835_spi_begin(void); + + /// End SPI operations. + /// SPI0 pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1) + /// are returned to their default INPUT behaviour. + extern void bcm2835_spi_end(void); + + /// Sets the SPI bit order + /// NOTE: has no effect. Not supported by SPI0. + /// Defaults to + /// \param[in] order The desired bit order, one of BCM2835_SPI_BIT_ORDER_*, + /// see \ref bcm2835SPIBitOrder + extern void bcm2835_spi_setBitOrder(uint8_t order); + + /// Sets the SPI clock divider and therefore the + /// SPI clock speed. + /// \param[in] divider The desired SPI clock divider, one of BCM2835_SPI_CLOCK_DIVIDER_*, + /// see \ref bcm2835SPIClockDivider + extern void bcm2835_spi_setClockDivider(uint16_t divider); + + /// Sets the SPI data mode + /// Sets the clock polariy and phase + /// \param[in] mode The desired data mode, one of BCM2835_SPI_MODE*, + /// see \ref bcm2835SPIMode + extern void bcm2835_spi_setDataMode(uint8_t mode); + + /// Sets the chip select pin(s) + /// When an bcm2835_spi_transfer() is made, the selected pin(s) will be asserted during the + /// transfer. + /// \param[in] cs Specifies the CS pins(s) that are used to activate the desired slave. + /// One of BCM2835_SPI_CS*, see \ref bcm2835SPIChipSelect + extern void bcm2835_spi_chipSelect(uint8_t cs); + + /// Sets the chip select pin polarity for a given pin + /// When an bcm2835_spi_transfer() occurs, the currently selected chip select pin(s) + /// will be asserted to the + /// value given by active. When transfers are not happening, the chip select pin(s) + /// return to the complement (inactive) value. + /// \param[in] cs The chip select pin to affect + /// \param[in] active Whether the chip select pin is to be active HIGH + extern void bcm2835_spi_setChipSelectPolarity(uint8_t cs, uint8_t active); + + /// Transfers one byte to and from the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// Clocks the 8 bit value out on MOSI, and simultaneously clocks in data from MISO. + /// Returns the read data byte from the slave. + /// Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual + /// \param[in] value The 8 bit data byte to write to MOSI + /// \return The 8 bit byte simultaneously read from MISO + /// \sa bcm2835_spi_transfern() + extern uint8_t bcm2835_spi_transfer(uint8_t value); + + /// Transfers any number of bytes to and from the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// Clocks the len 8 bit bytes out on MOSI, and simultaneously clocks in data from MISO. + /// The data read read from the slave is placed into rbuf. rbuf must be at least len bytes long + /// Uses polled transfer as per section 10.6.1 of the BCM 2835 ARM Peripherls manual + /// \param[in] tbuf Buffer of bytes to send. + /// \param[out] rbuf Received bytes will by put in this buffer + /// \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send/received + /// \sa bcm2835_spi_transfer() + extern void bcm2835_spi_transfernb(char* tbuf, char* rbuf, uint32_t len); + + /// Transfers any number of bytes to and from the currently selected SPI slave + /// using bcm2835_spi_transfernb. + /// The returned data from the slave replaces the transmitted data in the buffer. + /// \param[in,out] buf Buffer of bytes to send. Received bytes will replace the contents + /// \param[in] len Number of bytes int eh buffer, and the number of bytes to send/received + /// \sa bcm2835_spi_transfer() + extern void bcm2835_spi_transfern(char* buf, uint32_t len); + + /// Transfers any number of bytes to the currently selected SPI slave. + /// Asserts the currently selected CS pins (as previously set by bcm2835_spi_chipSelect) + /// during the transfer. + /// \param[in] buf Buffer of bytes to send. + /// \param[in] len Number of bytes in the tbuf buffer, and the number of bytes to send + extern void bcm2835_spi_writenb(char* buf, uint32_t len); + + /// @} + + /// \defgroup i2c I2C access + /// These functions let you use I2C (The Broadcom Serial Control bus with the Philips + /// I2C bus/interface version 2.1 January 2000.) to interface with an external I2C device. + /// @{ + + /// Start I2C operations. + /// Forces RPi I2C pins P1-03 (SDA) and P1-05 (SCL) + /// to alternate function ALT0, which enables those pins for I2C interface. + /// You should call bcm2835_i2c_end() when all I2C functions are complete to return the pins to + /// their default functions + /// \sa bcm2835_i2c_end() + extern void bcm2835_i2c_begin(void); + + /// End I2C operations. + /// I2C pins P1-03 (SDA) and P1-05 (SCL) + /// are returned to their default INPUT behaviour. + extern void bcm2835_i2c_end(void); + + /// Sets the I2C slave address. + /// \param[in] addr The I2C slave address. + extern void bcm2835_i2c_setSlaveAddress(uint8_t addr); + + /// Sets the I2C clock divider and therefore the I2C clock speed. + /// \param[in] divider The desired I2C clock divider, one of BCM2835_I2C_CLOCK_DIVIDER_*, + /// see \ref bcm2835I2CClockDivider + extern void bcm2835_i2c_setClockDivider(uint16_t divider); + + /// Sets the I2C clock divider by converting the baudrate parameter to + /// the equivalent I2C clock divider. ( see \sa bcm2835_i2c_setClockDivider) + /// For the I2C standard 100khz you would set baudrate to 100000 + /// The use of baudrate corresponds to its use in the I2C kernel device + /// driver. (Of course, bcm2835 has nothing to do with the kernel driver) + extern void bcm2835_i2c_set_baudrate(uint32_t baudrate); + + /// Transfers any number of bytes to the currently selected I2C slave. + /// (as previously set by \sa bcm2835_i2c_setSlaveAddress) + /// \param[in] buf Buffer of bytes to send. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to send. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_write(const char * buf, uint32_t len); + + /// Transfers any number of bytes from the currently selected I2C slave. + /// (as previously set by \sa bcm2835_i2c_setSlaveAddress) + /// \param[in] buf Buffer of bytes to receive. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to received. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_read(char* buf, uint32_t len); + + /// Allows reading from I2C slaves that require a repeated start (without any prior stop) + /// to read after the required slave register has been set. For example, the popular + /// MPL3115A2 pressure and temperature sensor. Note that your device must support or + /// require this mode. If your device does not require this mode then the standard + /// combined: + /// \sa bcm2835_i2c_write + /// \sa bcm2835_i2c_read + /// are a better choice. + /// Will read from the slave previously set by \sa bcm2835_i2c_setSlaveAddress + /// \param[in] regaddr Buffer containing the slave register you wish to read from. + /// \param[in] buf Buffer of bytes to receive. + /// \param[in] len Number of bytes in the buf buffer, and the number of bytes to received. + /// \return reason see \ref bcm2835I2CReasonCodes + extern uint8_t bcm2835_i2c_read_register_rs(char* regaddr, char* buf, uint32_t len); + + /// @} + + /// \defgroup st System Timer access + /// Allows access to and delays using the System Timer Counter. + /// @{ + + /// Read the System Timer Counter register. + /// \return the value read from the System Timer Counter Lower 32 bits register + uint64_t bcm2835_st_read(void); + + /// Delays for the specified number of microseconds with offset. + /// \param[in] offset_micros Offset in microseconds + /// \param[in] micros Delay in microseconds + extern void bcm2835_st_delay(uint64_t offset_micros, uint64_t micros); + + /// @} + +#ifdef __cplusplus +} +#endif + +#endif // BCM2835_H + +/// @example blink.c +/// Blinks RPi GPIO pin 11 on and off + +/// @example input.c +/// Reads the state of an RPi input pin + +/// @example event.c +/// Shows how to use event detection on an input pin + +/// @example spi.c +/// Shows how to use SPI interface to transfer a byte to and from an SPI device + +/// @example spin.c +/// Shows how to use SPI interface to transfer a number of bytes to and from an SPI device diff --git a/samples/C++/cuda.cu b/samples/C++/cuda.cu deleted file mode 100644 index ddef40cd..00000000 --- a/samples/C++/cuda.cu +++ /dev/null @@ -1,39 +0,0 @@ -void foo() -{ - cudaArray* cu_array; - texture tex; - - // Allocate array - cudaChannelFormatDesc description = cudaCreateChannelDesc(); - cudaMallocArray(&cu_array, &description, width, height); - - // Copy image data to array - cudaMemcpyToArray(cu_array, image, width*height*sizeof(float), cudaMemcpyHostToDevice); - - // Set texture parameters (default) - tex.addressMode[0] = cudaAddressModeClamp; - tex.addressMode[1] = cudaAddressModeClamp; - tex.filterMode = cudaFilterModePoint; - tex.normalized = false; // do not normalize coordinates - - // Bind the array to the texture - cudaBindTextureToArray(tex, cu_array); - - // Run kernel - dim3 blockDim(16, 16, 1); - dim3 gridDim((width + blockDim.x - 1)/ blockDim.x, (height + blockDim.y - 1) / blockDim.y, 1); - kernel<<< gridDim, blockDim, 0 >>>(d_data, height, width); - - // Unbind the array from the texture - cudaUnbindTexture(tex); -} //end foo() - -__global__ void kernel(float* odata, int height, int width) -{ - unsigned int x = blockIdx.x*blockDim.x + threadIdx.x; - unsigned int y = blockIdx.y*blockDim.y + threadIdx.y; - if (x < width && y < height) { - float c = tex2D(tex, x, y); - odata[y*width+x] = c; - } -} diff --git a/samples/C++/libcanister.h b/samples/C++/libcanister.h new file mode 100644 index 00000000..b7d82a52 --- /dev/null +++ b/samples/C++/libcanister.h @@ -0,0 +1,138 @@ +#ifndef LIBCANIH +#define LIBCANIH +#include +#include +#include +#include + +#define int64 unsigned long long +//#define DEBUG + +#ifdef DEBUG +#define dout cout +#else +#define dout if (0) cerr +#endif + +using namespace std; + +namespace libcanister +{ + + //the canmem object is a generic memory container used commonly + //throughout the canister framework to hold memory of uncertain + //length which may or may not contain null bytes. + class canmem + { + public: + char* data; //the raw memory block + int size; //the absolute length of the block + canmem(); //creates an unallocated canmem + canmem(int allocsize); //creates an allocated, blank canmem of size + canmem(char* strdata); //automates the creation of zero-limited canmems + ~canmem(); //cleans up the canmem + void zeromem(); //overwrites this canmem + void fragmem(); //overwrites this canmem with fragment notation + void countlen(); //counts length of zero-limited strings and stores it in size + void trim(); //removes any nulls from the end of the string + static canmem null(); //returns a singleton null canmem + + }; + + //contains information about the canister + class caninfo + { + public: + canmem path; //physical path + canmem internalname; //a name for the canister + int numfiles; //the number of files in the canister + }; + + //necessary for the use of this class as a type in canfile + class canister; + + //this object holds the definition of a 'file' within the + //canister 'filesystem.' + class canfile + { + public: + libcanister::canister* parent; //the canister that holds this file + canmem path; //internal path ('filename') + canmem data; //the file's decompressed contents + int isfrag; //0 = probably not fragment, 1 = definitely a fragment (ignore) + int cfid; //'canfile id' -- a unique ID for this file + int64 dsize; //ondisk size (compressed form size) + int cachestate; //0 = not in memory, 1 = in memory, 2 = in memory and needs flush + //-1 = error, check the data for the message + void cache(); //pull the file from disk and cache it in memory + void cachedump(); //deletes the contents of this file from the memory cache after assuring the on disk copy is up to date + void cachedumpfinal(fstream& infile); //same as cachedump, but more efficient during closing procedures + void flush(); //updates the on disk copy, but retains the memory cache + }; + + //the primary class + //this defines and controls a single canister + class canister + { + //table of contents + //absolutely worthless to the control code in the canister + //but quite useful to programs using the API, as they may + //desire to enumerate the files in a canister for a user's + //use or for their own. + //contains a newline-delimited list of files in the container. + canfile TOC; + public: + caninfo info; //the general info about this canister + + //the raw canfiles -- recommended that programs do not modify + //these files directly, but not enforced. + canfile* files; + bool readonly; //if true then no write routines will do anything + + //maximum number of files to have in memory at any given + //time, change this to whatever suits your application. + int cachemax; + int cachecnt; //number of files in the cache (should not be modified) + + //both initialize the canister from a physical location + canister (canmem fspath); + canister (char* fspath); + + //destroys the canister (after flushing the modded buffers, of course) + ~canister(); + + //open the fspath + //does it exist? + // | --- yes --- opening it (return 1) + // | --- yes --- file is corrupted, halting (return -1) + // | --- no --- making a new one (return 0) + int open(); + + //close the canister, flush all buffers, clean up + int close(); + + //deletes the file at path inside this canister + int delFile(canmem path); + + //pulls the contents of the file from disk or memory and returns it as a file + canfile getFile(canmem path); + + //creates a file if it does not exist, otherwise overwrites + //returns whether operation succeeded + bool writeFile(canmem path, canmem data); + bool writeFile(canfile file); + + //get the 'table of contents', a file containing a newline delimited + //list of the file paths in the container which have contents + canfile getTOC(); + + //brings the cache back within the cachemax limit + //important: sCFID is the safe CFID + //(the CFID of the file we want to avoid uncaching) + //really just used internally, but it can't do any harm. + void cacheclean(int sCFID, bool dFlush = false); + }; + +} + +#endif \ No newline at end of file diff --git a/samples/C++/metrics.h b/samples/C++/metrics.h new file mode 100644 index 00000000..b6da859d --- /dev/null +++ b/samples/C++/metrics.h @@ -0,0 +1,92 @@ +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef NINJA_METRICS_H_ +#define NINJA_METRICS_H_ + +#include +#include +using namespace std; + +#include "util.h" // For int64_t. + +/// The Metrics module is used for the debug mode that dumps timing stats of +/// various actions. To use, see METRIC_RECORD below. + +/// A single metrics we're tracking, like "depfile load time". +struct Metric { + string name; + /// Number of times we've hit the code path. + int count; + /// Total time (in micros) we've spent on the code path. + int64_t sum; +}; + + +/// A scoped object for recording a metric across the body of a function. +/// Used by the METRIC_RECORD macro. +struct ScopedMetric { + explicit ScopedMetric(Metric* metric); + ~ScopedMetric(); + +private: + Metric* metric_; + /// Timestamp when the measurement started. + /// Value is platform-dependent. + int64_t start_; +}; + +/// The singleton that stores metrics and prints the report. +struct Metrics { + Metric* NewMetric(const string& name); + + /// Print a summary report to stdout. + void Report(); + +private: + vector metrics_; +}; + +/// Get the current time as relative to some epoch. +/// Epoch varies between platforms; only useful for measuring elapsed time. +int64_t GetTimeMillis(); + +/// A simple stopwatch which returns the time +/// in seconds since Restart() was called. +struct Stopwatch { + public: + Stopwatch() : started_(0) {} + + /// Seconds since Restart() call. + double Elapsed() const { + return 1e-6 * static_cast(Now() - started_); + } + + void Restart() { started_ = Now(); } + + private: + uint64_t started_; + uint64_t Now() const; +}; + +/// The primary interface to metrics. Use METRIC_RECORD("foobar") at the top +/// of a function to get timing stats recorded for each call of the function. +#define METRIC_RECORD(name) \ + static Metric* metrics_h_metric = \ + g_metrics ? g_metrics->NewMetric(name) : NULL; \ + ScopedMetric metrics_h_scoped(metrics_h_metric); + +extern Metrics* g_metrics; + +#endif // NINJA_METRICS_H_ diff --git a/samples/C++/render_adapter.cpp b/samples/C++/render_adapter.cpp new file mode 100644 index 00000000..4a18f6f6 --- /dev/null +++ b/samples/C++/render_adapter.cpp @@ -0,0 +1,6 @@ +#include + +namespace Gui +{ + +} diff --git a/samples/C++/rpc.h b/samples/C++/rpc.h new file mode 100644 index 00000000..ce810992 --- /dev/null +++ b/samples/C++/rpc.h @@ -0,0 +1,26 @@ +// Copyright (C) 2013 Simon Que +// +// This file is part of DuinoCube. +// +// DuinoCube is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// DuinoCube is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with DuinoCube. If not, see . + +// DuinoCube remote procedure call functions. + +#include + +// Initializes RPC system. +void rpc_init(); + +// Runs the RPC server loop forever. +void rpc_server_loop(); diff --git a/samples/C/bootstrap.h b/samples/C/bootstrap.h new file mode 100644 index 00000000..8c29de82 --- /dev/null +++ b/samples/C/bootstrap.h @@ -0,0 +1,102 @@ +#ifndef BOOTSTRAP_H +#define BOOTSTRAP_H + +#include +#include "cxrs.h" + +/* If we're not using GNU C, elide __attribute__ */ +#ifndef __GNUC__ +# define __attribute__(x) /*NOTHING*/ +#endif + +typedef struct object object; + +object *true; +object *false; +object *eof; +object *empty_list; +object *global_enviroment; + +enum obj_type { + scm_bool, + scm_empty_list, + scm_eof, + scm_char, + scm_int, + scm_pair, + scm_symbol, + scm_prim_fun, + scm_lambda, + scm_str, + scm_file +}; + +typedef object *(*prim_proc)(object *args); + +object *read(FILE *in); +object *eval(object *code, object *env); +void print(FILE *out, object *obj, int display); + +int check_type(enum obj_type type, object *obj, int err_on_false); + +static inline int is_true(object *obj) +{ + return obj != false; +} + +object *make_int(int value); +int obj2int(object *i); + +object *make_bool(int value); +int obj2bool(object *b); + +object *make_char(char c); +char obj2char(object *ch); + +object *make_str(char *str); +char *obj2str(object *str); + +object *cons(object *car, object *cdr); +object *car(object *pair); +object *cdr(object *pair); +void set_car(object *pair, object *new); +void set_cdr(object *pair, object *new); + +object *make_symbol(char *name); +char *sym2str(object *sym); +object *get_symbol(char *name) __attribute__((pure)); + +object *make_prim_fun(prim_proc fun); +prim_proc obj2prim_proc(object *proc); + +object *make_lambda(object *args, object *code, object *env); +object *lambda_code(object *lambda); +object *lambda_args(object *lambda); + +object *make_port(FILE *handle, int direction); +int port_direction(object *port); +FILE *port_handle(object *port); +void set_port_handle_to_null(object *port); + +/*both of these should never be called*/ +object *apply_proc(object *); +object *eval_proc(object *); + + +object *maybe_add_begin(object *code); + +void init_enviroment(object *env); + + +void eval_err(char *msg, object *code) __attribute__((noreturn)); + +void define_var(object *var, object *val, object *env); +void set_var(object *var, object *val, object *env); +object *get_var(object *var, object *env); + +object *cond2nested_if(object *cond); +object *let2lambda(object *let); +object *and2nested_if(object *and); +object *or2nested_if(object *or); + +#endif /*include guard*/ diff --git a/samples/C/dynarray.cats b/samples/C/dynarray.cats new file mode 100644 index 00000000..95ee54ba --- /dev/null +++ b/samples/C/dynarray.cats @@ -0,0 +1,56 @@ +/* ******************************************************************* */ +/* */ +/* Applied Type System */ +/* */ +/* ******************************************************************* */ + +/* +** ATS/Postiats - Unleashing the Potential of Types! +** Copyright (C) 2011-20?? Hongwei Xi, ATS Trustful Software, Inc. +** All rights reserved +** +** ATS is free software; you can redistribute it and/or modify it under +** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the +** Free Software Foundation; either version 3, or (at your option) any +** later version. +** +** ATS 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 ATS; see the file COPYING. If not, please write to the +** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA +** 02110-1301, USA. +*/ + +/* ****** ****** */ + +/* +(* Author: Hongwei Xi *) +(* Authoremail: hwxi AT cs DOT bu DOT edu *) +(* Start time: March, 2013 *) +*/ + +/* ****** ****** */ + +#ifndef ATSHOME_LIBATS_DYNARRAY_CATS +#define ATSHOME_LIBATS_DYNARRAY_CATS + +/* ****** ****** */ + +#include + +/* ****** ****** */ + +#define atslib_dynarray_memcpy memcpy +#define atslib_dynarray_memmove memmove + +/* ****** ****** */ + +#endif // ifndef ATSHOME_LIBATS_DYNARRAY_CATS + +/* ****** ****** */ + +/* end of [dynarray.cats] */ diff --git a/samples/C/jni_layer.h b/samples/C/jni_layer.h new file mode 100644 index 00000000..ededf805 --- /dev/null +++ b/samples/C/jni_layer.h @@ -0,0 +1,61 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class jni_JniLayer */ + +#ifndef _Included_jni_JniLayer +#define _Included_jni_JniLayer +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: jni_JniLayer + * Method: jni_layer_initialize + * Signature: ([II)J + */ +JNIEXPORT jlong JNICALL Java_jni_JniLayer_jni_1layer_1initialize + (JNIEnv *, jobject, jintArray, jint, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_mainloop + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1mainloop + (JNIEnv *, jobject, jlong); + +/* + * Class: jni_JniLayer + * Method: jni_layer_set_button + * Signature: (JII)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1button + (JNIEnv *, jobject, jlong, jint, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_set_analog + * Signature: (JIIF)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1set_1analog + (JNIEnv *, jobject, jlong, jint, jint, jfloat); + +/* + * Class: jni_JniLayer + * Method: jni_layer_report_analog_chg + * Signature: (JI)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1report_1analog_1chg + (JNIEnv *, jobject, jlong, jint); + +/* + * Class: jni_JniLayer + * Method: jni_layer_kill + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jni_JniLayer_jni_1layer_1kill + (JNIEnv *, jobject, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/samples/C/readline.cats b/samples/C/readline.cats new file mode 100644 index 00000000..3fad326b --- /dev/null +++ b/samples/C/readline.cats @@ -0,0 +1,47 @@ +/* +** API in ATS for GNU-readline +*/ + +/* ****** ****** */ + +/* +** Permission to use, copy, modify, and distribute this software for any +** purpose with or without fee is hereby granted, provided that the above +** copyright notice and this permission notice appear in all copies. +** +** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +** ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +** WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +** ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ + +/* ****** ****** */ + +#ifndef READLINE_READLINE_CATS +#define READLINE_READLINE_CATS + +/* ****** ****** */ + +#include + +/* ****** ****** */ +// +#define \ +atscntrb_readline_rl_library_version() ((char*)rl_library_version) +// +#define atscntrb_readline_rl_readline_version() (rl_readline_version) +// +/* ****** ****** */ + +#define atscntrb_readline_readline readline + +/* ****** ****** */ + +#endif // ifndef READLINE_READLINE_CATS + +/* ****** ****** */ + +/* end of [readline.cats] */ diff --git a/samples/C/syscalldefs.h b/samples/C/syscalldefs.h new file mode 100644 index 00000000..a29c867e --- /dev/null +++ b/samples/C/syscalldefs.h @@ -0,0 +1,5 @@ +static const syscalldef syscalldefs[] = { + [SYSCALL_OR_NUM(0, SYS_restart_syscall)] = MAKE_UINT16(0, 1), + [SYSCALL_OR_NUM(1, SYS_exit)] = MAKE_UINT16(1, 17), + [SYSCALL_OR_NUM(2, SYS_fork)] = MAKE_UINT16(0, 22), +}; diff --git a/samples/Cirru/array.cirru b/samples/Cirru/array.cirru new file mode 100644 index 00000000..9375c650 --- /dev/null +++ b/samples/Cirru/array.cirru @@ -0,0 +1,12 @@ + +print $ array + int 1 + string 2 + +print $ array + int 1 + array + int 2 + string 3 + array + string 4 \ No newline at end of file diff --git a/samples/Cirru/block.cirru b/samples/Cirru/block.cirru new file mode 100644 index 00000000..a9bf0c83 --- /dev/null +++ b/samples/Cirru/block.cirru @@ -0,0 +1,7 @@ + +set f $ block (a b c) + print a b c + +call f (int 1) (int 2) (int 3) + +f (int 1) (int 2) (int 3) \ No newline at end of file diff --git a/samples/Cirru/bool.cirru b/samples/Cirru/bool.cirru new file mode 100644 index 00000000..686d132e --- /dev/null +++ b/samples/Cirru/bool.cirru @@ -0,0 +1,7 @@ + +print $ bool true +print $ bool false +print $ bool yes +print $ bool no +print $ bool 1 +print $ bool 0 \ No newline at end of file diff --git a/samples/Cirru/map.cirru b/samples/Cirru/map.cirru new file mode 100644 index 00000000..5f445668 --- /dev/null +++ b/samples/Cirru/map.cirru @@ -0,0 +1,14 @@ + +print $ map + a $ int 5 + b $ array (int 1) (int 2) + c $ map + int 1 + array (int 4) + +set m $ map + a $ int 1 + +set m b $ int 2 + +print m \ No newline at end of file diff --git a/samples/Cirru/number.cirru b/samples/Cirru/number.cirru new file mode 100644 index 00000000..56e0ac7d --- /dev/null +++ b/samples/Cirru/number.cirru @@ -0,0 +1,3 @@ + +print $ int 1 +print $ float 1.2 \ No newline at end of file diff --git a/samples/Cirru/require.cirru b/samples/Cirru/require.cirru new file mode 100644 index 00000000..53283468 --- /dev/null +++ b/samples/Cirru/require.cirru @@ -0,0 +1,2 @@ + +require ./stdio.cr diff --git a/samples/Cirru/scope.cirru b/samples/Cirru/scope.cirru new file mode 100644 index 00000000..9a6512c9 --- /dev/null +++ b/samples/Cirru/scope.cirru @@ -0,0 +1,23 @@ + +set a (int 2) + +print (self) + +set c (child) + +under c + under parent + print a + +print $ get c a + +set c x (int 3) +print $ get c x + +set just-print $ code + print a + +print just-print + +eval (self) just-print +eval just-print \ No newline at end of file diff --git a/samples/Cirru/stdio.cirru b/samples/Cirru/stdio.cirru new file mode 100644 index 00000000..ef5400e6 --- /dev/null +++ b/samples/Cirru/stdio.cirru @@ -0,0 +1,55 @@ + +set a $ string 1 +print a + +print (string 1) + +print nothing + +print + map + a (int 4) + b $ map + a $ int 5 + b $ int 6 + c $ map + int 7 + +print + array + int 1 + int 2 + array + int 3 + int 4 + +print + array + int 1 + map + a $ int 2 + b $ array + int 3 + +print + int 1 + int 2 + +print $ code + set a 1 + print (get a) + print $ array + int a + array + int a + +set container (map) +set container code $ code + set a 1 + print (get a) + print $ array + int a + array + int a + +print container \ No newline at end of file diff --git a/samples/Cirru/string.cirru b/samples/Cirru/string.cirru new file mode 100644 index 00000000..d4c4331b --- /dev/null +++ b/samples/Cirru/string.cirru @@ -0,0 +1,3 @@ + +print $ string a +print $ string "a b" \ No newline at end of file diff --git a/samples/Clojure/for.clj b/samples/Clojure/for.clj new file mode 100644 index 00000000..725f7b2d --- /dev/null +++ b/samples/Clojure/for.clj @@ -0,0 +1,17 @@ +(defn prime? [n] + (not-any? zero? (map #(rem n %) (range 2 n)))) + +(range 3 33 2) +'(3 5 7 9 11 13 15 17 19 21 23 25 27 29 31) + +;; :when continues through the collection even if some have the +;; condition evaluate to false, like filter +(for [x (range 3 33 2) :when (prime? x)] + x) +'(3 5 7 11 13 17 19 23 29 31) + +;; :while stops at the first collection element that evaluates to +;; false, like take-while +(for [x (range 3 33 2) :while (prime? x)] + x) +'(3 5 7) diff --git a/samples/Clojure/hiccup.hic b/samples/Clojure/hiccup.hic new file mode 100644 index 00000000..318f03da --- /dev/null +++ b/samples/Clojure/hiccup.hic @@ -0,0 +1,8 @@ +[:html + [:head + [:meta {:charset "utf-8"}] + [:link {:rel "stylesheet" :href "css/bootstrap.min.css"}] + [:script {:src "app.js"}]] + [:body + [:div.nav + [:p "Hello world!"]]]] diff --git a/samples/Clojure/into-array.cljc b/samples/Clojure/into-array.cljc new file mode 100644 index 00000000..a1c9fa29 --- /dev/null +++ b/samples/Clojure/into-array.cljc @@ -0,0 +1,13 @@ +(defn into-array + ([aseq] + (into-array nil aseq)) + ([type aseq] + (let [n (count aseq) + a (make-array n)] + (loop [aseq (seq aseq) + i 0] + (if (< i n) + (do + (aset a i (first aseq)) + (recur (next aseq) (inc i))) + a))))) diff --git a/samples/Clojure/protocol.cljs b/samples/Clojure/protocol.cljs new file mode 100644 index 00000000..5496ac0c --- /dev/null +++ b/samples/Clojure/protocol.cljs @@ -0,0 +1,15 @@ +(defprotocol ISound (sound [])) + +(deftype Cat [] + ISound + (sound [_] "Meow!")) + +(deftype Dog [] + ISound + (sound [_] "Woof!")) + +(extend-type default + ISound + (sound [_] "... silence ...")) + +(sound 1) ;; => "... silence ..." diff --git a/samples/Clojure/rand.cljscm b/samples/Clojure/rand.cljscm new file mode 100644 index 00000000..ca07579d --- /dev/null +++ b/samples/Clojure/rand.cljscm @@ -0,0 +1,5 @@ +(defn rand + "Returns a random floating point number between 0 (inclusive) and + n (default 1) (exclusive)." + ([] (scm* [n] (random-real))) + ([n] (* (rand) n))) \ No newline at end of file diff --git a/samples/Clojure/svg.cljx b/samples/Clojure/svg.cljx new file mode 100644 index 00000000..dd2206d4 --- /dev/null +++ b/samples/Clojure/svg.cljx @@ -0,0 +1,20 @@ +^:clj (ns c2.svg + (:use [c2.core :only [unify]] + [c2.maths :only [Pi Tau radians-per-degree + sin cos mean]])) + +^:cljs (ns c2.svg + (:use [c2.core :only [unify]] + [c2.maths :only [Pi Tau radians-per-degree + sin cos mean]]) + (:require [c2.dom :as dom])) + +;;Stub for float fn, which does not exist on cljs runtime +^:cljs (def float identity) + +(defn ->xy + "Convert coordinates (potentially map of `{:x :y}`) to 2-vector." + [coordinates] + (cond + (and (vector? coordinates) (= 2 (count coordinates))) coordinates + (map? coordinates) [(:x coordinates) (:y coordinates)])) diff --git a/samples/Clojure/unit-test.cl2 b/samples/Clojure/unit-test.cl2 new file mode 100644 index 00000000..bac21586 --- /dev/null +++ b/samples/Clojure/unit-test.cl2 @@ -0,0 +1,20 @@ +(deftest function-tests + (is (= 3 + (count [1 2 3]))) + (is (= false + (not true))) + (is (= true + (contains? {:foo 1 :bar 2} :foo))) + + (is (= {"foo" 1, "baz" 3} + (select-keys {:foo 1 :bar 2 :baz 3} [:foo :baz]))) + + (is (= [1 2 3] + (vals {:foo 1 :bar 2 :baz 3}))) + + (is (= ["foo" "bar" "baz"] + (keys {:foo 1 :bar 2 :baz 3}))) + + (is (= [2 4 6] + (filter (fn [x] (=== (rem x 2) 0)) [1 2 3 4 5 6])))) + diff --git a/samples/Common Lisp/sample.lisp b/samples/Common Lisp/sample.lisp new file mode 100644 index 00000000..9bef6781 --- /dev/null +++ b/samples/Common Lisp/sample.lisp @@ -0,0 +1,21 @@ +;;;; -*- lisp -*- + +(in-package :foo) + +;;; Header comment. +(defvar *foo*) + +(eval-when (:execute :compile-toplevel :load-toplevel) + (defun add (x &optional y &key z) + (declare (ignore z)) + ;; Inline comment. + (+ x (or y 1)))) + +#| +Multi-line comment. +|# + +(defmacro foo (x &body b) + (if x + `(1+ ,x) ;After-line comment. + 42)) diff --git a/samples/Creole/creole.creole b/samples/Creole/creole.creole new file mode 100644 index 00000000..7e3b8bef --- /dev/null +++ b/samples/Creole/creole.creole @@ -0,0 +1,47 @@ += Creole + +Creole is a Creole-to-HTML converter for Creole, the lightweight markup +language (http://wikicreole.org/). Github uses this converter to render *.creole files. + +Project page on github: + +* http://github.com/minad/creole + +Travis-CI: + +* https://travis-ci.org/minad/creole + +RDOC: + +* http://rdoc.info/projects/minad/creole + +== INSTALLATION + +{{{ +gem install creole +}}} + +== SYNOPSIS + +{{{ +require 'creole' +html = Creole.creolize('== Creole text') +}}} + +== BUGS + +If you found a bug, please report it at the Creole project's tracker +on GitHub: + +http://github.com/minad/creole/issues + +== AUTHORS + +* Lars Christensen (larsch) +* Daniel Mendler (minad) + +== LICENSE + +Creole is Copyright (c) 2008 - 2013 Lars Christensen, Daniel Mendler. It is free software, and +may be redistributed under the terms specified in the README file of +the Ruby distribution. diff --git a/samples/Cuda/scalarProd_kernel.cuh b/samples/Cuda/scalarProd_kernel.cuh new file mode 100644 index 00000000..7622c597 --- /dev/null +++ b/samples/Cuda/scalarProd_kernel.cuh @@ -0,0 +1,52 @@ +__global__ void scalarProdGPU( + float *d_C, + float *d_A, + float *d_B, + int vectorN, + int elementN +) +{ + //Accumulators cache + __shared__ float accumResult[ACCUM_N]; + + //////////////////////////////////////////////////////////////////////////// + // Cycle through every pair of vectors, + // taking into account that vector counts can be different + // from total number of thread blocks + //////////////////////////////////////////////////////////////////////////// + for (int vec = blockIdx.x; vec < vectorN; vec += gridDim.x) + { + int vectorBase = IMUL(elementN, vec); + int vectorEnd = vectorBase + elementN; + + //////////////////////////////////////////////////////////////////////// + // Each accumulator cycles through vectors with + // stride equal to number of total number of accumulators ACCUM_N + // At this stage ACCUM_N is only preferred be a multiple of warp size + // to meet memory coalescing alignment constraints. + //////////////////////////////////////////////////////////////////////// + for (int iAccum = threadIdx.x; iAccum < ACCUM_N; iAccum += blockDim.x) + { + float sum = 0; + + for (int pos = vectorBase + iAccum; pos < vectorEnd; pos += ACCUM_N) + sum += d_A[pos] * d_B[pos]; + + accumResult[iAccum] = sum; + } + + //////////////////////////////////////////////////////////////////////// + // Perform tree-like reduction of accumulators' results. + // ACCUM_N has to be power of two at this stage + //////////////////////////////////////////////////////////////////////// + for (int stride = ACCUM_N / 2; stride > 0; stride >>= 1) + { + __syncthreads(); + + for (int iAccum = threadIdx.x; iAccum < stride; iAccum += blockDim.x) + accumResult[iAccum] += accumResult[stride + iAccum]; + } + + if (threadIdx.x == 0) d_C[vec] = accumResult[0]; + } +} \ No newline at end of file diff --git a/samples/Cuda/vectorAdd.cu b/samples/Cuda/vectorAdd.cu new file mode 100644 index 00000000..cdc21dff --- /dev/null +++ b/samples/Cuda/vectorAdd.cu @@ -0,0 +1,46 @@ +#include +#include + +/** + * CUDA Kernel Device code + * + * Computes the vector addition of A and B into C. The 3 vectors have the same + * number of elements numElements. + */ +__global__ void +vectorAdd(const float *A, const float *B, float *C, int numElements) +{ + int i = blockDim.x * blockIdx.x + threadIdx.x; + + if (i < numElements) + { + C[i] = A[i] + B[i]; + } +} + +/** + * Host main routine + */ +int +main(void) +{ + // Error code to check return values for CUDA calls + cudaError_t err = cudaSuccess; + + // Launch the Vector Add CUDA Kernel + int threadsPerBlock = 256; + int blocksPerGrid =(numElements + threadsPerBlock - 1) / threadsPerBlock; + vectorAdd<<>>(d_A, d_B, d_C, numElements); + err = cudaGetLastError(); + + if (err != cudaSuccess) + { + fprintf(stderr, "Failed to launch vectorAdd kernel (error code %s)!\n", cudaGetErrorString(err)); + exit(EXIT_FAILURE); + } + + // Reset the device and exit + err = cudaDeviceReset(); + + return 0; +} \ No newline at end of file diff --git a/samples/DM/example.dm b/samples/DM/example.dm new file mode 100644 index 00000000..b8f1fad4 --- /dev/null +++ b/samples/DM/example.dm @@ -0,0 +1,87 @@ +// This is a single line comment. +/* + This is a multi-line comment +*/ + +// Pre-processor keywords + +#define PI 3.1415 + +#if PI == 4 + +#define G 5 + +#elif PI == 3 + +#define I 6 + +#else + +#define K 7 + +#endif + + +var/GlobalCounter = 0 +var/const/CONST_VARIABLE = 2 +var/list/MyList = list("anything", 1, new /datum/entity) +var/list/EmptyList[99] // creates a list of 99 null entries +var/list/NullList = null + +/* + Entity Class +*/ + +/datum/entity + var/name = "Entity" + var/number = 0 + +/datum/entity/proc/myFunction() + world.log << "Entity has called myFunction" + +/datum/entity/New() + number = GlobalCounter++ + +/* + Unit Class, Extends from Entity +*/ + +/datum/entity/unit + name = "Unit" + +/datum/entity/unit/New() + ..() // calls the parent's proc; equal to super() and base() in other languages + number = rand(1, 99) + +/datum/entity/unit/myFunction() + world.log << "Unit has overriden and called myFunction" + +// Global Function +/proc/ReverseList(var/list/input) + var/list/output = list() + for(var/i = input.len; i >= 1; i--) // IMPORTANT: List Arrays count from 1. + output += input[i] // "+= x" is ".Add(x)" + return output + +// Bitflags +/proc/DoStuff() + var/bitflag = 0 + bitflag |= 8 + return bitflag + +/proc/DoOtherStuff() + var/bitflag = 65535 // 16 bits is the maximum amount + bitflag &= ~8 + return bitflag + +// Logic +/proc/DoNothing() + var/pi = PI + if(pi == 4) + world.log << "PI is 4" + else if(pi == CONST_VARIABLE) + world.log << "PI is [CONST_VARIABLE]!" + else + world.log << "PI is approximety [pi]" + +#undef PI // Undefine PI \ No newline at end of file diff --git a/samples/Dart/point.dart b/samples/Dart/point.dart index 5bb74b29..ee91239b 100644 --- a/samples/Dart/point.dart +++ b/samples/Dart/point.dart @@ -1,15 +1,19 @@ +import 'dart:math' as math; + class Point { + num x, y; + Point(this.x, this.y); - distanceTo(Point other) { + + num distanceTo(Point other) { var dx = x - other.x; var dy = y - other.y; - return Math.sqrt(dx * dx + dy * dy); + return math.sqrt(dx * dx + dy * dy); } - var x, y; } -main() { - Point p = new Point(2, 3); - Point q = new Point(3, 4); +void main() { + var p = new Point(2, 3); + var q = new Point(3, 4); print('distance from p to q = ${p.distanceTo(q)}'); } 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/Ecl/sample.ecl b/samples/ECL/sample.ecl similarity index 100% rename from samples/Ecl/sample.ecl rename to samples/ECL/sample.ecl 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/Gosu/hello.gsp b/samples/Gosu/hello.gsp deleted file mode 100644 index ce47b771..00000000 --- a/samples/Gosu/hello.gsp +++ /dev/null @@ -1 +0,0 @@ -print("hello") \ No newline at end of file diff --git a/samples/Hy/fibonacci.hy b/samples/Hy/fibonacci.hy new file mode 100644 index 00000000..9ccdd76c --- /dev/null +++ b/samples/Hy/fibonacci.hy @@ -0,0 +1,9 @@ +;; Fibonacci example in Hy. + +(defn fib [n] + (if (<= n 2) n + (+ (fib (- n 1)) (fib (- n 2))))) + +(if (= __name__ "__main__") + (for [x [1 2 3 4 5 6 7 8]] + (print (fib x)))) diff --git a/samples/Hy/hello-world.hy b/samples/Hy/hello-world.hy new file mode 100644 index 00000000..181095e1 --- /dev/null +++ b/samples/Hy/hello-world.hy @@ -0,0 +1,13 @@ +;; The concurrent.futures example in Hy. + +(import [concurrent.futures [ThreadPoolExecutor as-completed]] + [random [randint]] + [sh [sleep]]) + +(defn task-to-do [] + (sleep (randint 1 5))) + +(with-as (ThreadPoolExecutor 10) executor + (setv jobs (list-comp (.submit executor task-to-do) (x (range 0 10)))) + (for (future (as-completed jobs)) + (.result future))) diff --git a/samples/IDL/mg_acosh.pro b/samples/IDL/mg_acosh.pro new file mode 100644 index 00000000..1510f09f --- /dev/null +++ b/samples/IDL/mg_acosh.pro @@ -0,0 +1,29 @@ +; docformat = 'rst' + +;+ +; Inverse hyperbolic cosine. Uses the formula: +; +; $$\text{acosh}(z) = \ln(z + \sqrt{z + 1} \sqrt{z - 1})$$ +; +; :Examples: +; The arc hyperbolic sine function looks like:: +; +; IDL> x = 2.5 * findgen(1000) / 999. + 1. +; IDL> plot, x, mg_acosh(x), xstyle=1 +; +; This should look like: +; +; .. image:: acosh.png +; +; :Returns: +; float, double, complex, or double complex depending on the input +; +; :Params: +; z : in, required, type=numeric +; input +;- +function mg_acosh, z + compile_opt strictarr + + return, alog(z + sqrt(z + 1) * sqrt(z - 1)) +end \ No newline at end of file diff --git a/samples/IDL/mg_analysis.dlm b/samples/IDL/mg_analysis.dlm new file mode 100644 index 00000000..6cb7881f --- /dev/null +++ b/samples/IDL/mg_analysis.dlm @@ -0,0 +1,9 @@ +MODULE mg_analysis +DESCRIPTION Tools for analysis +VERSION 1.0 +SOURCE mgalloy +BUILD_DATE January 18, 2011 + +FUNCTION MG_ARRAY_EQUAL 2 2 KEYWORDS +FUNCTION MG_TOTAL 1 1 + diff --git a/samples/IDL/mg_gcd.pro b/samples/IDL/mg_gcd.pro new file mode 100644 index 00000000..2287723f --- /dev/null +++ b/samples/IDL/mg_gcd.pro @@ -0,0 +1,35 @@ +; docformat = 'rst' + +;+ +; Find the greatest common denominator (GCD) for two positive integers. +; +; :Returns: +; integer +; +; :Params: +; a : in, required, type=integer +; first integer +; b : in, required, type=integer +; second integer +;- +function mg_gcd, a, b + compile_opt strictarr + on_error, 2 + + if (n_params() ne 2) then message, 'incorrect number of arguments' + if (~mg_isinteger(a) || ~mg_isinteger(b)) then begin + message, 'integer arguments required' + endif + + _a = abs(a) + _b = abs(b) + minArg = _a < _b + maxArg = _a > _b + + if (minArg eq 0) then return, maxArg + + remainder = maxArg mod minArg + if (remainder eq 0) then return, minArg + + return, mg_gcd(minArg, remainder) +end diff --git a/samples/IDL/mg_trunc.pro b/samples/IDL/mg_trunc.pro new file mode 100644 index 00000000..c5288908 --- /dev/null +++ b/samples/IDL/mg_trunc.pro @@ -0,0 +1,42 @@ +; docformat = 'rst' + +;+ +; Truncate argument towards 0.0, i.e., takes the `FLOOR` of positive values +; and the `CEIL` of negative values. +; +; :Examples: +; Try the main-level program at the end of this file. It does:: +; +; IDL> print, mg_trunc([1.2, -1.2, 0.0]) +; 1 -1 0 +; IDL> print, floor([1.2, -1.2, 0.0]) +; 1 -2 0 +; IDL> print, ceil([1.2, -1.2, 0.0]) +; 2 -1 0 +; +; :Returns: +; array of same type as argument +; +; :Params: +; x : in, required, type=float/double +; array containing values to truncate +;- +function mg_trunc, x + compile_opt strictarr + + result = ceil(x) + posInd = where(x gt 0, nposInd) + + if (nposInd gt 0L) then begin + result[posInd] = floor(x[posInd]) + endif + + return, result +end + + +; main-level example program + +print, mg_trunc([1.2, -1.2, 0.0]) + +end diff --git a/samples/Idris/Chars.idr b/samples/Idris/Chars.idr new file mode 100644 index 00000000..7e3e3e86 --- /dev/null +++ b/samples/Idris/Chars.idr @@ -0,0 +1,42 @@ +module Prelude.Char + +import Builtins + +isUpper : Char -> Bool +isUpper x = x >= 'A' && x <= 'Z' + +isLower : Char -> Bool +isLower x = x >= 'a' && x <= 'z' + +isAlpha : Char -> Bool +isAlpha x = isUpper x || isLower x + +isDigit : Char -> Bool +isDigit x = (x >= '0' && x <= '9') + +isAlphaNum : Char -> Bool +isAlphaNum x = isDigit x || isAlpha x + +isSpace : Char -> Bool +isSpace x = x == ' ' || x == '\t' || x == '\r' || + x == '\n' || x == '\f' || x == '\v' || + x == '\xa0' + +isNL : Char -> Bool +isNL x = x == '\r' || x == '\n' + +toUpper : Char -> Char +toUpper x = if (isLower x) + then (prim__intToChar (prim__charToInt x - 32)) + else x + +toLower : Char -> Char +toLower x = if (isUpper x) + then (prim__intToChar (prim__charToInt x + 32)) + else x + +isHexDigit : Char -> Bool +isHexDigit x = elem (toUpper x) hexChars where + hexChars : List Char + hexChars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F'] diff --git a/samples/JSON/composer.lock b/samples/JSON/composer.lock new file mode 100644 index 00000000..09323450 --- /dev/null +++ b/samples/JSON/composer.lock @@ -0,0 +1,267 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" + ], + "hash": "d8ff8fcb71824f5199f3499bf71862f1", + "packages": [ + { + "name": "arbit/system-process", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/Arbitracker/system-process.git", + "reference": "1.0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Arbitracker/system-process/zipball/1.0", + "reference": "1.0", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "SystemProcess": "src/main/php/" + } + }, + "notification-url": "http://packagist.org/downloads/", + "description": "System process execution library", + "time": "2013-03-31 12:42:56" + }, + { + "name": "pdepend/staticReflection", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/manuelpichler/staticReflection.git", + "reference": "origin/master" + }, + "type": "library" + }, + { + "name": "qafoo/rmf", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Qafoo/REST-Micro-Framework.git", + "reference": "5f43983f15a8aa12be42ad6068675d4008bfb9ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Qafoo/REST-Micro-Framework/zipball/5f43983f15a8aa12be42ad6068675d4008bfb9ed", + "reference": "5f43983f15a8aa12be42ad6068675d4008bfb9ed", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "Qafoo\\RMF": "src/main/" + } + }, + "description": "Very simple VC framework which makes it easy to build HTTP applications / REST webservices", + "support": { + "source": "https://github.com/Qafoo/REST-Micro-Framework/tree/master", + "issues": "https://github.com/Qafoo/REST-Micro-Framework/issues" + }, + "time": "2012-12-07 13:33:01" + }, + { + "name": "twig/twig", + "version": "1.6.0", + "source": { + "type": "git", + "url": "git://github.com/fabpot/Twig.git", + "reference": "v1.6.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/fabpot/Twig/zipball/v1.6.0", + "reference": "v1.6.0", + "shasum": "" + }, + "require": { + "php": ">=5.2.4" + }, + "type": "library", + "autoload": { + "psr-0": { + "Twig_": "lib/" + } + }, + "license": [ + "BSD" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "http://twig.sensiolabs.org", + "keywords": [ + "templating" + ], + "time": "2012-02-03 23:34:52" + }, + { + "name": "twitter/bootstrap", + "version": "0.1", + "source": { + "type": "git", + "url": "https://github.com/twitter/bootstrap/", + "reference": "origin/master" + }, + "type": "library" + }, + { + "name": "zetacomponents/base", + "version": "1.8", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Base.git", + "reference": "1.8" + }, + "dist": { + "type": "zip", + "url": "https://github.com/zetacomponents/Base/zipball/1.8", + "reference": "1.8", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "license": [ + "apache2" + ], + "authors": [ + { + "name": "Sergey Alexeev" + }, + { + "name": "Sebastian Bergmann" + }, + { + "name": "Jan Borsodi" + }, + { + "name": "Raymond Bosman" + }, + { + "name": "Frederik Holljen" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Vadym Savchuk" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + } + ], + "description": "The Base package provides the basic infrastructure that all packages rely on. Therefore every component relies on this package.", + "homepage": "https://github.com/zetacomponents", + "time": "2009-12-21 04:14:16" + }, + { + "name": "zetacomponents/graph", + "version": "1.5", + "source": { + "type": "git", + "url": "https://github.com/zetacomponents/Graph.git", + "reference": "1.5" + }, + "dist": { + "type": "zip", + "url": "https://github.com/zetacomponents/Graph/zipball/1.5", + "reference": "1.5", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src" + ] + }, + "license": [ + "apache2" + ], + "authors": [ + { + "name": "Sergey Alexeev" + }, + { + "name": "Sebastian Bergmann" + }, + { + "name": "Jan Borsodi" + }, + { + "name": "Raymond Bosman" + }, + { + "name": "Frederik Holljen" + }, + { + "name": "Kore Nordmann" + }, + { + "name": "Derick Rethans" + }, + { + "name": "Vadym Savchuk" + }, + { + "name": "Tobias Schlitt" + }, + { + "name": "Alexandru Stanoi" + }, + { + "name": "Lars Jankowski" + }, + { + "name": "Elger Thiele" + }, + { + "name": "Michael Maclean" + } + ], + "description": "A component for creating pie charts, line graphs and other kinds of diagrams.", + "homepage": "https://github.com/zetacomponents", + "time": "2009-12-21 04:26:17" + } + ], + "packages-dev": [ + + ], + "aliases": [ + + ], + "minimum-stability": "stable", + "stability-flags": { + "qafoo/rmf": 20, + "arbit/system-process": 0 + }, + "platform": [ + + ], + "platform-dev": [ + + ] +} diff --git a/samples/JSON5/example.json5 b/samples/JSON5/example.json5 new file mode 100644 index 00000000..95f12408 --- /dev/null +++ b/samples/JSON5/example.json5 @@ -0,0 +1,29 @@ +/* + * The following is a contrived example, but it illustrates most of the features: + */ + +{ + foo: 'bar', + while: true, + + this: 'is a \ +multi-line string', + + // this is an inline comment + here: 'is another', // inline comment + + /* this is a block comment + that continues on another line */ + + hex: 0xDEADbeef, + half: .5, + delta: +10, + to: Infinity, // and beyond! + + finally: 'a trailing comma', + oh: [ + "we shouldn't forget", + 'arrays can have', + 'trailing commas too', + ], +} diff --git a/samples/JSON5/package.json5 b/samples/JSON5/package.json5 new file mode 100644 index 00000000..9e52ed24 --- /dev/null +++ b/samples/JSON5/package.json5 @@ -0,0 +1,28 @@ +// This file is written in JSON5 syntax, naturally, but npm needs a regular +// JSON file, so compile via `npm run build`. Be sure to keep both in sync! + +{ + name: 'json5', + version: '0.2.0', + description: 'JSON for the ES5 era.', + keywords: ['json', 'es5'], + author: 'Aseem Kishore ', + contributors: [ + 'Max Nanasy ', + ], + main: 'lib/json5.js', + bin: 'lib/cli.js', + dependencies: {}, + devDependencies: { + mocha: '~1.0.3', + }, + scripts: { + build: './lib/cli.js -c package.json5', + test: 'mocha --ui exports --reporter spec', + }, + homepage: 'http://json5.org/', + repository: { + type: 'git', + url: 'https://github.com/aseemk/json5.git', + }, +} diff --git a/samples/JSONLD/sample.jsonld b/samples/JSONLD/sample.jsonld new file mode 100644 index 00000000..dbae017a --- /dev/null +++ b/samples/JSONLD/sample.jsonld @@ -0,0 +1,30 @@ +{ + "@context": { + "property": "http://example.com/vocab#property" + }, + "@id": "../document-relative", + "@type": "#document-relative", + "property": { + "@context": { + "@base": "http://example.org/test/" + }, + "@id": "../document-base-overwritten", + "@type": "#document-base-overwritten", + "property": [ + { + "@context": null, + "@id": "../document-relative", + "@type": "#document-relative", + "property": "context completely reset, drops property" + }, + { + "@context": { + "@base": null + }, + "@id": "../document-relative", + "@type": "#document-relative", + "property": "only @base is cleared" + } + ] + } +} diff --git a/samples/Jade/hello.jade b/samples/Jade/hello.jade new file mode 100644 index 00000000..32c72739 --- /dev/null +++ b/samples/Jade/hello.jade @@ -0,0 +1,3 @@ +p. + Hello, + World! diff --git a/samples/KRL/helloworld.krl b/samples/KRL/helloworld.krl new file mode 100644 index 00000000..0daf048b --- /dev/null +++ b/samples/KRL/helloworld.krl @@ -0,0 +1,15 @@ +ruleset sample { + meta { + name "Hello World" + description << +Hello world +>> + author "Phil Windley" + } + + // just one rule + rule hello { + select when web pageview + notify("Hello world!", "Just a note to say hello"); + } +} diff --git a/samples/Literate Agda/NatCat.lagda b/samples/Literate Agda/NatCat.lagda new file mode 100644 index 00000000..97059356 --- /dev/null +++ b/samples/Literate Agda/NatCat.lagda @@ -0,0 +1,82 @@ +\documentclass{article} + + % The following packages are needed because unicode + % is translated (using the next set of packages) to + % latex commands. You may need more packages if you + % use more unicode characters: + + \usepackage{amssymb} + \usepackage{bbm} + \usepackage[greek,english]{babel} + + % This handles the translation of unicode to latex: + + \usepackage{ucs} + \usepackage[utf8x]{inputenc} + \usepackage{autofe} + + % Some characters that are not automatically defined + % (you figure out by the latex compilation errors you get), + % and you need to define: + + \DeclareUnicodeCharacter{8988}{\ensuremath{\ulcorner}} + \DeclareUnicodeCharacter{8989}{\ensuremath{\urcorner}} + \DeclareUnicodeCharacter{8803}{\ensuremath{\overline{\equiv}}} + + % Add more as you need them (shouldn’t happen often). + + % Using “\newenvironment” to redefine verbatim to + % be called “code” doesn’t always work properly. + % You can more reliably use: + + \usepackage{fancyvrb} + + \DefineVerbatimEnvironment + {code}{Verbatim} + {} % Add fancy options here if you like. + + \begin{document} + + \begin{code} +module NatCat where + +open import Relation.Binary.PropositionalEquality + +-- If you can show that a relation only ever has one inhabitant +-- you get the category laws for free +module + EasyCategory + (obj : Set) + (_⟶_ : obj → obj → Set) + (_∘_ : ∀ {x y z} → x ⟶ y → y ⟶ z → x ⟶ z) + (id : ∀ x → x ⟶ x) + (single-inhabitant : (x y : obj) (r s : x ⟶ y) → r ≡ s) + where + + idʳ : ∀ x y (r : x ⟶ y) → r ∘ id y ≡ r + idʳ x y r = single-inhabitant x y (r ∘ id y) r + + idˡ : ∀ x y (r : x ⟶ y) → id x ∘ r ≡ r + idˡ x y r = single-inhabitant x y (id x ∘ r) r + + ∘-assoc : ∀ w x y z (r : w ⟶ x) (s : x ⟶ y) (t : y ⟶ z) → (r ∘ s) ∘ t ≡ r ∘ (s ∘ t) + ∘-assoc w x y z r s t = single-inhabitant w z ((r ∘ s) ∘ t) (r ∘ (s ∘ t)) + +open import Data.Nat + +same : (x y : ℕ) (r s : x ≤ y) → r ≡ s +same .0 y z≤n z≤n = refl +same .(suc m) .(suc n) (s≤s {m} {n} r) (s≤s s) = cong s≤s (same m n r s) + +≤-trans : ∀ x y z → x ≤ y → y ≤ z → x ≤ z +≤-trans .0 y z z≤n s = z≤n +≤-trans .(suc m) .(suc n) .(suc n₁) (s≤s {m} {n} r) (s≤s {.n} {n₁} s) = s≤s (≤-trans m n n₁ r s) + +≤-refl : ∀ x → x ≤ x +≤-refl zero = z≤n +≤-refl (suc x) = s≤s (≤-refl x) + +module Nat-EasyCategory = EasyCategory ℕ _≤_ (λ {x}{y}{z} → ≤-trans x y z) ≤-refl same + \end{code} + + \end{document} \ No newline at end of file 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/Mask/view.mask b/samples/Mask/view.mask new file mode 100644 index 00000000..521273e6 --- /dev/null +++ b/samples/Mask/view.mask @@ -0,0 +1,61 @@ + +// HTML Elements +header { + + img .logo src='/images/~[currentLogo].png' alt=logo; + + h4 > 'Bar View' + + if (currentUser) { + + .account > + a href='/acount' > + 'Hello, ~[currentUser.username]' + } +} + +.view { + ul { + + // Iteration + for ((user, index) of users) { + + li.user data-id='~[user.id]' { + + // interpolation + .name > '~[ user.username ]' + + // expression + .count > '~[: user.level.toFixed(2) ]' + + // util + /* Localization sample + * lastActivity: "Am {0:dd. MM} war der letzte Eintrag" + */ + .date > '~[ L: "lastActivity", user.date]' + } + } + } + + // Component + :countdownComponent { + input type = text > + :dualbind value='number'; + + button x-signal='click: countdownStart' > 'Start'; + + h5 { + '~[bind: number]' + + :animation x-slot='countdownStart' { + @model > 'transition | scale(0) > scale(1) | 500ms' + @next > 'background-color | red > blue | 2s linear' + } + } + } +} + +footer > :bazCompo { + + 'Component generated at ~[: $u.format($c.date, "HH-mm") ]' +} \ No newline at end of file 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/Matlab/cross_validation.m b/samples/Matlab/cross_validation.m new file mode 100644 index 00000000..034182e5 --- /dev/null +++ b/samples/Matlab/cross_validation.m @@ -0,0 +1,31 @@ +function [ error ] = cross_validation(x,y,hyper_parameter) + + num_data = size(x,1); + + K = 10; + indices = crossvalind('Kfold', num_data, K); + + errors = zeros(K,1); + for i = 1:K + % get indices + test_idx = (indices == i); + train_idx = ~test_idx; + + % get training data + x_train = x(train_idx,:); + y_train = y(train_idx,:); + + % train + w = train(x_train, y_train, hyper_parameter); + + % get test data + x_test = x(test_idx,:); + y_test = y(test_idx,:); + + % calculate error + errors(i) = calc_cost(x_test, y_test, w, hyper_parameter); %calc_error + %errors(i) = calc_error(x_test, y_test, w); + end + + error = mean(errors); +end diff --git a/samples/Matlab/normalize.m b/samples/Matlab/normalize.m new file mode 100644 index 00000000..f4f33493 --- /dev/null +++ b/samples/Matlab/normalize.m @@ -0,0 +1,6 @@ +function [ d, d_mean, d_std ] = normalize( d ) + d_mean = mean(d); + d = d - repmat(d_mean, size(d,1), 1); + d_std = std(d); + d = d./ repmat(d_std, size(d,1), 1); +end diff --git a/samples/JSON/Hello.maxhelp b/samples/Max/Hello.maxhelp similarity index 100% rename from samples/JSON/Hello.maxhelp rename to samples/Max/Hello.maxhelp diff --git a/samples/JSON/Hello.maxpat b/samples/Max/Hello.maxpat similarity index 100% rename from samples/JSON/Hello.maxpat rename to samples/Max/Hello.maxpat diff --git a/samples/MediaWiki/mediawiki.mediawiki b/samples/MediaWiki/mediawiki.mediawiki new file mode 100644 index 00000000..088c955c --- /dev/null +++ b/samples/MediaWiki/mediawiki.mediawiki @@ -0,0 +1,90 @@ + += Overview = + +The GDB Tracepoint Analysis feature is an extension to the Tracing and Monitoring Framework that allows the visualization and analysis of C/C++ tracepoint data collected by GDB and stored to a log file. + += Getting Started = + +The feature can be installed from the Eclipse update site by selecting '''Linux Tools''' > '''GDB Tracepoint Analysis'''. + +The feature requires GDB version 7.2 or later to be installed on the local host. The executable program 'gdb' must be found in the path. + += GDB Trace Perspective = + +To open the perspective, select '''Window''' > '''Open Perspective''' > '''Other...''' > '''GDB Trace'''. + +The perspective includes the following views by default: + +* '''Project Explorer''': This view shows the projects in the workspace and is used to create and manage Tracing projects. +* '''Debug''': This view shows the running C/C++ Postmortem Debugger instances and displays the thread and stack trace associated with a tracepoint. +* '''Trace Control''': This view shows the status of the debugger and allows navigation of trace records. +* '''Console''': This view displays console output of the C/C++ Postmortem Debugger. + +The editor area contains the '''Events''' and '''C/C++''' editors when a GDB Trace is opened. + +[[Image:images/GDBTracePerspective.png]] + += Collecting Tracepoint Data = + +Collecting the C/C++ tracepoint data is outside the scope of this feature. It can be done from the GDB command line or by using the CDT debug component within Eclipse. See the CDT FAQ entry in the [[#References | References]] section. + += Importing Tracepoint Data = + +Some information in this section is redundant with the LTTng User Guide. For further details, see the LTTng User Guide entry in the [[#References | References]] section. + +== Creating a Tracing Project == + +In the '''Project Explorer''' view, right-click and select '''New''' > '''Project...''' from the context menu. In the '''New Project''' dialog, select '''Tracing''' > '''Tracing Project''', click '''Next''', name your project and click '''Finish'''. + +== Importing a GDB Trace == + +In your tracing project, right-click on the '''Traces''' folder and select '''Import...'''. Browse to, or enter, a source directory. Select the trace file in the tree. Optionally set the trace type to '''GDB : GDB Trace'''. Click '''Finish'''. + +Alternatively, the trace can be drag & dropped to the '''Traces''' folder from any external file manager. + +== Selecting the GDB Trace Type == + +Right-click the imported trace in the '''Traces''' folder and choose '''Select Trace Type...''' > '''GDB''' > '''GDB Trace''' from the context menu. This step can be omitted if the trace type was selected at import. + +The trace will be updated with the GDB icon [[Image:images/gdb_icon16.png]]. + +== Selecting the Trace Executable == + +The executable file that created the tracepoint data must be identified so that the C/C++ Postmortem Debugger can be launched properly. + +Right-click the GDB trace in the '''Traces''' folder and choose '''Select Trace Executable...''' from the context menu. Browse to, or enter, the path of the executable file and press '''OK'''. + +The selected file must be recognized by GDB as an executable. + += Visualizing Tracepoint Data = + +== Opening a GDB Trace == + +In the '''Traces''' folder, double-click the GDB trace or right-click it and select '''Open''' from the context menu. + +The tracepoint data will be opened in an Events editor, and a C/C++ Postmortem Debugger instance will be launched. + +If available in the workspace, the source code corresponding to the first trace record will also be opened in a C/C++ editor. + +At this point it is recommended to relocate the Events editor outside of the default editor area, so that it is not hidden by the C/C++ editor. + +== Viewing Trace Data == + +In the Events editor, a table is shown with one row for each trace record. The '''Trace Frame''' column shows the sequential trace record number. The '''Tracepoint''' column shows the number assigned by GDB at collection time for this tracepoint. The '''File''' column shows the file name, line number and method where the tracepoint was set. The '''Content''' column shows the data collected at run-time by the tracepoint. + +Searching and filtering can be done on any column by entering a regular expression in the column header. + +== Navigating the GDB Trace == + +Trace records can be selected in the Events editor using the keyboard or mouse. The C/C++ Postmortem Debugger in the '''Debug''' view will be updated to show the stack trace of the current trace record. + +The trace can also be navigated from the '''Trace Control''' view by clicking the '''Next Trace Record''' or '''Previous Trace Record''' buttons. The Events editor and '''Debug''' views will be updated. + += References = + +* [http://wiki.eclipse.org/index.php/Linux_Tools_Project/LTTng2/User_Guide LTTng User Guide] +* [http://wiki.eclipse.org/CDT/User/FAQ#How_can_I_trace_my_application_using_C.2FC.2B.2B_Tracepoints.3F CDT FAQ - How can I trace my application using C/C++ Tracepoints?] + += Updating This Document = + +This document is maintained in a collaborative wiki. If you wish to update or modify this document please visit [http://wiki.eclipse.org/index.php/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide http://wiki.eclipse.org/Linux_Tools_Project/GDB_Tracepoint_Analysis/User_Guide] diff --git a/samples/NetLogo/Life.nlogo b/samples/NetLogo/Life.nlogo new file mode 100644 index 00000000..cb28c1a3 --- /dev/null +++ b/samples/NetLogo/Life.nlogo @@ -0,0 +1,55 @@ +patches-own [ + living? ;; indicates if the cell is living + live-neighbors ;; counts how many neighboring cells are alive +] + +to setup-blank + clear-all + ask patches [ cell-death ] + reset-ticks +end + +to setup-random + clear-all + ask patches + [ ifelse random-float 100.0 < initial-density + [ cell-birth ] + [ cell-death ] ] + reset-ticks +end + +to cell-birth + set living? true + set pcolor fgcolor +end + +to cell-death + set living? false + set pcolor bgcolor +end + +to go + ask patches + [ set live-neighbors count neighbors with [living?] ] + ;; Starting a new "ask patches" here ensures that all the patches + ;; finish executing the first ask before any of them start executing + ;; the second ask. This keeps all the patches in synch with each other, + ;; so the births and deaths at each generation all happen in lockstep. + ask patches + [ ifelse live-neighbors = 3 + [ cell-birth ] + [ if live-neighbors != 2 + [ cell-death ] ] ] + tick +end + +to draw-cells + let erasing? [living?] of patch mouse-xcor mouse-ycor + while [mouse-down?] + [ ask patch mouse-xcor mouse-ycor + [ ifelse erasing? + [ cell-death ] + [ cell-birth ] ] + display ] +end + diff --git a/samples/OpenCL/sample.cl b/samples/OpenCL/sample.cl new file mode 100644 index 00000000..9360b8e3 --- /dev/null +++ b/samples/OpenCL/sample.cl @@ -0,0 +1,23 @@ +/* Old-style comment. */ + +// New-style comment. + +typedef float foo_t; + +#ifndef ZERO +#define ZERO (0.0) +#endif + +#define FOO(x) ((x) + \ + ZERO) + +__kernel +void foo(__global const foo_t * x, __local foo_t y, const uint n) +{ + barrier(CLK_LOCAL_MEM_FENCE); + + if (n > 42) { + *x += y; + } +} + diff --git a/samples/Org/org.org b/samples/Org/org.org new file mode 100644 index 00000000..5246e97f --- /dev/null +++ b/samples/Org/org.org @@ -0,0 +1,164 @@ +#+OPTIONS: H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc +#+STARTUP: align fold nodlcheck hidestars oddeven lognotestate +#+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@) +#+TAGS: Write(w) Update(u) Fix(f) Check(c) +#+TITLE: org-ruby +#+AUTHOR: Brian Dewey +#+EMAIL: bdewey@gmail.com +#+LANGUAGE: en +#+PRIORITIES: A C B +#+CATEGORY: worg + +{Back to Worg's index} + +* Motivation + + The dominant simple plain-text markup languages for the web are + Textile and Markdown. A factor for the popularity of those markup + formats is the widespread availability of simple, free packages for + converting the formats to HTML. For example, the world of + Ruby-powered websites has settled on RedCloth for converting Textile + to HTML. + + The default way to convert org-mode files to HTML is the powerful + publishing functionality provided by =emacs=. However, =emacs= does + not easiliy integrate into many existing website frameworks. + + =Org-ruby= tries to make it easier to use org-mode files in both + dyanmic and static website generation tools written in + Ruby. =Org-ruby= is a simple Ruby gem to convert org-mode files to + HTML. + +* Using Org-ruby + + =Org-ruby= follows the same model as other Ruby markup + libraries. You install the gem: + + #+BEGIN_EXAMPLE + sudo gem install org-ruby + #+END_EXAMPLE + + Then, to convert an org-file to HTML in your Ruby code: + + #+BEGIN_EXAMPLE + require 'rubygems' + require 'org-ruby' + + data = IO.read(filename) + puts Orgmode::Parser.new(data).to_html + #+END_EXAMPLE + +* Walkthrough: Using org-ruby with Webby + + Here is an example of how to integrate =org-ruby= into Webby, a + static website generation tool written in Ruby. + + Webby follows a similar pattern to other static site generation + tools (like nanoc, Jekyll, and webgen): + + - You author website content in text with simple markup + - Each page is fed through one or more /filters/ to produce HTML + - The HTML is mixed in with layouts to produce the final pages + + For a Webby site, a the source for a page may look like this: + + #+BEGIN_EXAMPLE + --- + title: Special Directories + created_at: 2009-12-17 + status: Complete + filter: + - erb + - maruku + tags: + - powershell + --- + <%= @page.title %> + ================== + + Special Directories are a set of directories, each of which has a + function that will navigate you to the appropriate directory using + the push-location cmdlet. For example, the function `home` might + navigate to `c:\users\bdewey.` + + Install + ------- + + Copy the module to somewhere in `ENV:PSModulePath`. Then, + + InstallModule SpecialDirectories + #+END_EXAMPLE + + In the above example, the text is written in Markdown. At the top of + the file, metadata informs Webby to pass the text through two + /filters/ to produce HTML. The first filter, =erb=, handles embedded + Ruby. In this case, it will replace ~<%= @page.title %>~ with the + page title (=Special Directories=). The second filter uses Maruku to + translate Markdown into HTML. + + You can use the exact same pattern to include org-mode files in a + Webby site. For this walkthrough, I assume you already have Webby + installed, and that you've already created a site. + + 1. Make sure you have =org-ruby= installed: =sudo gem install + org-ruby=. + 2. You need to register a new Webby filter to handle org-mode + content. Webby makes this easy. In the =lib/= folder of your + site, create a file =orgmode.rb=: + + #+BEGIN_EXAMPLE + require 'org-ruby' + + Webby::Filters.register :org do |input| + Orgmode::Parser.new(input).to_html + end + #+END_EXAMPLE + + This code creates a new filter, =org=, that will use the + =org-ruby= parser to translate org-mode input into HTML. + 3. Create your content. For example: + + #+BEGIN_EXAMPLE +--- +title: Orgmode Parser +created_at: 2009-12-21 +status: Under development +filter: + - erb + - org +tags: + - orgmode + - ruby +--- +<%= @page.title %> + + Status: <%= @page.status %> + +* Description + + Helpful Ruby routines for parsing orgmode files. The most + significant thing this library does today is convert orgmode files + to textile. Currently, you cannot do much to customize the + conversion. The supplied textile conversion is optimized for + extracting "content" from the orgfile as opposed to "metadata." + + +* History + +** 2009-12-29: Version 0.4 + + - The first thing output in HTML gets the class "title" + - HTML output is now indented + - Proper support for multi-paragraph list items. + + See? This paragraph is part of the last bullet. + + - Fixed bugs: + - "rake spec" wouldn't work on Linux. Needed "require 'rubygems'". + #+END_EXAMPLE + + This file will go through the =erb= and =org= filters; as defined + in the previous step, the =org= filter will use =org-ruby= to + generate HTML. + + That's all there is to it! diff --git a/samples/Oxygene/Loops.oxygene b/samples/Oxygene/Loops.oxygene new file mode 100644 index 00000000..427d86f5 --- /dev/null +++ b/samples/Oxygene/Loops.oxygene @@ -0,0 +1,55 @@ + + + Loops + exe + Loops + False + False + False + Properties\App.ico + Release + {916BD89C-B610-4CEE-9CAF-C515D88E2C94} + + + DEBUG;TRACE; + .\bin\Debug + True + True + + + .\bin\Release + False + + + + + $(Framework)\mscorlib.dll + + + $(Framework)\System.dll + + + $(ProgramFiles)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll + True + + + $(Framework)\System.Data.dll + + + $(Framework)\System.Xml.dll + + + + + + + + ResXFileCodeGenerator + + + + SettingsSingleFileGenerator + + + + \ No newline at end of file diff --git a/samples/PAWN/grandlarc.pwn b/samples/PAWN/grandlarc.pwn new file mode 100644 index 00000000..76e96c66 --- /dev/null +++ b/samples/PAWN/grandlarc.pwn @@ -0,0 +1,520 @@ +//---------------------------------------------------------- +// +// GRAND LARCENY 1.0 +// A freeroam gamemode for SA-MP 0.3 +// +//---------------------------------------------------------- + +#include +#include +#include +#include "../include/gl_common.inc" +#include "../include/gl_spawns.inc" + +#pragma tabsize 0 + +//---------------------------------------------------------- + +#define COLOR_WHITE 0xFFFFFFFF +#define COLOR_NORMAL_PLAYER 0xFFBB7777 + +#define CITY_LOS_SANTOS 0 +#define CITY_SAN_FIERRO 1 +#define CITY_LAS_VENTURAS 2 + +new total_vehicles_from_files=0; + +// Class selection globals +new gPlayerCitySelection[MAX_PLAYERS]; +new gPlayerHasCitySelected[MAX_PLAYERS]; +new gPlayerLastCitySelectionTick[MAX_PLAYERS]; + +new Text:txtClassSelHelper; +new Text:txtLosSantos; +new Text:txtSanFierro; +new Text:txtLasVenturas; + +new thisanimid=0; +new lastanimid=0; + +//---------------------------------------------------------- + +main() +{ + print("\n---------------------------------------"); + print("Running Grand Larceny - by the SA-MP team\n"); + print("---------------------------------------\n"); +} + +//---------------------------------------------------------- + +public OnPlayerConnect(playerid) +{ + GameTextForPlayer(playerid,"~w~Grand Larceny",3000,4); + SendClientMessage(playerid,COLOR_WHITE,"Welcome to {88AA88}G{FFFFFF}rand {88AA88}L{FFFFFF}arceny"); + + // class selection init vars + gPlayerCitySelection[playerid] = -1; + gPlayerHasCitySelected[playerid] = 0; + gPlayerLastCitySelectionTick[playerid] = GetTickCount(); + + //SetPlayerColor(playerid,COLOR_NORMAL_PLAYER); + + //Kick(playerid); + + /* + Removes vending machines + RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0); + RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0); + RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0); + RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0); + RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0); + */ + + /* + new ClientVersion[32]; + GetPlayerVersion(playerid, ClientVersion, 32); + printf("Player %d reports client version: %s", playerid, ClientVersion);*/ + + return 1; +} + +//---------------------------------------------------------- + +public OnPlayerSpawn(playerid) +{ + if(IsPlayerNPC(playerid)) return 1; + + new randSpawn = 0; + + SetPlayerInterior(playerid,0); + TogglePlayerClock(playerid,0); + ResetPlayerMoney(playerid); + GivePlayerMoney(playerid, 30000); + + if(CITY_LOS_SANTOS == gPlayerCitySelection[playerid]) { + randSpawn = random(sizeof(gRandomSpawns_LosSantos)); + SetPlayerPos(playerid, + gRandomSpawns_LosSantos[randSpawn][0], + gRandomSpawns_LosSantos[randSpawn][1], + gRandomSpawns_LosSantos[randSpawn][2]); + SetPlayerFacingAngle(playerid,gRandomSpawns_LosSantos[randSpawn][3]); + } + else if(CITY_SAN_FIERRO == gPlayerCitySelection[playerid]) { + randSpawn = random(sizeof(gRandomSpawns_SanFierro)); + SetPlayerPos(playerid, + gRandomSpawns_SanFierro[randSpawn][0], + gRandomSpawns_SanFierro[randSpawn][1], + gRandomSpawns_SanFierro[randSpawn][2]); + SetPlayerFacingAngle(playerid,gRandomSpawns_SanFierro[randSpawn][3]); + } + else if(CITY_LAS_VENTURAS == gPlayerCitySelection[playerid]) { + randSpawn = random(sizeof(gRandomSpawns_LasVenturas)); + SetPlayerPos(playerid, + gRandomSpawns_LasVenturas[randSpawn][0], + gRandomSpawns_LasVenturas[randSpawn][1], + gRandomSpawns_LasVenturas[randSpawn][2]); + SetPlayerFacingAngle(playerid,gRandomSpawns_LasVenturas[randSpawn][3]); + } + + //SetPlayerColor(playerid,COLOR_NORMAL_PLAYER); + + SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_PISTOL_SILENCED,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_DESERT_EAGLE,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_SHOTGUN,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_SAWNOFF_SHOTGUN,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_SPAS12_SHOTGUN,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_MICRO_UZI,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_MP5,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_AK47,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_M4,200); + SetPlayerSkillLevel(playerid,WEAPONSKILL_SNIPERRIFLE,200); + + GivePlayerWeapon(playerid,WEAPON_COLT45,100); + //GivePlayerWeapon(playerid,WEAPON_MP5,100); + TogglePlayerClock(playerid, 0); + + return 1; +} + +//---------------------------------------------------------- + +public OnPlayerDeath(playerid, killerid, reason) +{ + new playercash; + + // if they ever return to class selection make them city + // select again first + gPlayerHasCitySelected[playerid] = 0; + + if(killerid == INVALID_PLAYER_ID) { + ResetPlayerMoney(playerid); + } else { + playercash = GetPlayerMoney(playerid); + if(playercash > 0) { + GivePlayerMoney(killerid, playercash); + ResetPlayerMoney(playerid); + } + } + return 1; +} + +//---------------------------------------------------------- + +ClassSel_SetupCharSelection(playerid) +{ + if(gPlayerCitySelection[playerid] == CITY_LOS_SANTOS) { + SetPlayerInterior(playerid,11); + SetPlayerPos(playerid,508.7362,-87.4335,998.9609); + SetPlayerFacingAngle(playerid,0.0); + SetPlayerCameraPos(playerid,508.7362,-83.4335,998.9609); + SetPlayerCameraLookAt(playerid,508.7362,-87.4335,998.9609); + } + else if(gPlayerCitySelection[playerid] == CITY_SAN_FIERRO) { + SetPlayerInterior(playerid,3); + SetPlayerPos(playerid,-2673.8381,1399.7424,918.3516); + SetPlayerFacingAngle(playerid,181.0); + SetPlayerCameraPos(playerid,-2673.2776,1394.3859,918.3516); + SetPlayerCameraLookAt(playerid,-2673.8381,1399.7424,918.3516); + } + else if(gPlayerCitySelection[playerid] == CITY_LAS_VENTURAS) { + SetPlayerInterior(playerid,3); + SetPlayerPos(playerid,349.0453,193.2271,1014.1797); + SetPlayerFacingAngle(playerid,286.25); + SetPlayerCameraPos(playerid,352.9164,194.5702,1014.1875); + SetPlayerCameraLookAt(playerid,349.0453,193.2271,1014.1797); + } + +} + +//---------------------------------------------------------- +// Used to init textdraws of city names + +ClassSel_InitCityNameText(Text:txtInit) +{ + TextDrawUseBox(txtInit, 0); + TextDrawLetterSize(txtInit,1.25,3.0); + TextDrawFont(txtInit, 0); + TextDrawSetShadow(txtInit,0); + TextDrawSetOutline(txtInit,1); + TextDrawColor(txtInit,0xEEEEEEFF); + TextDrawBackgroundColor(txtClassSelHelper,0x000000FF); +} + +//---------------------------------------------------------- + +ClassSel_InitTextDraws() +{ + // Init our observer helper text display + txtLosSantos = TextDrawCreate(10.0, 380.0, "Los Santos"); + ClassSel_InitCityNameText(txtLosSantos); + txtSanFierro = TextDrawCreate(10.0, 380.0, "San Fierro"); + ClassSel_InitCityNameText(txtSanFierro); + txtLasVenturas = TextDrawCreate(10.0, 380.0, "Las Venturas"); + ClassSel_InitCityNameText(txtLasVenturas); + + // Init our observer helper text display + txtClassSelHelper = TextDrawCreate(10.0, 415.0, + " Press ~b~~k~~GO_LEFT~ ~w~or ~b~~k~~GO_RIGHT~ ~w~to switch cities.~n~ Press ~r~~k~~PED_FIREWEAPON~ ~w~to select."); + TextDrawUseBox(txtClassSelHelper, 1); + TextDrawBoxColor(txtClassSelHelper,0x222222BB); + TextDrawLetterSize(txtClassSelHelper,0.3,1.0); + TextDrawTextSize(txtClassSelHelper,400.0,40.0); + TextDrawFont(txtClassSelHelper, 2); + TextDrawSetShadow(txtClassSelHelper,0); + TextDrawSetOutline(txtClassSelHelper,1); + TextDrawBackgroundColor(txtClassSelHelper,0x000000FF); + TextDrawColor(txtClassSelHelper,0xFFFFFFFF); +} + +//---------------------------------------------------------- + +ClassSel_SetupSelectedCity(playerid) +{ + if(gPlayerCitySelection[playerid] == -1) { + gPlayerCitySelection[playerid] = CITY_LOS_SANTOS; + } + + if(gPlayerCitySelection[playerid] == CITY_LOS_SANTOS) { + SetPlayerInterior(playerid,0); + SetPlayerCameraPos(playerid,1630.6136,-2286.0298,110.0); + SetPlayerCameraLookAt(playerid,1887.6034,-1682.1442,47.6167); + + TextDrawShowForPlayer(playerid,txtLosSantos); + TextDrawHideForPlayer(playerid,txtSanFierro); + TextDrawHideForPlayer(playerid,txtLasVenturas); + } + else if(gPlayerCitySelection[playerid] == CITY_SAN_FIERRO) { + SetPlayerInterior(playerid,0); + SetPlayerCameraPos(playerid,-1300.8754,68.0546,129.4823); + SetPlayerCameraLookAt(playerid,-1817.9412,769.3878,132.6589); + + TextDrawHideForPlayer(playerid,txtLosSantos); + TextDrawShowForPlayer(playerid,txtSanFierro); + TextDrawHideForPlayer(playerid,txtLasVenturas); + } + else if(gPlayerCitySelection[playerid] == CITY_LAS_VENTURAS) { + SetPlayerInterior(playerid,0); + SetPlayerCameraPos(playerid,1310.6155,1675.9182,110.7390); + SetPlayerCameraLookAt(playerid,2285.2944,1919.3756,68.2275); + + TextDrawHideForPlayer(playerid,txtLosSantos); + TextDrawHideForPlayer(playerid,txtSanFierro); + TextDrawShowForPlayer(playerid,txtLasVenturas); + } +} + +//---------------------------------------------------------- + +ClassSel_SwitchToNextCity(playerid) +{ + gPlayerCitySelection[playerid]++; + if(gPlayerCitySelection[playerid] > CITY_LAS_VENTURAS) { + gPlayerCitySelection[playerid] = CITY_LOS_SANTOS; + } + PlayerPlaySound(playerid,1052,0.0,0.0,0.0); + gPlayerLastCitySelectionTick[playerid] = GetTickCount(); + ClassSel_SetupSelectedCity(playerid); +} + +//---------------------------------------------------------- + +ClassSel_SwitchToPreviousCity(playerid) +{ + gPlayerCitySelection[playerid]--; + if(gPlayerCitySelection[playerid] < CITY_LOS_SANTOS) { + gPlayerCitySelection[playerid] = CITY_LAS_VENTURAS; + } + PlayerPlaySound(playerid,1053,0.0,0.0,0.0); + gPlayerLastCitySelectionTick[playerid] = GetTickCount(); + ClassSel_SetupSelectedCity(playerid); +} + +//---------------------------------------------------------- + +ClassSel_HandleCitySelection(playerid) +{ + new Keys,ud,lr; + GetPlayerKeys(playerid,Keys,ud,lr); + + if(gPlayerCitySelection[playerid] == -1) { + ClassSel_SwitchToNextCity(playerid); + return; + } + + // only allow new selection every ~500 ms + if( (GetTickCount() - gPlayerLastCitySelectionTick[playerid]) < 500 ) return; + + if(Keys & KEY_FIRE) { + gPlayerHasCitySelected[playerid] = 1; + TextDrawHideForPlayer(playerid,txtClassSelHelper); + TextDrawHideForPlayer(playerid,txtLosSantos); + TextDrawHideForPlayer(playerid,txtSanFierro); + TextDrawHideForPlayer(playerid,txtLasVenturas); + TogglePlayerSpectating(playerid,0); + return; + } + + if(lr > 0) { + ClassSel_SwitchToNextCity(playerid); + } + else if(lr < 0) { + ClassSel_SwitchToPreviousCity(playerid); + } +} + +//---------------------------------------------------------- + +public OnPlayerRequestClass(playerid, classid) +{ + if(IsPlayerNPC(playerid)) return 1; + + if(gPlayerHasCitySelected[playerid]) { + ClassSel_SetupCharSelection(playerid); + return 1; + } else { + if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING) { + TogglePlayerSpectating(playerid,1); + TextDrawShowForPlayer(playerid, txtClassSelHelper); + gPlayerCitySelection[playerid] = -1; + } + } + + return 0; +} + +//---------------------------------------------------------- + +public OnGameModeInit() +{ + SetGameModeText("Grand Larceny"); + ShowPlayerMarkers(PLAYER_MARKERS_MODE_GLOBAL); + ShowNameTags(1); + SetNameTagDrawDistance(40.0); + EnableStuntBonusForAll(0); + DisableInteriorEnterExits(); + SetWeather(2); + SetWorldTime(11); + + //UsePlayerPedAnims(); + //ManualVehicleEngineAndLights(); + //LimitGlobalChatRadius(300.0); + + ClassSel_InitTextDraws(); + + // Player Class + AddPlayerClass(281,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(282,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(283,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(284,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(285,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(286,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(287,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(288,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(265,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(266,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(267,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(268,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(269,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(270,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(1,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(2,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(3,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(4,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(5,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(6,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(8,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(42,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(65,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + //AddPlayerClass(74,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(86,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(119,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(149,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(208,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(273,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(289,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + + AddPlayerClass(47,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(48,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(49,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(50,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(51,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(52,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(53,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(54,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(55,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(56,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(57,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(58,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(68,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(69,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(70,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(71,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(72,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(73,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(75,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(76,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(78,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(79,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(80,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(81,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(82,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(83,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(84,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(85,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(87,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(88,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(89,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(91,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(92,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(93,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(95,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(96,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(97,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(98,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + AddPlayerClass(99,1759.0189,-1898.1260,13.5622,266.4503,-1,-1,-1,-1,-1,-1); + + // SPECIAL + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/trains.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/pilots.txt"); + + // LAS VENTURAS + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_law.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_airport.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/lv_gen.txt"); + + // SAN FIERRO + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_law.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_airport.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/sf_gen.txt"); + + // LOS SANTOS + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_law.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_airport.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_inner.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/ls_gen_outer.txt"); + + // OTHER AREAS + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/whetstone.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/bone.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/flint.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/tierra.txt"); + total_vehicles_from_files += LoadStaticVehiclesFromFile("vehicles/red_county.txt"); + + printf("Total vehicles from files: %d",total_vehicles_from_files); + + return 1; +} + +//---------------------------------------------------------- + +public OnPlayerUpdate(playerid) +{ + if(!IsPlayerConnected(playerid)) return 0; + if(IsPlayerNPC(playerid)) return 1; + + // changing cities by inputs + if( !gPlayerHasCitySelected[playerid] && + GetPlayerState(playerid) == PLAYER_STATE_SPECTATING ) { + ClassSel_HandleCitySelection(playerid); + return 1; + } + + // No weapons in interiors + if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) { + SetPlayerArmedWeapon(playerid,0); // fists + return 0; // no syncing until they change their weapon + } + + // Don't allow minigun + if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN) { + Kick(playerid); + return 0; + } + + /* No jetpacks allowed + if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK) { + Kick(playerid); + return 0; + }*/ + + /* For testing animations + new msg[128+1]; + new animlib[32+1]; + new animname[32+1]; + + thisanimid = GetPlayerAnimationIndex(playerid); + if(lastanimid != thisanimid) + { + GetAnimationName(thisanimid,animlib,32,animname,32); + format(msg, 128, "anim(%d,%d): %s %s", lastanimid, thisanimid, animlib, animname); + lastanimid = thisanimid; + SendClientMessage(playerid, 0xFFFFFFFF, msg); + }*/ + + return 1; +} + +//---------------------------------------------------------- \ No newline at end of file diff --git a/samples/Perl6/RoleQ.pm6 b/samples/Perl6/RoleQ.pm6 new file mode 100644 index 00000000..9b66bde4 --- /dev/null +++ b/samples/Perl6/RoleQ.pm6 @@ -0,0 +1,23 @@ +role q { + token stopper { \' } + + token escape:sym<\\> { } + + token backslash:sym { } + token backslash:sym<\\> { } + token backslash:sym { } + + token backslash:sym { {} . } + + method tweak_q($v) { self.panic("Too late for :q") } + method tweak_qq($v) { self.panic("Too late for :qq") } +} + +role qq does b1 does c1 does s1 does a1 does h1 does f1 { + token stopper { \" } + token backslash:sym { {} (\w) { self.throw_unrecog_backslash_seq: $/[0].Str } } + token backslash:sym { \W } + + method tweak_q($v) { self.panic("Too late for :q") } + method tweak_qq($v) { self.panic("Too late for :qq") } +} diff --git a/samples/Perl6/grammar-test.p6 b/samples/Perl6/grammar-test.p6 new file mode 100644 index 00000000..28107f3e --- /dev/null +++ b/samples/Perl6/grammar-test.p6 @@ -0,0 +1,22 @@ +token pod_formatting_code { + $=<[A..Z]> + '<' { $*POD_IN_FORMATTINGCODE := 1 } + $=[ '> ]+ + '>' { $*POD_IN_FORMATTINGCODE := 0 } +} + +token pod_string { + + +} + +token something:sym«<» { + +} + +token name { + +} + +token comment:sym<#> { + '#' {} \N* +} diff --git a/samples/Perl6/test.p6 b/samples/Perl6/test.p6 new file mode 100644 index 00000000..3d12b56c --- /dev/null +++ b/samples/Perl6/test.p6 @@ -0,0 +1,252 @@ +#!/usr/bin/env perl6 + +use v6; + +my $string = 'I look like a # comment!'; + +if $string eq 'foo' { + say 'hello'; +} + +regex http-verb { + 'GET' + | 'POST' + | 'PUT' + | 'DELETE' + | 'TRACE' + | 'OPTIONS' + | 'HEAD' +} + +# a sample comment + +say 'Hello from Perl 6!' + + +#`{ +multi-line comment! +} + +say 'here'; + +#`( +multi-line comment! +) + +say 'here'; + +#`{{{ +I'm a special comment! +}}} + +say 'there'; + +#`{{ +I'm { even } specialer! +}} + +say 'there'; + +#`{{ +does {{nesting}} work? +}} + +#`«< +trying mixed delimiters +» + +my $string = qq; +my $string = qq«Hooray, arbitrary delimiter!»; +my $string = q ; +my $string = qq<>; + +my %hash := Hash.new; + +=begin pod + +Here's some POD! Wooo + +=end pod + +=for Testing + This is POD (see? role isn't highlighted) + +say('this is not!'); + +=table + Of role things + +say('not in your table'); +#= A single line declarator "block" (with a keyword like role) +#| Another single line declarator "block" (with a keyword like role) +#={ + A declarator block (with a keyword like role) + } +#|{ + Another declarator block (with a keyword like role) + } +#= { A single line declarator "block" with a brace (with a keyword like role) +#=« + More declarator blocks! (with a keyword like role) + » +#|« + More declarator blocks! (with a keyword like role) + » + +say 'Moar code!'; + +my $don't = 16; + +sub don't($x) { + !$x +} + +say don't 'foo'; + +my %hash = ( + :foo(1), +); + +say %hash; +say %hash<>; +say %hash«foo»; + +say %*hash; +say %*hash<>; +say %*hash«foo»; + +say $; +say $; + +for (@A Z @B) -> $a, $b { + say $a + $b; +} + +Q:PIR { + .loadlib "somelib" +} + +my $longstring = q/ + lots + of + text +/; + +my $heredoc = q:to/END_SQL/; +SELECT * FROM Users +WHERE first_name = 'Rob' +END_SQL +my $hello; + +# Fun with regexen + +if 'food' ~~ /foo/ { + say 'match!' +} + +my $re = /foo/; +my $re2 = m/ foo /; +my $re3 = m:i/ FOO /; + +call-a-sub(/ foo /); +call-a-sub(/ foo \/ bar /); + +my $re4 = rx/something | something-else/; +my $result = ms/regexy stuff/; +my $sub0 = s/regexy stuff/more stuff/; +my $sub = ss/regexy stuff/more stuff/; +my $trans = tr/regexy stuff/more stuff/; + +my @values = ; +call-sub(); +call-sub ; + +my $result = $a < $b; + +for -> $letter { + say $letter; +} + +sub test-sub { + say @_; + say $!; + say $/; + say $0; + say $1; + say @*ARGS; + say $*ARGFILES; + say &?BLOCK; + say ::?CLASS; + say $?CLASS; + say @=COMMENT; + say %?CONFIG; + say $*CWD; + say $=data; + say %?DEEPMAGIC; + say $?DISTRO; + say $*DISTRO; + say $*EGID; + say %*ENV; + say $*ERR; + say $*EUID; + say $*EXECUTABLE_NAME; + say $?FILE; + say $?GRAMMAR; + say $*GID; + say $*IN; + say @*INC; + say %?LANG; + say $*LANG; + say $?LINE; + say %*META-ARGS; + say $?MODULE; + say %*OPTS; + say %*OPT; + say $?KERNEL; + say $*KERNEL; + say $*OUT; + say $?PACKAGE; + say $?PERL; + say $*PERL; + say $*PID; + say %=pod; + say $*PROGRAM_NAME; + say %*PROTOCOLS; + say ::?ROLE; + say $?ROLE; + say &?ROUTINE; + say $?SCOPE; + say $*TZ; + say $*UID; + say $?USAGE; + say $?VM; + say $?XVM; +} + +say ; + +my $perl5_re = m:P5/ fo{2} /; +my $re5 = rx«something | something-else»; + +my $M := %*COMPILING<%?OPTIONS>; + +say $M; + +sub regex-name { ... } +my $pair = role-name => 'foo'; +$pair = rolesque => 'foo'; + +my sub something(Str:D $value) { ... } + +my $s = q«< +some +string +stuff +»; + +my $regex = m«< some chars »; +# after + +say $/; + +roleq; diff --git a/samples/Pod/contents.pod b/samples/Pod/contents.pod new file mode 100644 index 00000000..a5ec66f2 --- /dev/null +++ b/samples/Pod/contents.pod @@ -0,0 +1,159 @@ +$Id: contents.pod,v 1.3 2003/05/04 04:05:14 tower Exp $ + +=begin html + + + +=end html + +=head1 Net::Z3950::AsyncZ + +=head2 Intro + +Net::Z3950::AsyncZ adds an additional layer of asynchronous support for the Z3950 module through the use +of multiple forked processes. I hope that users will also find that it provides a convenient +front end to C. My initial idea was to write something that +would provide a convenient means of processing and formatting Z39.50 records--which I +did, using the C synchronous code. But I also wanted something that could +handle queries to large numbers of servers at one session. Working on this part of my +project, I found that I had trouble with the C asynchronous features +and so ended up with what I have here. + +=begin html + +I give a more detailed account in the DESCRIPTION +section of AsyncZ.html. + +=end html + +=pod + +I give a more detailed account in in the B section of C. + +=cut + +=head2 Documentation + +=pod + +=over 4 + +=item AsyncZ.pod + +This is the starting point--it gives an overview of the AsyncZ module, +describes the basic mechanics of its asynchronous workings, and details +the particulars of the objects and methods. But see +L for detailed explanations of the sample +scripts which come with the C distribution. + +=item Options.pod + +This document details the various options that can be set to modify +the behavior of AsyncZ Index + +=item Report.pod + +Report.pod deals with how records are treated line by line +and how you can affect the apearance of a record's line by line output + +=item Examples.pod + +This document goes through the sample scripts that come with the +C distribution and annotates them +in a line-by-line fashion. It's a basic HOW-TO. + +=back + +=cut + +=begin html + +
    +
  • + AsyncZ.html +
    This is the starting point--it gives an overview of the AsyncZ module, +describes the basic mechanics of its asynchronous workings, and details +the particulars of the objects and methods. But see +Examples for detailed explanations of the sample +scripts which come with the Net::Z3950::AsyncZ distribution. + +
  • + Options.html +
    This document details the various options that can be set to modify +the behavior of AsyncZ + +
  • + Report.html +
    Report.html deals with how records are treated line by line +and how you can affect the apearance of a record's line by line output + +
  • + Examples.html +This document goes through the sample scripts that come with the +Net::Z3950::AsyncZ distribution and annotates them +in a line-by-line fashion. It's a basic HOW-TO. + +
+ +=end html + +=head2 The Modules + +=pod + +There are more modules than there is documentation. The reason for this +is that the only module you have full and complete access to is +C. The other modules are either internal to C +or accessed indirectly or in part indirectly. + +=cut + +=for html +There are more modules than there is documentation. The reason for this +is that the only module you have full and complete access to is +Net::Z3950::AsyncZ. The other modules are either internal to Net::AsyncZ +or accessed indirectly or in part indirectly. + +=head3 Here are the modules: + +=over 4 + +=item Net::Z3950::AsyncZ + +The main module: direct access --documented in +C and C documentation + +=item Net::Z3950::AsyncZ::ErrMsg + +User error message handling: indirect access -- documented in +C documentation + +=item Net::Z3950::AsyncZ::Errors + +Error handling for debugging: limited access -- documented in +C documentation + +=item Net::Z3950::AsyncZ::Report + +Module reponsible for fetching and formatting records: limited access -- documented + +=item Net::Z3950::AsyncZ::ZLoop + +Event loop for child processes: no access -- not documented + +=item Net::Z3950::AsyncZ::ZSend + +Connection details for child processes: no access -- not documented + +=item Net::Z3950::AsyncZ::Options::_params + +Options for child processes: direct and indirect access -- documented +in C and C documentation + +=back + +=head1 INDEX + + diff --git a/samples/PostScript/sierpinski.ps b/samples/PostScript/sierpinski.ps new file mode 100644 index 00000000..e3c9f665 --- /dev/null +++ b/samples/PostScript/sierpinski.ps @@ -0,0 +1,41 @@ +%!PS-Adobe-3.0 +%%Creator: Aaron Puchert +%%Title: The Sierpinski triangle +%%Pages: 1 +%%PageOrder: Ascend + +%%BeginProlog +% PAGE SETTINGS +/pageset { + 28.3464566 28.3464566 scale % set cm = 1 + 0.5 0.5 translate + 0 setlinewidth +} def + +% sierpinski(n) draws a sierpinski triangle of order n +/sierpinski { +dup 0 gt { + [0.5 0 0 0.5 0 0] concat dup 1 sub sierpinski + [1 0 0 1 1 0] concat dup 1 sub sierpinski + [1 0 0 1 -1 1] concat dup 1 sub sierpinski + [2 0 0 2 0 -1] concat +} { + newpath + 0 0 moveto + 1 0 lineto + 0 1 lineto + closepath + fill +} ifelse pop} def +%%EndProlog + +%%BeginSetup +<< /PageSize [596 843] >> setpagedevice % A4 +%%EndSetup + +%%Page: Test 1 +pageset +[20 0 10 300 sqrt 0 0] concat +9 sierpinski +showpage +%%EOF diff --git a/samples/Prolog/calc.pl b/samples/Prolog/calc.pl deleted file mode 100644 index b7492ca8..00000000 --- a/samples/Prolog/calc.pl +++ /dev/null @@ -1,68 +0,0 @@ -action_module(calculator) . - - -%[-,-,d1,-] --push(D)--> [-,-,D,-] if mode(init) -push(D) < - - mode(init), - deny([displayed(D1),mode(init)]), - affirm([displayed(D),mode(cont)]). - -%[-,-,D1,-] --push(D)--> [-,-,10*D1+D,-] if mode(cont) -push(D) < - - mode(cont), - deny(displayed(D1)), - New = 10*D1 + D, - affirm(displayed(New)). - -%[a,op,d,m] --push(clear)--> [0,nop,0,0] -push(clear) < - - deny([accumulator(A),op(O),displayed(D),memory(M),mode(X)]), - affirm([accumulator(0),op(nop),displayed(0),memory(0),mode(init)]). - -%[a,op,d,m] --push(mem_rec)--> [a,op,m,m] -push(mem_rec) < - - memory(M), - deny([displayed(D),mode(X)]), - affirm([displayed(M),mode(init)]). - -%[a,op,d,m] --push(plus)--> [op(a,d),plus,d,m] -push(plus) < - - displayed(D), - deny([accumulator(A),op(O),mode(X)]), - eval(O,A,D,V), ; use normal arithmetic, i.e., V=O(A,D) - affirm([accumulator(V),op(plus),mode(init)]). - -%[a,op,d,m] --push(minus)--> [op(a,d,minus,d,m] -push(minus) lt - - displayed(D), - deny([accumulator(A),op(O),mode(X)]), - eval(O,A,D,V), ; use normal arithmetic, i.e., V=O(A,D) - affirm([accumulator(V),op(minus),mode(init)]). - -%[a,op,d,m] --push(times)--> [op(a,d),times,d,m] -push(times) < - - displayed(D), - deny([accumulator(A),op(O),mode(X)]), - eval(O,A,D,V), ; use normal arithmetic, i.e., V=O(A,D) - affirm([accumulator(V),op(times),mode(init)]). - -%[a,op,d,m] --push(equal)--> [a,nop,op(a,d),m] -push(equal) < - - accumulator(A), - deny([op(O),displayed(D),mode(X)]), - eval(O,A,D,V), - affirm([op(nop),displayed(V),mode(init)]). - -%[a,op,d,m] --push(mem_plus)--> [a,nop,v,plus(m,v)] where v=op(a,d) -push(mem_plus) < - - accumulator(A), - deny([op(O),displayed(D),memory(M),mode(X)]), - eval(O,A,D,V), - eval(plus,M,V,V1), - affirm([op(nop),displayed(V),memory(V1),mode(init)]). - -%[a,op,d,m] --push(plus_minus)--> [a,op,-d,m] -push(clear) < - - deny([displayed(D),mode(X)]), - eval(minus,0,D,V), - affirm([displayed(V),mode(init)]). diff --git a/samples/Prolog/normal_form.pl b/samples/Prolog/normal_form.pl deleted file mode 100644 index 808e5221..00000000 --- a/samples/Prolog/normal_form.pl +++ /dev/null @@ -1,94 +0,0 @@ -%%----- normalize(+Wff,-NormalClauses) ------ -normalize(Wff,NormalClauses) :- - conVert(Wff,[],S), - cnF(S,T), - flatten_and(T,U), - make_clauses(U,NormalClauses). - -%%----- make a sequence out of a conjunction ----- -flatten_and(X /\ Y, F) :- - !, - flatten_and(X,A), - flatten_and(Y, B), - sequence_append(A,B,F). -flatten_and(X,X). - -%%----- make a sequence out of a disjunction ----- -flatten_or(X \/ Y, F) :- - !, - flatten_or(X,A), - flatten_or(Y,B), - sequence_append(A,B,F). -flatten_or(X,X). - - -%%----- append two sequences ------------------------------- -sequence_append((X,R),S,(X,T)) :- !, sequence_append(R,S,T). -sequence_append((X),S,(X,S)). - -%%----- separate into positive and negative literals ----------- -separate((A,B),P,N) :- - !, - (A = ~X -> N=[X|N1], - separate(B,P,N1) - ; - P=[A|P1], - separate(B,P1,N) ). -separate(A,P,N) :- - (A = ~X -> N=[X], - P = [] - ; - P=[A], - N = [] ). - -%%----- tautology ---------------------------- -tautology(P,N) :- some_occurs(N,P). - -some_occurs([F|R],B) :- - occurs(F,B) | some_occurs(R,B). - -occurs(A,[F|_]) :- - A == F, - !. -occurs(A,[_|R]) :- - occurs(A,R). - -make_clauses((A,B),C) :- - !, - flatten_or(A,F), - separate(F,P,N), - (tautology(P,N) -> - make_clauses(B,C) - ; - make_clause(P,N,D), - C = [D|R], - make_clauses(B,R) ). -make_clauses(A,C) :- - flatten_or(A,F), - separate(F,P,N), - (tautology(P,N) -> - C = [] - ; - make_clause(P,N,D), - C = [D] ). - -make_clause([],N, false :- B) :- - !, - make_sequence(N,B,','). -make_clause(P,[],H) :- - !, - make_sequence(P,H,'|'). -make_clause(P,N, H :- T) :- - make_sequence(P,H,'|'), - make_sequence(N,T,','). - -make_sequence([A],A,_) :- !. -make_sequence([F|R],(F|S),'|') :- - make_sequence(R,S,'|'). -make_sequence([F|R],(F,S),',') :- - make_sequence(R,S,','). - -write_list([F|R]) :- - write(F), write('.'), nl, - write_list(R). -write_list([]). diff --git a/samples/Prolog/or-constraint.ecl b/samples/Prolog/or-constraint.ecl new file mode 100644 index 00000000..02748be0 --- /dev/null +++ b/samples/Prolog/or-constraint.ecl @@ -0,0 +1,90 @@ +:- lib(ic). + +/** + * Question 1.11 + * vabs(?Val, ?AbsVal) + */ +vabs(Val, AbsVal):- + AbsVal #> 0, + ( + Val #= AbsVal + ; + Val #= -AbsVal + ), + labeling([Val, AbsVal]). + +/** + * vabsIC(?Val, ?AbsVal) + */ +vabsIC(Val, AbsVal):- + AbsVal #> 0, + Val #= AbsVal or Val #= -AbsVal, + labeling([Val, AbsVal]). + +/** + * Question 1.12 + */ +% X #:: -10..10, vabs(X, Y). +% X #:: -10..10, vabsIC(X, Y). + +/** + * Question 1.13 + * faitListe(?ListVar, ?Taille, +Min, +Max) + */ +faitListe([], 0, _, _):-!. +faitListe([First|Rest], Taille, Min, Max):- + First #:: Min..Max, + Taille1 #= Taille - 1, + faitListe(Rest, Taille1, Min, Max). + +/** + * Question 1.14 + * suite(?ListVar) + */ +suite([Xi, Xi1, Xi2]):- + checkRelation(Xi, Xi1, Xi2). +suite([Xi, Xi1, Xi2|Rest]):- + checkRelation(Xi, Xi1, Xi2), + suite([Xi1, Xi2|Rest]). + +/** + * checkRelation(?Xi, ?Xi1, ?Xi2) + */ +checkRelation(Xi, Xi1, Xi2):- + vabs(Xi1, VabsXi1), + Xi2 #= VabsXi1 - Xi. + +/** + * Question 1.15 + * checkPeriode(+ListVar). + */ +% TODO Any better solution? +checkPeriode(ListVar):- + length(ListVar, Length), + Length < 10. +checkPeriode([X1, X2, X3, X4, X5, X6, X7, X8, X9, X10|Rest]):- + X1 =:= X10, + checkPeriode([X2, X3, X4, X5, X6, X7, X8, X9, X10|Rest]). +% faitListe(ListVar, 18, -9, 9), suite(ListVar), checkPeriode(ListVar). => 99 solutions + + +/** + * Tests + */ +/* +vabs(5, 5). => Yes +vabs(5, -5). => No +vabs(-5, 5). => Yes +vabs(X, 5). +vabs(X, AbsX). +vabsIC(5, 5). => Yes +vabsIC(5, -5). => No +vabsIC(-5, 5). => Yes +vabsIC(X, 5). +vabsIC(X, AbsX). + +faitListe(ListVar, 5, 1, 3). => 243 solutions +faitListe([_, _, _, _, _], Taille, 1, 3). => Taille = 5 !!!!!!!!!!!!!!!! + +faitListe(ListVar, 18, -9, 9), suite(ListVar). => 99 solutions +*/ \ No newline at end of file diff --git a/samples/Prolog/puzzle.pl b/samples/Prolog/puzzle.pl deleted file mode 100644 index 9b0deb9c..00000000 --- a/samples/Prolog/puzzle.pl +++ /dev/null @@ -1,287 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% -%%% A* Algorithm -%%% -%%% -%%% Nodes have form S#D#F#A -%%% where S describes the state or configuration -%%% D is the depth of the node -%%% F is the evaluation function value -%%% A is the ancestor list for the node - -:- op(400,yfx,'#'). /* Node builder notation */ - -solve(State,Soln) :- f_function(State,0,F), - search([State#0#F#[]],S), reverse(S,Soln). - -f_function(State,D,F) :- h_function(State,H), - F is D + H. - -search([State#_#_#Soln|_], Soln) :- goal(State). -search([B|R],S) :- expand(B,Children), - insert_all(Children,R,Open), - search(Open,S). - -insert_all([F|R],Open1,Open3) :- insert(F,Open1,Open2), - insert_all(R,Open2,Open3). -insert_all([],Open,Open). - -insert(B,Open,Open) :- repeat_node(B,Open), ! . -insert(B,[C|R],[B,C|R]) :- cheaper(B,C), ! . -insert(B,[B1|R],[B1|S]) :- insert(B,R,S), !. -insert(B,[],[B]). - -repeat_node(P#_#_#_, [P#_#_#_|_]). - -cheaper( _#_#F1#_ , _#_#F2#_ ) :- F1 < F2. - -expand(State#D#_#S,All_My_Children) :- - bagof(Child#D1#F#[Move|S], - (D1 is D+1, - move(State,Child,Move), - f_function(Child,D1,F)), - All_My_Children). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% -%%% 8-puzzle solver -%%% -%%% -%%% State have form A/B/C/D/E/F/G/H/I -%%% where {A,...,I} = {0,...,8} -%%% 0 represents the empty tile -%%% - -goal(1/2/3/8/0/4/7/6/5). - -%%% The puzzle moves - -left( A/0/C/D/E/F/H/I/J , 0/A/C/D/E/F/H/I/J ). -left( A/B/C/D/0/F/H/I/J , A/B/C/0/D/F/H/I/J ). -left( A/B/C/D/E/F/H/0/J , A/B/C/D/E/F/0/H/J ). -left( A/B/0/D/E/F/H/I/J , A/0/B/D/E/F/H/I/J ). -left( A/B/C/D/E/0/H/I/J , A/B/C/D/0/E/H/I/J ). -left( A/B/C/D/E/F/H/I/0 , A/B/C/D/E/F/H/0/I ). - -up( A/B/C/0/E/F/H/I/J , 0/B/C/A/E/F/H/I/J ). -up( A/B/C/D/0/F/H/I/J , A/0/C/D/B/F/H/I/J ). -up( A/B/C/D/E/0/H/I/J , A/B/0/D/E/C/H/I/J ). -up( A/B/C/D/E/F/0/I/J , A/B/C/0/E/F/D/I/J ). -up( A/B/C/D/E/F/H/0/J , A/B/C/D/0/F/H/E/J ). -up( A/B/C/D/E/F/H/I/0 , A/B/C/D/E/0/H/I/F ). - -right( A/0/C/D/E/F/H/I/J , A/C/0/D/E/F/H/I/J ). -right( A/B/C/D/0/F/H/I/J , A/B/C/D/F/0/H/I/J ). -right( A/B/C/D/E/F/H/0/J , A/B/C/D/E/F/H/J/0 ). -right( 0/B/C/D/E/F/H/I/J , B/0/C/D/E/F/H/I/J ). -right( A/B/C/0/E/F/H/I/J , A/B/C/E/0/F/H/I/J ). -right( A/B/C/D/E/F/0/I/J , A/B/C/D/E/F/I/0/J ). - -down( A/B/C/0/E/F/H/I/J , A/B/C/H/E/F/0/I/J ). -down( A/B/C/D/0/F/H/I/J , A/B/C/D/I/F/H/0/J ). -down( A/B/C/D/E/0/H/I/J , A/B/C/D/E/J/H/I/0 ). -down( 0/B/C/D/E/F/H/I/J , D/B/C/0/E/F/H/I/J ). -down( A/0/C/D/E/F/H/I/J , A/E/C/D/0/F/H/I/J ). -down( A/B/0/D/E/F/H/I/J , A/B/F/D/E/0/H/I/J ). - -%%% the heuristic function -h_function(Puzz,H) :- p_fcn(Puzz,P), - s_fcn(Puzz,S), - H is P + 3*S. - - -%%% the move -move(P,C,left) :- left(P,C). -move(P,C,up) :- up(P,C). -move(P,C,right) :- right(P,C). -move(P,C,down) :- down(P,C). - -%%% the Manhattan distance function -p_fcn(A/B/C/D/E/F/G/H/I, P) :- - a(A,Pa), b(B,Pb), c(C,Pc), - d(D,Pd), e(E,Pe), f(F,Pf), - g(G,Pg), h(H,Ph), i(I,Pi), - P is Pa+Pb+Pc+Pd+Pe+Pf+Pg+Ph+Pg+Pi. - -a(0,0). a(1,0). a(2,1). a(3,2). a(4,3). a(5,4). a(6,3). a(7,2). a(8,1). -b(0,0). b(1,1). b(2,0). b(3,1). b(4,2). b(5,3). b(6,2). b(7,3). b(8,2). -c(0,0). c(1,2). c(2,1). c(3,0). c(4,1). c(5,2). c(6,3). c(7,4). c(8,3). -d(0,0). d(1,1). d(2,2). d(3,3). d(4,2). d(5,3). d(6,2). d(7,2). d(8,0). -e(0,0). e(1,2). e(2,1). e(3,2). e(4,1). e(5,2). e(6,1). e(7,2). e(8,1). -f(0,0). f(1,3). f(2,2). f(3,1). f(4,0). f(5,1). f(6,2). f(7,3). f(8,2). -g(0,0). g(1,2). g(2,3). g(3,4). g(4,3). g(5,2). g(6,2). g(7,0). g(8,1). -h(0,0). h(1,3). h(2,3). h(3,3). h(4,2). h(5,1). h(6,0). h(7,1). h(8,2). -i(0,0). i(1,4). i(2,3). i(3,2). i(4,1). i(5,0). i(6,1). i(7,2). i(8,3). - -%%% the out-of-cycle function -s_fcn(A/B/C/D/E/F/G/H/I, S) :- - s_aux(A,B,S1), s_aux(B,C,S2), s_aux(C,F,S3), - s_aux(F,I,S4), s_aux(I,H,S5), s_aux(H,G,S6), - s_aux(G,D,S7), s_aux(D,A,S8), s_aux(E,S9), - S is S1+S2+S3+S4+S5+S6+S7+S8+S9. - -s_aux(0,0) :- !. -s_aux(_,1). - -s_aux(X,Y,0) :- Y is X+1, !. -s_aux(8,1,0) :- !. -s_aux(_,_,2). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% -%%% 8-puzzle animation -- using VT100 character graphics -%%% -%%% -%%% - -puzzle(P) :- solve(P,S), - animate(P,S), - message. - -animate(P,S) :- initialize(P), - cursor(1,2), write(S), - cursor(1,22), write('Hit ENTER to step solver.'), - get0(_X), - play_back(S). - -:- dynamic location/3. - -initialize(A/B/C/D/E/F/H/I/J) :- - cls, - retractall(location(_,_,_)), - assert(location(A,20,5)), - assert(location(B,30,5)), - assert(location(C,40,5)), - assert(location(F,40,10)), - assert(location(J,40,15)), - assert(location(I,30,15)), - assert(location(H,20,15)), - assert(location(D,20,10)), - assert(location(E,30,10)), draw_all. - -draw_all :- draw(1), draw(2), draw(3), draw(4), - draw(5), draw(6), draw(7), draw(8). - -%%% play_back([left,right,up,...]). -play_back([M|R]) :- call(M), get0(_X), play_back(R). -play_back([]) :- cursor(1,24). %%% Put cursor out of the way - -message :- nl,nl, - write(' ********************************************'), nl, - write(' * Enter 8-puzzle goals in the form ... *'), nl, - write(' * ?- puzzle(0/8/1/2/4/3/7/6/5). *'), nl, - write(' * Enter goal ''message'' to reread this. *'), nl, - write(' ********************************************'), nl, nl. - - -cursor(X,Y) :- put(27), put(91), %%% ESC [ - write(Y), - put(59), %%% ; - write(X), - put(72). %%% M - -%%% clear the screen, quickly -cls :- put(27), put("["), put("2"), put("J"). - -%%% video attributes -- bold and blink not working -plain :- put(27), put("["), put("0"), put("m"). -reverse_video :- put(27), put("["), put("7"), put("m"). - - -%%% Tile objects, character map(s) -%%% Each tile should be drawn using the character map, -%%% drawn at 'location', which is asserted and retracted -%%% by 'playback'. -character_map(N, [ [' ',' ',' ',' ',' ',' ',' '], - [' ',' ',' ', N ,' ',' ',' '], - [' ',' ',' ',' ',' ',' ',' '] ]). - - -%%% move empty tile (spot) to the left -left :- retract(location(0,X0,Y0)), - Xnew is X0 - 10, - location(Tile,Xnew,Y0), - assert(location(0,Xnew,Y0)), - right(Tile),right(Tile),right(Tile), - right(Tile),right(Tile), - right(Tile),right(Tile),right(Tile), - right(Tile),right(Tile). - -up :- retract(location(0,X0,Y0)), - Ynew is Y0 - 5, - location(Tile,X0,Ynew), - assert(location(0,X0,Ynew)), - down(Tile),down(Tile),down(Tile),down(Tile),down(Tile). - -right :- retract(location(0,X0,Y0)), - Xnew is X0 + 10, - location(Tile,Xnew,Y0), - assert(location(0,Xnew,Y0)), - left(Tile),left(Tile),left(Tile),left(Tile),left(Tile), - left(Tile),left(Tile),left(Tile),left(Tile),left(Tile). - -down :- retract(location(0,X0,Y0)), - Ynew is Y0 + 5, - location(Tile,X0,Ynew), - assert(location(0,X0,Ynew)), - up(Tile),up(Tile),up(Tile),up(Tile),up(Tile). - - -draw(Obj) :- reverse_video, character_map(Obj,M), - location(Obj,X,Y), - draw(X,Y,M), plain. - -%%% hide tile -hide(Obj) :- character_map(Obj,M), - location(Obj,X,Y), - hide(X,Y,M). - -hide(_,_,[]). -hide(X,Y,[R|G]) :- hide_row(X,Y,R), - Y1 is Y + 1, - hide(X,Y1,G). - -hide_row(_,_,[]). -hide_row(X,Y,[_|R]) :- cursor(X,Y), - write(' '), - X1 is X + 1, - hide_row(X1,Y,R). - -%%% draw tile -draw(_,_,[]). -draw(X,Y,[R|G]) :- draw_row(X,Y,R), - Y1 is Y + 1, - draw(X,Y1,G). - -draw_row(_,_,[]). -draw_row(X,Y,[P|R]) :- cursor(X,Y), - write(P), - X1 is X + 1, - draw_row(X1,Y,R). - -%%% Move an Object up -up(Obj) :- hide(Obj), - retract(location(Obj,X,Y)), - Y1 is Y - 1, - assert(location(Obj,X,Y1)), - draw(Obj). - -down(Obj) :- hide(Obj), - retract(location(Obj,X,Y)), - Y1 is Y + 1, - assert(location(Obj,X,Y1)), - draw(Obj). - -left(Obj) :- hide(Obj), - retract(location(Obj,X,Y)), - X1 is X - 1, - assert(location(Obj,X1,Y)), - draw(Obj). - -right(Obj) :- hide(Obj), - retract(location(Obj,X,Y)), - X1 is X + 1, - assert(location(Obj,X1,Y)), - draw(Obj). - -:- message. diff --git a/samples/Prolog/quicksort.pl b/samples/Prolog/quicksort.pl deleted file mode 100644 index eb4467b4..00000000 --- a/samples/Prolog/quicksort.pl +++ /dev/null @@ -1,13 +0,0 @@ -partition([], _, [], []). -partition([X|Xs], Pivot, Smalls, Bigs) :- - ( X @< Pivot -> - Smalls = [X|Rest], - partition(Xs, Pivot, Rest, Bigs) - ; Bigs = [X|Rest], - partition(Xs, Pivot, Smalls, Rest) - ). - -quicksort([]) --> []. -quicksort([X|Xs]) --> - { partition(Xs, X, Smaller, Bigger) }, - quicksort(Smaller), [X], quicksort(Bigger). diff --git a/samples/Prolog/test-prolog.pl b/samples/Prolog/test-prolog.pl deleted file mode 100644 index aab83d54..00000000 --- a/samples/Prolog/test-prolog.pl +++ /dev/null @@ -1,12 +0,0 @@ -/* Prolog test file */ -male(john). -male(peter). - -female(vick). -female(christie). - -parents(john, peter, christie). -parents(vick, peter, christie). - -/* X is a brother of Y */ -brother(X, Y) :- male(X), parents(X, F, M), parents(Y, F, M). diff --git a/samples/Prolog/test-prolog.prolog b/samples/Prolog/test-prolog.prolog new file mode 100644 index 00000000..b1b34b67 --- /dev/null +++ b/samples/Prolog/test-prolog.prolog @@ -0,0 +1,12 @@ +-/* Prolog test file */ + -male(john). + -male(peter). + - + -female(vick). + -female(christie). + - + -parents(john, peter, christie). + -parents(vick, peter, christie). + - + -/* X is a brother of Y */ + -brother(X, Y) :- male(X), parents(X, F, M), parents(Y, F, M). diff --git a/samples/Prolog/turing.pl b/samples/Prolog/turing.pl index 82fe104f..a7c36e84 100644 --- a/samples/Prolog/turing.pl +++ b/samples/Prolog/turing.pl @@ -1,21 +1,21 @@ -turing(Tape0, Tape) :- - perform(q0, [], Ls, Tape0, Rs), - reverse(Ls, Ls1), - append(Ls1, Rs, Tape). - -perform(qf, Ls, Ls, Rs, Rs) :- !. -perform(Q0, Ls0, Ls, Rs0, Rs) :- - symbol(Rs0, Sym, RsRest), - once(rule(Q0, Sym, Q1, NewSym, Action)), - action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1), - perform(Q1, Ls1, Ls, Rs1, Rs). - -symbol([], b, []). -symbol([Sym|Rs], Sym, Rs). - -action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs). -action(stay, Ls, Ls, Rs, Rs). -action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs). - -left([], [], Rs0, [b|Rs0]). -left([L|Ls], Ls, Rs, [L|Rs]). +-turing(Tape0, Tape) :- + - perform(q0, [], Ls, Tape0, Rs), + - reverse(Ls, Ls1), + - append(Ls1, Rs, Tape). + - + -perform(qf, Ls, Ls, Rs, Rs) :- !. + -perform(Q0, Ls0, Ls, Rs0, Rs) :- + - symbol(Rs0, Sym, RsRest), + - once(rule(Q0, Sym, Q1, NewSym, Action)), + - action(Action, Ls0, Ls1, [NewSym|RsRest], Rs1), + - perform(Q1, Ls1, Ls, Rs1, Rs). + - + -symbol([], b, []). + -symbol([Sym|Rs], Sym, Rs). + - + -action(left, Ls0, Ls, Rs0, Rs) :- left(Ls0, Ls, Rs0, Rs). + -action(stay, Ls, Ls, Rs, Rs). + -action(right, Ls0, [Sym|Ls0], [Sym|Rs], Rs). + - + -left([], [], Rs0, [b|Rs0]). + -left([L|Ls], Ls, Rs, [L|Rs]). diff --git a/samples/Protocol Buffer/addressbook.proto b/samples/Protocol Buffer/addressbook.proto new file mode 100644 index 00000000..2dee2965 --- /dev/null +++ b/samples/Protocol Buffer/addressbook.proto @@ -0,0 +1,27 @@ +package tutorial; + +option java_package = "com.example.tutorial"; +option java_outer_classname = "AddressBookProtos"; + +message Person { + required string name = 1; + required int32 id = 2; + optional string email = 3; + + enum PhoneType { + MOBILE = 0; + HOME = 1; + WORK = 2; + } + + message PhoneNumber { + required string number = 1; + optional PhoneType type = 2 [default = HOME]; + } + + repeated PhoneNumber phone = 4; +} + +message AddressBook { + repeated Person person = 1; +} diff --git a/samples/R/R-qgis-extension.rsx b/samples/R/R-qgis-extension.rsx new file mode 100644 index 00000000..adf59e67 --- /dev/null +++ b/samples/R/R-qgis-extension.rsx @@ -0,0 +1,5 @@ +##polyg=vector +##numpoints=number 10 +##output=output vector +##[Example scripts]=group +pts=spsample(polyg,numpoints,type="regular") diff --git a/samples/RDoc/rdoc.rdoc b/samples/RDoc/rdoc.rdoc new file mode 100644 index 00000000..c0206be6 --- /dev/null +++ b/samples/RDoc/rdoc.rdoc @@ -0,0 +1,129 @@ += \RDoc - Ruby Documentation System + +home :: https://github.com/rdoc/rdoc +rdoc :: http://docs.seattlerb.org/rdoc +bugs :: https://github.com/rdoc/rdoc/issues +code quality :: {code climate}[https://codeclimate.com/github/rdoc/rdoc] + +== Description + +RDoc produces HTML and command-line documentation for Ruby projects. RDoc +includes the +rdoc+ and +ri+ tools for generating and displaying documentation +from the command-line. + +== Generating Documentation + +Once installed, you can create documentation using the +rdoc+ command + + $ rdoc [options] [names...] + +For an up-to-date option summary, type + + $ rdoc --help + +A typical use might be to generate documentation for a package of Ruby +source (such as RDoc itself). + + $ rdoc + +This command generates documentation for all the Ruby and C source +files in and below the current directory. These will be stored in a +documentation tree starting in the subdirectory +doc+. + +You can make this slightly more useful for your readers by having the +index page contain the documentation for the primary file. In our +case, we could type + + % rdoc --main README.rdoc + +You'll find information on the various formatting tricks you can use +in comment blocks in the documentation this generates. + +RDoc uses file extensions to determine how to process each file. File names +ending +.rb+ and +.rbw+ are assumed to be Ruby source. Files +ending +.c+ are parsed as C files. All other files are assumed to +contain just Markup-style markup (with or without leading '#' comment +markers). If directory names are passed to RDoc, they are scanned +recursively for C and Ruby source files only. + +To generate documentation using +rake+ see RDoc::Task. + +To generate documentation programmatically: + + gem 'rdoc' + require 'rdoc/rdoc' + + options = RDoc::Options.new + # see RDoc::Options + + rdoc = RDoc::RDoc.new + rdoc.document options + # see RDoc::RDoc + +== Writing Documentation + +To write documentation for RDoc place a comment above the class, module, +method, constant, or attribute you want documented: + + ## + # This class represents an arbitrary shape by a series of points. + + class Shape + + ## + # Creates a new shape described by a +polyline+. + # + # If the +polyline+ does not end at the same point it started at the + # first pointed is copied and placed at the end of the line. + # + # An ArgumentError is raised if the line crosses itself, but shapes may + # be concave. + + def initialize polyline + # ... + end + + end + +The default comment markup format is the RDoc::Markup format. +TomDoc[rdoc-ref:RDoc::TomDoc], Markdown[rdoc-ref:RDoc::Markdown] and +RD[rdoc-ref:RDoc::RD] format comments are also supported. You can set the +default comment format for your entire project by creating a +.rdoc_options file. See RDoc::Options@Saved+Options for instructions +on creating one. You can also set the comment format for a single file +through the +:markup:+ directive, but this is only recommended if you wish to +switch markup formats. See RDoc::Markup@Other+directives. + +Comments can contain directives that tell RDoc information that it cannot +otherwise discover through parsing. See RDoc::Markup@Directives to control +what is or is not documented, to define method arguments or to break up +methods in a class by topic. See RDoc::Parser::Ruby for directives used to +teach RDoc about metaprogrammed methods. + +See RDoc::Parser::C for documenting C extensions with RDoc. + +To determine how well your project is documented run rdoc -C lib to +get a documentation coverage report. rdoc -C1 lib includes parameter +names in the documentation coverage report. + +== Bugs + +See CONTRIBUTING@Bugs for information on filing a bug report. It's OK to file +a bug report for anything you're having a problem with. If you can't figure +out how to make RDoc produce the output you like that is probably a +documentation bug. + +== License + +RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers. +Portions (c) 2007-2011 Eric Hodel. Portions copyright others, see individual +files and LEGAL.rdoc for details. + +RDoc is free software, and may be redistributed under the terms specified in +LICENSE.rdoc. + +== Warranty + +This software is provided "as is" and without any express or implied +warranties, including, without limitation, the implied warranties of +merchantability and fitness for a particular purpose. diff --git a/samples/RMarkdown/example.rmd b/samples/RMarkdown/example.rmd new file mode 100644 index 00000000..edd7c2d5 --- /dev/null +++ b/samples/RMarkdown/example.rmd @@ -0,0 +1,10 @@ +# An example RMarkdown + +Some text. + +## A graphic in R + +```{r} +plot(1:10) +hist(rnorm(10000)) +``` \ No newline at end of file diff --git a/samples/Racket/rkt.script! b/samples/Racket/rkt.script! deleted file mode 100755 index bc5a8ca4..00000000 --- a/samples/Racket/rkt.script! +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -#| -*- scheme -*- -exec racket -um "$0" "$@" -|# - -(require racket/file racket/path racket/list racket/string - (for-syntax racket/base)) diff --git a/samples/RobotFramework/data_driven.robot b/samples/RobotFramework/data_driven.robot new file mode 100644 index 00000000..4f02837a --- /dev/null +++ b/samples/RobotFramework/data_driven.robot @@ -0,0 +1,45 @@ +*** Settings *** +Documentation Example test cases using the data-driven testing approach. +... +... Tests use `Calculate` keyword created in this file, that in +... turn uses keywords in `CalculatorLibrary`. An exception is +... the last test that has a custom _template keyword_. +... +... The data-driven style works well when you need to repeat +... the same workflow multiple times. +... +... Notice that one of these tests fails on purpose to show how +... failures look like. +Test Template Calculate +Library CalculatorLibrary + +*** Test Cases *** Expression Expected +Addition 12 + 2 + 2 16 + 2 + -3 -1 + +Subtraction 12 - 2 - 2 8 + 2 - -3 5 + +Multiplication 12 * 2 * 2 48 + 2 * -3 -6 + +Division 12 / 2 / 2 3 + 2 / -3 -1 + +Failing 1 + 1 3 + +Calculation error [Template] Calculation should fail + kekkonen Invalid button 'k'. + ${EMPTY} Invalid expression. + 1 / 0 Division by zero. + +*** Keywords *** +Calculate + [Arguments] ${expression} ${expected} + Push buttons C${expression}= + Result should be ${expected} + +Calculation should fail + [Arguments] ${expression} ${expected} + ${error} = Should cause error C${expression}= + Should be equal ${expected} ${error} # Using `BuiltIn` keyword diff --git a/samples/RobotFramework/gherkin.robot b/samples/RobotFramework/gherkin.robot new file mode 100644 index 00000000..34b69865 --- /dev/null +++ b/samples/RobotFramework/gherkin.robot @@ -0,0 +1,33 @@ +*** Settings *** +Documentation Example test case using the gherkin syntax. +... +... This test has a workflow similar to the keyword-driven +... examples. The difference is that the keywords use higher +... abstraction level and their arguments are embedded into +... the keyword names. +... +... This kind of _gherkin_ syntax has been made popular by +... [http://cukes.info|Cucumber]. It works well especially when +... tests act as examples that need to be easily understood also +... by the business people. +Library CalculatorLibrary + +*** Test Cases *** +Addition + Given calculator has been cleared + When user types "1 + 1" + and user pushes equals + Then result is "2" + +*** Keywords *** +Calculator has been cleared + Push button C + +User types "${expression}" + Push buttons ${expression} + +User pushes equals + Push button = + +Result is "${result}" + Result should be ${result} diff --git a/samples/RobotFramework/keyword_driven.robot b/samples/RobotFramework/keyword_driven.robot new file mode 100644 index 00000000..6f85c813 --- /dev/null +++ b/samples/RobotFramework/keyword_driven.robot @@ -0,0 +1,37 @@ +*** Settings *** +Documentation Example test cases using the keyword-driven testing approach. +... +... All tests contain a workflow constructed from keywords in +... `CalculatorLibrary`. Creating new tests or editing existing +... is easy even for people without programming skills. +... +... This kind of style works well for normal test automation. +... If also business people need to understand tests, using +... _gherkin_ style may work better. +Library CalculatorLibrary + +*** Test Cases *** +Push button + Push button 1 + Result should be 1 + +Push multiple buttons + Push button 1 + Push button 2 + Result should be 12 + +Simple calculation + Push button 1 + Push button + + Push button 2 + Push button = + Result should be 3 + +Longer calculation + Push buttons 5 + 4 - 3 * 2 / 1 = + Result should be 3 + +Clear + Push button 1 + Push button C + Result should be ${EMPTY} # ${EMPTY} is a built-in variable diff --git a/samples/Ruby/filenames/Appraisals b/samples/Ruby/filenames/Appraisals new file mode 100644 index 00000000..dea46a60 --- /dev/null +++ b/samples/Ruby/filenames/Appraisals @@ -0,0 +1,7 @@ +appraise "rails32" do + gem 'rails', '~> 3.2.0' +end + +appraise "rails40" do + gem 'rails', '~> 4.0.0' +end diff --git a/samples/Scala/node11.sc b/samples/Scala/node11.sc new file mode 100644 index 00000000..fadabe17 --- /dev/null +++ b/samples/Scala/node11.sc @@ -0,0 +1,75 @@ +import math.random +import scala.language.postfixOps +import scala.util._ +import scala.util.{Try, Success, Failure} +import scala.concurrent._ +import duration._ +import ExecutionContext.Implicits.global +import scala.concurrent.{ ExecutionContext, CanAwait, OnCompleteRunnable, TimeoutException, ExecutionException, blocking } +/* This worksheet demonstrates some of the code snippets from +* Week3, Lecture 4, "Composing Futures". +*/ + + +object node11 { + println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheet + + /** + * Retry successfully completing block at most noTimes + * and give up after that + */ + + def retry[T](n: Int)(block: =>Future[T]): Future[T] = { + val ns: Iterator[Int] = (1 to n).iterator + val attempts: Iterator[()=>Future[T]] = ns.map(_ => ()=>block) + val failed: Future[T] = Future.failed(new Exception) + attempts.foldLeft(failed)((a, block) => a fallbackTo { block() }) + } //> retry: [T](n: Int)(block: => scala.concurrent.Future[T])scala.concurrent.Fut + //| ure[T] + def rb(i: Int) = { + blocking{Thread.sleep(100*random.toInt)} + println("Hi " ++ i.toString) + i + 10 + } //> rb: (i: Int)Int + def block(i: Int) = { + println("Iteration: " + i.toString) + + val ri = retry(i)( Future {rb(i)} ) + + ri onComplete { + case Success(s) => println(s.toString ++ " = 10 + " ++ i.toString) + case Failure(t:Exception) => println(t.toString ++ " " ++ i.toString) + case r => println(r.toString ++ " " ++ i.toString) + } + + } //> block: (i: Int)Unit + /* Multiple executions of a block of commands where + * each block contains one collectCoins and + * one buyTreasure. If either call fails, the whole iteration does not fail, + * because we are catching exceptions (with flatMap) in this implementation. + * Note that these blocks execute synchrounsly. + */ + (0 to 4 toList).foreach(i =>block(i)) //> Iteration: 0 + //| Iteration: 1 + //| java.lang.Exception 0 + //| Hi 1 + //| Iteration: 2 + //| 11 = 10 + 1 + //| Hi 2 + //| Iteration: 3 + //| Hi 3 + //| Hi 2 + //| Iteration: 4 + //| 12 = 10 + 2 + blocking{Thread.sleep(3000)} //> Hi 4 + //| Hi 3 + //| 13 = 10 + 3 + //| Hi 3 + //| 14 = 10 + 4 + //| Hi 4 + //| Hi 4 + //| Hi 4- + + + +} diff --git a/samples/Scaml/hello.scaml b/samples/Scaml/hello.scaml new file mode 100644 index 00000000..accbf543 --- /dev/null +++ b/samples/Scaml/hello.scaml @@ -0,0 +1,3 @@ +%p + Hello, + World! diff --git a/samples/Scheme/basic.sld b/samples/Scheme/basic.sld new file mode 100644 index 00000000..85dc75c6 --- /dev/null +++ b/samples/Scheme/basic.sld @@ -0,0 +1,7 @@ +(define-library (libs basic) + (export list2 x) + (begin + (define (list2 . objs) objs) + (define x 'libs-basic) + (define not-exported 'should-not-be-exported) + )) diff --git a/samples/Shen/graph.shen b/samples/Shen/graph.shen new file mode 100644 index 00000000..1c42bb55 --- /dev/null +++ b/samples/Shen/graph.shen @@ -0,0 +1,321 @@ +\* graph.shen --- a library for graph definition and manipulation + +Copyright (C) 2011, Eric Schulte + +*** License: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*** Commentary: + +Graphs are represented as two dictionaries one for vertices and one +for edges. It is important to note that the dictionary implementation +used is able to accept arbitrary data structures as keys. This +structure technically encodes hypergraphs (a generalization of graphs +in which each edge may contain any number of vertices). Examples of a +regular graph G and a hypergraph H with the corresponding data +structure are given below. + + +--G=------------------------------------------------ + Vertices Edges + ---------- ------- + +----Graph G-----+ hash | key -> value hash | key -> value + | | -----+------>-------- -----+-------->--------- + | a---b---c g | 1 | a -> [1] 1 | [a b] -> [1 2] + | | | | 2 | b -> [1 2 3] 2 | [b c] -> [2 3] + | d---e---f | 3 | c -> [2 4] 3 | [b d] -> [2 4] + | | 4 | d -> [3 5] 4 | [c e] -> [3 5] + +----------------+ 5 | e -> [4 5 6] 5 | [d e] -> [4 5] + 6 | f -> [6] 6 | [e f] -> [5 6] + 7 | g -> [] + + +--H=------------------------------------------------ + Vertices Edges + ---------- ------- + hash | key -> value hash | key -> value + +-- Hypergraph H----+ -----+------>-------- -----+-------->--------- + | | 1 | a -> [1] 1 | [a b [1 2 + | +------+ | 2 | b -> [1] | c d -> 3 4 + | +------+------+ | 3 | c -> [1] | e f] 5 6] + | |a b c |d e f | | 4 | d -> [1 2] | + | +------+------+ | 5 | e -> [1 2] 2 | [d e [4 5 + | |g h i | j | 6 | f -> [1 2] | f g -> 6 7 + | +------+ | 7 | g -> [2] | h i] 8 9] + | | 8 | h -> [2] + +-------------------+ 9 | i -> [2] + 10 | j -> [] + + +--G=-------Graph with associated edge/vertex data--------- + Vertices Edges + ---------- ------- + +----Graph G-----+ hash | key -> value hash | key -> value + | 4 6 7 | -----+------>-------- -----+-------->--------- + |0a---b---c g | 1 | a -> (@p 0 [1]) 1 | [a b] -> (@p 4 [1 2]) + | 1| 3| | 2 | b -> [1 2 3] 2 | [b c] -> (@p 6 [2 3]) + | d---e---f | 3 | c -> [2 4] 3 | [b d] -> (@p 1 [2 4]) + | 2 5 | 4 | d -> [3 5] 4 | [c e] -> (@p 3 [3 5]) + +----------------+ 5 | e -> [4 5 6] 5 | [d e] -> (@p 2 [4 5]) + 6 | f -> [6] 6 | [e f] -> (@p 5 [5 6]) + 7 | g -> (@p 7 []) + +V = # of vertices +E = # of edges +M = # of vertex edge associations + +size = size of all vertices + all vertices stored in Vertices dict + M * sizeof(int) * 4 + indices into Vertices & Edge dicts + V * sizeof(dict entry) + storage in the Vertex dict + E * sizeof(dict entry) + storage in the Edge dict + 2 * sizeof(dict) the Vertices and Edge dicts + +*** Code: *\ +(require dict) +(require sequence) + +(datatype graph + Vertices : dictionary; + Edges : dictoinary; + =================== + (vector symbol Vertices Edges);) + +(package graph- [graph graph? vertices edges add-vertex + add-edge has-edge? has-vertex? edges-for + neighbors connected-to connected? connected-components + vertex-partition bipartite? + \* included from the sequence library\ *\ + take drop take-while drop-while range flatten + filter complement seperate zip indexed reduce + mapcon partition partition-with unique frequencies + shuffle pick remove-first interpose subset? + cartesian-product + \* included from the dict library\ *\ + dict? dict dict-> <-dict contents key? keys vals + dictionary make-dict] + +(define graph? + X -> (= graph (<-address X 0))) + +(define make-graph + \* create a graph with specified sizes for the vertex dict and edge dict *\ + {number --> number --> graph} + Vertsize Edgesize -> + (let Graph (absvector 3) + (do (address-> Graph 0 graph) + (address-> Graph 1 (make-dict Vertsize)) + (address-> Graph 2 (make-dict Edgesize)) + Graph))) + +(defmacro graph-macro + \* return a graph taking optional sizes for the vertex and edge dicts *\ + [graph] -> [make-graph 1024 1024] + [graph N] -> [make-graph N 1024] + [graph N M] -> [make-graph N M]) + +(define vert-dict Graph -> (<-address Graph 1)) + +(define edge-dict Graph -> (<-address Graph 2)) + +(define vertices + {graph --> (list A)} + Graph -> (keys (vert-dict Graph))) + +(define edges + {graph --> (list (list A))} + Graph -> (keys (edge-dict Graph))) + +(define get-data + Value V -> (if (tuple? Value) + (fst Value) + (error (make-string "no data for ~S~%" V)))) + +(define vertex-data + Graph V -> (get-data (<-dict (vert-dict Graph) V) V)) + +(define edge-data + Graph V -> (get-data (<-dict (edge-dict Graph) V) V)) + +(define resolve + {(vector (list A)) --> (@p number number) --> A} + Vector (@p Index Place) -> (nth (+ 1 Place) (<-vector Vector Index))) + +(define resolve-vert + {graph --> (@p number number) --> A} + Graph Place -> (resolve (<-address (vert-dict Graph) 2) Place)) + +(define resolve-edge + {graph --> (@p number number) --> A} + Graph Place -> (resolve (<-address (edge-dict Graph) 2) Place)) + +(define edges-for + {graph --> A --> (list (list A))} + Graph Vert -> (let Val (trap-error (<-dict (vert-dict Graph) Vert) (/. E [])) + Edges (if (tuple? Val) (snd Val) Val) + (map (lambda X (fst (resolve-edge Graph X))) Val))) + +(define add-vertex-w-data + \* add a vertex to a graph *\ + {graph --> A --> B --> A} + G V Data -> (do (dict-> (vert-dict G) V (@p Data (edges-for G V))) V)) + +(define add-vertex-w/o-data + \* add a vertex to a graph *\ + {graph --> A --> B --> A} + G V -> (do (dict-> (vert-dict G) V (edges-for G V)) V)) + +(defmacro add-vertex-macro + [add-vertex G V] -> [add-vertex-w/o-data G V] + [add-vertex G V D] -> [add-vertex-w-data G V D]) + +(define update-vert + \* in a dict, add an edge to a vertex's edge list *\ + {vector --> (@p number number) --> A --> number} + Vs Edge V -> (let Store (<-address Vs 2) + N (hash V (limit Store)) + VertLst (trap-error (<-vector Store N) (/. E [])) + Contents (trap-error (<-dict Vs V) (/. E [])) + (do (dict-> Vs V (if (tuple? Contents) + (@p (fst Contents) + (adjoin Edge (snd Contents))) + (adjoin Edge Contents))) + (@p N (length VertLst))))) + +(define update-edges-vertices + \* add an edge to a graph *\ + {graph --> (list A) --> (list A)} + Graph Edge -> + (let Store (<-address (edge-dict Graph) 2) + EdgeID (hash Edge (limit Store)) + EdgeLst (trap-error (<-vector Store EdgeID) (/. E [])) + (map (update-vert (vert-dict Graph) (@p EdgeID (length EdgeLst))) Edge))) + +(define add-edge-w-data + G E D -> (do (dict-> (edge-dict G) E (@p D (update-edges-vertices G E))) E)) + +(define add-edge-w/o-data + G E -> (do (dict-> (edge-dict G) E (update-edges-vertices G E)) E)) + +(defmacro add-edge-macro + [add-edge G E] -> [add-edge-w/o-data G E] + [add-edge G E V] -> [add-edge-w-data G E V]) + +(define has-edge? + {graph --> (list A) --> boolean} + Graph Edge -> (key? (edge-dict Graph) Edge)) + +(define has-vertex? + {graph --> A --> boolean} + Graph Vertex -> (key? (vert-dict Graph) Vertex)) + +(define neighbors + \* Return the neighbors of a vertex *\ + {graph --> A --> (list A)} + Graph Vert -> (unique (mapcon (remove-first Vert) (edges-for Graph Vert)))) + +(define connected-to- + {graph --> (list A) --> (list A) --> (list A)} + Graph [] Already -> Already + Graph New Already -> + (let Reachable (unique (mapcon (neighbors Graph) New)) + New (difference Reachable Already) + (connected-to- Graph New (append New Already)))) + +(define connected-to + \* return all vertices connected to the given vertex, including itself *\ + {graph --> A --> (list A)} + Graph V -> (connected-to- Graph [V] [V])) + +(define connected? + \* return if a graph is fully connected *\ + {graph --> boolean} + Graph -> (reduce (/. V Acc + (and Acc + (subset? (vertices Graph) (connected-to Graph V)))) + true (vertices Graph))) + +(define connected-components- + \* given a graph return a list of connected components *\ + {graph --> (list A) --> (list (list A)) --> (list graph)} + Graph [] _ -> [] + Graph VS [] -> (map (/. V (let Component (graph 1 0) + (do (add-vertex Component V) Component))) + VS) + Graph [V|VS] ES -> + (let Con-verts (connected-to Graph V) + Con-edges (filter (/. E (subset? E Con-verts)) ES) + Component (graph (length Con-verts) (length Con-edges)) + (do (map (add-edge-w/o-data Component) Con-edges) + (cons Component (connected-components- Graph + (difference VS Con-verts) + (difference ES Con-edges)))))) + +(define connected-components + {graph --> (list graph)} + Graph -> (connected-components- Graph (vertices Graph) (edges Graph))) + +(define place-vertex + \* given a graph, vertex and list of partitions, partition the vertex *\ + {graph --> A --> (list (list A)) --> (list (list A))} + Graph V [] -> (if (element? V (neighbors Graph V)) + (simple-error + (make-string "self-loop ~S, no vertex partition" V)) + [[V]]) + Graph V [C|CS] -> (let Neighbors (neighbors Graph V) + (if (element? V Neighbors) + (simple-error + (make-string "self-loop ~S, no vertex partition" V)) + (if (empty? (intersection C Neighbors)) + [[V|C]|CS] + [C|(place-vertex Graph V CS)])))) + +(define vertex-partition + \* partition the vertices of a graph *\ + {graph --> (list (list A))} + Graph -> (reduce (place-vertex Graph) [] (vertices Graph))) + +(define bipartite? + \* check if a graph is bipartite *\ + {graph --> boolean} + Graph -> (= 2 (length (vertex-partition Graph)))) + +) + +\* simple tests + +(set g (graph)) +(add-edge (value g) [chris patton]) +(add-edge (value g) [eric chris]) +(add-vertex (value g) nobody) +(has-edge? (value g) [patton chris]) +(edges-for (value g) chris) +(neighbors (value g) chris) +(neighbors (value g) nobody) +(connected-to (value g) chris) +(connected? (value g)) +(connected-components (value g)) <- fail when package wrapper is used +(map (function vertices) (connected-components (value g))) + +*\ \ No newline at end of file diff --git a/samples/Shen/html.shen b/samples/Shen/html.shen new file mode 100644 index 00000000..62d93c30 --- /dev/null +++ b/samples/Shen/html.shen @@ -0,0 +1,102 @@ +\* html.shen --- html generation functions for shen + +Copyright (C) 2011, Eric Schulte + +*** License: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +*** Commentary: + +The standard lisp-to-html conversion tool suite. Follows some of +the convertions of Clojure's hiccup. + + an example... + +(8-) (html [ul#todo1.tasks.stuff [: [title "today"]] + (map (lambda Str [li Str]) ["get milk" "dishes"])]) +"
    +
  • get milk
  • dishes
" + +*** Code: *\ +(trap-error + (require string) + (/. E (load "../string/string.shen"))) + +(package string- [html + \* symbols included from string *\ + takestr dropstr substr length-str index-str + reverse-str starts-with substr? replace-str + join split trim-left trim-right chomp trim] + +(define to-str + \* return argument as a string, if already a string do not change *\ + X -> X where (string? X) + X -> (str X)) + +(define gassoc + X Y -> (hd (tl (assoc X Y)))) + +(define dassoc + X Y -> (remove (assoc X Y) Y)) + +(define passoc + [] Y -> Y + [X XV] Y -> (let Orig (gassoc X Y) + New (if (cons? Orig) [XV|Orig] XV) + [[X New]|(dassoc X Y)])) + +(define html + X -> X where (string? X) + [Tag [: |Attrs] |Body] -> + (let Tag-comps (css-parse-symbol Tag) + Tag (gassoc tag Tag-comps) + New-attrs (passoc (assoc class Tag-comps) + (passoc (assoc id Tag-comps) Attrs)) + (@s (make-string "<~S" Tag) (attributes New-attrs) ">" + (html Body) + (make-string "" Tag))) where (symbol? Tag) + [Tag|Body] -> (html [Tag [:] Body]) where (symbol? Tag) + [H|HS] -> (@s (html H) (html HS)) + [] -> "") + +(define css-parse-symbol + {symbol --> [[symbol A]]} + Symbol -> (let String (str Symbol) + Class-split (split (str .) String) + Class (map (function intern) (tl Class-split)) + Id-split (split (str #) (hd Class-split)) + Tag (hd Id-split) + Id (tl Id-split) + ((if (= [] Id) (/. X X) (cons [id (intern (hd Id))])) + ((if (= [] Class) (/. X X) (cons [class Class])) + [[tag (intern Tag)]])))) + +(define attributes + [] -> "" + [[K V]|AS] -> (@s " " (to-str K) "='" + (if (cons? V) (join " " (map (function str) V)) (to-str V)) + "'" (attributes AS))) + +) \ No newline at end of file diff --git a/samples/Shen/json.shen b/samples/Shen/json.shen new file mode 100644 index 00000000..b330c5c6 --- /dev/null +++ b/samples/Shen/json.shen @@ -0,0 +1,39 @@ +(load "grammar.shen") + +\* + +JSON Lexer + +1. Read a stream of characters +2. Whitespace characters not in strings should be discarded. +3. Whitespace characters in strings should be preserved +4. Strings can contain escaped double quotes. e.g. "\"" + +*\ + +(define whitespacep + \* e.g. ASCII 32 == #\Space. *\ + \* All the others are whitespace characters from an ASCII table. *\ + Char -> (member Char ["c#9;" "c#10;" "c#11;" "c#12;" "c#13;" "c#32;"])) + +(define replace-whitespace + "" -> "" + (@s Whitespace Suffix) -> (@s "" (replace-whitespace Suffix)) where (whitespacep Whitespace) + (@s Prefix Suffix) -> (@s Prefix (replace-whitespace Suffix))) + +(define fetch-until-unescaped-doublequote + [] -> [] + ["\" "c#34;" | Chars] -> ["\" "c#34;" | (fetch-until-unescaped-doublequote Chars)] + ["c#34;" | Chars] -> [] + [Char | Chars] -> [Char | (fetch-until-unescaped-doublequote Chars)]) + +\* (define strip-whitespace-chars *\ +\* [] -> [] *\ +\* ["c#34;" | Chars] -> ["c#34;" | ( *\ +\* [WhitespaceChar | Chars] -> (strip-whitespace-chars Chars) where (whitespace? WhitespaceChar) *\ +\* [Char | Chars] -> [Char | (strip-whitespace-chars Chars)]) *\ + +(define tokenise + JSONString -> + (let CharList (explode JSONString) + CharList)) \ No newline at end of file diff --git a/samples/Standard ML/RedBlackTree.fun b/samples/Standard ML/RedBlackTree.fun new file mode 100644 index 00000000..42650efe --- /dev/null +++ b/samples/Standard ML/RedBlackTree.fun @@ -0,0 +1,254 @@ +(* From Twelf *) +(* Red/Black Trees *) +(* Author: Frank Pfenning *) + +functor RedBlackTree + (type key' + val compare : key' * key' -> order) + :> TABLE where type key = key' = +struct + type key = key' + type 'a entry = key * 'a + + datatype 'a dict = + Empty (* considered black *) + | Red of 'a entry * 'a dict * 'a dict + | Black of 'a entry * 'a dict * 'a dict + + type 'a Table = 'a dict ref + + (* Representation Invariants *) + (* + 1. The tree is ordered: for every node Red((key1,datum1), left, right) or + Black ((key1,datum1), left, right), every key in left is less than + key1 and every key in right is greater than key1. + + 2. The children of a red node are black (color invariant). + + 3. Every path from the root to a leaf has the same number of + black nodes, called the black height of the tree. + *) + + local + + fun lookup dict key = + let + fun lk (Empty) = NONE + | lk (Red tree) = lk' tree + | lk (Black tree) = lk' tree + and lk' ((key1, datum1), left, right) = + (case compare(key,key1) + of EQUAL => SOME(datum1) + | LESS => lk left + | GREATER => lk right) + in + lk dict + end + + (* val restore_right : 'a dict -> 'a dict *) + (* + restore_right (Black(e,l,r)) >=> dict + where (1) Black(e,l,r) is ordered, + (2) Black(e,l,r) has black height n, + (3) color invariant may be violated at the root of r: + one of its children might be red. + and dict is a re-balanced red/black tree (satisfying all invariants) + and same black height n. + *) + fun restore_right (Black(e, Red lt, Red (rt as (_,Red _,_)))) = + Red(e, Black lt, Black rt) (* re-color *) + | restore_right (Black(e, Red lt, Red (rt as (_,_,Red _)))) = + Red(e, Black lt, Black rt) (* re-color *) + | restore_right (Black(e, l, Red(re, Red(rle, rll, rlr), rr))) = + (* l is black, deep rotate *) + Black(rle, Red(e, l, rll), Red(re, rlr, rr)) + | restore_right (Black(e, l, Red(re, rl, rr as Red _))) = + (* l is black, shallow rotate *) + Black(re, Red(e, l, rl), rr) + | restore_right dict = dict + + (* restore_left is like restore_right, except *) + (* the color invariant may be violated only at the root of left child *) + fun restore_left (Black(e, Red (lt as (_,Red _,_)), Red rt)) = + Red(e, Black lt, Black rt) (* re-color *) + | restore_left (Black(e, Red (lt as (_,_,Red _)), Red rt)) = + Red(e, Black lt, Black rt) (* re-color *) + | restore_left (Black(e, Red(le, ll as Red _, lr), r)) = + (* r is black, shallow rotate *) + Black(le, ll, Red(e, lr, r)) + | restore_left (Black(e, Red(le, ll, Red(lre, lrl, lrr)), r)) = + (* r is black, deep rotate *) + Black(lre, Red(le, ll, lrl), Red(e, lrr, r)) + | restore_left dict = dict + + fun insert (dict, entry as (key,datum)) = + let + (* val ins : 'a dict -> 'a dict inserts entry *) + (* ins (Red _) may violate color invariant at root *) + (* ins (Black _) or ins (Empty) will be red/black tree *) + (* ins preserves black height *) + fun ins (Empty) = Red(entry, Empty, Empty) + | ins (Red(entry1 as (key1, datum1), left, right)) = + (case compare(key,key1) + of EQUAL => Red(entry, left, right) + | LESS => Red(entry1, ins left, right) + | GREATER => Red(entry1, left, ins right)) + | ins (Black(entry1 as (key1, datum1), left, right)) = + (case compare(key,key1) + of EQUAL => Black(entry, left, right) + | LESS => restore_left (Black(entry1, ins left, right)) + | GREATER => restore_right (Black(entry1, left, ins right))) + in + case ins dict + of Red (t as (_, Red _, _)) => Black t (* re-color *) + | Red (t as (_, _, Red _)) => Black t (* re-color *) + | dict => dict + end + + (* function below from .../smlnj-lib/Util/int-redblack-set.sml *) + (* Need to check and improve some time *) + (* Sun Mar 13 08:22:53 2005 -fp *) + + (* Remove an item. Returns true if old item found, false otherwise *) + local + exception NotFound + datatype 'a zipper + = TOP + | LEFTB of ('a entry * 'a dict * 'a zipper) + | LEFTR of ('a entry * 'a dict * 'a zipper) + | RIGHTB of ('a dict * 'a entry * 'a zipper) + | RIGHTR of ('a dict * 'a entry * 'a zipper) + in + fun delete t key = + let + fun zip (TOP, t) = t + | zip (LEFTB(x, b, z), a) = zip(z, Black(x, a, b)) + | zip (LEFTR(x, b, z), a) = zip(z, Red(x, a, b)) + | zip (RIGHTB(a, x, z), b) = zip(z, Black(x, a, b)) + | zip (RIGHTR(a, x, z), b) = zip(z, Red(x, a, b)) + (* bbZip propagates a black deficit up the tree until either the top + * is reached, or the deficit can be covered. It returns a boolean + * that is true if there is still a deficit and the zipped tree. + *) + fun bbZip (TOP, t) = (true, t) + | bbZip (LEFTB(x, Red(y, c, d), z), a) = (* case 1L *) + bbZip (LEFTR(x, c, LEFTB(y, d, z)), a) + | bbZip (LEFTB(x, Black(w, Red(y, c, d), e), z), a) = (* case 3L *) + bbZip (LEFTB(x, Black(y, c, Red(w, d, e)), z), a) + | bbZip (LEFTR(x, Black(w, Red(y, c, d), e), z), a) = (* case 3L *) + bbZip (LEFTR(x, Black(y, c, Red(w, d, e)), z), a) + | bbZip (LEFTB(x, Black(y, c, Red(w, d, e)), z), a) = (* case 4L *) + (false, zip (z, Black(y, Black(x, a, c), Black(w, d, e)))) + | bbZip (LEFTR(x, Black(y, c, Red(w, d, e)), z), a) = (* case 4L *) + (false, zip (z, Red(y, Black(x, a, c), Black(w, d, e)))) + | bbZip (LEFTR(x, Black(y, c, d), z), a) = (* case 2L *) + (false, zip (z, Black(x, a, Red(y, c, d)))) + | bbZip (LEFTB(x, Black(y, c, d), z), a) = (* case 2L *) + bbZip (z, Black(x, a, Red(y, c, d))) + | bbZip (RIGHTB(Red(y, c, d), x, z), b) = (* case 1R *) + bbZip (RIGHTR(d, x, RIGHTB(c, y, z)), b) + | bbZip (RIGHTR(Red(y, c, d), x, z), b) = (* case 1R *) + bbZip (RIGHTR(d, x, RIGHTB(c, y, z)), b) + | bbZip (RIGHTB(Black(y, Red(w, c, d), e), x, z), b) = (* case 3R *) + bbZip (RIGHTB(Black(w, c, Red(y, d, e)), x, z), b) + | bbZip (RIGHTR(Black(y, Red(w, c, d), e), x, z), b) = (* case 3R *) + bbZip (RIGHTR(Black(w, c, Red(y, d, e)), x, z), b) + | bbZip (RIGHTB(Black(y, c, Red(w, d, e)), x, z), b) = (* case 4R *) + (false, zip (z, Black(y, c, Black(x, Red(w, d, e), b)))) + | bbZip (RIGHTR(Black(y, c, Red(w, d, e)), x, z), b) = (* case 4R *) + (false, zip (z, Red(y, c, Black(w, Red(w, d, e), b)))) + | bbZip (RIGHTR(Black(y, c, d), x, z), b) = (* case 2R *) + (false, zip (z, Black(x, Red(y, c, d), b))) + | bbZip (RIGHTB(Black(y, c, d), x, z), b) = (* case 2R *) + bbZip (z, Black(x, Red(y, c, d), b)) + | bbZip (z, t) = (false, zip(z, t)) + fun delMin (Red(y, Empty, b), z) = (y, (false, zip(z, b))) + | delMin (Black(y, Empty, b), z) = (y, bbZip(z, b)) + | delMin (Black(y, a, b), z) = delMin(a, LEFTB(y, b, z)) + | delMin (Red(y, a, b), z) = delMin(a, LEFTR(y, b, z)) + | delMin (Empty, _) = raise Match + fun joinRed (Empty, Empty, z) = zip(z, Empty) + | joinRed (a, b, z) = let + val (x, (needB, b')) = delMin(b, TOP) + in + if needB + then #2(bbZip(z, Red(x, a, b'))) + else zip(z, Red(x, a, b')) + end + fun joinBlack (a, Empty, z) = #2(bbZip(z, a)) + | joinBlack (Empty, b, z) = #2(bbZip(z, b)) + | joinBlack (a, b, z) = let + val (x, (needB, b')) = delMin(b, TOP) + in + if needB + then #2(bbZip(z, Black(x, a, b'))) + else zip(z, Black(x, a, b')) + end + fun del (Empty, z) = raise NotFound + | del (Black(entry1 as (key1, datum1), a, b), z) = + (case compare(key,key1) + of EQUAL => joinBlack (a, b, z) + | LESS => del (a, LEFTB(entry1, b, z)) + | GREATER => del (b, RIGHTB(a, entry1, z))) + | del (Red(entry1 as (key1, datum1), a, b), z) = + (case compare(key,key1) + of EQUAL => joinRed (a, b, z) + | LESS => del (a, LEFTR(entry1, b, z)) + | GREATER => del (b, RIGHTR(a, entry1, z))) + in + (del(t, TOP); true) handle NotFound => false + end + end (* local *) + + (* use non-imperative version? *) + fun insertShadow (dict, entry as (key,datum)) = + let val oldEntry = ref NONE (* : 'a entry option ref *) + fun ins (Empty) = Red(entry, Empty, Empty) + | ins (Red(entry1 as (key1, datum1), left, right)) = + (case compare(key,key1) + of EQUAL => (oldEntry := SOME(entry1); + Red(entry, left, right)) + | LESS => Red(entry1, ins left, right) + | GREATER => Red(entry1, left, ins right)) + | ins (Black(entry1 as (key1, datum1), left, right)) = + (case compare(key,key1) + of EQUAL => (oldEntry := SOME(entry1); + Black(entry, left, right)) + | LESS => restore_left (Black(entry1, ins left, right)) + | GREATER => restore_right (Black(entry1, left, ins right))) + in + (oldEntry := NONE; + ((case ins dict + of Red (t as (_, Red _, _)) => Black t (* re-color *) + | Red (t as (_, _, Red _)) => Black t (* re-color *) + | dict => dict), + !oldEntry)) + end + + fun app f dict = + let fun ap (Empty) = () + | ap (Red tree) = ap' tree + | ap (Black tree) = ap' tree + and ap' (entry1, left, right) = + (ap left; f entry1; ap right) + in + ap dict + end + + in + fun new (n) = ref (Empty) (* ignore size hint *) + val insert = (fn table => fn entry => (table := insert (!table, entry))) + val insertShadow = + (fn table => fn entry => + let + val (dict, oldEntry) = insertShadow (!table, entry) + in + (table := dict; oldEntry) + end) + val lookup = (fn table => fn key => lookup (!table) key) + val delete = (fn table => fn key => (delete (!table) key; ())) + val clear = (fn table => (table := Empty)) + val app = (fn f => fn table => app f (!table)) + end + +end; (* functor RedBlackTree *) diff --git a/samples/Standard ML/main.fun b/samples/Standard ML/main.fun new file mode 100644 index 00000000..73ba50f6 --- /dev/null +++ b/samples/Standard ML/main.fun @@ -0,0 +1,1470 @@ +(* Copyright (C) 2010-2011,2013 Matthew Fluet. + * Copyright (C) 1999-2009 Henry Cejtin, Matthew Fluet, Suresh + * Jagannathan, and Stephen Weeks. + * Copyright (C) 1997-2000 NEC Research Institute. + * + * MLton is released under a BSD-style license. + * See the file MLton-LICENSE for details. + *) + +functor Main (S: MAIN_STRUCTS): MAIN = +struct + +open S + +structure Compile = Compile () + +structure Place = + struct + datatype t = Files | Generated | MLB | O | OUT | SML | TypeCheck + + val toInt: t -> int = + fn MLB => 1 + | SML => 1 + | Files => 2 + | TypeCheck => 4 + | Generated => 5 + | O => 6 + | OUT => 7 + + val toString = + fn Files => "files" + | SML => "sml" + | MLB => "mlb" + | Generated => "g" + | O => "o" + | OUT => "out" + | TypeCheck => "tc" + + fun compare (p, p') = Int.compare (toInt p, toInt p') + end + +structure OptPred = + struct + datatype t = + Target of string + | Yes + end + +structure Show = + struct + datatype t = Anns | PathMap + end + +val gcc: string ref = ref "" +val arScript: string ref = ref "" +val asOpts: {opt: string, pred: OptPred.t} list ref = ref [] +val ccOpts: {opt: string, pred: OptPred.t} list ref = ref [] +val linkOpts: {opt: string, pred: OptPred.t} list ref = ref [] + +val buildConstants: bool ref = ref false +val debugRuntime: bool ref = ref false +datatype debugFormat = Dwarf | DwarfPlus | Dwarf2 | Stabs | StabsPlus +val debugFormat: debugFormat option ref = ref NONE +val expert: bool ref = ref false +val explicitAlign: Control.align option ref = ref NONE +val explicitChunk: Control.chunk option ref = ref NONE +datatype explicitCodegen = Native | Explicit of Control.codegen +val explicitCodegen: explicitCodegen option ref = ref NONE +val keepGenerated = ref false +val keepO = ref false +val output: string option ref = ref NONE +val profileSet: bool ref = ref false +val profileTimeSet: bool ref = ref false +val runtimeArgs: string list ref = ref ["@MLton"] +val show: Show.t option ref = ref NONE +val stop = ref Place.OUT + +fun parseMlbPathVar (line: String.t) = + case String.tokens (line, Char.isSpace) of + [var, path] => SOME {var = var, path = path} + | _ => NONE + +fun readMlbPathMap (file: File.t) = + if not (File.canRead file) then + Error.bug (concat ["can't read MLB path map file: ", file]) + else + List.keepAllMap + (File.lines file, fn line => + if String.forall (line, Char.isSpace) + then NONE + else + case parseMlbPathVar line of + NONE => Error.bug (concat ["strange mlb path mapping: ", + file, ":: ", line]) + | SOME v => SOME v) + +val targetMap: unit -> {arch: MLton.Platform.Arch.t, + os: MLton.Platform.OS.t, + target: string} list = + Promise.lazy + (fn () => + let + val targetsDir = + OS.Path.mkAbsolute { path = "targets", + relativeTo = !Control.libDir } + val potentialTargets = Dir.lsDirs targetsDir + fun targetMap target = + let + val targetDir = + OS.Path.mkAbsolute { path = target, + relativeTo = targetsDir } + val osFile = + OS.Path.joinDirFile { dir = targetDir, + file = "os" } + val archFile = + OS.Path.joinDirFile { dir = targetDir, + file = "arch" } + val os = File.contents osFile + val arch = File.contents archFile + val os = List.first (String.tokens (os, Char.isSpace)) + val arch = List.first (String.tokens (arch, Char.isSpace)) + val os = + case MLton.Platform.OS.fromString os of + NONE => Error.bug (concat ["strange os: ", os]) + | SOME os => os + val arch = + case MLton.Platform.Arch.fromString arch of + NONE => Error.bug (concat ["strange arch: ", arch]) + | SOME a => a + in + SOME { arch = arch, os = os, target = target } + end + handle _ => NONE + in + List.keepAllMap (potentialTargets, targetMap) + end) + +fun setTargetType (target: string, usage): unit = + case List.peek (targetMap (), fn {target = t, ...} => target = t) of + NONE => usage (concat ["invalid target: ", target]) + | SOME {arch, os, ...} => + let + open Control + in + Target.arch := arch + ; Target.os := os + end + +fun hasCodegen (cg) = + let + datatype z = datatype Control.Target.arch + datatype z = datatype Control.Target.os + datatype z = datatype Control.Format.t + datatype z = datatype Control.codegen + in + case !Control.Target.arch of + AMD64 => (case cg of + x86Codegen => false + | _ => true) + | X86 => (case cg of + amd64Codegen => false + | x86Codegen => + (* Darwin PIC doesn't work *) + !Control.Target.os <> Darwin orelse + !Control.format = Executable orelse + !Control.format = Archive + | _ => true) + | _ => (case cg of + amd64Codegen => false + | x86Codegen => false + | _ => true) + end +fun hasNativeCodegen () = + let + datatype z = datatype Control.codegen + in + hasCodegen amd64Codegen + orelse hasCodegen x86Codegen + end + + +fun defaultAlignIs8 () = + let + datatype z = datatype Control.Target.arch + in + case !Control.Target.arch of + Alpha => true + | AMD64 => true + | ARM => true + | HPPA => true + | IA64 => true + | MIPS => true + | Sparc => true + | S390 => true + | _ => false + end + +fun makeOptions {usage} = + let + val usage = fn s => (ignore (usage s); raise Fail "unreachable") + fun reportAnnotation (s, flag, e) = + case e of + Control.Elaborate.Bad => + usage (concat ["invalid -", flag, " flag: ", s]) + | Control.Elaborate.Deprecated ids => + if !Control.warnDeprecated + then + Out.output + (Out.error, + concat ["Warning: ", "deprecated annotation: ", s, ", use ", + List.toString Control.Elaborate.Id.name ids, ".\n"]) + else () + | Control.Elaborate.Good () => () + | Control.Elaborate.Other => + usage (concat ["invalid -", flag, " flag: ", s]) + open Control Popt + datatype z = datatype MLton.Platform.Arch.t + datatype z = datatype MLton.Platform.OS.t + fun tokenizeOpt f opts = + List.foreach (String.tokens (opts, Char.isSpace), + fn opt => f opt) + fun tokenizeTargetOpt f (target, opts) = + List.foreach (String.tokens (opts, Char.isSpace), + fn opt => f (target, opt)) + in + List.map + ( + [ + (Normal, "align", if defaultAlignIs8 () then " {8|4}" else " {4|8}", + "object alignment", + (SpaceString (fn s => + explicitAlign + := SOME (case s of + "4" => Align4 + | "8" => Align8 + | _ => usage (concat ["invalid -align flag: ", + s]))))), + (Expert, "ar-script", " ", "path to a script producing archives", + SpaceString (fn s => arScript := s)), + (Normal, "as-opt", " ", "pass option to assembler", + (SpaceString o tokenizeOpt) + (fn s => List.push (asOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "as-opt-quote", " ", "pass (quoted) option to assembler", + SpaceString + (fn s => List.push (asOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "build-constants", " {false|true}", + "output C file that prints basis constants", + boolRef buildConstants), + (Expert, "cc", " ", "path to gcc executable", + SpaceString (fn s => gcc := s)), + (Normal, "cc-opt", " ", "pass option to C compiler", + (SpaceString o tokenizeOpt) + (fn s => List.push (ccOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "cc-opt-quote", " ", "pass (quoted) option to C compiler", + SpaceString + (fn s => List.push (ccOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "chunkify", " {coalesce|func|one}", "set chunkify method", + SpaceString (fn s => + explicitChunk + := SOME (case s of + "func" => ChunkPerFunc + | "one" => OneChunk + | _ => let + val usage = fn () => + usage (concat ["invalid -chunkify flag: ", s]) + in + if String.hasPrefix (s, {prefix = "coalesce"}) + then let + val s = String.dropPrefix (s, 8) + in + if String.forall (s, Char.isDigit) + then (case Int.fromString s of + NONE => usage () + | SOME n => Coalesce + {limit = n}) + else usage () + end + else usage () + end))), + (Expert, "closure-convert-globalize", " {true|false}", + "whether to globalize during closure conversion", + Bool (fn b => (closureConvertGlobalize := b))), + (Expert, "closure-convert-shrink", " {true|false}", + "whether to shrink during closure conversion", + Bool (fn b => (closureConvertShrink := b))), + (Normal, "codegen", + concat [" {", + String.concatWith + (List.keepAllMap + (Native :: (List.map (Control.Codegen.all, Explicit)), + fn cg => + case cg of + Native => if hasNativeCodegen () then SOME "native" else NONE + | Explicit cg => if hasCodegen cg + then SOME (Control.Codegen.toString cg) + else NONE), + "|"), + "}"], + "which code generator to use", + SpaceString (fn s => + explicitCodegen + := SOME (if s = "native" + then Native + else (case List.peek + (Control.Codegen.all, fn cg => + s = Control.Codegen.toString cg) of + SOME cg => Explicit cg + | NONE => usage (concat ["invalid -codegen flag: ", s]))))), + (Normal, "const", " ' '", "set compile-time constant", + SpaceString (fn s => + case String.tokens (s, Char.isSpace) of + [name, value] => + Compile.setCommandLineConstant {name = name, + value = value} + | _ => usage (concat ["invalid -const flag: ", s]))), + (Expert, "contify-into-main", " {false|true}", + "contify functions into main", + boolRef contifyIntoMain), + (Expert, "debug", " {false|true}", "produce executable with debug info", + Bool (fn b => (debug := b + ; debugRuntime := b))), + (Expert, "debug-runtime", " {false|true}", "produce executable with debug info", + boolRef debugRuntime), + (Expert, "debug-format", " {default|dwarf|dwarf+|drwaf2|stabs|stabs+}", + "choose debug symbol format", + SpaceString (fn s => + debugFormat := + (case s of + "default" => NONE + | "dwarf" => SOME Dwarf + | "dwarf+" => SOME DwarfPlus + | "dwarf2" => SOME Dwarf2 + | "stabs" => SOME Stabs + | "stabs+" => SOME StabsPlus + | _ => usage (concat ["invalid -debug-format flag: ", s])))), + let + val flag = "default-ann" + in + (Normal, flag, " ", "set annotation default for mlb files", + SpaceString + (fn s => reportAnnotation (s, flag, + Control.Elaborate.processDefault s))) + end, + (Normal, "default-type", " ''", "set default type", + SpaceString + (fn s => (case s of + "char8" => Control.defaultChar := s + | "int8" => Control.defaultInt := s + | "int16" => Control.defaultInt := s + | "int32" => Control.defaultInt := s + | "int64" => Control.defaultInt := s + | "intinf" => Control.defaultInt := s + | "real32" => Control.defaultReal := s + | "real64" => Control.defaultReal := s + | "widechar16" => Control.defaultWideChar := s + | "widechar32" => Control.defaultWideChar := s + | "word8" => Control.defaultWord := s + | "word16" => Control.defaultWord := s + | "word32" => Control.defaultWord := s + | "word64" => Control.defaultWord := s + | _ => usage (concat ["invalid -default-type flag: ", s])))), + (Expert, "diag-pass", " ", "keep diagnostic info for pass", + SpaceString + (fn s => + (case Regexp.fromString s of + SOME (re,_) => let val re = Regexp.compileDFA re + in List.push (diagPasses, re) + end + | NONE => usage (concat ["invalid -diag-pass flag: ", s])))), + let + val flag = "disable-ann" + in + (Normal, flag, " ", "disable annotation in mlb files", + SpaceString + (fn s => + reportAnnotation (s, flag, + Control.Elaborate.processEnabled (s, false)))) + end, + (Expert, "drop-pass", " ", "omit optimization pass", + SpaceString + (fn s => (case Regexp.fromString s of + SOME (re,_) => let val re = Regexp.compileDFA re + in List.push (dropPasses, re) + end + | NONE => usage (concat ["invalid -drop-pass flag: ", s])))), + let + val flag = "enable-ann" + in + (Expert, flag, " ", "globally enable annotation", + SpaceString + (fn s => + reportAnnotation (s, flag, + Control.Elaborate.processEnabled (s, true)))) + end, + (Expert, "error-threshhold", " ", "error threshhold (20)", + intRef errorThreshhold), + (Expert, "emit-main", " {true|false}", "emit main() startup function", + boolRef emitMain), + (Expert, "expert", " {false|true}", "enable expert status", + boolRef expert), + (Normal, "export-header", " ", "write C header file for _export's", + SpaceString (fn s => exportHeader := SOME s)), + (Expert, "format", + concat [" {", + String.concatWith + (List.keepAllMap + (Control.Format.all, fn cg => SOME (Control.Format.toString cg)), + "|"), + "}"], + "generated output format", + SpaceString (fn s => + Control.format + := (case List.peek + (Control.Format.all, fn cg => + s = Control.Format.toString cg) of + SOME cg => cg + | NONE => usage (concat ["invalid -format flag: ", s])))), + (Expert, "gc-check", " {limit|first|every}", "force GCs", + SpaceString (fn s => + gcCheck := + (case s of + "limit" => Limit + | "first" => First + | "every" => Every + | _ => usage (concat ["invalid -gc-check flag: ", s])))), + (Normal, "ieee-fp", " {false|true}", "use strict IEEE floating-point", + boolRef Native.IEEEFP), + (Expert, "indentation", " ", "indentation level in ILs", + intRef indentation), + (Normal, "inline", " ", "set inlining threshold", + Int (fn i => inlineNonRec := {small = i, + product = #product (!inlineNonRec)})), + (Expert, "inline-into-main", " {true|false}", + "inline functions into main", + boolRef inlineIntoMain), + (Expert, "inline-leafa-loops", " {true|false}", "leaf inline loops", + Bool (fn loops => + case !inlineLeafA of + {repeat, size, ...} => + inlineLeafA := + {loops = loops, repeat = repeat, size = size})), + (Expert, "inline-leafa-repeat", " {true|false}", "leaf inline repeat", + Bool (fn repeat => + case !inlineLeafA of + {loops, size, ...} => + inlineLeafA := + {loops = loops, repeat = repeat, size = size})), + (Expert, "inline-leafa-size", " ", "set leaf inlining threshold (20)", + SpaceString (fn s => + case !inlineLeafA of + {loops, repeat, ...} => + inlineLeafA := + {loops = loops, repeat = repeat, + size = (if s = "inf" + then NONE + else if String.forall (s, Char.isDigit) + then Int.fromString s + else (usage o concat) + ["invalid -inline-leaf-size flag: ", s])})), + (Expert, "inline-leafb-loops", " {true|false}", "leaf inline loops", + Bool (fn loops => + case !inlineLeafB of + {repeat, size, ...} => + inlineLeafB := + {loops = loops, repeat = repeat, size = size})), + (Expert, "inline-leafb-repeat", " {true|false}", "leaf inline repeat", + Bool (fn repeat => + case !inlineLeafB of + {loops, size, ...} => + inlineLeafB := + {loops = loops, repeat = repeat, size = size})), + (Expert, "inline-leafb-size", " ", "set leaf inlining threshold (40)", + SpaceString (fn s => + case !inlineLeafB of + {loops, repeat, ...} => + inlineLeafB := + {loops = loops, repeat = repeat, + size = (if s = "inf" + then NONE + else if String.forall (s, Char.isDigit) + then Int.fromString s + else (usage o concat) + ["invalid -inline-leaf-size flag: ", s])})), + (Expert, "inline-nonrec-product", " ", "set inlining threshold (320)", + Int (fn product => + case !inlineNonRec of + {small, ...} => + inlineNonRec := {small = small, product = product})), + (Expert, "inline-nonrec-small", " ", "set inlining threshold (60)", + Int (fn small => + case !inlineNonRec of + {product, ...} => + inlineNonRec := {small = small, product = product})), + (Normal, "keep", " {g|o}", "save intermediate files", + SpaceString (fn s => + case s of + "core-ml" => keepCoreML := true + | "dot" => keepDot := true + | "g" => keepGenerated := true + | "machine" => keepMachine := true + | "o" => keepO := true + | "rssa" => keepRSSA := true + | "ssa" => keepSSA := true + | "ssa2" => keepSSA2 := true + | "sxml" => keepSXML := true + | "xml" => keepXML := true + | _ => usage (concat ["invalid -keep flag: ", s]))), + (Expert, "keep-pass", " ", "keep the results of pass", + SpaceString + (fn s => (case Regexp.fromString s of + SOME (re,_) => let val re = Regexp.compileDFA re + in List.push (keepPasses, re) + end + | NONE => usage (concat ["invalid -keep-pass flag: ", s])))), + (Expert, "libname", " ", "the name of the generated library", + SpaceString (fn s => libname := s)), + (Normal, "link-opt", " ", "pass option to linker", + (SpaceString o tokenizeOpt) + (fn s => List.push (linkOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "link-opt-quote", " ", "pass (quoted) option to linker", + SpaceString + (fn s => List.push (linkOpts, {opt = s, pred = OptPred.Yes}))), + (Expert, "loop-passes", " ", "loop optimization passes (1)", + Int + (fn i => + if i >= 1 + then loopPasses := i + else usage (concat ["invalid -loop-passes arg: ", Int.toString i]))), + (Expert, "mark-cards", " {true|false}", "mutator marks cards", + boolRef markCards), + (Expert, "max-function-size", " ", "max function size (blocks)", + intRef maxFunctionSize), + (Normal, "mlb-path-map", " ", "additional MLB path map", + SpaceString (fn s => mlbPathVars := !mlbPathVars @ readMlbPathMap s)), + (Normal, "mlb-path-var", " ' '", "additional MLB path var", + SpaceString + (fn s => mlbPathVars := !mlbPathVars @ + [case parseMlbPathVar s of + NONE => Error.bug ("strange mlb path var: " ^ s) + | SOME v => v])), + (Expert, "native-commented", " ", "level of comments (0)", + intRef Native.commented), + (Expert, "native-copy-prop", " {true|false}", + "use copy propagation", + boolRef Native.copyProp), + (Expert, "native-cutoff", " ", + "live transfer cutoff distance", + intRef Native.cutoff), + (Expert, "native-live-transfer", " {0,...,8}", + "use live transfer", + intRef Native.liveTransfer), + (Expert, "native-live-stack", " {false|true}", + "track liveness of stack slots", + boolRef Native.liveStack), + (Expert, "native-move-hoist", " {true|false}", + "use move hoisting", + boolRef Native.moveHoist), + (Expert, "native-optimize", " ", "level of optimizations", + intRef Native.optimize), + (Expert, "native-split", " ", "split assembly files at ~n lines", + Int (fn i => Native.split := SOME i)), + (Expert, "native-shuffle", " {true|false}", + "shuffle registers at C-calls", + Bool (fn b => Native.shuffle := b)), + (Expert, "opt-passes", " {default|minimal}", "level of optimizations", + SpaceString (fn s => + let + fun err s = + usage (concat ["invalid -opt-passes flag: ", s]) + in + List.foreach + (!optimizationPasses, fn {il,set,...} => + case set s of + Result.Yes () => () + | Result.No s' => err (concat [s', "(for ", il, ")"])) + end)), + (Normal, "output", " ", "name of output file", + SpaceString (fn s => output := SOME s)), + (Expert, "polyvariance", " {true|false}", "use polyvariance", + Bool (fn b => if b then () else polyvariance := NONE)), + (Expert, "polyvariance-hofo", " {true|false}", "duplicate higher-order fns only", + Bool (fn hofo => + case !polyvariance of + SOME {product, rounds, small, ...} => + polyvariance := SOME {hofo = hofo, + product = product, + rounds = rounds, + small = small} + | _ => ())), + (Expert, "polyvariance-product", " ", "set polyvariance threshold (300)", + Int (fn product => + case !polyvariance of + SOME {hofo, rounds, small, ...} => + polyvariance := SOME {hofo = hofo, + product = product, + rounds = rounds, + small = small} + | _ => ())), + (Expert, "polyvariance-rounds", " ", "set polyvariance rounds (2)", + Int (fn rounds => + case !polyvariance of + SOME {hofo, product, small, ...} => + polyvariance := SOME {hofo = hofo, + product = product, + rounds = rounds, + small = small} + | _ => ())), + (Expert, "polyvariance-small", " ", "set polyvariance threshold (30)", + Int (fn small => + case !polyvariance of + SOME {hofo, product, rounds, ...} => + polyvariance := SOME {hofo = hofo, + product = product, + rounds = rounds, + small = small} + | _ => ())), + (Expert, "prefer-abs-paths", " {false|true}", + "prefer absolute paths when referring to files", + boolRef preferAbsPaths), + (Expert, "prof-pass", " ", "keep profile info for pass", + SpaceString (fn s => + (case Regexp.fromString s of + SOME (re,_) => let val re = Regexp.compileDFA re + in + List.push (profPasses, re) + end + | NONE => usage (concat ["invalid -diag-pass flag: ", s])))), + (Normal, "profile", " {no|alloc|count|time}", + "produce executable suitable for profiling", + SpaceString + (fn s => + if !profileSet + then usage "can't have multiple -profile switches" + else + (profileSet := true + ; profile := (case s of + "no" => ProfileNone + | "alloc" => ProfileAlloc + | "call" => ProfileCallStack + | "count" => ProfileCount + | "drop" => ProfileDrop + | "label" => ProfileLabel + | "time" => (profileTimeSet := true + ; ProfileTimeLabel) + | "time-field" => ProfileTimeField + | "time-label" => ProfileTimeLabel + | _ => usage (concat + ["invalid -profile arg: ", s]))))), + (Normal, "profile-branch", " {false|true}", + "profile branches in addition to functions", + boolRef profileBranch), + (Expert, "profile-c", " ", + "include C-calls in files matching in profile", + SpaceString + (fn s => + (case Regexp.fromString s of + SOME (re,_) => let + open Regexp + val re = seq [anys, re, anys] + val re = compileDFA re + in List.push (profileC, re) + end + | NONE => usage (concat ["invalid -profile-c flag: ", s])))), + (Expert, "profile-exclude", " ", + "exclude files matching from profile", + SpaceString + (fn s => + (case Regexp.fromString s of + SOME (re,_) => let + open Regexp + val re = seq [anys, re, anys] + val re = compileDFA re + in List.push (profileInclExcl, (re, false)) + end + | NONE => usage (concat ["invalid -profile-exclude flag: ", s])))), + (Expert, "profile-il", " {source}", "where to insert profile exps", + SpaceString + (fn s => + case s of + "source" => profileIL := ProfileSource + | "ssa" => profileIL := ProfileSSA + | "ssa2" => profileIL := ProfileSSA2 + | _ => usage (concat ["invalid -profile-il arg: ", s]))), + (Expert, "profile-include", " ", + "include files matching from profile", + SpaceString + (fn s => + (case Regexp.fromString s of + SOME (re,_) => let + open Regexp + val re = seq [anys, re, anys] + val re = compileDFA re + in List.push (profileInclExcl, (re, true)) + end + | NONE => usage (concat ["invalid -profile-include flag: ", s])))), + (Expert, "profile-raise", " {false|true}", + "profile raises in addition to functions", + boolRef profileRaise), + (Normal, "profile-stack", " {false|true}", "profile the stack", + boolRef profileStack), + (Normal, "profile-val", " {false|true}", + "profile val bindings in addition to functions", + boolRef profileVal), + (Normal, "runtime", " ", "pass arg to runtime via @MLton", + SpaceString (fn s => List.push (runtimeArgs, s))), + (Expert, "show", " {anns|path-map}", "print specified data and stop", + SpaceString + (fn s => + show := SOME (case s of + "anns" => Show.Anns + | "path-map" => Show.PathMap + | _ => usage (concat ["invalid -show arg: ", s])))), + (Normal, "show-basis", " ", "write out the final basis environment", + SpaceString (fn s => showBasis := SOME s)), + (Normal, "show-def-use", " ", "write def-use information", + SpaceString (fn s => showDefUse := SOME s)), + (Expert, "show-types", " {true|false}", "show types in ILs", + boolRef showTypes), + (Expert, "ssa-passes", " ", "ssa optimization passes", + SpaceString + (fn s => + case List.peek (!Control.optimizationPasses, + fn {il, ...} => String.equals ("ssa", il)) of + SOME {set, ...} => + (case set s of + Result.Yes () => () + | Result.No s' => usage (concat ["invalid -ssa-passes arg: ", s'])) + | NONE => Error.bug "ssa optimization passes missing")), + (Expert, "ssa2-passes", " ", "ssa2 optimization passes", + SpaceString + (fn s => + case List.peek (!Control.optimizationPasses, + fn {il, ...} => String.equals ("ssa2", il)) of + SOME {set, ...} => + (case set s of + Result.Yes () => () + | Result.No s' => usage (concat ["invalid -ssa2-passes arg: ", s'])) + | NONE => Error.bug "ssa2 optimization passes missing")), + (Normal, "stop", " {f|g|o|tc}", "when to stop", + SpaceString + (fn s => + stop := (case s of + "f" => Place.Files + | "g" => Place.Generated + | "o" => Place.O + | "tc" => Place.TypeCheck + | _ => usage (concat ["invalid -stop arg: ", s])))), + (Expert, "sxml-passes", " ", "sxml optimization passes", + SpaceString + (fn s => + case List.peek (!Control.optimizationPasses, + fn {il, ...} => String.equals ("sxml", il)) of + SOME {set, ...} => + (case set s of + Result.Yes () => () + | Result.No s' => usage (concat ["invalid -sxml-passes arg: ", s'])) + | NONE => Error.bug "sxml optimization passes missing")), + (Normal, "target", + concat [" {", + (case targetMap () of + [] => "" + | [x] => #target x + | x :: _ => concat [#target x, "|..."]), + "}"], + "platform that executable will run on", + SpaceString + (fn t => + (target := (if t = "self" then Self else Cross t); + setTargetType (t, usage)))), + (Normal, "target-as-opt", " ", "target-dependent assembler option", + (SpaceString2 o tokenizeTargetOpt) + (fn (target, opt) => + List.push (asOpts, {opt = opt, pred = OptPred.Target target}))), + (Expert, "target-as-opt-quote", " ", "target-dependent assembler option (quoted)", + (SpaceString2 + (fn (target, opt) => + List.push (asOpts, {opt = opt, pred = OptPred.Target target})))), + (Normal, "target-cc-opt", " ", "target-dependent C compiler option", + (SpaceString2 o tokenizeTargetOpt) + (fn (target, opt) => + List.push (ccOpts, {opt = opt, pred = OptPred.Target target}))), + (Expert, "target-cc-opt-quote", " ", "target-dependent C compiler option (quoted)", + (SpaceString2 + (fn (target, opt) => + List.push (ccOpts, {opt = opt, pred = OptPred.Target target})))), + (Normal, "target-link-opt", " ", "target-dependent linker option", + (SpaceString2 o tokenizeTargetOpt) + (fn (target, opt) => + List.push (linkOpts, {opt = opt, pred = OptPred.Target target}))), + (Expert, "target-link-opt-quote", " ", "target-dependent linker option (quoted)", + (SpaceString2 + (fn (target, opt) => + List.push (linkOpts, {opt = opt, pred = OptPred.Target target})))), + (Expert, #1 trace, " name1,...", "trace compiler internals", #2 trace), + (Expert, "type-check", " {false|true}", "type check ILs", + boolRef typeCheck), + (Normal, "verbose", " {0|1|2|3}", "how verbose to be", + SpaceString + (fn s => + verbosity := (case s of + "0" => Silent + | "1" => Top + | "2" => Pass + | "3" => Detail + | _ => usage (concat ["invalid -verbose arg: ", s])))), + (Expert, "warn-ann", " {true|false}", + "unrecognized annotation warnings", + boolRef warnAnn), + (Expert, "warn-deprecated", " {true|false}", + "deprecated feature warnings", + boolRef warnDeprecated), + (Expert, "xml-passes", " ", "xml optimization passes", + SpaceString + (fn s => + case List.peek (!Control.optimizationPasses, + fn {il, ...} => String.equals ("xml", il)) of + SOME {set, ...} => + (case set s of + Result.Yes () => () + | Result.No s' => usage (concat ["invalid -xml-passes arg: ", s'])) + | NONE => Error.bug "xml optimization passes missing")), + (Expert, "zone-cut-depth", " ", "zone cut depth", + intRef zoneCutDepth) + ], + fn (style, name, arg, desc, opt) => + {arg = arg, desc = desc, name = name, opt = opt, style = style}) + end + +val mainUsage = + "mlton [option ...] file.{c|mlb|o|sml} [file.{c|o|s|S} ...]" + +val {parse, usage} = + Popt.makeUsage {mainUsage = mainUsage, + makeOptions = makeOptions, + showExpert = fn () => !expert} + +val usage = fn s => (usage s; raise Fail "unreachable") + +fun commandLine (args: string list): unit = + let + open Control + datatype z = datatype MLton.Platform.Arch.t + datatype z = datatype MLton.Platform.OS.t + val args = + case args of + lib :: args => + (libDir := OS.Path.mkCanonical lib + ; args) + | _ => Error.bug "incorrect args from shell script" + val () = setTargetType ("self", usage) + val result = parse args + + val target = !target + val targetStr = + case target of + Cross s => s + | Self => "self" + val targetsDir = + OS.Path.mkAbsolute { path = "targets", + relativeTo = !libDir } + val targetDir = + OS.Path.mkAbsolute { path = targetStr, + relativeTo = targetsDir } + val () = libTargetDir := targetDir + val targetArch = !Target.arch + val archStr = String.toLower (MLton.Platform.Arch.toString targetArch) + val targetOS = !Target.os + val OSStr = String.toLower (MLton.Platform.OS.toString targetOS) + + (* Determine whether code should be PIC (position independent) or not. + * This decision depends on the platform and output format. + *) + val positionIndependent = + case (targetOS, targetArch, !format) of + (* Windows is never position independent *) + (MinGW, _, _) => false + | (Cygwin, _, _) => false + (* Technically, Darwin should always be PIC. + * However, PIC on i386/darwin is unimplemented so we avoid it. + * PowerPC PIC is bad too, but the C codegen will use PIC behind + * our back unless forced, so let's just admit that it's PIC. + *) + | (Darwin, X86, Executable) => false + | (Darwin, X86, Archive) => false + | (Darwin, _, _) => true + (* On ELF systems, we only need PIC for LibArchive/Library *) + | (_, _, Library) => true + | (_, _, LibArchive) => true + | _ => false + val () = Control.positionIndependent := positionIndependent + + val stop = !stop + + val () = + align := (case !explicitAlign of + NONE => if defaultAlignIs8 () then Align8 else Align4 + | SOME a => a) + val () = + codegen := (case !explicitCodegen of + NONE => + if hasCodegen (x86Codegen) + then x86Codegen + else if hasCodegen (amd64Codegen) + then amd64Codegen + else CCodegen + | SOME Native => + if hasCodegen (x86Codegen) + then x86Codegen + else if hasCodegen (amd64Codegen) + then amd64Codegen + else usage (concat ["can't use native codegen on ", + MLton.Platform.Arch.toString targetArch, + " target"]) + | SOME (Explicit cg) => cg) + val () = MLton.Rusage.measureGC (!verbosity <> Silent) + val () = if !profileTimeSet + then (case !codegen of + x86Codegen => profile := ProfileTimeLabel + | amd64Codegen => profile := ProfileTimeLabel + | _ => profile := ProfileTimeField) + else () + val () = if !exnHistory + then (case !profile of + ProfileNone => profile := ProfileCallStack + | ProfileCallStack => () + | _ => usage "can't use -profile with Exn.keepHistory" + ; profileRaise := true) + else () + + val () = + Compile.setCommandLineConstant + {name = "CallStack.keep", + value = Bool.toString (!Control.profile = Control.ProfileCallStack)} + + val () = + let + val sizeMap = + List.map + (File.lines (OS.Path.joinDirFile {dir = !Control.libTargetDir, + file = "sizes"}), + fn line => + case String.tokens (line, Char.isSpace) of + [ty, "=", size] => + (case Int.fromString size of + NONE => Error.bug (concat ["strange size: ", size]) + | SOME size => + (ty, Bytes.toBits (Bytes.fromInt size))) + | _ => Error.bug (concat ["strange size mapping: ", line])) + fun lookup ty' = + case List.peek (sizeMap, fn (ty, _) => String.equals (ty, ty')) of + NONE => Error.bug (concat ["missing size mapping: ", ty']) + | SOME (_, size) => size + in + Control.Target.setSizes + {cint = lookup "cint", + cpointer = lookup "cpointer", + cptrdiff = lookup "cptrdiff", + csize = lookup "csize", + header = lookup "header", + mplimb = lookup "mplimb", + objptr = lookup "objptr", + seqIndex = lookup "seqIndex"} + end + + fun tokenize l = + String.tokens (concat (List.separate (l, " ")), Char.isSpace) + + (* When cross-compiling, use the named cross compiler. + * Older gcc versions used -b for multiple targets. + * If this is still needed, a shell script wrapper can hide this. + *) + val gcc = + case target of + Cross s => + let + val {dir = gccDir, file = gccFile} = + OS.Path.splitDirFile (!gcc) + in + OS.Path.joinDirFile + {dir = gccDir, + file = s ^ "-" ^ gccFile} + end + | Self => !gcc + val arScript = !arScript + + fun addTargetOpts opts = + List.fold + (!opts, [], fn ({opt, pred}, ac) => + if (case pred of + OptPred.Target s => + let + val s = String.toLower s + in + s = archStr orelse s = OSStr + end + | OptPred.Yes => true) + then opt :: ac + else ac) + val asOpts = addTargetOpts asOpts + val ccOpts = addTargetOpts ccOpts + val ccOpts = concat ["-I", + OS.Path.mkAbsolute { path = "include", + relativeTo = !libTargetDir }] + :: ccOpts + val linkOpts = + List.concat [[concat ["-L", !libTargetDir]], + if !debugRuntime then + ["-lmlton-gdb", "-lgdtoa-gdb"] + else if positionIndependent then + ["-lmlton-pic", "-lgdtoa-pic"] + else + ["-lmlton", "-lgdtoa"], + addTargetOpts linkOpts] + val linkArchives = + if !debugRuntime then + [OS.Path.joinDirFile { dir = !libTargetDir, file = "libmlton-gdb.a" }, + OS.Path.joinDirFile { dir = !libTargetDir, file = "libgdtoa-gdb.a" }] + else if positionIndependent then + [OS.Path.joinDirFile { dir = !libTargetDir, file = "libmlton-pic.a" }, + OS.Path.joinDirFile { dir = !libTargetDir, file = "libgdtoa-pic.a" }] + else + [OS.Path.joinDirFile { dir = !libTargetDir, file = "libmlton.a" }, + OS.Path.joinDirFile { dir = !libTargetDir, file = "libgdtoa.a" }] + val _ = + if not (hasCodegen (!codegen)) + then usage (concat ["can't use ", + Control.Codegen.toString (!codegen), + " codegen on ", + MLton.Platform.Arch.toString targetArch, + " target"]) + else () + val () = + Control.labelsHaveExtra_ := (case targetOS of + Cygwin => true + | Darwin => true + | MinGW => true + | _ => false) + val _ = + chunk := + (case !explicitChunk of + NONE => (case !codegen of + amd64Codegen => ChunkPerFunc + | CCodegen => Coalesce {limit = 4096} + | x86Codegen => ChunkPerFunc + ) + | SOME c => c) + val _ = if not (!Control.codegen = x86Codegen) andalso !Native.IEEEFP + then usage "must use x86 codegen with -ieee-fp true" + else () + val _ = + if !keepDot andalso List.isEmpty (!keepPasses) + then keepSSA := true + else () + val () = + keepDefUse + := (isSome (!showDefUse) + orelse (Control.Elaborate.enabled Control.Elaborate.warnUnused) + orelse (Control.Elaborate.default Control.Elaborate.warnUnused)) + val warnMatch = + (Control.Elaborate.enabled Control.Elaborate.nonexhaustiveMatch) + orelse (Control.Elaborate.enabled Control.Elaborate.redundantMatch) + orelse (Control.Elaborate.default Control.Elaborate.nonexhaustiveMatch <> + Control.Elaborate.DiagEIW.Ignore) + orelse (Control.Elaborate.default Control.Elaborate.redundantMatch <> + Control.Elaborate.DiagEIW.Ignore) + val _ = elaborateOnly := (stop = Place.TypeCheck + andalso not (warnMatch) + andalso not (!keepDefUse)) + val _ = + case targetOS of + Darwin => () + | FreeBSD => () + | HPUX => () + | Linux => () + | MinGW => () + | NetBSD => () + | OpenBSD => () + | Solaris => () + | _ => + if !profile = ProfileTimeField + orelse !profile = ProfileTimeLabel + then usage (concat ["can't use -profile time on ", + MLton.Platform.OS.toString targetOS]) + else () + fun printVersion (out: Out.t): unit = + Out.output (out, concat [Version.banner, "\n"]) + val () = + case !show of + NONE => () + | SOME info => + (case info of + Show.Anns => + Layout.outputl (Control.Elaborate.document {expert = !expert}, + Out.standard) + | Show.PathMap => + let + open Layout + in + outputl (align + (List.map (Control.mlbPathMap (), + fn {var, path, ...} => + str (concat [var, " ", path]))), + Out.standard) + end + ; let open OS.Process in exit success end) + in + case result of + Result.No msg => usage msg + | Result.Yes [] => + (inputFile := "" + ; if isSome (!showBasis) + then (trace (Top, "Type Check SML") + Compile.elaborateSML {input = []}) + else if !buildConstants + then Compile.outputBasisConstants Out.standard + else if !verbosity = Silent orelse !verbosity = Top + then printVersion Out.standard + else outputHeader' (No, Out.standard)) + | Result.Yes (input :: rest) => + let + val _ = inputFile := File.base (File.fileOf input) + val (start, base) = + let + val rec loop = + fn [] => usage (concat ["invalid file suffix on ", input]) + | (suf, start, hasNum) :: sufs => + if String.hasSuffix (input, {suffix = suf}) + then (start, + let + val f = File.base input + in + if hasNum + then File.base f + else f + end) + else loop sufs + datatype z = datatype Place.t + in + loop [(".mlb", MLB, false), + (".sml", SML, false), + (".c", Generated, true), + (".o", O, true)] + end + val _ = + List.foreach + (rest, fn f => + if List.exists ([".c", ".o", ".s", ".S"], fn suffix => + String.hasSuffix (f, {suffix = suffix})) + then File.withIn (f, fn _ => ()) + else usage (concat ["invalid file suffix: ", f])) + val csoFiles = rest + in + case Place.compare (start, stop) of + GREATER => usage (concat ["cannot go from ", Place.toString start, + " to ", Place.toString stop]) + | EQUAL => usage "nothing to do" + | LESS => + let + val _ = + if !verbosity = Top + then printVersion Out.error + else () + val tempFiles: File.t list ref = ref [] + val tmpDir = + let + val (tmpVar, default) = + case MLton.Platform.OS.host of + MinGW => ("TEMP", "C:/WINDOWS/TEMP") + | _ => ("TMPDIR", "/tmp") + in + case Process.getEnv tmpVar of + NONE => default + | SOME d => d + end + fun temp (suf: string): File.t = + let + val (f, out) = + File.temp {prefix = OS.Path.concat (tmpDir, "file"), + suffix = suf} + val _ = Out.close out + val _ = List.push (tempFiles, f) + in + f + end + fun suffix s = concat [base, s] + fun maybeOut suf = + case !output of + NONE => suffix suf + | SOME f => f + fun maybeOutBase suf = + case !output of + NONE => suffix suf + | SOME f => if File.extension f = SOME "exe" + then concat [File.base f, suf] + else concat [f, suf] + val { base = outputBase, ext=_ } = + OS.Path.splitBaseExt (maybeOut ".ext") + val { file = defLibname, dir=_ } = + OS.Path.splitDirFile outputBase + val defLibname = + if String.hasPrefix (defLibname, {prefix = "lib"}) + then String.extract (defLibname, 3, NONE) + else defLibname + fun toAlNum c = if Char.isAlphaNum c then c else #"_" + val () = + if !libname <> "" then () else + libname := CharVector.map toAlNum defLibname + (* Library output includes a header by default *) + val () = + case (!format, !exportHeader) of + (Executable, _) => () + | (_, NONE) => exportHeader := SOME (!libname ^ ".h") + | _ => () + val _ = + atMLtons := + Vector.fromList + (maybeOut "" :: tokenize (rev ("--" :: (!runtimeArgs)))) + (* The -Wa,--gstabs says to pass the --gstabs option to the + * assembler. This tells the assembler to generate stabs + * debugging information for each assembler line. + *) + val (gccDebug, asDebug) = + case !debugFormat of + NONE => (["-g"], "-Wa,-g") + | SOME Dwarf => (["-gdwarf", "-g2"], "-Wa,--gdwarf2") + | SOME DwarfPlus => (["-gdwarf+", "-g2"], "-Wa,--gdwarf2") + | SOME Dwarf2 => (["-gdwarf-2", "-g2"], "-Wa,--gdwarf2") + | SOME Stabs => (["-gstabs", "-g2"], "-Wa,--gstabs") + | SOME StabsPlus => (["-gstabs+", "-g2"], "-Wa,--gstabs") + fun compileO (inputs: File.t list): unit = + let + val output = + case (!format, targetOS) of + (Archive, _) => maybeOut ".a" + | (Executable, _) => maybeOut "" + | (LibArchive, _) => maybeOut ".a" + | (Library, Darwin) => maybeOut ".dylib" + | (Library, Cygwin) => !libname ^ ".dll" + | (Library, MinGW) => !libname ^ ".dll" + | (Library, _) => maybeOut ".so" + val libOpts = + case targetOS of + Darwin => [ "-dynamiclib" ] + | Cygwin => [ "-shared", + "-Wl,--out-implib," ^ + maybeOut ".a", + "-Wl,--output-def," ^ + !libname ^ ".def"] + | MinGW => [ "-shared", + "-Wl,--out-implib," ^ + maybeOut ".a", + "-Wl,--output-def," ^ + !libname ^ ".def"] + | _ => [ "-shared" ] + val _ = + trace (Top, "Link") + (fn () => + if !format = Archive orelse + !format = LibArchive + then System.system + (arScript, + List.concat + [[targetStr, OSStr, output], + inputs, + linkArchives]) + else System.system + (gcc, + List.concat + [["-o", output], + if !format = Library then libOpts else [], + if !debug then gccDebug else [], + inputs, + linkOpts])) + () + (* gcc on Cygwin appends .exe, which I don't want, so + * move the output file to it's rightful place. + * Notice that we do not use targetOS here, since we + * care about the platform we're running on, not the + * platform we're generating for. + * + * We want to keep the .exe as is for MinGW/Win32. + *) + val _ = + if MLton.Platform.OS.host = Cygwin + then + if String.contains (output, #".") + then () + else + File.move {from = concat [output, ".exe"], + to = output} + else () + in + () + end + fun mkOutputO (c: Counter.t, input: File.t): File.t = + if stop = Place.O orelse !keepO + then + if File.dirOf input = File.dirOf (maybeOutBase ".o") + then + concat [File.base input, ".o"] + else + maybeOutBase + (concat [".", + Int.toString (Counter.next c), + ".o"]) + else temp ".o" + fun compileC (c: Counter.t, input: File.t): File.t = + let + val debugSwitches = gccDebug @ ["-DASSERT=1"] + val output = mkOutputO (c, input) + + val _ = + System.system + (gcc, + List.concat + [[ "-std=gnu99", "-c" ], + if !format = Executable + then [] else [ "-DLIBNAME=" ^ !libname ], + if positionIndependent + then [ "-fPIC", "-DPIC" ] else [], + if !debug then debugSwitches else [], + ccOpts, + ["-o", output], + [input]]) + in + output + end + fun compileS (c: Counter.t, input: File.t): File.t = + let + val output = mkOutputO (c, input) + val _ = + System.system + (gcc, + List.concat + [["-c"], + if !debug then [asDebug] else [], + asOpts, + ["-o", output], + [input]]) + in + output + end + fun compileCSO (inputs: File.t list): unit = + if List.forall (inputs, fn f => + SOME "o" = File.extension f) + then compileO inputs + else + let + val c = Counter.new 0 + val oFiles = + trace (Top, "Compile and Assemble") + (fn () => + List.fold + (inputs, [], fn (input, ac) => + let + val extension = File.extension input + in + if SOME "o" = extension + then input :: ac + else if SOME "c" = extension + then (compileC (c, input)) :: ac + else if SOME "s" = extension + orelse SOME "S" = extension + then (compileS (c, input)) :: ac + else Error.bug + (concat + ["invalid extension: ", + Option.toString (fn s => s) extension]) + end)) + () + in + case stop of + Place.O => () + | _ => compileO (rev oFiles) + end + fun mkCompileSrc {listFiles, elaborate, compile} input = + let + val outputs: File.t list ref = ref [] + val r = ref 0 + fun make (style: style, suf: string) () = + let + val suf = concat [".", Int.toString (!r), suf] + val _ = Int.inc r + val file = (if !keepGenerated + orelse stop = Place.Generated + then maybeOutBase + else temp) suf + val _ = List.push (outputs, file) + val out = Out.openOut file + fun print s = Out.output (out, s) + val _ = outputHeader' (style, out) + fun done () = Out.close out + in + {file = file, + print = print, + done = done} + end + val _ = + case !verbosity of + Silent => () + | Top => () + | _ => + outputHeader + (Control.No, fn l => + let val out = Out.error + in Layout.output (l, out) + ; Out.newline out + end) + val _ = + case stop of + Place.Files => + Vector.foreach + (listFiles {input = input}, fn f => + (print (String.translate + (f, fn #"\\" => "/" | c => str c)) + ; print "\n")) + | Place.TypeCheck => + trace (Top, "Type Check SML") + elaborate + {input = input} + | _ => + trace (Top, "Compile SML") + compile + {input = input, + outputC = make (Control.C, ".c"), + outputS = make (Control.Assembly, ".s")} + in + case stop of + Place.Files => () + | Place.TypeCheck => () + | Place.Generated => () + | _ => + (* Shrink the heap before calling gcc. *) + (MLton.GC.pack () + ; compileCSO (List.concat [!outputs, csoFiles])) + end + val compileSML = + mkCompileSrc {listFiles = fn {input} => Vector.fromList input, + elaborate = Compile.elaborateSML, + compile = Compile.compileSML} + val compileMLB = + mkCompileSrc {listFiles = Compile.sourceFilesMLB, + elaborate = Compile.elaborateMLB, + compile = Compile.compileMLB} + fun compile () = + case start of + Place.SML => compileSML [input] + | Place.MLB => compileMLB input + | Place.Generated => compileCSO (input :: csoFiles) + | Place.O => compileCSO (input :: csoFiles) + | _ => Error.bug "invalid start" + val doit + = trace (Top, "MLton") + (fn () => + Exn.finally + (compile, fn () => + List.foreach (!tempFiles, File.remove))) + in + doit () + end + end + end + +val commandLine = Process.makeCommandLine commandLine + +val main = fn (_, args) => commandLine args + +val mainWrapped = fn () => OS.Process.exit (commandLine (CommandLine.arguments ())) + +end diff --git a/samples/Stylus/demo.styl b/samples/Stylus/demo.styl new file mode 100644 index 00000000..761d5be3 --- /dev/null +++ b/samples/Stylus/demo.styl @@ -0,0 +1,31 @@ +border-radius() + -webkit-border-radius arguments + -moz-border-radius arguments + border-radius arguments + +a.button + border-radius 5px + +fonts = helvetica, arial, sans-serif + +body { + padding: 50px; + font: 14px/1.4 fonts; +} + +form + input[type=text] + padding: 5px + border: 1px solid #eee + color: #ddd + +textarea + @extends form input[type=text] + padding: 10px + +$foo + color: #FFF + +.bar + background: #000 + @extends $foo diff --git a/samples/SuperCollider/BCR2000.sc b/samples/SuperCollider/BCR2000.sc deleted file mode 100644 index f8f96a70..00000000 --- a/samples/SuperCollider/BCR2000.sc +++ /dev/null @@ -1,114 +0,0 @@ -BCR2000 { - var controls, - controlBuses, - rangedControlBuses, - responders - ; - - *new { - ^super.new.init; - } - - init { - controls = Dictionary.new(108); - controlBuses = Dictionary.new(108); - rangedControlBuses = Dictionary.new(108); - - this.createCCResponders; - } - - createCCResponders { - responders = Array.fill(108, {|i| - CCResponder({|src, chan, num, val| - [src, chan, num, val].postln; - - // Write to controls - controls.put(i + 1, val); - - // Write to bus (converted to scalar 0..1) - controlBuses.put(i + 1, Bus.control(Server.default)); - controlBuses.at(i + 1).value = val / 127; - }, - // Adjust values as/if needed - nil, // src - nil, // chan - nil, // num - nil // value - ) - }); - } - - // Value from BCR - at {arg controlNum; - ^controls.at(controlNum) - } - - // Convert to 0..1 - scalarAt {arg controlNum; - ^controls.at(controlNum) / 127 - } - - // Get a bus - busAt {arg controlNum; - ^controlBuses.at(controlNum) - } - - /* - busRangeAt(arg controlNum, lo, hi; - if (rangedControlBuses.at(controlNum).isNil, { - rangedControlBuses.put(controlNum, Bus.control(Server.default)) - }); - - // Left to right order of operations - //rangedControlBuses.put( - bus.value = hi - lo * controls.at(controlNum) + lo; - - ^bus - } - */ -} - -/* Scratch -Dictionary -b = BCR2000(); -b.at(4); -b.scalarAt(4); -b.controls[5].get; -throw -z = Dictionary.new(2); -z.at(\1); -Array.fill(10, {|i| i.postln;}) -(2 + 3).asSymbol; - - -SynthDef(\x, { - arg amp = 0.01, - freq = 1200, - modDepth = 0.7, - modFreq = 2 - ; - - var - carrier, - modulator - ; - - modulator = SinOsc.ar(modFreq, mul: modDepth); - carrier = Saw.ar(freq, add: modulator, mul: amp); - - Out.ar([0,1], carrier) -}).store; - - -x = Synth(\x); -x.set(\modDepth, 1); -x.set(\modFreq, 64); - -x.map(\modFreq, b.busAt( - - - -ControlSpec -*/ - - diff --git a/samples/SystemVerilog/endpoint_phy_wrapper.svh b/samples/SystemVerilog/endpoint_phy_wrapper.svh new file mode 100644 index 00000000..e7ab790b --- /dev/null +++ b/samples/SystemVerilog/endpoint_phy_wrapper.svh @@ -0,0 +1,216 @@ +module endpoint_phy_wrapper + ( + input clk_sys_i, + input clk_ref_i, + input clk_rx_i, + input rst_n_i, + + IWishboneMaster.master src, + IWishboneSlave.slave snk, + IWishboneMaster.master sys, + + output [9:0] td_o, + input [9:0] rd_i, + + output txn_o, + output txp_o, + + input rxn_i, + input rxp_i + ); + + wire rx_clock; + + parameter g_phy_type = "GTP"; + + wire[15:0] gtx_data; + wire [1:0]gtx_k; + wire gtx_disparity; + wire gtx_enc_error; + wire [15:0] grx_data; + wire grx_clk; + wire [1:0]grx_k; + wire grx_enc_error; + wire [3:0] grx_bitslide; + wire gtp_rst; + wire tx_clock; + + generate + if(g_phy_type == "TBI") begin + + assign rx_clock = clk_ref_i; + assign tx_clock = clk_rx_i; + + + wr_tbi_phy U_Phy + ( + .serdes_rst_i (gtp_rst), + .serdes_loopen_i(1'b0), + .serdes_prbsen_i(1'b0), + .serdes_enable_i(1'b1), + .serdes_syncen_i(1'b1), + + .serdes_tx_data_i (gtx_data[7:0]), + .serdes_tx_k_i (gtx_k[0]), + .serdes_tx_disparity_o (gtx_disparity), + .serdes_tx_enc_err_o (gtx_enc_error), + + .serdes_rx_data_o (grx_data[7:0]), + .serdes_rx_k_o (grx_k[0]), + .serdes_rx_enc_err_o (grx_enc_error), + .serdes_rx_bitslide_o (grx_bitslide), + + + .tbi_refclk_i (clk_ref_i), + .tbi_rbclk_i (clk_rx_i), + + .tbi_td_o (td_o), + .tbi_rd_i (rd_i), + .tbi_syncen_o (), + .tbi_loopen_o (), + .tbi_prbsen_o (), + .tbi_enable_o () + ); + + end else if (g_phy_type == "GTX") begin // if (g_phy_type == "TBI") + wr_gtx_phy_virtex6 + #( + .g_simulation(1) + ) U_PHY + ( + .clk_ref_i(clk_ref_i), + + .tx_clk_o (tx_clock), + .tx_data_i (gtx_data), + .tx_k_i (gtx_k), + .tx_disparity_o (gtx_disparity), + .tx_enc_err_o(gtx_enc_error), + .rx_rbclk_o (rx_clock), + .rx_data_o (grx_data), + .rx_k_o (grx_k), + .rx_enc_err_o (grx_enc_error), + .rx_bitslide_o (), + + .rst_i (!rst_n_i), + .loopen_i (1'b0), + + .pad_txn_o (txn_o), + .pad_txp_o (txp_o), + + .pad_rxn_i (rxn_i), + .pad_rxp_i (rxp_i) + ); + + end else if (g_phy_type == "GTP") begin // if (g_phy_type == "TBI") + assign #1 tx_clock = clk_ref_i; + + wr_gtp_phy_spartan6 + #( + .g_simulation(1) + ) U_PHY + ( + .gtp_clk_i(clk_ref_i), + .ch0_ref_clk_i(clk_ref_i), + + .ch0_tx_data_i (gtx_data[7:0]), + .ch0_tx_k_i (gtx_k[0]), + .ch0_tx_disparity_o (gtx_disparity), + .ch0_tx_enc_err_o(gtx_enc_error), + .ch0_rx_rbclk_o (rx_clock), + .ch0_rx_data_o (grx_data[7:0]), + .ch0_rx_k_o (grx_k[0]), + .ch0_rx_enc_err_o (grx_enc_error), + .ch0_rx_bitslide_o (), + + .ch0_rst_i (!rst_n_i), + .ch0_loopen_i (1'b0), + + .pad_txn0_o (txn_o), + .pad_txp0_o (txp_o), + + .pad_rxn0_i (rxn_i), + .pad_rxp0_i (rxp_i) + ); + + end // else: !if(g_phy_type == "TBI") + endgenerate + + wr_endpoint + #( + .g_simulation (1), + .g_pcs_16bit(g_phy_type == "GTX" ? 1: 0), + .g_rx_buffer_size (1024), + .g_with_rx_buffer(0), + .g_with_timestamper (1), + .g_with_dmtd (0), + .g_with_dpi_classifier (1), + .g_with_vlans (0), + .g_with_rtu (0) + ) DUT ( + .clk_ref_i (clk_ref_i), + .clk_sys_i (clk_sys_i), + .clk_dmtd_i (clk_ref_i), + .rst_n_i (rst_n_i), + .pps_csync_p1_i (1'b0), + + .phy_rst_o (), + .phy_loopen_o (), + .phy_enable_o (), + .phy_syncen_o (), + + .phy_ref_clk_i (tx_clock), + .phy_tx_data_o (gtx_data), + .phy_tx_k_o (gtx_k), + .phy_tx_disparity_i (gtx_disparity), + .phy_tx_enc_err_i (gtx_enc_error), + + .phy_rx_data_i (grx_data), + .phy_rx_clk_i (rx_clock), + .phy_rx_k_i (grx_k), + .phy_rx_enc_err_i (grx_enc_error), + .phy_rx_bitslide_i (5'b0), + + .src_dat_o (snk.dat_i), + .src_adr_o (snk.adr), + .src_sel_o (snk.sel), + .src_cyc_o (snk.cyc), + .src_stb_o (snk.stb), + .src_we_o (snk.we), + .src_stall_i (snk.stall), + .src_ack_i (snk.ack), + .src_err_i(1'b0), + + .snk_dat_i (src.dat_o[15:0]), + .snk_adr_i (src.adr[1:0]), + .snk_sel_i (src.sel[1:0]), + .snk_cyc_i (src.cyc), + .snk_stb_i (src.stb), + .snk_we_i (src.we), + .snk_stall_o (src.stall), + .snk_ack_o (src.ack), + .snk_err_o (src.err), + .snk_rty_o (src.rty), + + .txtsu_ack_i (1'b1), + + .rtu_full_i (1'b0), + .rtu_almost_full_i (1'b0), + .rtu_rq_strobe_p1_o (), + .rtu_rq_smac_o (), + .rtu_rq_dmac_o (), + .rtu_rq_vid_o (), + .rtu_rq_has_vid_o (), + .rtu_rq_prio_o (), + .rtu_rq_has_prio_o (), + + .wb_cyc_i(sys.cyc), + .wb_stb_i (sys.stb), + .wb_we_i (sys.we), + .wb_sel_i(sys.sel), + .wb_adr_i(sys.adr[7:0]), + .wb_dat_i(sys.dat_o), + .wb_dat_o(sys.dat_i), + .wb_ack_o (sys.ack) + ); + +endmodule // endpoint_phy_wrapper diff --git a/samples/SystemVerilog/fifo.sv b/samples/SystemVerilog/fifo.sv new file mode 100644 index 00000000..6406bc32 --- /dev/null +++ b/samples/SystemVerilog/fifo.sv @@ -0,0 +1,7 @@ +module fifo ( + input clk_50, + input clk_2, + input reset_n, + output [7:0] data_out, + output empty +); diff --git a/samples/SystemVerilog/priority_encoder.sv b/samples/SystemVerilog/priority_encoder.sv new file mode 100644 index 00000000..614b11d5 --- /dev/null +++ b/samples/SystemVerilog/priority_encoder.sv @@ -0,0 +1,18 @@ +// http://hdlsnippets.com/parameterized_priority_encoder +module priority_encoder #(parameter INPUT_WIDTH=8,OUTPUT_WIDTH=3) +( + input logic [INPUT_WIDTH-1:0] input_data, + output logic [OUTPUT_WIDTH-1:0] output_data +); + +int ii; + +always_comb +begin + output_data = 'b0; + for(ii=0;ii 0; log2 = log2 + 1) + x = x >> 1; + end +endfunction diff --git a/samples/Tcl/stream-0.1.tm b/samples/Tcl/stream-0.1.tm new file mode 100644 index 00000000..24510d07 --- /dev/null +++ b/samples/Tcl/stream-0.1.tm @@ -0,0 +1,201 @@ +# A stream ensemble +# +# Copyright (c) 2013 Lawrence Woodman +# +# Licensed under an MIT licence. Please see LICENCE.md for details. +# + +package require Tcl 8.5 + +namespace eval stream { + namespace export {[a-z]*} + namespace ensemble create +} + +proc stream::create {first restCmdPrefix} { + return [list $first $restCmdPrefix] +} + +proc stream::first {stream} { + lassign $stream first + return $first +} + +proc stream::foldl {cmdPrefix initialValue args} { + set numStreams [llength $args] + if {$numStreams == 1} { + FoldlSingleStream $cmdPrefix $initialValue [lindex $args 0] + } elseif {$numStreams > 1} { + FoldlMultiStream $cmdPrefix $initialValue $args + } else { + Usage "stream foldl cmdPrefix initalValue stream ?stream ..?" + } +} + +proc stream::foreach {args} { + set numArgs [llength $args] + if {$numArgs == 3} { + lassign $args varName stream body + ForeachSingleStream $varName $stream $body + } elseif {($numArgs > 3) && (($numArgs % 2) == 1)} { + set body [lindex $args end] + set items [lrange $args 0 end-1] + ForeachMultiStream $items $body + } else { + Usage "stream foreach varName stream ?varName stream ..? body" + } +} + +proc stream::fromList {_list {index 0}} { + if {$index >= [llength $_list]} {return {}} + create [lindex $_list $index] [list fromList $_list [expr {$index + 1}]] +} + +proc stream::isEmpty {stream} { + expr {[llength $stream] == 0} +} + +proc stream::map {cmdPrefix args} { + set numArgs [llength $args] + if {$numArgs == 1} { + MapSingleStream $cmdPrefix [lindex $args 0] + } elseif {$numArgs > 1} { + MapMultiStream $cmdPrefix $args + } else { + Usage "stream map cmdPrefix stream ?stream ..?" + } +} + +proc stream::rest {stream} { + set rest [lindex $stream 1] + {*}$rest +} + +# Note: This will work through the elements of the stream until it finds +# the first element that is matched by the cmdPrefix predicate. +proc stream::select {cmdPrefix stream} { + while {![isEmpty $stream]} { + lassign $stream first rest + if {[{*}$cmdPrefix $first]} { + return [create $first [list select $cmdPrefix [{*}$rest]]] + } else { + set stream [{*}$rest] + } + } + return $stream +} + +proc stream::take {num stream} { + if {[isEmpty $stream] || $num <= 0} { + return [::list] + } else { + lassign $stream first rest + create $first [list take [expr {$num - 1}] [{*}$rest]] + } +} + +proc stream::toList {stream} { + set res [::list] + while {![isEmpty $stream]} { + lassign $stream first rest + lappend res $first + set stream [{*}$rest] + } + return $res +} + + +################################# +# Internal +################################# + +proc stream::FoldlSingleStream {cmdPrefix initialValue stream} { + set acc $initialValue + while {![isEmpty $stream]} { + lassign $stream first rest + set acc [{*}$cmdPrefix $acc $first] + set stream [{*}$rest] + } + return $acc +} + +proc stream::FoldlMultiStream {cmdPrefix initialValue streams} { + set acc $initialValue + + while 1 { + set firsts [::list] + set restStreams [::list] + ::foreach stream $streams { + if {[isEmpty $stream]} { + return $acc + } + lassign $stream first rest + lappend firsts $first + lappend restStreams [{*}$rest] + } + set acc [{*}$cmdPrefix $acc {*}$firsts] + set streams $restStreams + } + return $acc +} + +proc stream::ForeachSingleStream {varName stream body} { + set res {} + while {![isEmpty $stream]} { + lassign $stream first rest + uplevel 2 [list set $varName $first] + set stream [{*}$rest] + set res [uplevel 2 $body] + } + return $res +} + +proc stream::ForeachMultiStream {items body} { + set res {} + + while 1 { + set nextItems [::list] + ::foreach {varName stream} $items { + if {[isEmpty $stream]} { + return $res + } + lassign $stream first rest + uplevel 2 [list set $varName $first] + lappend nextItems $varName + lappend nextItems [{*}$rest] + } + set res [uplevel 2 $body] + set items $nextItems + } + + return $res +} + +proc stream::MapSingleStream {cmdPrefix stream} { + if {[isEmpty $stream]} { + return $stream + } + lassign $stream first rest + create [{*}$cmdPrefix $first] [list MapSingleStream $cmdPrefix [{*}$rest]] +} + +proc stream::MapMultiStream {cmdPrefix streams} { + set firsts [::list] + set restStreams [::list] + + ::foreach stream $streams { + if {[isEmpty $stream]} { + return $stream + } + lassign $stream first rest + lappend firsts $first + lappend restStreams [{*}$rest] + } + + return [create [{*}$cmdPrefix {*}$firsts] \ + [list MapMultiStream $cmdPrefix $restStreams]] +} + +proc stream::Usage {msg} { + return -code error -level 2 "wrong # args: should be \"$msg\"" +} diff --git a/samples/Tcl/xdgbasedir-0.3.tm b/samples/Tcl/xdgbasedir-0.3.tm new file mode 100644 index 00000000..cc5cd8a6 --- /dev/null +++ b/samples/Tcl/xdgbasedir-0.3.tm @@ -0,0 +1,76 @@ +# XDG Base Directory Specification handling +# +# Copyright (C) 2013 Lawrence Woodman +# +# Licensed under an MIT licence. Please see LICENCE.md for details. +# +# For XDG Base Directory Specification +# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +# +package require Tcl 8.5 + +namespace eval XDG { + variable DEFAULTS "" + namespace export DATA_HOME CONFIG_HOME CACHE_HOME + namespace export RUNTIME_DIR DATA_DIRS CONFIG_DIRS +} + +proc XDG::SetDefaults {} { + variable DEFAULTS + if {$DEFAULTS ne ""} return + set DEFAULTS [list \ + DATA_HOME [file join $::env(HOME) .local share] \ + CONFIG_HOME [file join $::env(HOME) .config] \ + CACHE_HOME [file join $::env(HOME) .cache] \ + DATA_DIRS [list [file join /usr local share] [file join /usr share]] \ + CONFIG_DIRS [list [file join /etc xdg ]] + ] +} + +proc XDG::XDGVarSet {var} { + expr {[info exists ::env(XDG_$var)] && $::env(XDG_$var) ne ""} +} + +proc XDG::Dir {var {subdir ""} } { + variable DEFAULTS + SetDefaults + set dir [dict get $DEFAULTS $var] + + if {[XDGVarSet $var]} { + set dir $::env(XDG_$var) + } + + return [file join $dir $subdir] +} + +proc XDG::Dirs {var {subdir ""} } { + variable DEFAULTS + SetDefaults + set rawDirs [dict get $DEFAULTS $var] + + if {[XDGVarSet $var]} { + set rawDirs [split $::env(XDG_$var) ":"] + } + + set outDirs {} + foreach dir $rawDirs { + lappend outDirs [file join $dir $subdir] + } + return $outDirs +} + +# The remaining procs reference the environmental variables XDG_ +# followed by the proc name. +proc XDG::DATA_HOME {{subdir ""}} {Dir DATA_HOME $subdir} +proc XDG::CONFIG_HOME {{subdir ""}} {Dir CONFIG_HOME $subdir} +proc XDG::CACHE_HOME {{subdir ""}} {Dir CACHE_HOME $subdir} + +proc XDG::RUNTIME_DIR {{subdir ""}} { + if {![XDGVarSet RUNTIME_DIR]} { return {} } + return [file join $::env(XDG_RUNTIME_DIR) $subdir] +} + +# The following procs returning the directories as a list with the most +# important first. +proc XDG::DATA_DIRS {{subdir ""}} {Dirs DATA_DIRS $subdir} +proc XDG::CONFIG_DIRS {{subdir ""}} {Dirs CONFIG_DIRS $subdir} diff --git a/samples/TeX/problemset.cls b/samples/TeX/problemset.cls new file mode 100644 index 00000000..6add7189 --- /dev/null +++ b/samples/TeX/problemset.cls @@ -0,0 +1,380 @@ +% ===================================== +% problemset Document Style +% For Problem Sets +% +% Options: +% final hides to-dos +% worksheet hides solutions and places each problem on separate page +% expand places each problem on a separate page +% ===================================== + +\ProvidesClass{problemset} +\DeclareOption*{\PassOptionsToClass{final}{article}} +\DeclareOption{worksheet}{\providecommand{\@solutionvis}{0}} +\DeclareOption{expand}{\providecommand{\@expand}{1}} +\ProcessOptions\relax + +% ================== Packages and Document Options ================== +\LoadClass[10pt,letterpaper]{article} +\RequirePackage[% + top=0.85in, + bottom=1in, + left=1in, + right=1in + ]{geometry} +\RequirePackage{pgfkeys} % For mathtable environment. +\RequirePackage{tabularx} % For pset heading +\RequirePackage{float} % Used for floats (tables, figures, etc.) +\RequirePackage{graphicx} % Used for inserting images. +\RequirePackage{enumerate} % Used for the enumerate environment. +\RequirePackage{mathtools} % Required. Loads amsmath. +\RequirePackage{amsthm} % Required. Used for theorem environments. +\RequirePackage{amssymb} % Required. +\RequirePackage{booktabs} % Required. Used for mathtable environment. +\RequirePackage{esdiff} % For derivatives and partial derivatives +\RequirePackage{mathtools} % Optional. Used for \shortintertext. +\RequirePackage{fancyhdr} % Required. For customizing headers/footers. +\RequirePackage{lastpage} % Required. For page count in header/footer. +\RequirePackage{xcolor} % Required. For setting the color of hyperlinks +\RequirePackage[% + obeyFinal, % Disable todos by setting [final] option for class + color=@todoclr, + linecolor=red + ]{todonotes} % For keeping track of to-dos. +\RequirePackage[% + colorlinks=true, + linkcolor=navy, + urlcolor=black + ]{hyperref} % For following urls and references in a document. +\RequirePackage{url} % Enables urls with the \url tag +\RequirePackage[all]{hypcap} +% hypcap: Links go to object instead of caption. [Keep as last package] + +% ================== Appearance Settings ================== +\definecolor{@todoclr}{gray}{0.80} % For To-Dos. 50% brightness +\definecolor{navy}{RGB}{0,0,150} % For coloring hyperlinks +\setlength{\parskip}{1.5ex} % Sets space between paragraphs. +\setlength{\parindent}{0pt} % Indent for first line of new paragraphs. + +% Smaller verbatim type size +\let\VERBATIM\verbatim +\def\verbatim{% + \def\verbatim@font{\small\ttfamily}% +\VERBATIM} + +% ============= Caption Modifications ============= +\usepackage[small]{caption} +\usepackage[footnotesize]{subcaption} + % For no visible number, use: \caption*{Unnumbered figure caption.} +\captionsetup[table]{labelformat=simple, labelsep=period, labelfont=bf} +\captionsetup[figure]{labelformat=simple, labelsep=period, labelfont=bf} +\captionsetup[subtable]{labelformat=parens, labelsep=space, labelfont=bf} +\captionsetup[subfigure]{labelformat=simple, labelsep=period, labelfont=bf} + +% ================== Booleans ================== +\def\TRUE{1} +\def\FALSE{0} +\def\SHOW{1} +\def\HIDE{0} + +% ============= Gets Document Info, Generates Heading ============= +\providecommand{\heading}[5][]{ + \thispagestyle{empty} + \listoftodos + \clearpage + \pagenumbering{arabic} + % + \providecommand{\shortname}{#1} + \providecommand{\authorname}{#2} + \providecommand{\coursename}{#3} + \providecommand{\assignment}{#4} + \providecommand{\duedate}{#5} + \begin{minipage}{0.5\textwidth} + \begin{flushleft} + \hypertarget{@assignment}{ + \textbf{\assignment} + }\\ + \authorname + \end{flushleft} + \end{minipage} + \begin{minipage}{0.5\textwidth} + \begin{flushright} + \coursename\\ + \duedate\\ + \end{flushright} + \end{minipage} + \thispagestyle{empty} +} + +% ============= Headers and Footers ============= +\renewcommand{\headrulewidth}{0pt} +\renewcommand{\footrulewidth}{0.5pt} +\pagestyle{fancyplain} +\fancyhf{} +\lfoot{% +\fancyplain{}{% + \hyperlink{@assignment}{% + \small{% + \color{black}{% + \assignment + } + } + } +} +} +\cfoot{% +\fancyplain{}{% + \small{% + \coursename + } +} +} +\rfoot{% +\fancyplain{}{% + \small{\shortname~\thepage~of~\pageref{LastPage}} +} +} + +% ============= Problem Command ============= +% INPUT: Points for question [#1] (Optional) +\newcounter{theproblem} % Problem counter for environment + +\providecommand{\problem}[1][]{% + \addtocounter{theproblem}{1}% + \setcounter{table}{0}% + \setcounter{figure}{0}% + \setcounter{equation}{0}% + \noindent% + \textbf{% + Problem~\arabic{theproblem}.}~\textit{\small{#1}} + +} + +% ============= QED, Page Breaks After QED? ============= +\providecommand{\@expand}{\HIDE} % Default is to omit pagebreaks after the solution +\providecommand{\qqed}{\hfill\rule{2mm}{2mm}\ifnum\@expand=\SHOW\\\pagebreak\fi} + + +% ============= Solution Command ============= +\providecommand{\@solutionvis}{1} % Default setting is to show solutions. +\providecommand{\solution}[2][\@solutionvis]{ +\vspace{0.5em}\noindent\textbf{Solution.} +\ifnum#1=\SHOW% +#2 + +\hfill\qqed\vspace{0.1em} +\else% +\pagebreak% +\fi +} + +% ============= Chapter, Section, Item Commands ============= +\providecommand{\chap}[2][0]{ +\ifnum#1=0% +\else% +\setcounter{section}{#1}% +\addtocounter{section}{-1}% +\fi% +\vspace{-1.75em}% +\section{#2} +} + +\providecommand{\sect}[2][0]{ +\ifnum#1=0% +\else% +\setcounter{subsection}{#1}% +\addtocounter{subsection}{-1}% +\fi% +\vspace{-0.5em}% +\subsection{#2} +} + +\providecommand{\subsect}[1]{\noindent\textbf{#1.}} + +% ============= Insert Non-Float Image ============= +\providecommand{\insertgraphic}[2][0.5\textwidth]{ +\vspace{-1em} +\begin{center} + \includegraphics[width=#1]{#2} +\end{center} +\vspace{-1em} +} + + + +% ============= Object Numbering by Problem ============= +\renewcommand{\thetable}{\arabic{theproblem}.\arabic{table}} +\renewcommand{\thefigure}{\arabic{theproblem}.\arabic{figure}} +\renewcommand{\theequation}{\arabic{theproblem}.\arabic{equation}} + + +% ============= Formula Environment ============= +\newcounter{formula} +\newenvironment{formula}[1][Formula \arabic{formula}] +{ + \addtocounter{formula}{1} + \begin{displaymath} + \tag*{\parbox{5em}{\textbf{\small{#1}}}} +}{ + \end{displaymath}\\ +} + +% ============= Math Table ============= +\newif\ifcaption +\pgfkeys +{ + /mypkg/title/.store in=\Caption,% Any value assigned to title will be stored in \Caption + /mypkg/title= , % Initialize so \Caption exists + /mypkg/label/.store in=\Label, % Any value assigned to label will be stored in \Label + /mypkg/label= , % Initialize so \Label exists + /mypkg/caption/.is if=caption, % Declare a boolean, defaults to false +} +\newenvironment{mathtable}[2][]{ + \pgfkeys{/mypkg/.cd, #1}% + \vspace{-1em}% + \begin{table}[ht!]% + \small \begin{center}% + \begin{displaymath}% + \begin{array}{#2}% + \toprule +}{ + \bottomrule + \end{array}% + \end{displaymath}% + \ifcaption% + \vspace{-1em}\caption{\Caption}\label{\Label}% + \fi% + \end{center}% + \end{table}% + \vspace{-1em}% +} + + +% ============= Double-line Column-Heading for table ============= +\providecommand{\double}[2]{% + \multicolumn{1}{c}{% + \genfrac{}{}{0pt}{}{\text{#1}}{\text{#2}} + } +} + + +% ============= Theorem-Style Environments ============= +\theoremstyle{plain} % Bold label, italic letters +\newtheorem{thm}{Theorem}[section] % Numbered by section +\newtheorem{lma}[thm]{Lemma} +\newtheorem{crl}[thm]{Corollary} +\newtheorem{prp}[thm]{Proposition} +\newtheorem{cnj}[thm]{Conjecture} +\newtheorem{alg}[thm]{Algorithm} + +% Associated environments (for numbered theorem environments) +\newenvironment{theorem}[2][]{\begin{thm}[#1]\label{#2}}{\end{thm}} +\newenvironment{lemma}[2][]{\begin{lma}[#1]\label{#2}}{\end{lma}} +\newenvironment{corollary}[2][]{\begin{crl}[#1]\label{#2}}{\end{thm}} +\newenvironment{proposition}[2][]{\begin{prp}[#1]\label{#2}}{\end{crl}} +\newenvironment{conjecture}[2][]{\begin{cnj}[#1]\label{#2}}{\end{cnj}} +\newenvironment{algorithm}[2][]{\begin{alg}[#1]\label{#2}}{\end{alg}} + +\theoremstyle{remark} % Italic label, roman letters +\newtheorem{rmk}{Remark}[section] % Numbered by section. Remarks are used to expand on and integrate material. +\newtheorem*{note}{Note} % Un-numbered. Notes are used to comment on specific elements of the material. +\newtheorem*{caveat}{Caveat} % Un-numbered. Caveats are used to guide the reader away from a common error. +\newtheorem*{warning}{Warning} % Un-numbered. Warnings are used to guide away from especially egregious errors. + +\theoremstyle{definition} % Bold label, roman letters +\newtheorem{dfn}{Definition}[section] % Numbered by section. Definitions of concepts and terms. +\newtheorem{exm}{Example}[section] % Numbered by section. Illustrative examples. +\newtheorem{smm}{Summary}[subsection] % Numbered by subsection. For section summaries. +\newtheorem*{question}{Question} % Un-numbered. For questions to motivate further analysis. +\newtheorem*{speculation}{Speculation} % Un-numbered. For questions that arise but will not be immediately answered. + +% Associated environments (for numbered theorem environments) +\newenvironment{remark}[2][]{\begin{rmk}[#1]\label{#2}}{\end{rmk}} +\newenvironment{definition}[2][]{\begin{dfn}[#1]\label{#2}}{\end{dfn}} +\newenvironment{example}[2][]{\begin{exm}[#1]\label{#2}}{\end{exm}} +\newenvironment{summary}[2][]{\begin{smm}[#1]\label{#2}}{\end{smm}} + + +% ============= Greek Letters ============= +\renewcommand{\a}{\ensuremath{\alpha}} +\renewcommand{\b}{\ensuremath{\beta}} +\renewcommand{\c}{\ensuremath{\gamma}} +\newcommand{\ch}{\ensuremath{\chi}} +\renewcommand{\d}{\ensuremath{\delta}} +\newcommand{\ep}{\ensuremath{\epsilon}} +\newcommand{\et}{\ensuremath{\eta}} +\newcommand{\ve}{\ensuremath{\varepsilon}} +\renewcommand{\r}{\ensuremath{\rho}} +\newcommand{\s}{\ensuremath{\sigma}} +\renewcommand{\t}{\ensuremath{\tau}} +\newcommand{\f}{\ensuremath{\psi}} +\newcommand{\w}{\ensuremath{\omega}} +\newcommand{\h}{\ensuremath{\phi}} +\newcommand{\m}{\ensuremath{\mu}} +\renewcommand{\l}{\ensuremath{\lambda}} +\renewcommand{\k}{\ensuremath{\kappa}} +\renewcommand{\v}{\ensuremath{\nu}} +\renewcommand{\i}{\ensuremath{\iota}} +\renewcommand{\o}{\ensuremath{\theta}} +\newcommand{\z}{\ensuremath{\zeta}} + +% ============= Mathematical Symbols ============= +\providecommand{\NN}{\ensuremath{\mathbb{N}}} +\providecommand{\ZZ}{\ensuremath{\mathbb{Z}}} +\providecommand{\QQ}{\ensuremath{\mathbb{Q}}} +\providecommand{\RR}{\ensuremath{\mathbb{R}}} +\providecommand{\CC}{\ensuremath{\mathbb{C}}} +\providecommand{\pd}{\partial} % 'dee' symbol for partial derivatives +\providecommand{\dd}{\mathrm{d}} % 'dee' symbol for ordinary derivatives +\providecommand{\x}{\times} +\providecommand{\n}{\scalebox{0.6}[1.0]{\ensuremath{-}}} + + + +% ============= Mathematical Macros ============= +\providecommand{\Sum}[3][n]{\ensuremath{\sum_{{#1}={#2}}^{#3}}} % Sum from [n]={1}to{2}. \Sum{1}{10} +\providecommand{\infsum}[2][n]{\ensuremath{\sum_{{#1}={#2}}^\infty}} % Infinite sum from [n]={1} \infsum{1} +\providecommand{\Int}[4][x]{\ensuremath{\int_{#3}^{#4}\!{#2}\,\mathrm{d}{#1}}} % Integrate {1} from {2} to {3} with respect to [x] +\providecommand{\Lim}[3][\infty]{\ensuremath{\displaystyle \lim_{{#2}\to{#1}}\!\!{#3}}} % Take the limit from {1} to [infinity] of {3} \Lim{x}{f(x)} +\providecommand{\Frac}[2]{\ensuremath{\,^{#1}\!/\!_{#2}}} % Slanted fraction with proper spacing. Usefule for in-line display of fractions. +\providecommand{\eval}[3]{\ensuremath{\left[ #1 \right \vert_{#2}^{#3}}} +\renewcommand{\L}{\left} % for left-hand right-sizing +\providecommand{\R}{\right} % for right-hand right-sizing +\providecommand{\D}{\diff} % for writing derivatives +\providecommand{\PD}{\diffp} % for writing partial derivatives +\providecommand{\full}{\displaystyle} % Forces display style in math mode +\providecommand{\Deg}{\ensuremath{^\circ}} % for adding a degree symbol, even if not in math mode +\providecommand{\abs}[1]{\left\vert #1 \right\vert} % Absolute Value +\providecommand{\norm}[1]{\left \Vert #1 \right \Vert} % Norm (vector magnitude) +\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}} % Scientific Notation with times symbol +\providecommand{\E}[1]{\ensuremath{10^{#1}}} % Scientific Notation +\renewcommand{\u}[1]{\text{ #1}} % For inserting units in Roman text +\providecommand{\mc}{\text{,}\hspace{1em}} % For inserting comma and space into math mode +\providecommand{\mtxt}[2][]{#1\hspace{0.5em}\text{#2}\hspace{0.5em}} % For insterting text into math mode with space on either side. Option for preceding punctuation. + +% ============= Probability and Statistics ============= +\providecommand{\prob}[1]{\ensuremath{P\!\left(#1\right)} } +\providecommand{\cndprb}[2]{\ensuremath{P\!\left(#1 \left\vert #2 \right. \right)} } +\providecommand{\cov}[1]{\ensuremath{\text{Cov}\!\left(#1\right)} } +\providecommand{\ex}[1]{\ensuremath{E\!\left[#1\right]} } + +% ============= Linear Algebra ============= + +% Column vectors +\providecommand{\twovector}[3][r]{\left(\begin{array}{#1} #2 \\ #3\end{array}\right)} +\providecommand{\threevector}[4][r]{\left(\begin{array}{#1} #2 \\ #3 \\ #4\end{array}\right)} +\providecommand{\fourvector}[5][r]{\left(\begin{array}{#1} #2 \\ #3 \\ #4 \\ #5 \end{array}\right)} + +% ============= Vector Calculus ============= +% ------------- Susan Lea's notation --------------- +\providecommand{\vecs}[1]{\ensuremath{\vec{\bm{#1}}} } % bolded symbol, arrow +\providecommand{\vect}[1]{\ensuremath{\vec{\textbf{#1}}} } % bolded text, arrow +\providecommand{\unitvecs}[1]{\bm{\hat{#1}}} +\providecommand{\unitvect}[1]{\hat{\textbf{#1}}} +\providecommand{\Div}[1]{\vecs{\del} \cdot \vect{#1}} +\providecommand{\Curl}[1]{\vecs{\del} \times \vect{#1}} +\providecommand{\Grad}{\vecs{\del}} + + + + diff --git a/samples/TypeScript/hello.ts b/samples/TypeScript/hello.ts index 4b65a573..184dfcc9 100644 --- a/samples/TypeScript/hello.ts +++ b/samples/TypeScript/hello.ts @@ -1 +1 @@ -console.log "Hello, World!" +console.log("Hello, World!"); diff --git a/samples/UnrealScript/MutU2Weapons.uc b/samples/UnrealScript/MutU2Weapons.uc new file mode 100755 index 00000000..9c27aaf9 --- /dev/null +++ b/samples/UnrealScript/MutU2Weapons.uc @@ -0,0 +1,644 @@ +/* + * Copyright (c) 2008, 2013 Dainius "GreatEmerald" Masiliūnas + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +//----------------------------------------------------------------------------- +// MutU2Weapons.uc +// Mutator class for replacing weapons +// GreatEmerald, 2008 +//----------------------------------------------------------------------------- + +class MutU2Weapons extends Mutator + config(U2Weapons); + +var() config string ReplacedWeaponClassNames0; +var() config string ReplacedWeaponClassNames1, ReplacedWeaponClassNames2, ReplacedWeaponClassNames3; +var() config string ReplacedWeaponClassNames4, ReplacedWeaponClassNames5, ReplacedWeaponClassNames6; +var() config string ReplacedWeaponClassNames7, ReplacedWeaponClassNames8, ReplacedWeaponClassNames9; +var() config string ReplacedWeaponClassNames10, ReplacedWeaponClassNames11, ReplacedWeaponClassNames12; +var() config bool bConfigUseU2Weapon0, bConfigUseU2Weapon1, bConfigUseU2Weapon2, bConfigUseU2Weapon3; +var() config bool bConfigUseU2Weapon4, bConfigUseU2Weapon5, bConfigUseU2Weapon6, bConfigUseU2Weapon7; +var() config bool bConfigUseU2Weapon8, bConfigUseU2Weapon9, bConfigUseU2Weapon10, bConfigUseU2Weapon11; +var() config bool bConfigUseU2Weapon12; +//var byte bUseU2Weapon[13]; +//var class ReplacedWeaponClasses[13]; +//var class ReplacedWeaponPickupClasses[13]; +//var class ReplacedAmmoPickupClasses[13]; +var class U2WeaponClasses[13]; //GE: For default properties ONLY! +//var string U2WeaponPickupClassNames[13]; +var string U2AmmoPickupClassNames[13]; //GE: For default properties ONLY! +var byte bIsVehicle[13], bNotVehicle[13]; //GE: For default properties ONLY! +var localized string U2WeaponDisplayText[33], U2WeaponDescText[33]; +//var localized string GUISelectOptions[4]; +//var config int FirePowerMode; +var config bool bExperimental; +var config bool bUseFieldGenerator; +var config bool bUseProximitySensor; +var config bool bIntegrateShieldReward; +var int IterationNum; //GE: Weapons.Length +const DamageMultiplier=1.818182; +var config int DamagePercentage; +var config bool bUseXMPFeel; +var config string FlashbangModeString; +struct WeaponInfo +{ + var class ReplacedWeaponClass; //GE: Generated from ReplacedWeaponClassName. This is what we replace. + //var class ReplacedWeaponPickupClass; //GE: UNUSED?! + var class ReplacedAmmoPickupClass; //GE: Generated from ReplacedWeaponClassName. + + var class WeaponClass; //GE: This is the weapon we are going to put inside the world. + var string WeaponPickupClassName; //GE: Generated from WeponClass. + var string AmmoPickupClassName; //GE: Generated from WeaponClass. + var bool bEnabled; //GE: Structs can't be defaultproperty'd, thus we still require bConfigUseU2WeaponX + var bool bIsVehicle; //GE: This indicates that the weapon spawns a vehicle (deployable turrets). These only work in vehicle gametypes, duh. + var bool bNotVehicle; //GE: Opposite of bIsVehicle, that is, only works in non-vehicle gametypes. Think shotgun. +}; +var WeaponInfo Weapons[13]; + +/* + * GE: Here we initialise the mutator. First of all, structs can't use defaultproperties (until UE3) and thus config, so here we need to initialise the structs. + */ +function PostBeginPlay() +{ + local int FireMode, x; + //local string ReplacedWeaponPickupClassName; + + //IterationNum = ArrayCount(ReplacedWeaponClasses) - int(Level.Game.bAllowVehicles); //GE: He he, neat way to get the required number. + IterationNum = ArrayCount(Weapons); + + for (x = 0; x < IterationNum; x++) + { + Weapons[x].bEnabled = bool(GetPropertyText("bConfigUseU2Weapon"$x)); //GE: GetPropertyText() is needed to use variables in an array-like fashion. + //bUseU2Weapon[x] = byte(bool(GetPropertyText("bConfigUseU2Weapon"$x))); + Weapons[x].ReplacedWeaponClass = class(DynamicLoadObject(GetPropertyText("ReplacedWeaponClassNames"$x),class'Class')); + //ReplacedWeaponClasses[x] = class(DynamicLoadObject(GetPropertyText("ReplacedWeaponClassNames"$x),class'Class')); + //ReplacedWeaponPickupClassName = string(ReplacedWeaponClasses[x].default.PickupClass); + for(FireMode = 0; FireMode<2; FireMode++) + { + if( (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode] != None) + && (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass != None) + && (Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass.default.PickupClass != None) ) + { + Weapons[x].ReplacedAmmoPickupClass = class(Weapons[x].ReplacedWeaponClass.default.FireModeClass[FireMode].default.AmmoClass.default.PickupClass); + break; + } + } + Weapons[x].WeaponClass = U2WeaponClasses[x]; + Weapons[x].WeaponPickupClassName = string(Weapons[x].WeaponClass.default.PickupClass); + Weapons[x].AmmoPickupClassName = U2AmmoPickupClassNames[x]; + Weapons[x].bIsVehicle = bool(bIsVehicle[x]); + Weapons[x].bNotVehicle = bool(bNotVehicle[x]); + } + Super.PostBeginPlay(); +} + +/* + * GE: Utility function for checking if we can replace the item with the weapon/ammo of choice. + */ +function bool ValidReplacement(int x) +{ + if (Level.Game.bAllowVehicles) + return (Weapons[x].bEnabled && !Weapons[x].bNotVehicle ); + return (Weapons[x].bEnabled && !Weapons[x].bIsVehicle); +} + +/* + * GE: Here we replace things. + */ +function bool CheckReplacement( Actor Other, out byte bSuperRelevant ) +{ + local int x, i; + local WeaponLocker L; + + bSuperRelevant = 0; + if (xWeaponBase(Other) != None) + { + for (x = 0; x < IterationNum; x++) + { + if (ValidReplacement(x) && xWeaponBase(Other).WeaponType == Weapons[x].ReplacedWeaponClass) + { + xWeaponBase(Other).WeaponType = Weapons[x].WeaponClass; + return false; + } + } + return true; + } + if (Weapon(Other) != None) + { + if ( Other.IsA('BallLauncher') ) + return true; + for (x = 0; x < IterationNum; x++) + if (ValidReplacement(x) && Other.Class == Weapons[x].ReplacedWeaponClass) + return false; + return true; + } + /*if (WeaponPickup(Other) != None) //GE: This should never happen. + { + for (x = 0; x < IterationNum; x++) + { + if (Weapons[x].bEnabled && Other.Class == Weapons[x].ReplacedWeaponPickupClass) + { + ReplaceWith(Other, U2WeaponPickupClassNames[x]); + return false; + } + } + } */ + if (Ammo(Other) != None) + { + for (x = 0; x < IterationNum; x++) + { + if (ValidReplacement(x) && Other.Class == Weapons[x].ReplacedAmmoPickupClass) + { + ReplaceWith(Other, Weapons[x].AmmoPickupClassName); + return false; + } + } + return true; + } + if (WeaponLocker(Other) != None) + { + L = WeaponLocker(Other); + for (x = 0; x < IterationNum; x++) + if (ValidReplacement(x)) + for (i = 0; i < L.Weapons.Length; i++) + if (L.Weapons[i].WeaponClass == Weapons[x].ReplacedWeaponClass) + L.Weapons[i].WeaponClass = Weapons[x].WeaponClass; + return true; + } + + //STARTING WEAPON + if( xPawn(Other) != None ) + xPawn(Other).RequiredEquipment[0] = string(Weapons[1].WeaponClass); + if( xPawn(Other) != None && bUseFieldGenerator == True && Level.Game.bAllowVehicles) + xPawn(Other).RequiredEquipment[2] = "U2Weapons.U2WeaponFieldGenerator"; + if( xPawn(Other) != None && bUseProximitySensor == True && Level.Game.bAllowVehicles) + xPawn(Other).RequiredEquipment[3] = "U2Weapons.U2ProximitySensorDeploy"; + + //GE: Special handling - Shield Reward integration + if (bIntegrateShieldReward && Other.IsA('ShieldReward')) + { + ShieldPack(Other).SetStaticMesh(StaticMesh'XMPWorldItemsM.items.Pickup_TD_001'); + ShieldPack(Other).Skins[0] = Shader'U2343T.Pickups.Energy_Pickup_B_FX_01'; + ShieldPack(Other).RepSkin = Shader'U2343T.Pickups.Energy_Pickup_B_FX_01'; + ShieldPack(Other).SetDrawScale(0.35); + ShieldPack(Other).SetCollisionSize(27.0, 4.0); + ShieldPack(Other).PickupMessage = "You got an Energy Pickup."; + ShieldPack(Other).PickupSound = Sound'U2A.Powerups.EnergyPowerUp'; + } + + return Super.CheckReplacement(Other,bSuperRelevant); +} + +/* + * GE: This is for further replacement, I think... + */ +function string GetInventoryClassOverride(string InventoryClassName) +{ + local int x; + + for (x = 0; x < IterationNum; x++) + { + if (InventoryClassName ~= string(Weapons[x].ReplacedWeaponClass) && ValidReplacement(x)) + return string(Weapons[x].WeaponClass); + } + + return Super.GetInventoryClassOverride(InventoryClassName); +} + +/* + * GE: Configuration options. + */ +static function FillPlayInfo(PlayInfo PlayInfo) +{ + local array Recs; + local string WeaponOptions; + local int i; + + Super.FillPlayInfo(PlayInfo); + + class'CacheManager'.static.GetWeaponList(Recs); + for (i = 0; i < Recs.Length; i++) + { + if (WeaponOptions != "") + WeaponOptions $= ";"; + + WeaponOptions $= Recs[i].ClassName $ ";" $ Recs[i].FriendlyName; + } + + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon0", default.U2WeaponDisplayText[0], 0, 3, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames0", default.U2WeaponDisplayText[1], 0, 4, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon1", default.U2WeaponDisplayText[2], 0, 5, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames1", default.U2WeaponDisplayText[3], 0, 6, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon2", default.U2WeaponDisplayText[6], 0, 7, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames2", default.U2WeaponDisplayText[7], 0, 8, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon3", default.U2WeaponDisplayText[8], 0, 9, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames3", default.U2WeaponDisplayText[9], 0, 10, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon4", default.U2WeaponDisplayText[10], 0, 11, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames4", default.U2WeaponDisplayText[11], 0, 12, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon5", default.U2WeaponDisplayText[12], 0, 13, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames5", default.U2WeaponDisplayText[13], 0, 14, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon6", default.U2WeaponDisplayText[14], 0, 15, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames6", default.U2WeaponDisplayText[15], 0, 16, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon7", default.U2WeaponDisplayText[16], 0, 17, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames7", default.U2WeaponDisplayText[17], 0, 18, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon8", default.U2WeaponDisplayText[18], 0, 19, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames8", default.U2WeaponDisplayText[19], 0, 20, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon9", default.U2WeaponDisplayText[20], 0, 21, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames9", default.U2WeaponDisplayText[21], 0, 22, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon10", default.U2WeaponDisplayText[22], 0, 23, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames10", default.U2WeaponDisplayText[23], 0, 24, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon11", default.U2WeaponDisplayText[24], 0, 25, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames11", default.U2WeaponDisplayText[25], 0, 26, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bConfigUseU2Weapon12", default.U2WeaponDisplayText[26], 0, 27, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "ReplacedWeaponClassNames12", default.U2WeaponDisplayText[27], 0, 28, "Select", WeaponOptions); + PlayInfo.AddSetting(default.RulesGroup, "bUseXMPFeel", default.U2WeaponDisplayText[4], 0, 29, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "DamagePercentage", default.U2WeaponDisplayText[30], 0, 30, "Text", "3;0:100"); + PlayInfo.AddSetting(default.RulesGroup, "bExperimental", default.U2WeaponDisplayText[5], 0, 31, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "bUseFieldGenerator", default.U2WeaponDisplayText[28], 0, 32, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "bUseProximitySensor", default.U2WeaponDisplayText[29], 0, 33, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "bIntegrateShieldReward", default.U2WeaponDisplayText[31], 0, 34, "Check"); + PlayInfo.AddSetting(default.RulesGroup, "FlashbangModeString", default.U2WeaponDisplayText[32], 0, 35, "Select", "FM_None;None;FM_Directional;Direction-based;FM_DistanceBased;Distance-based"); +} + +/* + * GE: Configuration tooltips. + */ +static event string GetDescriptionText(string PropName) +{ + if (PropName == "bConfigUseU2Weapon0") + return default.U2WeaponDescText[0]; + if (PropName == "ReplacedWeaponClassNames0") + return default.U2WeaponDescText[1]; + if (PropName == "bConfigUseU2Weapon1") + return default.U2WeaponDescText[2]; + if (PropName == "ReplacedWeaponClassNames1") + return default.U2WeaponDescText[3]; + if (PropName == "bConfigUseU2Weapon2") + return default.U2WeaponDescText[6]; + if (PropName == "ReplacedWeaponClassNames2") + return default.U2WeaponDescText[7]; + if (PropName == "bConfigUseU2Weapon3") + return default.U2WeaponDescText[8]; + if (PropName == "ReplacedWeaponClassNames3") + return default.U2WeaponDescText[9]; + if (PropName == "bConfigUseU2Weapon4") + return default.U2WeaponDescText[10]; + if (PropName == "ReplacedWeaponClassNames4") + return default.U2WeaponDescText[11]; + if (PropName == "bConfigUseU2Weapon5") + return default.U2WeaponDescText[12]; + if (PropName == "ReplacedWeaponClassNames5") + return default.U2WeaponDescText[13]; + if (PropName == "bConfigUseU2Weapon6") + return default.U2WeaponDescText[14]; + if (PropName == "ReplacedWeaponClassNames6") + return default.U2WeaponDescText[15]; + if (PropName == "bConfigUseU2Weapon7") + return default.U2WeaponDescText[16]; + if (PropName == "ReplacedWeaponClassNames7") + return default.U2WeaponDescText[17]; + if (PropName == "bConfigUseU2Weapon8") + return default.U2WeaponDescText[18]; + if (PropName == "ReplacedWeaponClassNames8") + return default.U2WeaponDescText[19]; + if (PropName == "bConfigUseU2Weapon9") + return default.U2WeaponDescText[20]; + if (PropName == "ReplacedWeaponClassNames9") + return default.U2WeaponDescText[21]; + if (PropName == "bConfigUseU2Weapon10") + return default.U2WeaponDescText[22]; + if (PropName == "ReplacedWeaponClassNames10") + return default.U2WeaponDescText[23]; + if (PropName == "bConfigUseU2Weapon11") + return default.U2WeaponDescText[24]; + if (PropName == "ReplacedWeaponClassNames11") + return default.U2WeaponDescText[25]; + if (PropName == "bConfigUseU2Weapon12") + return default.U2WeaponDescText[26]; + if (PropName == "ReplacedWeaponClassNames12") + return default.U2WeaponDescText[27]; + if (PropName == "bUseXMPFeel") + return default.U2WeaponDescText[4]; + if (PropName == "bExperimental") + return default.U2WeaponDescText[5]; + if (PropName == "bUseFieldGenerator") + return default.U2WeaponDescText[28]; + if (PropName == "bUseProximitySensor") + return default.U2WeaponDescText[29]; + if (PropName == "DamagePercentage") + return default.U2WeaponDescText[30]; + if (PropName == "bIntegrateShieldReward") + return default.U2WeaponDescText[31]; + if (PropName == "FlashbangModeString") + return default.U2WeaponDescText[32]; + + return Super.GetDescriptionText(PropName); +} + +/* + * GE: Here we set all the properties for different play styles. + */ +event PreBeginPlay() +{ + //local int x; + //local class Weapons; + local float k; //GE: Multiplier. + + Super.PreBeginPlay(); + + k=float(DamagePercentage)/100.0; + //log("MutU2Weapons: k is"@k); + //Sets various settings that match different games + + /*if (FirePowerMode == 1) { //Original XMP - use the UTXMP original values + k=1; + } + else */if (!bUseXMPFeel && DamagePercentage != class'MutU2Weapons'.default.DamagePercentage) { //Original U2; compensate for float division errors + Class'U2Weapons.U2AssaultRifleFire'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2AssaultRifleFire'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2AssaultRifleProjAlt'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileASExplAlt'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2FireFlameThrower'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2FireFlameThrower'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileFragGrenade'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileConcussionGrenade'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileRocketDrunken'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileRocketSeeking'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileRocket'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileAltShotgun'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2FireShotgun'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2FireShotgun'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2FireSniper'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2FireSniper'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2FirePistol'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2FirePistol'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2FireAltPistol'.default.DamageMin *= DamageMultiplier * k; + Class'U2Weapons.U2FireAltPistol'.default.DamageMax *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileEMPGrenade'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2ProjectileToxicGrenade'.default.Damage *= DamageMultiplier * k; + Class'U2Weapons.U2HurterProxy_Gas'.default.myDamage *= DamageMultiplier * k; + Class'U2Weapons.U2HurterProxy_Fire'.default.myDamage *= DamageMultiplier * k; + } + //Dampened U2 is already the default - no need for a rewrite? + else if (bUseXMPFeel) { //General XMP + Class'U2Weapons.U2AssaultRifleFire'.default.Spread = 6.0; + Class'U2Weapons.U2AssaultRifleAmmoInv'.default.MaxAmmo = 300; + Class'U2Weapons.U2AssaultRifleProjAlt'.default.Speed = 5000; + Class'U2Weapons.U2AssaultRifleProjAlt'.default.MomentumTransfer = 8000; + Class'U2Weapons.U2WeaponEnergyRifle'.default.ClipSize = 30; + Class'U2Weapons.U2FireAltEnergyRifle'.default.FireLastReloadTime = 2.265000; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Speed = 1400.000000; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.DamageRadius = 290.000000; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.LifeSpan = 6.0; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.ShakeRadius = 1024.0; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.ShakeMagnitude = 1.0; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.Speed = 2500.0; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.MaxSpeed = 5000.0; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.LifeSpan = 6.0; + Class'U2Weapons.U2AmmoEnergyRifle'.default.MaxAmmo = 150; + Class'U2Weapons.U2FireAltFlameThrower'.default.FireRate = 0.25; + Class'U2Weapons.U2ProjectileAltFlameThrower'.default.MaxSpeed = 500.0; + Class'U2Weapons.U2ProjectileAltFlameThrower'.default.LifeSpan = 22.0; + Class'U2Weapons.U2ProjectileAltFlameThrower'.default.MomentumTransfer = 500.0; + Class'U2Weapons.U2WeaponFlameThrower'.default.ClipSize = 80; + Class'U2Weapons.U2WeaponFlameThrower'.default.ReloadTime = 2.0; + Class'U2Weapons.U2AmmoFlameThrower'.default.MaxAmmo = 480; + Class'U2Weapons.U2ProjectileFragGrenade'.default.MomentumTransfer = 9000; + Class'U2Weapons.U2ProjectileFragGrenade'.default.MaxSpeed = 2600.0; + Class'U2Weapons.U2ProjectileFragGrenade'.default.Speed = 2600.0; + Class'U2Weapons.U2ProjectileSmokeGrenade'.default.MaxSpeed = 2600.0; + Class'U2Weapons.U2ProjectileSmokeGrenade'.default.Speed = 2600.0; + Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.DamageRadius = 256.0; + Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.MomentumTransfer = 9000.0; + Class'U2Weapons.U2ProjectileConcussionGrenade'.default.DamageRadius = 180.0; + Class'U2Weapons.U2FireGrenade'.default.FireRate = 1.33; + Class'U2Weapons.U2WeaponRocketLauncher'.default.ReloadTime = 2.0; + Class'U2Weapons.U2AmmoRocketLauncher'.default.MaxAmmo = 25; + Class'U2Weapons.U2ProjectileRocketDrunken'.default.Speed = 1200.0; + Class'U2Weapons.U2ProjectileRocketSeeking'.default.Speed = 1200.0; + Class'U2Weapons.U2ProjectileRocket'.default.Speed = 2133.0;//3200 is too much + Class'U2Weapons.U2ProjectileRocket'.default.MaxSpeed = 2133.0; + Class'U2Weapons.U2ProjectileRocket'.default.DamageRadius = 384.0; + Class'U2Weapons.U2WeaponShotgun'.default.ReloadTime = 2.21; + Class'U2Weapons.U2WeaponShotgun'.default.ClipSize = 6; + Class'U2Weapons.U2AmmoShotgun'.default.MaxAmmo = 42; + Class'U2Weapons.U2WeaponSniper'.default.ClipSize = 3; + Class'U2Weapons.U2FireSniper'.default.FireRate = 1.0; + Class'U2Weapons.U2AmmoSniper'.default.MaxAmmo = 18; + Class'U2Weapons.U2FirePistol'.default.FireLastReloadTime = 2.4; + Class'U2Weapons.U2FireAltPistol'.default.FireLastReloadTime = 2.4; + Class'U2Weapons.U2AmmoPistol'.default.MaxAmmo = 45; + Class'U2Weapons.U2DamTypePistol'.default.VehicleDamageScaling = 0.30; + Class'U2Weapons.U2DamTypeAltPistol'.default.VehicleDamageScaling = 0.30; + + Class'U2Weapons.U2AssaultRifleFire'.default.DamageMin = 20*k; + Class'U2Weapons.U2AssaultRifleFire'.default.DamageMax = 20*k; + Class'U2Weapons.U2AssaultRifleProjAlt'.default.Damage = 175*k; + Class'U2Weapons.U2ProjectileASExplAlt'.default.Damage = 64.0*k; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage = 120.0*k; + Class'U2Weapons.U2ProjectileEnergyRifle'.default.Damage = 13.0*k; + Class'U2Weapons.U2FireFlameThrower'.default.DamageMin = 15*k; + Class'U2Weapons.U2FireFlameThrower'.default.DamageMax = 15*k; + Class'U2Weapons.U2ProjectileFragGrenade'.default.Damage = 200.0*k; + Class'U2Weapons.U2ProjectileIncendiaryGrenade'.default.Damage = 50.0*k; + Class'U2Weapons.U2ProjectileConcussionGrenade'.default.Damage = 15.0*k; + Class'U2Weapons.U2ProjectileRocketDrunken'.default.Damage = 70.0*k; + Class'U2Weapons.U2ProjectileRocketSeeking'.default.Damage = 70.0*k; + Class'U2Weapons.U2ProjectileRocket'.default.Damage = 190.0*k; + Class'U2Weapons.U2ProjectileAltShotgun'.default.Damage = 22.0*k; + Class'U2Weapons.U2FireShotgun'.default.DamageMin = 16*k; + Class'U2Weapons.U2FireShotgun'.default.DamageMax = 16*k; + Class'U2Weapons.U2FireSniper'.default.DamageMin = 75*k; + Class'U2Weapons.U2FireSniper'.default.DamageMax = 75*k; + Class'U2Weapons.U2FirePistol'.default.DamageMin = 40*k; + Class'U2Weapons.U2FirePistol'.default.DamageMax = 40*k; + Class'U2Weapons.U2FireAltPistol'.default.DamageMin = 65*k; + Class'U2Weapons.U2FireAltPistol'.default.DamageMax = 65*k; + Class'U2Weapons.U2ProjectileEMPGrenade'.default.Damage = 140.0*k; + Class'U2Weapons.U2ProjectileToxicGrenade'.default.Damage = 100.0*k; + Class'U2Weapons.U2HurterProxy_Gas'.default.myDamage = 30.0*k; + Class'U2Weapons.U2HurterProxy_Fire'.default.myDamage = 80.0*k; + } + + // + //----------------------------------------------------------- + // + //Experimental options - lets you Unuse EMPimp projectile and fire from two CAR barrels + if ((bExperimental) && (!bUseXMPFeel)) { //General U2 + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.LifeSpan = 2.0; + Class'U2Weapons.U2ProjectileAltEnergyRifle'.default.Damage = 210.0*k; + } + if (bExperimental) { //CAR - nothing's setting it, FireMode independent + Class'U2Weapons.U2AssaultRifleFire'.default.bModeExclusive = false; + Class'U2Weapons.U2AssaultRifleAltFire'.default.bModeExclusive = false; + } + + class'U2ProjectileConcussionGrenade'.static.SetFlashbangMode(FlashbangModeString); +} + +defaultproperties +{ + ReplacedWeaponClassNames0="XWeapons.Minigun" + ReplacedWeaponClassNames1="XWeapons.AssaultRifle" + ReplacedWeaponClassNames2="XWeapons.BioRifle" + ReplacedWeaponClassNames3="XWeapons.ShockRifle" + ReplacedWeaponClassNames4="Onslaught.ONSGrenadeLauncher" + ReplacedWeaponClassNames5="XWeapons.RocketLauncher" + ReplacedWeaponClassNames6="XWeapons.FlakCannon" + ReplacedWeaponClassNames7="XWeapons.SniperRifle" + ReplacedWeaponClassNames8="UTClassic.ClassicSniperRifle" + ReplacedWeaponClassNames9="Onslaught.ONSMineLayer" + ReplacedWeaponClassNames10="XWeapons.Redeemer" + ReplacedWeaponClassNames11="XWeapons.Painter" + ReplacedWeaponClassNames12="XWeapons.LinkGun" + bConfigUseU2Weapon0=True + bConfigUseU2Weapon1=True + bConfigUseU2Weapon2=True + bConfigUseU2Weapon3=True + bConfigUseU2Weapon4=True + bConfigUseU2Weapon5=True + bConfigUseU2Weapon6=True + bConfigUseU2Weapon7=True + bConfigUseU2Weapon8=True + bConfigUseU2Weapon9=True + bConfigUseU2Weapon10=True + bConfigUseU2Weapon11=True + bConfigUseU2Weapon12=True + bUseFieldGenerator=True + bUseProximitySensor=True + U2WeaponClasses(0)=Class'U2Weapons.U2AssaultRifleInv' + U2WeaponClasses(1)=Class'U2Weapons.U2WeaponEnergyRifle' + U2WeaponClasses(2)=Class'U2Weapons.U2WeaponFlameThrower' + U2WeaponClasses(3)=Class'U2Weapons.U2WeaponPistol' + U2WeaponClasses(4)=Class'U2Weapons.U2AutoTurretDeploy' + U2WeaponClasses(5)=Class'U2Weapons.U2WeaponRocketLauncher' + U2WeaponClasses(6)=Class'U2Weapons.U2WeaponGrenadeLauncher' + U2WeaponClasses(7)=Class'U2Weapons.U2WeaponSniper' + U2WeaponClasses(8)=Class'U2Weapons.U2WeaponSniper' + U2WeaponClasses(9)=Class'U2Weapons.U2WeaponRocketTurret' + U2WeaponClasses(10)=Class'U2Weapons.U2WeaponLandMine' + U2WeaponClasses(11)=Class'U2Weapons.U2WeaponLaserTripMine' + U2WeaponClasses(12)=Class'U2Weapons.U2WeaponShotgun' //GE: Has to be in !Level.Game.bAllowVehicles + bIsVehicle(0)=0 + bIsVehicle(1)=0 + bIsVehicle(2)=0 + bIsVehicle(3)=0 + bIsVehicle(4)=1 + bIsVehicle(5)=0 + bIsVehicle(6)=0 + bIsVehicle(7)=0 + bIsVehicle(8)=0 + bIsVehicle(9)=1 + bIsVehicle(10)=1 + bIsVehicle(11)=1 + bIsVehicle(12)=0 + bNotVehicle(12)=1 + U2AmmoPickupClassNames(0)="U2Weapons.U2AssaultRifleAmmoPickup" + U2AmmoPickupClassNames(1)="U2Weapons.U2PickupAmmoEnergyRifle" + U2AmmoPickupClassNames(2)="U2Weapons.U2PickupAmmoFlameThrower" + U2AmmoPickupClassNames(3)="U2Weapons.U2PickupAmmoPistol" + U2AmmoPickupClassNames(4)="U2Weapons.U2PickupAutoTurret" + U2AmmoPickupClassNames(5)="U2Weapons.U2PickupAmmoRocket" + U2AmmoPickupClassNames(6)="U2Weapons.U2PickupAmmoGrenade" + U2AmmoPickupClassNames(7)="U2Weapons.U2PickupAmmoSniper" + U2AmmoPickupClassNames(8)="U2Weapons.U2PickupAmmoSniper" + U2AmmoPickupClassNames(9)="U2Weapons.U2PickupRocketTurret" + U2AmmoPickupClassNames(10)="U2Weapons.U2PickupLandMine" + U2AmmoPickupClassNames(11)="U2Weapons.U2PickupLaserTripMine" + U2AmmoPickupClassNames(12)="U2Weapons.U2PickupAmmoShotgun" + U2WeaponDisplayText(0)="Include the Combat Assault Rifle" + U2WeaponDisplayText(1)="Replace this with the M32 Duster CAR" + U2WeaponDisplayText(2)="Include the Shock Lance" + U2WeaponDisplayText(3)="Replace this with the Shock Lance" + U2WeaponDisplayText(4)="Use XMP-style fire power?" + U2WeaponDisplayText(5)="Use alternative options?" + U2WeaponDisplayText(6)="Include the Flamethrower" + U2WeaponDisplayText(7)="Replace this with the Vulcan" + U2WeaponDisplayText(8)="Include the Magnum Pistol" + U2WeaponDisplayText(9)="Replace this with the Magnum Pistol" + U2WeaponDisplayText(10)="Include the Auto Turret" + U2WeaponDisplayText(11)="Replace this with the Auto Turret" + U2WeaponDisplayText(12)="Include the Shark Rocket Launcher" + U2WeaponDisplayText(13)="Replace this with the Shark" + U2WeaponDisplayText(14)="Include the Grenade Launcher" + U2WeaponDisplayText(15)="Replace this with the Hydra" + U2WeaponDisplayText(16)="Include the Widowmaker Sniper (1)" + U2WeaponDisplayText(17)="Replace this with the Widowmaker Rifle" + U2WeaponDisplayText(18)="Include the Widowmaker Sniper (2)" + U2WeaponDisplayText(19)="Replace this with the Widowmaker Rifle too" + U2WeaponDisplayText(20)="Include the Rocket Turret" + U2WeaponDisplayText(21)="Replace this with the Rocket Turret" + U2WeaponDisplayText(22)="Include the Land Mine" + U2WeaponDisplayText(23)="Replace this with the Land Mine" + U2WeaponDisplayText(24)="Include the Laser Trip Mine" + U2WeaponDisplayText(25)="Replace this with the Laser Trip Mine" + U2WeaponDisplayText(26)="Include the Crowd Pleaser Shotgun" + U2WeaponDisplayText(27)="Replace this with the Crowd Pleaser" + U2WeaponDisplayText(28)="Include the Field Generator" + U2WeaponDisplayText(29)="Include the Proximity Sensor" + U2WeaponDisplayText(30)="Firepower damping percentage" + U2WeaponDisplayText(31)="Integrate with Shield Reward" + U2WeaponDisplayText(32)="Concussion grenade behaviour" + U2WeaponDescText(0)="Include the M32 Duster Combat Assault Rifle in the game, i.e. enable it?" + U2WeaponDescText(1)="What weapon should be replaced with the CAR. By default it's the Minigun." + U2WeaponDescText(2)="Enable the Shock Lance Energy Rifle?" + U2WeaponDescText(3)="What weapon should be replaced with the Energy Rifle. By default it's the Assault Rifle. NOTE: Changing this value is not recommended." + U2WeaponDescText(4)="If enabled, this option will make all weapon firepower the same as in Unreal II XMP; if not, the firepower is consistent with Unreal II SP." + U2WeaponDescText(5)="If enabled, will make the Shock Lance use another, limited, secondary fire mode and allow Combat Assault Rifle use Unreal: Return to Na Pali fire style (shooting out of 2 barrels)." + U2WeaponDescText(6)="Enable the Vulcan Flamethrower?" + U2WeaponDescText(7)="What weapon should be replaced with the Flamethrower. By default it's the Bio Rifle." + U2WeaponDescText(8)="Enable the Magnum Pistol?" + U2WeaponDescText(9)="What weapon should be replaced with the Magnum Pistol. By default it's the Shock Rifle." + U2WeaponDescText(10)="Enable the Automatic Turret?" + U2WeaponDescText(11)="What weapon should be replaced with the Auto Turret. By default it's the Onslaught Grenade Launcher." + U2WeaponDescText(12)="Enable the Shark Rocket Launcher?" + U2WeaponDescText(13)="What weapon should be replaced with the Shark Rocket Launcher. By default it's the Rocket Launcher." + U2WeaponDescText(14)="Enable the Hydra Grenade Launcher?" + U2WeaponDescText(15)="What weapon should be replaced with the Hydra Grenade Launcher. By default it's the Flak Cannon." + U2WeaponDescText(16)="Should the Lightning Gun be replaced with the Widowmaker Sniper Rifle?" + U2WeaponDescText(17)="What weapon should be replaced with the Widowmaker Sniper Rifle. By default it's the Lightning Gun here." + U2WeaponDescText(18)="Should the Classic Sniper Rifle be replaced with the Widowmaker Sniper Rifle?" + U2WeaponDescText(19)="What weapon should be replaced with the Widowmaker Sniper Rifle. By default it's the Classic Sniper Rifle here." + U2WeaponDescText(20)="Enable the Rocket Turret delpoyable?" + U2WeaponDescText(21)="What weapon should be replaced with the Rocket Turret deployable. By default it's the Mine Layer." + U2WeaponDescText(22)="Enable the Land Mine?" + U2WeaponDescText(23)="What weapon should be replaced with the Land Mine. By default it's the Redeemer." + U2WeaponDescText(24)="Enable the Laser Trip Mine?" + U2WeaponDescText(25)="What weapon should be replaced with the Laser Trip Mine. By default it's the Ion Painter." + U2WeaponDescText(26)="Enable the Crowd Pleaser Shotgun? It won't replace the Link Gun in matches with vehicles." + U2WeaponDescText(27)="What weapon should be replaced with the Crowd Pleaser Shotgun. By default it's the Link Gun. It does not replace it in vehicle matches." + U2WeaponDescText(28)="Enable the Field Generator? If enabled, you start with one." + U2WeaponDescText(29)="Enable the Proximity Sensor? If enabled, you start with one." + U2WeaponDescText(30)="This number controls how powerful all weapons are. By deafult the firepower is set to 55% of the original in order to compensate for the fact that players in UT2004 don't have shields or damage filtering." + U2WeaponDescText(31)="If checked, the Shield Reward mutator produces Unreal II shield pickups." + U2WeaponDescText(32)="Choose between no white overlay, overlay depending on the player's view (XMP style) and overlay depending on the distance from the player (default, foolproof)." + //FirePowerMode=4 + DamagePercentage=55 + bUseXMPFeel=False + bIntegrateShieldReward=True + FlashbangModeString="FM_DistanceBased" + GroupName="Arena" + FriendlyName="Unreal II or XMP Weapons" + Description="Add the Unreal II weapons to other gametypes. Fully customisable, you can choose between Unreal II and XMP weapon behaviour." +} diff --git a/samples/UnrealScript/US3HelloWorld.uc b/samples/UnrealScript/US3HelloWorld.uc new file mode 100644 index 00000000..3dcf151f --- /dev/null +++ b/samples/UnrealScript/US3HelloWorld.uc @@ -0,0 +1,10 @@ +class US3HelloWorld extends GameInfo; + +event InitGame( string Options, out string Error ) +{ + `log( "Hello, world!" ); +} + +defaultproperties +{ +} diff --git a/samples/Visual Basic/Index.vbhtml b/samples/Visual Basic/Index.vbhtml new file mode 100644 index 00000000..6aa2b37b --- /dev/null +++ b/samples/Visual Basic/Index.vbhtml @@ -0,0 +1,47 @@ +@Code + ViewData("Title") = "Home Page" +End Code + +@section featured + +End Section + +

We suggest the following:

+
    +
  1. +
    Getting Started
    + ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that + enables a clean separation of concerns and that gives you full control over markup + for enjoyable, agile development. ASP.NET MVC includes many features that enable + fast, TDD-friendly development for creating sophisticated applications that use + the latest web standards. + Learn more… +
  2. + +
  3. +
    Add NuGet packages and jump-start your coding
    + NuGet makes it easy to install and update free libraries and tools. + Learn more… +
  4. + +
  5. +
    Find Web Hosting
    + You can easily find a web hosting company that offers the right mix of features + and price for your applications. + Learn more… +
  6. +
diff --git a/samples/Visual Basic/Module1.vb b/samples/Visual Basic/Module1.vb new file mode 100644 index 00000000..caa09195 --- /dev/null +++ b/samples/Visual Basic/Module1.vb @@ -0,0 +1,8 @@ +Module Module1 + + Sub Main() + Console.Out.WriteLine("Hello, I am a little sample application to test GitHub's Linguist module.") + Console.Out.WriteLine("I also include a Razor MVC file just to prove it handles cshtml files now.") + End Sub + +End Module diff --git a/samples/XML/pt_BR.xml b/samples/XML/pt_BR.xml new file mode 100644 index 00000000..bfaf0015 --- /dev/null +++ b/samples/XML/pt_BR.xml @@ -0,0 +1,47 @@ + + + + + MainWindow + + + United Kingdom + Reino Unido + + + + God save the Queen + Deus salve a Rainha + + + + England + Inglaterra + + + + Wales + Gales + + + + Scotland + Escócia + + + + Northern Ireland + Irlanda Norte + + + + Portuguese + Português + + + + English + Inglês + + + diff --git a/samples/YAML/vcr_cassette.yml b/samples/YAML/vcr_cassette.yml new file mode 100644 index 00000000..cf21a3fb --- /dev/null +++ b/samples/YAML/vcr_cassette.yml @@ -0,0 +1,20 @@ +--- +http_interactions: +- request: + method: get + uri: http://example.com/ + body: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/html;charset=utf-8 + Content-Length: + - '26' + body: This is the response body + http_version: '1.1' + recorded_at: Tue, 01 Nov 2011 04:58:44 GMT +recorded_with: VCR 2.0.0 diff --git a/test/test_blob.rb b/test/test_blob.rb index 3dd90a99..3e82f7a8 100644 --- a/test/test_blob.rb +++ b/test/test_blob.rb @@ -179,9 +179,15 @@ class TestBlob < Test::Unit::TestCase # TypeScript-generated JS # TODO + # Composer generated composer.lock file + assert blob("JSON/composer.lock").generated? + # PEG.js-generated parsers assert blob("JavaScript/parser.js").generated? + # Generated PostScript + assert !blob("PostScript/sierpinski.ps").generated? + # These examples are too basic to tell assert !blob("JavaScript/empty.js").generated? assert !blob("JavaScript/hello.js").generated? @@ -198,21 +204,40 @@ class TestBlob < Test::Unit::TestCase assert blob("Java/ProtocolBuffer.java").generated? assert blob("Python/protocol_buffer_pb2.py").generated? + # Generated JNI + assert blob("C/jni_layer.h").generated? + # Minified CSS assert !blob("CSS/bootstrap.css").generated? assert blob("CSS/bootstrap.min.css").generated? + + # Generated VCR + assert blob("YAML/vcr_cassette.yml").generated? + + assert Linguist::Generated.generated?("node_modules/grunt/lib/grunt.js", nil) end def test_vendored assert !blob("Text/README").vendored? assert !blob("ext/extconf.rb").vendored? + # Dependencies + assert blob("dependencies/windows/headers/GL/glext.h").vendored? + # Node dependencies assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored? + # Bower Components + assert blob("bower_components/custom/custom.js").vendored? + assert blob("app/bower_components/custom/custom.js").vendored? + assert blob("vendor/assets/bower_components/custom/custom.js").vendored? + # Rails vendor/ assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored? + # 'thirdparty' directory + assert blob("thirdparty/lib/main.c").vendored? + # C deps assert blob("deps/http_parser/http_parser.c").vendored? assert blob("deps/v8/src/v8.h").vendored? @@ -236,6 +261,8 @@ class TestBlob < Test::Unit::TestCase assert blob("public/javascripts/jquery-1.5.2.js").vendored? assert blob("public/javascripts/jquery-1.6.1.js").vendored? assert blob("public/javascripts/jquery-1.6.1.min.js").vendored? + assert blob("public/javascripts/jquery-1.10.1.js").vendored? + assert blob("public/javascripts/jquery-1.10.1.min.js").vendored? assert !blob("public/javascripts/jquery.github.menu.js").vendored? # jQuery UI @@ -254,7 +281,6 @@ class TestBlob < Test::Unit::TestCase assert blob("ui/minified/jquery.effects.blind.min.js").vendored? assert blob("ui/minified/jquery.ui.accordion.min.js").vendored? - # MooTools assert blob("public/javascripts/mootools-core-1.3.2-full-compat.js").vendored? assert blob("public/javascripts/mootools-core-1.3.2-full-compat-yc.js").vendored? @@ -276,6 +302,10 @@ class TestBlob < Test::Unit::TestCase assert blob("public/javascripts/tiny_mce_popup.js").vendored? assert blob("public/javascripts/tiny_mce_src.js").vendored? + # AngularJS + assert blob("public/javascripts/angular.js").vendored? + assert blob("public/javascripts/angular.min.js").vendored? + # Fabric assert blob("fabfile.py").vendored? @@ -307,6 +337,23 @@ class TestBlob < Test::Unit::TestCase # Test fixtures assert blob("test/fixtures/random.rkt").vendored? assert blob("Test/fixtures/random.rkt").vendored? + + # Cordova/PhoneGap + assert blob("cordova.js").vendored? + assert blob("cordova.min.js").vendored? + assert blob("cordova-2.1.0.js").vendored? + assert blob("cordova-2.1.0.min.js").vendored? + + # Vagrant + assert blob("Vagrantfile").vendored? + + # Gradle + assert blob("gradlew").vendored? + assert blob("gradlew.bat").vendored? + assert blob("gradle/wrapper/gradle-wrapper.properties").vendored? + assert blob("subproject/gradlew").vendored? + assert blob("subproject/gradlew.bat").vendored? + assert blob("subproject/gradle/wrapper/gradle-wrapper.properties").vendored? end def test_language diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb new file mode 100644 index 00000000..0c1a07ff --- /dev/null +++ b/test/test_heuristics.rb @@ -0,0 +1,87 @@ +require 'linguist/heuristics' +require 'linguist/language' +require 'linguist/samples' + +require 'test/unit' + +class TestHeuristcs < Test::Unit::TestCase + include Linguist + + def samples_path + File.expand_path("../../samples", __FILE__) + end + + def fixture(name) + File.read(File.join(samples_path, name)) + end + + def all_fixtures(language_name, file="*") + Dir.glob("#{samples_path}/#{language_name}/#{file}") + end + + def test_obj_c_by_heuristics + languages = ["C++", "Objective-C"] + # Only calling out '.h' filenames as these are the ones causing issues + all_fixtures("Objective-C", "*.h").each do |fixture| + results = Heuristics.disambiguate_c(fixture("Objective-C/#{File.basename(fixture)}"), languages) + assert_equal Language["Objective-C"], results.first + end + end + + def test_cpp_by_heuristics + languages = ["C++", "Objective-C"] + results = Heuristics.disambiguate_c(fixture("C++/render_adapter.cpp"), languages) + assert_equal Language["C++"], results.first + end + + def test_detect_still_works_if_nothing_matches + match = Language.detect("Hello.m", fixture("Objective-C/hello.m")) + assert_equal Language["Objective-C"], match + end + + def test_pl_prolog_by_heuristics + languages = ["Perl", "Prolog"] + results = Heuristics.disambiguate_pl(fixture("Prolog/turing.pl"), languages) + assert_equal Language["Prolog"], results.first + end + + def test_pl_perl_by_heuristics + languages = ["Perl", "Prolog"] + results = Heuristics.disambiguate_pl(fixture("Perl/perl-test.t"), languages) + assert_equal Language["Perl"], results.first + end + + def test_ecl_prolog_by_heuristics + languages = ["ECL", "Prolog"] + results = Heuristics.disambiguate_ecl(fixture("Prolog/or-constraint.ecl"), languages) + assert_equal Language["Prolog"], results.first + end + + def test_ecl_ecl_by_heuristics + languages = ["ECL", "Prolog"] + results = Heuristics.disambiguate_ecl(fixture("ECL/sample.ecl"), languages) + assert_equal Language["ECL"], results.first + end + + def test_ts_typescript_by_heuristics + languages = ["TypeScript", "XML"] + results = Heuristics.disambiguate_ts(fixture("TypeScript/classes.ts"), languages) + assert_equal Language["TypeScript"], results.first + end + + def test_ts_xml_by_heuristics + languages = ["TypeScript", "XML"] + results = Heuristics.disambiguate_ts(fixture("XML/pt_BR.xml"), languages) + assert_equal Language["XML"], results.first + end + + def test_cl_by_heuristics + languages = ["Common Lisp", "OpenCL"] + languages.each do |language| + all_fixtures(language).each do |fixture| + results = Heuristics.disambiguate_cl(fixture("#{language}/#{File.basename(fixture)}"), languages) + assert_equal Language[language], results.first + end + end + end +end diff --git a/test/test_language.rb b/test/test_language.rb index 38ed4a06..423434fb 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -10,6 +10,7 @@ class TestLanguage < Test::Unit::TestCase def test_lexer assert_equal Lexer['ActionScript 3'], Language['ActionScript'].lexer + assert_equal Lexer['AspectJ'], Language['AspectJ'].lexer assert_equal Lexer['Bash'], Language['Gentoo Ebuild'].lexer assert_equal Lexer['Bash'], Language['Gentoo Eclass'].lexer assert_equal Lexer['Bash'], Language['Shell'].lexer @@ -40,6 +41,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal Lexer['REBOL'], Language['Rebol'].lexer assert_equal Lexer['RHTML'], Language['HTML+ERB'].lexer assert_equal Lexer['RHTML'], Language['RHTML'].lexer + assert_equal Lexer['Ruby'], Language['Crystal'].lexer assert_equal Lexer['Ruby'], Language['Mirah'].lexer assert_equal Lexer['Ruby'], Language['Ruby'].lexer assert_equal Lexer['S'], Language['R'].lexer @@ -103,6 +105,7 @@ class TestLanguage < Test::Unit::TestCase assert_equal Language['Raw token data'], Language.find_by_alias('raw') assert_equal Language['Ruby'], Language.find_by_alias('rb') assert_equal Language['Ruby'], Language.find_by_alias('ruby') + assert_equal Language['R'], Language.find_by_alias('r') assert_equal Language['Scheme'], Language.find_by_alias('scheme') assert_equal Language['Shell'], Language.find_by_alias('bash') assert_equal Language['Shell'], Language.find_by_alias('sh') @@ -191,12 +194,18 @@ class TestLanguage < Test::Unit::TestCase def test_markup assert_equal :markup, Language['HTML'].type + assert_equal :markup, Language['SCSS'].type end def test_data assert_equal :data, Language['YAML'].type end + def test_prose + assert_equal :prose, Language['Markdown'].type + assert_equal :prose, Language['Org'].type + end + def test_other assert_nil Language['Brainfuck'].type assert_nil Language['Makefile'].type @@ -249,6 +258,36 @@ class TestLanguage < Test::Unit::TestCase assert_equal [Language['HTML+Django']], Language.find_by_filename('index.jinja') end + def test_find_by_shebang + assert_equal 'ruby', Linguist.interpreter_from_shebang("#!/usr/bin/ruby\n# baz") + { [] => ["", + "foo", + "#bar", + "#baz", + "///", + "\n\n\n\n\n", + " #!/usr/sbin/ruby", + "\n#!/usr/sbin/ruby"], + ['Ruby'] => ["#!/usr/bin/env ruby\n# baz", + "#!/usr/sbin/ruby\n# bar", + "#!/usr/bin/ruby\n# foo", + "#!/usr/sbin/ruby", + "#!/usr/sbin/ruby foo bar baz\n"], + ['R'] => ["#!/usr/bin/env Rscript\n# example R script\n#\n"], + ['Shell'] => ["#!/usr/bin/bash\n", "#!/bin/sh"], + ['Python'] => ["#!/bin/python\n# foo\n# bar\n# baz", + "#!/usr/bin/python2.7\n\n\n\n", + "#!/usr/bin/python3\n\n\n\n"], + ["Common Lisp"] => ["#!/usr/bin/sbcl --script\n\n"] + }.each do |languages, bodies| + bodies.each do |body| + assert_equal([body, languages.map{|l| Language[l]}], + [body, Language.find_by_shebang(body)]) + + end + end + end + def test_find assert_equal 'Ruby', Language['Ruby'].name assert_equal 'Ruby', Language['ruby'].name @@ -284,7 +323,7 @@ class TestLanguage < Test::Unit::TestCase def test_color assert_equal '#701516', Language['Ruby'].color assert_equal '#3581ba', Language['Python'].color - assert_equal '#f15501', Language['JavaScript'].color + assert_equal '#f7df1e', Language['JavaScript'].color assert_equal '#31859c', Language['TypeScript'].color end @@ -338,12 +377,24 @@ class TestLanguage < Test::Unit::TestCase assert !Language['Ruby'].eql?(Language['Python']) end + def test_by_type + assert !Language.by_type(:prose).nil? + end def test_colorize assert_equal <<-HTML.chomp, Language['Ruby'].colorize("def foo\n 'foo'\nend\n")
def foo
   'foo'
 end
+
+ HTML + end + + def test_colorize_with_options + assert_equal <<-HTML.chomp, Language['Ruby'].colorize("def foo\n 'foo'\nend\n", :options => { :cssclass => "highlight highlight-ruby" }) +
def foo
+  'foo'
+end
 
HTML end diff --git a/test/test_repository.rb b/test/test_repository.rb index 26025c09..832489d3 100644 --- a/test/test_repository.rb +++ b/test/test_repository.rb @@ -25,6 +25,12 @@ class TestRepository < Test::Unit::TestCase assert linguist_repo.size > 30_000 end + def test_linguist_breakdown + assert linguist_repo.breakdown_by_file.has_key?("Ruby") + assert linguist_repo.breakdown_by_file["Ruby"].include?("bin/linguist") + assert linguist_repo.breakdown_by_file["Ruby"].include?("lib/linguist/language.rb") + end + def test_binary_override assert_equal repo(File.expand_path("../../samples/Nimrod", __FILE__)).language, Language["Nimrod"] end
": 1, + "class=": 7, + "
": 1, + "
": 1, + "

": 1, + "@ViewData": 2, + ".": 3, + "

": 1, + "

": 1, + "

": 1, + "
": 1, + "

": 1, + "To": 1, + "learn": 1, + "more": 4, + "about": 2, + "ASP.NET": 5, + "MVC": 4, + "visit": 2, + "": 5, + "href=": 5, + "title=": 2, + "http": 1, + "//asp.net/mvc": 1, + "": 5, + "The": 1, + "page": 1, + "features": 3, + "": 1, + "videos": 1, + "tutorials": 1, + "and": 6, + "samples": 1, + "": 1, + "help": 1, + "you": 4, + "get": 1, + "most": 1, + "MVC.": 1, + "have": 1, + "any": 1, + "questions": 1, + "our": 1, + "forums": 1, + "

": 1, + "
": 1, + "