mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' into newlisp
This commit is contained in:
@@ -10,7 +10,7 @@ This can usually be solved either by adding a new filename or file name extensio
|
||||
|
||||
### Syntax highlighting looks wrong
|
||||
|
||||
Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream.
|
||||
Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report.
|
||||
|
||||
You can also try to fix the bug yourself and submit a Pull Request. [This piece from TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com).
|
||||
|
||||
|
||||
14
grammars.yml
14
grammars.yml
@@ -9,8 +9,6 @@ http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle:
|
||||
- source.forth
|
||||
http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle:
|
||||
- source.parrot.pir
|
||||
http://svn.textmate.org/trunk/Review/Bundles/Ruby%20Sass.tmbundle:
|
||||
- source.sass
|
||||
http://svn.textmate.org/trunk/Review/Bundles/SecondLife%20LSL.tmbundle:
|
||||
- source.lsl
|
||||
http://svn.textmate.org/trunk/Review/Bundles/VHDL.tmbundle:
|
||||
@@ -85,6 +83,8 @@ https://github.com/atom/language-csharp:
|
||||
- source.cs
|
||||
- source.csx
|
||||
- source.nant-build
|
||||
https://github.com/atom/language-gfm:
|
||||
- text.html.markdown
|
||||
https://github.com/atom/language-javascript:
|
||||
- source.js
|
||||
- source.js.regexp
|
||||
@@ -92,6 +92,9 @@ https://github.com/atom/language-python:
|
||||
- source.python
|
||||
- source.regexp.python
|
||||
- text.python.traceback
|
||||
https://github.com/atom/language-sass:
|
||||
- source.css.scss
|
||||
- source.sass
|
||||
https://github.com/atom/language-shellscript:
|
||||
- source.shell
|
||||
- text.shell-session
|
||||
@@ -170,6 +173,7 @@ https://github.com/lavrton/sublime-better-typescript:
|
||||
https://github.com/leafo/moonscript-tmbundle:
|
||||
- source.moonscript
|
||||
https://github.com/lsf37/Isabelle.tmbundle:
|
||||
- source.isabelle.root
|
||||
- source.isabelle.theory
|
||||
https://github.com/lunixbochs/x86-assembly-textmate-bundle:
|
||||
- source.asm.x86
|
||||
@@ -323,8 +327,6 @@ https://github.com/textmate/lua.tmbundle:
|
||||
- source.lua
|
||||
https://github.com/textmate/make.tmbundle:
|
||||
- source.makefile
|
||||
https://github.com/textmate/markdown.tmbundle:
|
||||
- text.html.markdown
|
||||
https://github.com/textmate/matlab.tmbundle:
|
||||
- source.matlab
|
||||
- source.octave
|
||||
@@ -422,3 +424,7 @@ https://raw.githubusercontent.com/eregon/oz-tmbundle/master/Syntaxes/Oz.tmLangua
|
||||
- source.oz
|
||||
https://raw.githubusercontent.com/tenbits/sublime-mask/release/Syntaxes/mask.tmLanguage:
|
||||
- source.mask
|
||||
https://github.com/l15n/fish-tmbundle:
|
||||
- source.fish
|
||||
https://raw.githubusercontent.com/andik/IDL-Syntax/master/IDL.tmLanguage:
|
||||
- source.webidl
|
||||
|
||||
@@ -61,6 +61,14 @@ module Linguist
|
||||
@heuristic.call(data)
|
||||
end
|
||||
|
||||
disambiguate "BitBake", "BlitzBasic" do |data|
|
||||
if /^\s*; /.match(data) || data.include?("End Function")
|
||||
Language["BlitzBasic"]
|
||||
elsif /^\s*(# |include|require)\b/.match(data)
|
||||
Language["BitBake"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "Objective-C", "C++", "C" do |data|
|
||||
if (/@(interface|class|protocol|property|end|synchronised|selector|implementation)\b/.match(data))
|
||||
Language["Objective-C"]
|
||||
@@ -129,7 +137,7 @@ module Linguist
|
||||
disambiguate "FORTRAN", "Forth" do |data|
|
||||
if /^: /.match(data)
|
||||
Language["Forth"]
|
||||
elsif /^([c*][^a-z]| subroutine\s)/i.match(data)
|
||||
elsif /^([c*][^a-z]| (subroutine|program)\s|!)/i.match(data)
|
||||
Language["FORTRAN"]
|
||||
end
|
||||
end
|
||||
@@ -172,13 +180,13 @@ module Linguist
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "Frege", "Forth", "text" do |data|
|
||||
disambiguate "Frege", "Forth", "Text" do |data|
|
||||
if /^(: |also |new-device|previous )/.match(data)
|
||||
Language["Forth"]
|
||||
elsif /\s*(import|module|package|data|type) /.match(data)
|
||||
Language["Frege"]
|
||||
else
|
||||
Language["text"]
|
||||
Language["Text"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -269,8 +269,12 @@ module Linguist
|
||||
|
||||
# Public: A List of languages compatible with Ace.
|
||||
#
|
||||
# TODO: Remove this method in a 5.x release. Every language now needs an ace_mode
|
||||
# key, so this function isn't doing anything unique anymore.
|
||||
#
|
||||
# Returns an Array of Languages.
|
||||
def self.ace_modes
|
||||
warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set."
|
||||
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
|
||||
end
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
||||
# This file should only be edited by GitHub staff
|
||||
|
||||
- ActionScript
|
||||
- Bash
|
||||
- C
|
||||
- C#
|
||||
- C++
|
||||
@@ -27,3 +26,4 @@
|
||||
- SQL
|
||||
- Scala
|
||||
- Scheme
|
||||
- Shell
|
||||
|
||||
@@ -34,10 +34,6 @@ module Linguist
|
||||
Dir.entries(ROOT).sort!.each do |category|
|
||||
next if category == '.' || category == '..'
|
||||
|
||||
# Skip text and binary for now
|
||||
# Possibly reconsider this later
|
||||
next if category == 'Text' || category == 'Binary'
|
||||
|
||||
dirname = File.join(ROOT, category)
|
||||
Dir.entries(dirname).each do |filename|
|
||||
next if filename == '.' || filename == '..'
|
||||
|
||||
@@ -18,23 +18,32 @@ module Linguist
|
||||
#
|
||||
# Returns a String or nil
|
||||
def self.interpreter(data)
|
||||
lines = data.lines
|
||||
return unless match = /^#! ?(.+)$/.match(lines.first)
|
||||
shebang = data.lines.first
|
||||
|
||||
tokens = match[1].split(' ')
|
||||
script = tokens.first.split('/').last
|
||||
# First line must start with #!
|
||||
return unless shebang && shebang.start_with?("#!")
|
||||
|
||||
# Get the parts of the shebang without the #!
|
||||
tokens = shebang.sub(/^#!\s*/, '').strip.split(' ')
|
||||
|
||||
# There was nothing after the #!
|
||||
return if tokens.empty?
|
||||
|
||||
# Get the name of the interpreter
|
||||
script = File.basename(tokens.first)
|
||||
|
||||
# Get next argument if interpreter was /usr/bin/env
|
||||
script = tokens[1] if script == 'env'
|
||||
|
||||
# If script has an invalid shebang, we might get here
|
||||
# Interpreter was /usr/bin/env with no arguments
|
||||
return unless script
|
||||
|
||||
# "python2.6" -> "python2"
|
||||
script.sub! $1, '' if script =~ /(\.\d+)$/
|
||||
script.sub! /(\.\d+)$/, ''
|
||||
|
||||
# Check for multiline shebang hacks that call `exec`
|
||||
if script == 'sh' &&
|
||||
lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
|
||||
data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
|
||||
script = $1
|
||||
end
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
# Erlang bundles
|
||||
- ^rebar$
|
||||
- erlang.mk
|
||||
|
||||
# Go dependencies
|
||||
- Godeps/_workspace/
|
||||
|
||||
25
samples/BitBake/gstreamer-libav.bb
Normal file
25
samples/BitBake/gstreamer-libav.bb
Normal file
@@ -0,0 +1,25 @@
|
||||
include gstreamer1.0-libav.inc
|
||||
|
||||
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
|
||||
file://COPYING.LIB;md5=6762ed442b3822387a51c92d928ead0d \
|
||||
file://ext/libav/gstav.h;beginline=1;endline=18;md5=a752c35267d8276fd9ca3db6994fca9c \
|
||||
file://gst-libs/ext/libav/LICENSE;md5=23a54f59b82572c203a559346e89ed57 \
|
||||
file://gst-libs/ext/libav/COPYING.GPLv2;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
|
||||
file://gst-libs/ext/libav/COPYING.GPLv3;md5=d32239bcb673463ab874e80d47fae504 \
|
||||
file://gst-libs/ext/libav/COPYING.LGPLv2.1;md5=bd7a443320af8c812e4c18d1b79df004 \
|
||||
file://gst-libs/ext/libav/COPYING.LGPLv3;md5=e6a600fd5e1d9cbde2d983680233ad02"
|
||||
|
||||
SRC_URI = " \
|
||||
http://gstreamer.freedesktop.org/src/gst-libav/gst-libav-${PV}.tar.xz \
|
||||
file://0001-Disable-yasm-for-libav-when-disable-yasm.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "86540dee14d31daf976eb2713f2294f3"
|
||||
SRC_URI[sha256sum] = "585eb7971006100ad771a852e07bd2f3e23bcc6eb0b1253a40b5a0e40e4e7418"
|
||||
|
||||
LIBAV_EXTRA_CONFIGURE_COMMON_ARG = "--target-os=linux \
|
||||
--cc='${CC}' --as='${CC}' --ld='${CC}' --nm='${NM}' --ar='${AR}' \
|
||||
--ranlib='${RANLIB}' \
|
||||
${GSTREAMER_1_0_DEBUG}"
|
||||
|
||||
S = "${WORKDIR}/gst-libav-${PV}"
|
||||
|
||||
13
samples/BitBake/qtbase-native.bb
Normal file
13
samples/BitBake/qtbase-native.bb
Normal file
@@ -0,0 +1,13 @@
|
||||
require qt5-git.inc
|
||||
require ${PN}.inc
|
||||
|
||||
do_install_append() {
|
||||
# for modules which are still using syncqt and call qtPrepareTool(QMAKE_SYNCQT, syncqt)
|
||||
# e.g. qt3d, qtwayland
|
||||
ln -sf syncqt.pl ${D}${OE_QMAKE_PATH_QT_BINS}/syncqt
|
||||
}
|
||||
|
||||
QT_MODULE_BRANCH = "release"
|
||||
# v5.2.1 + 168 commits
|
||||
SRCREV = "08cbbde61778276ccdda73d89fd64d02c623779f"
|
||||
|
||||
47
samples/C/bitmap.h
Normal file
47
samples/C/bitmap.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2010 Christoph Sünderhauf
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "generic.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t numbits;
|
||||
/* an array large enough for numbits to fit in. Might
|
||||
* (if numbits%8!=0) have some spare bits at the end
|
||||
*/
|
||||
uint32_t* bits;
|
||||
} bitmap_t;
|
||||
|
||||
|
||||
// creates a new bitmap.
|
||||
// CONTENT IS RANDOM! - use bitmap_clearall() to clear the bitmap.
|
||||
bitmap_t bitmap_init(uint32_t numbits);
|
||||
|
||||
// returns 1 or 0
|
||||
uint8_t bitmap_get(bitmap_t bitmap, uint32_t bitnum);
|
||||
// sets a bit (to 1)
|
||||
void bitmap_set(bitmap_t bitmap, uint32_t bitnum);
|
||||
// clears a bit (to 0)
|
||||
void bitmap_clear(bitmap_t bitmap, uint32_t bitnum);
|
||||
|
||||
// clears every bit to 0
|
||||
void bitmap_clearAll(bitmap_t bitmap);
|
||||
|
||||
// finds the first bit set to 0 returns 0 if no cleared bit found (0 is also returned if the first bit is cleared)
|
||||
uint32_t bitmap_findFirstClear(bitmap_t bitmap);
|
||||
44
samples/C/color.h
Normal file
44
samples/C/color.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t background;
|
||||
uint32_t foreground;
|
||||
} console_color_t;
|
||||
|
||||
#define CONSOLE_COLOR_BLACK 0x0
|
||||
#define CONSOLE_COLOR_BLUE 0x1
|
||||
#define CONSOLE_COLOR_GREEN 0x2
|
||||
#define CONSOLE_COLOR_CYAN 0x3
|
||||
#define CONSOLE_COLOR_RED 0x4
|
||||
#define CONSOLE_COLOR_MAGENTA 0x5
|
||||
#define CONSOLE_COLOR_BROWN 0x6
|
||||
#define CONSOLE_COLOR_LGREY 0x7
|
||||
#define CONSOLE_COLOR_DGREY 0x8
|
||||
#define CONSOLE_COLOR_LBLUE 0x9
|
||||
#define CONSOLE_COLOR_LGREEN 0xa
|
||||
#define CONSOLE_COLOR_LCYAN 0xb
|
||||
#define CONSOLE_COLOR_LRED 0xc
|
||||
#define CONSOLE_COLOR_LMAGENTA 0xd
|
||||
#define CONSOLE_COLOR_YELLOW 0xe
|
||||
#define CONSOLE_COLOR_WHITE 0xf
|
||||
|
||||
52
samples/C/driver.h
Normal file
52
samples/C/driver.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <console/info.h>
|
||||
|
||||
#define CONSOLE_DRV_CAP_CLEAR 0x01
|
||||
#define CONSOLE_DRV_CAP_SCROLL 0x02
|
||||
#define CONSOLE_DRV_CAP_SET_CURSOR 0x04
|
||||
|
||||
// Input modifier keys
|
||||
typedef struct {
|
||||
bool shift_left:1;
|
||||
bool shift_right:1;
|
||||
bool control_left:1;
|
||||
bool control_right:1;
|
||||
bool alt:1;
|
||||
bool super:1;
|
||||
} console_modifiers_t;
|
||||
|
||||
typedef struct {
|
||||
char character;
|
||||
console_modifiers_t* modifiers;
|
||||
} console_read_t;
|
||||
|
||||
typedef struct {
|
||||
int (*write)(console_info_t*, char);
|
||||
console_read_t* (*read)(console_info_t*);
|
||||
|
||||
int capabilities;
|
||||
|
||||
int (*_clear)(console_info_t*);
|
||||
int (*scroll)(console_info_t*, int32_t);
|
||||
void (*setCursor)(console_info_t*, uint32_t, uint32_t);
|
||||
} console_driver_t;
|
||||
70
samples/C/elf.h
Normal file
70
samples/C/elf.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <tasks/scheduler.h>
|
||||
|
||||
#define ELF_TYPE_NONE 0
|
||||
#define ELF_TYPE_REL 1
|
||||
#define ELF_TYPE_EXEC 2
|
||||
#define ELF_TYPE_DYN 3
|
||||
#define ELF_TYPE_CORE 4
|
||||
|
||||
#define ELF_ARCH_NONE 0
|
||||
#define ELF_ARCH_386 3
|
||||
|
||||
#define ELF_VERSION_CURRENT 1
|
||||
|
||||
typedef struct {
|
||||
unsigned char magic[4];
|
||||
/* Note: There _is_ other stuff in here, but we don't need it */
|
||||
unsigned char pad[12];
|
||||
} __attribute__((packed)) elf_ident_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t type;
|
||||
uint32_t offset;
|
||||
void* virtaddr;
|
||||
void* physaddr;
|
||||
uint32_t filesize;
|
||||
uint32_t memsize;
|
||||
uint32_t flags;
|
||||
uint32_t alignment;
|
||||
} __attribute__((packed)) elf_program_t;
|
||||
|
||||
typedef struct {
|
||||
elf_ident_t ident;
|
||||
uint16_t type; /* Object file type */
|
||||
uint16_t machine; /* Architecture */
|
||||
uint32_t version; /* Object file version */
|
||||
void* entry; /* Entry point virtual address */
|
||||
uint32_t phoff; /* Program header table file offset */
|
||||
uint32_t shoff; /* Section header table file offset */
|
||||
uint32_t flags; /* Processor-specific flags */
|
||||
uint16_t ehsize; /* ELF header size in bytes */
|
||||
uint16_t phentsize; /* Program header table entry size */
|
||||
uint16_t phnum; /* Program header table entry count */
|
||||
uint16_t shentsize; /* Section header table entry size */
|
||||
uint16_t shnum; /* Section header table entry count */
|
||||
uint16_t shstrndx; /* Section header string table index */
|
||||
} __attribute__((packed)) elf_t;
|
||||
|
||||
task_t* elf_load(elf_t* bin, char* name, char** environ, char** argv, int argc);
|
||||
task_t* elf_load_file(char* path, char** environ, char** argv, int argc);
|
||||
45
samples/C/filter.h
Normal file
45
samples/C/filter.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <console/info.h>
|
||||
#include <console/driver.h>
|
||||
|
||||
struct console_filter {
|
||||
// General callback for all actions etc.
|
||||
// Preferred prototype:
|
||||
// char <name>(char c, console_info_t *info, console_driver_t *input, console_driver_t *output);
|
||||
char (*callback)(char, console_info_t*, console_driver_t*, console_driver_t*);
|
||||
|
||||
// Specific callbacks for read and write
|
||||
// Preferred prototype:
|
||||
// char <name>(char c, console_info_t *info, console_driver_t *input);
|
||||
char (*read_callback)(char, console_info_t*, console_driver_t*);
|
||||
|
||||
// Preferred prototype:
|
||||
// char <name>(char c, console_info_t *info, console_driver_t *output);
|
||||
char (*write_callback)(char, console_info_t*, console_driver_t*);
|
||||
|
||||
// The next filter in the filter chain
|
||||
struct console_filter* next;
|
||||
};
|
||||
|
||||
typedef struct console_filter console_filter_t;
|
||||
|
||||
44
samples/C/info.h
Normal file
44
samples/C/info.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <console/color.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t cursor_x;
|
||||
uint32_t cursor_y;
|
||||
|
||||
uint32_t rows;
|
||||
uint32_t columns;
|
||||
|
||||
uint32_t tabstop;
|
||||
|
||||
console_color_t default_color;
|
||||
console_color_t current_color;
|
||||
|
||||
uint8_t nonblocking;
|
||||
uint8_t reverse_video;
|
||||
uint8_t bold;
|
||||
uint8_t blink;
|
||||
uint8_t underline;
|
||||
uint8_t newline_mode;
|
||||
uint8_t auto_echo;
|
||||
uint8_t handle_backspace;
|
||||
} console_info_t;
|
||||
47
samples/C/interface.h
Normal file
47
samples/C/interface.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <console/info.h>
|
||||
#include <console/filter.h>
|
||||
#include <console/driver.h>
|
||||
|
||||
typedef struct {
|
||||
console_info_t info;
|
||||
|
||||
console_filter_t* input_filter;
|
||||
console_filter_t* output_filter;
|
||||
|
||||
console_driver_t* input_driver;
|
||||
console_driver_t* output_driver;
|
||||
} console_t;
|
||||
|
||||
console_t* default_console;
|
||||
|
||||
// Generate raw console, connected to the Display, Keyboard and the
|
||||
// ECMA-48-Filter
|
||||
void console_init();
|
||||
|
||||
size_t console_write(console_t* console, const char* buffer, int32_t length);
|
||||
#define console_write2(console, buffer) console_write(console, buffer, strlen(buffer))
|
||||
size_t console_read(console_t* console, char* buffer, size_t length);
|
||||
size_t console_scroll(console_t* console, int32_t pages);
|
||||
|
||||
void console_clear(console_t* console);
|
||||
50
samples/C/ip4.h
Normal file
50
samples/C/ip4.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <net/net.h>
|
||||
|
||||
#define IP4_TOS_ICMP 0
|
||||
|
||||
typedef uint32_t ip4_addr_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned int hl:4; /* both fields are 4 bits */
|
||||
unsigned int version:4;
|
||||
uint8_t tos;
|
||||
uint16_t len;
|
||||
uint16_t id;
|
||||
uint16_t off;
|
||||
uint8_t ttl;
|
||||
uint8_t p;
|
||||
uint16_t checksum;
|
||||
ip4_addr_t src;
|
||||
ip4_addr_t dst;
|
||||
} ip4_header_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
uint8_t code;
|
||||
uint16_t checksum;
|
||||
uint16_t id;
|
||||
uint16_t sequence;
|
||||
} ip4_icmp_header_t;
|
||||
|
||||
void ip4_receive(net_device_t* origin, net_l2proto_t proto, size_t size, void* raw);
|
||||
110
samples/C/multiboot.h
Normal file
110
samples/C/multiboot.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2010, 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
|
||||
#define MULTIBOOT_KERNELMAGIC 0x2BADB002
|
||||
|
||||
#define MULTIBOOT_FLAG_MEM 0x001
|
||||
#define MULTIBOOT_FLAG_DEVICE 0x002
|
||||
#define MULTIBOOT_FLAG_CMDLINE 0x004
|
||||
#define MULTIBOOT_FLAG_MODS 0x008
|
||||
#define MULTIBOOT_FLAG_AOUT 0x010
|
||||
#define MULTIBOOT_FLAG_ELF 0x020
|
||||
#define MULTIBOOT_FLAG_MMAP 0x040
|
||||
#define MULTIBOOT_FLAG_CONFIG 0x080
|
||||
#define MULTIBOOT_FLAG_LOADER 0x100
|
||||
#define MULTIBOOT_FLAG_APM 0x200
|
||||
#define MULTIBOOT_FLAG_VBE 0x400
|
||||
|
||||
// The symbol table for a.out.
|
||||
typedef struct
|
||||
{
|
||||
uint32_t tabSize;
|
||||
uint32_t strSize;
|
||||
uint32_t addr;
|
||||
uint32_t reserved;
|
||||
} __attribute__((packed)) multiboot_aoutSymbolTable_t;
|
||||
|
||||
// The section header table for ELF.
|
||||
typedef struct
|
||||
{
|
||||
uint32_t num;
|
||||
uint32_t size;
|
||||
uint32_t addr;
|
||||
uint32_t shndx;
|
||||
} __attribute__((packed)) multiboot_elfSectionHeaderTable_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t size;
|
||||
uint64_t addr;
|
||||
uint64_t length;
|
||||
uint32_t type;
|
||||
} __attribute__((packed)) multiboot_memoryMap_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t start;
|
||||
uint32_t end;
|
||||
char* cmdLine;
|
||||
uint32_t reserved;
|
||||
} __attribute__((packed)) multiboot_module_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flags;
|
||||
uint32_t memLower;
|
||||
uint32_t memUpper;
|
||||
uint32_t bootDevice;
|
||||
char* cmdLine;
|
||||
uint32_t modsCount;
|
||||
multiboot_module_t* modsAddr;
|
||||
|
||||
union
|
||||
{
|
||||
multiboot_aoutSymbolTable_t aoutSym;
|
||||
multiboot_elfSectionHeaderTable_t elfSec;
|
||||
} u;
|
||||
|
||||
uint32_t mmapLength;
|
||||
uint32_t mmapAddr;
|
||||
|
||||
uint32_t drivesLength;
|
||||
uint32_t drivesAddr;
|
||||
|
||||
// ROM configuration table
|
||||
uint32_t configTable;
|
||||
|
||||
char* bootLoaderName;
|
||||
uint32_t apmTable;
|
||||
|
||||
// Video
|
||||
uint32_t vbeControlInfo;
|
||||
uint32_t vbeModeInfo;
|
||||
uint16_t vbeMode;
|
||||
uint16_t vbeInterfaceSeg;
|
||||
uint16_t vbeInterfaceOff;
|
||||
uint16_t vbeInterfaceLen;
|
||||
} __attribute__((packed)) multiboot_info_t;
|
||||
|
||||
multiboot_info_t* multiboot_info;
|
||||
|
||||
void arch_multiboot_printInfo();
|
||||
43
samples/C/portio.h
Normal file
43
samples/C/portio.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <lib/stdint.h>
|
||||
|
||||
// Legacy
|
||||
#define outb(args...) portio_out8(args)
|
||||
#define outw(args...) portio_out16(args)
|
||||
#define outl(args...) portio_out32(args)
|
||||
#define outq(args...) portio_out64(args)
|
||||
|
||||
#define inb(args...) portio_in8(args)
|
||||
#define inw(args...) portio_in16(args)
|
||||
#define inl(args...) portio_in32(args)
|
||||
#define inq(args...) portio_in64(args)
|
||||
|
||||
void portio_out8(uint16_t port, uint8_t value);
|
||||
void portio_out16(uint16_t port, uint16_t value);
|
||||
void portio_out32(uint16_t port, uint32_t value);
|
||||
void portio_out64(uint16_t port, uint64_t value);
|
||||
|
||||
uint8_t portio_in8(uint16_t port);
|
||||
uint16_t portio_in16(uint16_t port);
|
||||
uint32_t portio_in32(uint16_t port);
|
||||
uint64_t portio_in64(uint16_t port);
|
||||
69
samples/C/scheduler.h
Normal file
69
samples/C/scheduler.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <hw/cpu.h>
|
||||
#include <memory/vmem.h>
|
||||
|
||||
#define SCHEDULER_MAXNAME 256
|
||||
#define SCHEDULER_TASK_PATH_MAX 256
|
||||
|
||||
// Single linked list
|
||||
typedef struct task {
|
||||
uint32_t pid;
|
||||
char name[SCHEDULER_MAXNAME];
|
||||
struct task *parent;
|
||||
cpu_state_t* state;
|
||||
struct task* next;
|
||||
struct task* previous;
|
||||
|
||||
void* stack;
|
||||
void* entry;
|
||||
struct vmem_context *memory_context;
|
||||
|
||||
// Current task state
|
||||
enum {
|
||||
TASK_STATE_KILLED,
|
||||
TASK_STATE_TERMINATED,
|
||||
TASK_STATE_BLOCKING,
|
||||
TASK_STATE_STOPPED,
|
||||
TASK_STATE_RUNNING
|
||||
} task_state;
|
||||
|
||||
char** environ;
|
||||
char** argv;
|
||||
int argc;
|
||||
|
||||
// TODO Is this actually the same as PATH_MAX in our toolchain?
|
||||
char cwd[SCHEDULER_TASK_PATH_MAX + 1];
|
||||
} task_t;
|
||||
|
||||
int scheduler_state;
|
||||
|
||||
task_t* scheduler_new(void* entry, task_t* parent, char name[SCHEDULER_MAXNAME],
|
||||
char** environ, char** argv, int argc, struct vmem_context* memory_context, bool map_structs);
|
||||
void scheduler_add(task_t *task);
|
||||
void scheduler_terminate_current();
|
||||
task_t* scheduler_get_current();
|
||||
task_t* scheduler_select(cpu_state_t* lastRegs);
|
||||
void scheduler_init();
|
||||
void scheduler_yield();
|
||||
void scheduler_remove(task_t *t);
|
||||
task_t* scheduler_fork(task_t* to_fork, cpu_state_t* state);
|
||||
95
samples/C/syscalls.h
Normal file
95
samples/C/syscalls.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
#include <tasks/syscall.h>
|
||||
|
||||
#include "syscalls/write.h"
|
||||
#include "syscalls/exit.h"
|
||||
#include "syscalls/getpid.h"
|
||||
#include "syscalls/getppid.h"
|
||||
#include "syscalls/read.h"
|
||||
#include "syscalls/brk.h"
|
||||
#include "syscalls/mmap.h"
|
||||
#include "syscalls/munmap.h"
|
||||
#include "syscalls/test.h"
|
||||
#include "syscalls/hostname.h"
|
||||
#include "syscalls/uname.h"
|
||||
#include "syscalls/open.h"
|
||||
#include "syscalls/execve.h"
|
||||
#include "syscalls/seek.h"
|
||||
#include "syscalls/opendir.h"
|
||||
#include "syscalls/readdir.h"
|
||||
#include "syscalls/kill.h"
|
||||
#include "syscalls/getexecdata.h"
|
||||
#include "syscalls/cwd.h"
|
||||
#include "syscalls/fork.h"
|
||||
|
||||
syscall_t syscall_table[] = {
|
||||
NULL,
|
||||
sys_exit, // 1
|
||||
sys_read, // 2
|
||||
sys_write, // 3
|
||||
sys_getpid, // 4
|
||||
sys_brk, // 5
|
||||
sys_getppid, // 6
|
||||
sys_mmap, // 7
|
||||
sys_munmap, // 8
|
||||
sys_test, // 9
|
||||
sys_get_hostname, // 10
|
||||
sys_set_hostname, // 11
|
||||
sys_uname, // 12
|
||||
sys_open, // 13
|
||||
sys_execve, // 14
|
||||
sys_seek, // 15
|
||||
sys_opendir, // 16
|
||||
sys_readdir, // 17
|
||||
sys_kill, // 18
|
||||
sys_getexecdata, // 19
|
||||
sys_chdir, // 20
|
||||
sys_getcwd, // 21
|
||||
sys_fork, // 22
|
||||
};
|
||||
|
||||
char* syscall_name_table[] = {
|
||||
NULL,
|
||||
"exit", // 1
|
||||
"read", // 2
|
||||
"write", // 3
|
||||
"getpid", // 4
|
||||
"brk", // 5
|
||||
"getppid", // 6
|
||||
"mmap", // 7
|
||||
"munmap", // 8
|
||||
"test", // 9
|
||||
"get_hostname", // 10
|
||||
"set_hostname", // 11
|
||||
"uname", // 12
|
||||
"open", // 13
|
||||
"execve", // 14
|
||||
"seek", // 15
|
||||
"opendir", // 16
|
||||
"readdir", // 17
|
||||
"kill", // 18
|
||||
"getexecdata", // 19
|
||||
"chdir", // 20
|
||||
"getcwd", // 21
|
||||
"fork", // 22
|
||||
};
|
||||
56
samples/C/vfs.h
Normal file
56
samples/C/vfs.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2010, 2011 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
|
||||
#define VFS_SEEK_SET 0
|
||||
#define VFS_SEEK_CUR 1
|
||||
#define VFS_SEEK_END 2
|
||||
|
||||
typedef struct {
|
||||
uint64_t num;
|
||||
char path[512];
|
||||
char mount_path[512];
|
||||
uint32_t offset;
|
||||
uint32_t mountpoint;
|
||||
} vfs_file_t;
|
||||
|
||||
typedef struct {
|
||||
uint64_t num;
|
||||
char path[512];
|
||||
char mount_path[512];
|
||||
uint32_t mountpoint;
|
||||
} vfs_dir_t;
|
||||
|
||||
typedef void* (*vfs_read_callback_t)(char* path, uint32_t offset, uint32_t size);
|
||||
typedef char* (*vfs_read_dir_callback_t)(char* path, uint32_t offset);
|
||||
|
||||
|
||||
// Used to always store the last read/write attempt (used for kernel panic debugging)
|
||||
char vfs_last_read_attempt[512];
|
||||
|
||||
vfs_file_t* vfs_get_from_id(uint32_t id);
|
||||
vfs_dir_t* vfs_get_dir_from_id(uint32_t id);
|
||||
void* vfs_read(vfs_file_t* fp, uint32_t size);
|
||||
char* vfs_dir_read(vfs_dir_t* dir, uint32_t offset);
|
||||
void vfs_seek(vfs_file_t* fp, uint32_t offset, int origin);
|
||||
vfs_file_t* vfs_open(char* path);
|
||||
vfs_dir_t* vfs_dir_open(char* path);
|
||||
int vfs_mount(char* path, vfs_read_callback_t read_callback, vfs_read_dir_callback_t read_dir_callback);
|
||||
94
samples/C/vmem.h
Normal file
94
samples/C/vmem.h
Normal file
@@ -0,0 +1,94 @@
|
||||
#pragma once
|
||||
|
||||
/* Copyright © 2011 Fritz Grimpen
|
||||
* Copyright © 2013 Lukas Martini
|
||||
*
|
||||
* This file is part of Xelix.
|
||||
*
|
||||
* Xelix 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.
|
||||
*
|
||||
* Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <lib/generic.h>
|
||||
|
||||
struct vmem_context;
|
||||
|
||||
struct vmem_page
|
||||
{
|
||||
enum
|
||||
{
|
||||
VMEM_SECTION_STACK, /* Initial stack */
|
||||
VMEM_SECTION_CODE, /* Contains program code and is read-only */
|
||||
VMEM_SECTION_DATA, /* Contains static data */
|
||||
VMEM_SECTION_HEAP, /* Allocated by brk(2) at runtime */
|
||||
VMEM_SECTION_MMAP, /* Allocated by mmap(2) at runtime */
|
||||
VMEM_SECTION_KERNEL, /* Contains kernel-internal data */
|
||||
VMEM_SECTION_UNMAPPED /* Unmapped */
|
||||
} section;
|
||||
|
||||
bool readonly:1;
|
||||
bool cow:1; /* Copy-on-Write mechanism */
|
||||
bool allocated:1;
|
||||
|
||||
void *cow_src_addr;
|
||||
void *virt_addr;
|
||||
void *phys_addr;
|
||||
};
|
||||
|
||||
typedef void (*vmem_iterator_t)(struct vmem_context *, struct vmem_page *, uint32_t);
|
||||
|
||||
/* Initialize vmem_kernelContext for paging_init() */
|
||||
void vmem_init();
|
||||
struct vmem_context *vmem_kernelContext;
|
||||
struct vmem_context *vmem_currentContext;
|
||||
struct vmem_context *vmem_processContext;
|
||||
void *vmem_faultAddress;
|
||||
|
||||
/* Some callbacks for magic functions */
|
||||
void (*vmem_applyPage)(struct vmem_context *, struct vmem_page *);
|
||||
|
||||
/* Generate new page context */
|
||||
struct vmem_context *vmem_new();
|
||||
struct vmem_page *vmem_new_page();
|
||||
|
||||
int vmem_add_page(struct vmem_context *ctx, struct vmem_page *pg);
|
||||
|
||||
struct vmem_page *vmem_get_page_phys(struct vmem_context *ctx, void *phys_addr);
|
||||
struct vmem_page *vmem_get_page_virt(struct vmem_context *ctx, void *virt_addr);
|
||||
struct vmem_page *vmem_get_page(struct vmem_context *ctx, uint32_t offset);
|
||||
|
||||
/* Remove pages in a specific context by physical or virtual address */
|
||||
struct vmem_page *vmem_rm_page_phys(struct vmem_context *ctx, void *phys_addr);
|
||||
struct vmem_page *vmem_rm_page_virt(struct vmem_context *ctx, void *virt_addr);
|
||||
|
||||
/* Iterator */
|
||||
int vmem_iterate(struct vmem_context *ctx, vmem_iterator_t callback);
|
||||
|
||||
uint32_t vmem_count_pages(struct vmem_context *ctx);
|
||||
void vmem_dump_page(struct vmem_page *pg);
|
||||
void vmem_dump(struct vmem_context *ctx);
|
||||
void vmem_handle_fault(uint32_t code, void *addr, void *instruction);
|
||||
|
||||
/* Get/Set cached paging context */
|
||||
void vmem_set_cache(struct vmem_context *ctx, void *cache);
|
||||
void *vmem_get_cache(struct vmem_context *ctx);
|
||||
|
||||
#ifdef __i386__
|
||||
#define PAGE_SIZE 4096
|
||||
#define VMEM_ALIGN(x) (typeof(x))(((intptr_t)(x) & 0xFFFFF000) + 0x1000)
|
||||
#define VMEM_ALIGN_DOWN(x) (typeof(x))( \
|
||||
((intptr_t)(x) - ((intptr_t)(x) % PAGE_SIZE)))
|
||||
#else
|
||||
#define PAGE_SIZE 0
|
||||
#define VMEM_ALIGN(x) (x)
|
||||
#endif
|
||||
76
samples/Public Key/gpg_key.asc
Normal file
76
samples/Public Key/gpg_key.asc
Normal file
@@ -0,0 +1,76 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: GnuPG v2
|
||||
|
||||
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
|
||||
=xJ8l
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
1
samples/Public Key/id.pub
Normal file
1
samples/Public Key/id.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQConqV+vS0WfY9swk8St+JcRuhft0jTg4IrAEfmxahSLurkbf54jbe8mrNn96Nm2gkRzs2RNVQ9r4dZzdhKTUk395Vs3LbX3cfdRNaCrs3udqhRZK7Go69DQECnEHFNczBxSrhT5DoO4nuzVimHgSsX7rHKHo6J7SDNowf83/nLUr7SAJvOeQo5yZQqqZQi5NXqH6pEOQtWPILdbZWuhq8s4JIXc38I+w3IXEJ0ttsfkyShv85bhwSFzrOlq2oGY37YVWeXPREXg9ksA6rlxe29SIdAQbINlgJ/ELzDVMYiaQkI5opAvI2EzPVd4325PcMgyFM/weO9F6bKZaGCNyt3
|
||||
1
samples/Public Key/id_rsa.pub
Normal file
1
samples/Public Key/id_rsa.pub
Normal file
@@ -0,0 +1 @@
|
||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCw3QQtYgRViVH8ZpkQ2A7BuCeyPYC4hB9kKNhxwUfJ2hFgW8soGMBhsLN+vOeAJ2IXDMsezJO2/qhoZFQMvHoWpWTRTLPeNtBsKD+nhOZX28A4D+QRzVZ6hdWoh9W+mIP69MIT3aX35oLb86IycbNdRJlEK4FAUt7tjezNkU7boQ== root@use1-2.nitrousbox.com
|
||||
15
samples/Public Key/sunCert.asc
Normal file
15
samples/Public Key/sunCert.asc
Normal file
@@ -0,0 +1,15 @@
|
||||
Type Bits/KeyID Date User ID
|
||||
pub 1024/79949ADD 2005/08/07 sun <sun.strongswan.org>
|
||||
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
Version: 2.6.3i
|
||||
|
||||
mQCNA0L2Km8AAAEEANRAVMn8HBxfYaGhLqtQ3IZJArn9wpcQ+7sH/F9PaXIjzHRQ
|
||||
rfFkfmxxp9lVjCk0LM/BnnlnUmyz6F8K7V0Gi40Am4+ln1zHvZZIQJYGrDhDnjb7
|
||||
I5TVeD4Ib5bQ1CoUbIhv2LocCeR6OjefQgGmerC5RQ3d5ci7uB0pVpd5lJrdAAUR
|
||||
tBhzdW4gPHN1bi5zdHJvbmdzd2FuLm9yZz6JAJUDBRBC9ipvHSlWl3mUmt0BAUZR
|
||||
A/43nuZbxADMSviu54Mj8pvQbYeGLQVabiWT6h7L0ZPX4MWpFH3dTixBfRrZRSsj
|
||||
0AgiMMuZAMebfOe+Xf9uDQv7p1yumEiNg43tg85zyawkARWNTZZ04woxtvAqNwXn
|
||||
lQotGz7YA6JMxry9RQo5yI4Y4dPnVZ/o8eDpP0+I88cOhQ==
|
||||
=lLvB
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
55
samples/Shell/filenames/9fs
Normal file
55
samples/Shell/filenames/9fs
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/bin/rc
|
||||
# 9fs filesystem [mountpoint] - srv & mount filesystem, usually from plan 9
|
||||
|
||||
rfork e
|
||||
switch($1){
|
||||
case ''
|
||||
echo usage: 9fs service '[mountpoint]' >[1=2]
|
||||
exit usage
|
||||
case kfs
|
||||
if(! test -f /srv/kfs)
|
||||
disk/kfs
|
||||
mount -c /srv/kfs /n/kfs
|
||||
case dump
|
||||
mount /srv/boot /n/dump dump >[2]/dev/null ||
|
||||
mount /srv/boot /n/dump main/archive ||
|
||||
mount /srv/boot /n/dump dump # again to print error
|
||||
case snap
|
||||
mount /srv/boot /n/snap main/snapshot
|
||||
case other
|
||||
mount -C /srv/boot /n/other other
|
||||
case juke # ye olde file server
|
||||
srv -q il!jukefs && mount /srv/il!jukefs /n/juke
|
||||
case sources
|
||||
srv -nq tcp!sources.cs.bell-labs.com sources /n/sources
|
||||
case sourcesdump
|
||||
9fs sources
|
||||
mount -n /srv/sources /n/sourcesdump main/archive
|
||||
case sourcessnap
|
||||
9fs sources
|
||||
mount -n /srv/sources /n/sourcessnap main/snapshot
|
||||
# arbitrary venti archives
|
||||
case vac:*
|
||||
vacfs <{echo $1}
|
||||
case *.vac
|
||||
if (test -e $1)
|
||||
score=$1
|
||||
if not if (! ~ $1 /* && test -e $home/lib/vac/$1)
|
||||
score=$home/lib/vac/$1
|
||||
if not if (! ~ $1 /* && test -e /lib/vac/$1)
|
||||
score=/lib/vac/$1
|
||||
if not {
|
||||
echo $0: $1: no such score file >[1=2]
|
||||
exit 'no score file'
|
||||
}
|
||||
vacfs -m /n/`{basename $1 .vac} `{cat $score}
|
||||
case wiki
|
||||
srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
|
||||
case *
|
||||
switch($#*){
|
||||
case 1
|
||||
srv -m $1
|
||||
case *
|
||||
srv -m $1 $1 $2
|
||||
}
|
||||
}
|
||||
149
samples/Shell/filenames/man
Normal file
149
samples/Shell/filenames/man
Normal file
@@ -0,0 +1,149 @@
|
||||
#!/bin/rc
|
||||
# man - print manual pages
|
||||
rfork e
|
||||
|
||||
. /sys/man/fonts
|
||||
|
||||
cmd=n
|
||||
sec=()
|
||||
S=/sys/man
|
||||
d=0
|
||||
|
||||
fn roff {
|
||||
preproc=()
|
||||
postproc=cat
|
||||
x=`{doctype $2}
|
||||
if (~ $1 t) {
|
||||
if(~ $x *grap*)
|
||||
preproc=($preproc grap)
|
||||
if(~ $x *pic*)
|
||||
preproc=($preproc pic)
|
||||
Nflag=-Tutf
|
||||
}
|
||||
if not {
|
||||
Nflag='-N'
|
||||
Lflag='-rL1000i'
|
||||
# setting L changes page length to infinity (sed script removes empty lines)
|
||||
if (grep -s '^\.(2C|sp *[0-9]*\.)' $2)
|
||||
postproc=col
|
||||
}
|
||||
if(~ $x *eqn*)
|
||||
preproc=($preproc eqn)
|
||||
if(~ $x *tbl*)
|
||||
preproc=($preproc tbl)
|
||||
{echo -n $FONTS; cat $2 </dev/null} |
|
||||
switch($#preproc) {
|
||||
case 0
|
||||
troff $Nflag $Lflag -$MAN
|
||||
case 1
|
||||
$preproc | troff $Nflag $Lflag -$MAN
|
||||
case 2
|
||||
$preproc(1) | $preproc(2) | troff $Nflag $Lflag -$MAN
|
||||
case 3
|
||||
$preproc(1) | $preproc(2) | $preproc(3) |
|
||||
troff $Nflag $Lflag -$MAN
|
||||
case *
|
||||
$preproc(1) | $preproc(2) | $preproc(3) |
|
||||
$preproc(4) | troff $Nflag $Lflag -$MAN
|
||||
} | $postproc
|
||||
}
|
||||
|
||||
fn page {
|
||||
if(test -d /mnt/wsys/acme)
|
||||
/bin/page -w
|
||||
if not
|
||||
/bin/page
|
||||
}
|
||||
|
||||
|
||||
search=yes
|
||||
while(~ $d 0) {
|
||||
if(~ $#* 0) {
|
||||
echo 'Usage: man [-bntpPSw] [0-9] [0-9] ... name1 name2 ...' >[1=2]
|
||||
exit
|
||||
}
|
||||
if(test -d $S/$1){
|
||||
sec=($sec $1)
|
||||
shift
|
||||
}
|
||||
if not
|
||||
switch($1) {
|
||||
case -b ; cmd=b ; shift
|
||||
case -n ; cmd=n ; shift
|
||||
case -P ; cmd=P ; shift
|
||||
case -p ; cmd=p ; shift
|
||||
case -S ; search=no ; shift
|
||||
case -t ; cmd=t ; shift
|
||||
case -w ; cmd=w ; shift
|
||||
case * ; d=1
|
||||
}
|
||||
}
|
||||
if(~ $#sec 0) {
|
||||
sec=`{ls -pd $S/[0-9]* }
|
||||
}
|
||||
ix=$S/$sec/INDEX
|
||||
if(~ $#* 1) pat='^'^$1^' '
|
||||
if not pat='^('^`{echo $* | sed 's/ /|/g'}^') '
|
||||
fils=()
|
||||
if(~ $search yes)
|
||||
for(i in $S/$sec){
|
||||
if(/bin/test -f $i/INDEX){
|
||||
try=`{grep -i $pat $i/INDEX | sed 's/^[^ ]* //' | sort -u}
|
||||
if(! ~ $#try 0)
|
||||
fils=($fils $i/$try)
|
||||
}
|
||||
}
|
||||
# bug: should also do following loop if not all pages found
|
||||
if(~ $#fils 0) {
|
||||
# nothing in INDEX. try for file of given name
|
||||
for(i) {
|
||||
if(~ $i intro) i=0intro
|
||||
for(n in $sec) {
|
||||
try=`{echo $S/$n/$i | tr A-Z a-z}
|
||||
if (/bin/test -f $try)
|
||||
fils=($fils $try)
|
||||
}
|
||||
}
|
||||
if(~ $#fils 0) {
|
||||
echo 'man: no manual page' >[1=2]
|
||||
exit 'no man'
|
||||
}
|
||||
}
|
||||
for(i in $fils) {
|
||||
if(! /bin/test -f $i)
|
||||
echo need $i >[1=2]
|
||||
if not {
|
||||
switch($cmd) {
|
||||
case w
|
||||
echo $i
|
||||
|
||||
case t
|
||||
roff t $i
|
||||
|
||||
case p
|
||||
roff t $i | grep -v '^x X html' | proof
|
||||
|
||||
case P
|
||||
roff t $i | page
|
||||
|
||||
case n
|
||||
roff n $i | sed '
|
||||
${
|
||||
/^$/p
|
||||
}
|
||||
//N
|
||||
/^\n$/D'
|
||||
|
||||
case b
|
||||
x=`{echo $i | sed 's;/sys/man/(.*)/(.*);\1 \2;'}
|
||||
if(~ $x(2) 0intro) x=($x(1) intro)
|
||||
roff n $i | sed '
|
||||
${
|
||||
/^$/p
|
||||
}
|
||||
//N
|
||||
/^\n$/D' |
|
||||
plumb -i -d edit -a 'action=showdata filename=/man/'$x(2)^'('$x(1)^')'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,703 +0,0 @@
|
||||
#==============================================================================
|
||||
#
|
||||
# <20><> Yanfly Engine Ace - Visual Battlers v1.01
|
||||
# -- Last Updated: 2012.07.24
|
||||
# -- Level: Easy
|
||||
# -- Requires: n/a
|
||||
#
|
||||
# <20><> Modified by:
|
||||
# -- Yami
|
||||
# -- Kread-Ex
|
||||
# -- Archeia_Nessiah
|
||||
#==============================================================================
|
||||
|
||||
$imported = {} if $imported.nil?
|
||||
$imported["YEA-VisualBattlers"] = true
|
||||
|
||||
#==============================================================================
|
||||
# <20><> Updates
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
# 2012.12.18 - Added preset views and able to change direction in-game.
|
||||
# 2012.07.24 - Finished Script.
|
||||
# 2012.01.05 - Started Script.
|
||||
#
|
||||
#==============================================================================
|
||||
# <20><> Introduction
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
# This script provides a visual for all actors by default charsets. The actions
|
||||
# and movements are alike Final Fantasy 1, only move forward and backward when
|
||||
# start and finish actions.
|
||||
#
|
||||
#==============================================================================
|
||||
# <20><> Instructions
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
# To change the player direction in-game, use the snippet below in a script
|
||||
# call:
|
||||
#
|
||||
# $game_system.party_direction = n
|
||||
#
|
||||
# To install this script, open up your script editor and copy/paste this script
|
||||
# to an open slot below <20><> Materials but above <20><> Main. Remember to save.
|
||||
#
|
||||
#==============================================================================
|
||||
# <20><> Compatibility
|
||||
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
|
||||
# it will run with RPG Maker VX without adjusting.
|
||||
#
|
||||
#==============================================================================
|
||||
|
||||
module YEA
|
||||
module VISUAL_BATTLERS
|
||||
|
||||
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
# - Party Location Setting -
|
||||
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
# These settings are adjusted for Party Location. Each Actor will have
|
||||
# coordinates calculated by below formula. There are two samples coordinates
|
||||
# below, change PARTY_DIRECTION to the base index you want to use.
|
||||
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
PARTY_DIRECTION = 6 # This direction is opposite from actual direction.
|
||||
|
||||
PARTY_LOCATION_BASE_COORDINATES ={
|
||||
# Index => [base_x, base_y, mod_x, mod_y],
|
||||
2 => [ 250, 290, 40, 0], #UP
|
||||
4 => [ 150, 280, 20, -20], #LEFT
|
||||
3 => [ 460, 280, 30, -10], #RIGHT
|
||||
6 => [ 460, 230, 20, 20], #DEFAULT RIGHT
|
||||
8 => [ 260, 230, 40, 0], #DOWN
|
||||
} # Do not remove this.
|
||||
|
||||
PARTY_LOCATION_FORMULA_X = "base_x + index * mod_x"
|
||||
PARTY_LOCATION_FORMULA_Y = "base_y + index * mod_y"
|
||||
|
||||
end # VISUAL_BATTLERS
|
||||
end # YEA
|
||||
|
||||
#==============================================================================
|
||||
# <20><> Editting anything past this point may potentially result in causing
|
||||
# computer damage, incontinence, explosion of user's head, coma, death, and/or
|
||||
# halitosis so edit at your own risk.
|
||||
#==============================================================================
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Direction
|
||||
#==============================================================================
|
||||
|
||||
module Direction
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# self.correct
|
||||
#--------------------------------------------------------------------------
|
||||
def self.correct(direction)
|
||||
case direction
|
||||
when 1; return 4
|
||||
when 3; return 6
|
||||
when 7; return 4
|
||||
when 9; return 6
|
||||
else; return direction
|
||||
end
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# self.opposite
|
||||
#--------------------------------------------------------------------------
|
||||
def self.opposite(direction)
|
||||
case direction
|
||||
when 1; return 6
|
||||
when 2; return 8
|
||||
when 3; return 4
|
||||
when 4; return 6
|
||||
when 6; return 4
|
||||
when 7; return 6
|
||||
when 8; return 2
|
||||
when 9; return 4
|
||||
else; return direction
|
||||
end
|
||||
end
|
||||
|
||||
end # Direction
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_System
|
||||
#==============================================================================
|
||||
|
||||
class Game_System; attr_accessor :party_direction; end
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_BattleCharacter
|
||||
#==============================================================================
|
||||
|
||||
class Game_BattleCharacter < Game_Character
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# initialize
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(actor)
|
||||
super()
|
||||
setup_actor(actor)
|
||||
@move_x_rate = 0
|
||||
@move_y_rate = 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# setup_actor
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_actor(actor)
|
||||
@actor = actor
|
||||
@step_anime = true
|
||||
set_graphic(@actor.character_name, @actor.character_index)
|
||||
setup_coordinates
|
||||
dr = $game_system.party_direction || YEA::VISUAL_BATTLERS::PARTY_DIRECTION
|
||||
direction = Direction.opposite(dr)
|
||||
set_direction(Direction.correct(direction))
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# sprite=
|
||||
#--------------------------------------------------------------------------
|
||||
def sprite=(sprite)
|
||||
@sprite = sprite
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# setup_coordinates
|
||||
#--------------------------------------------------------------------------
|
||||
def setup_coordinates
|
||||
location = ($game_system.party_direction ||
|
||||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
|
||||
base_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][0]
|
||||
base_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][1]
|
||||
mod_x = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][2]
|
||||
mod_y = YEA::VISUAL_BATTLERS::PARTY_LOCATION_BASE_COORDINATES[location][3]
|
||||
@actor.screen_x = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_X)
|
||||
@actor.screen_y = eval(YEA::VISUAL_BATTLERS::PARTY_LOCATION_FORMULA_Y)
|
||||
@actor.origin_x = @actor.screen_x
|
||||
@actor.origin_y = @actor.screen_y
|
||||
@actor.create_move_to(screen_x, screen_y, 1)
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# index
|
||||
#--------------------------------------------------------------------------
|
||||
def index
|
||||
return @actor.index
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# screen_x
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_x
|
||||
return @actor.screen_x
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# screen_y
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_y
|
||||
return @actor.screen_y
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# screen_z
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_z
|
||||
return @actor.screen_z
|
||||
end
|
||||
|
||||
end # Game_BattleCharacter
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_Battler
|
||||
#==============================================================================
|
||||
|
||||
class Game_Battler < Game_BattlerBase
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# public instance variables
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :moved_back
|
||||
attr_accessor :origin_x
|
||||
attr_accessor :origin_y
|
||||
attr_accessor :screen_x
|
||||
attr_accessor :screen_y
|
||||
attr_accessor :started_turn
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: execute_damage
|
||||
#--------------------------------------------------------------------------
|
||||
alias game_battler_execute_damage_vb execute_damage
|
||||
def execute_damage(user)
|
||||
game_battler_execute_damage_vb(user)
|
||||
if @result.hp_damage > 0
|
||||
move_backward(24, 6) unless @moved_back
|
||||
@moved_back = true
|
||||
end
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# face_opposing_party
|
||||
#--------------------------------------------------------------------------
|
||||
def face_opposing_party
|
||||
direction = ($game_system.party_direction ||
|
||||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
|
||||
character.set_direction(Direction.correct(direction)) rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: face_coordinate
|
||||
#--------------------------------------------------------------------------
|
||||
def face_coordinate(destination_x, destination_y)
|
||||
x1 = Integer(@screen_x)
|
||||
x2 = Integer(destination_x)
|
||||
y1 = Graphics.height - Integer(@screen_y)
|
||||
y2 = Graphics.height - Integer(destination_y)
|
||||
return if x1 == x2 and y1 == y2
|
||||
#---
|
||||
angle = Integer(Math.atan2((y2-y1),(x2-x1)) * 1800 / Math::PI)
|
||||
if (0..225) === angle or (-225..0) === angle
|
||||
direction = 6
|
||||
elsif (226..675) === angle
|
||||
direction = 9
|
||||
elsif (676..1125) === angle
|
||||
direction = 8
|
||||
elsif (1126..1575) === angle
|
||||
direction = 7
|
||||
elsif (1576..1800) === angle or (-1800..-1576) === angle
|
||||
direction = 4
|
||||
elsif (-1575..-1126) === angle
|
||||
direction = 1
|
||||
elsif (-1125..-676) === angle
|
||||
direction = 2
|
||||
elsif (-675..-226) === angle
|
||||
direction = 3
|
||||
end
|
||||
#---
|
||||
character.set_direction(Direction.correct(direction)) rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# create_move_to
|
||||
#--------------------------------------------------------------------------
|
||||
def create_move_to(destination_x, destination_y, frames = 12)
|
||||
@destination_x = destination_x
|
||||
@destination_y = destination_y
|
||||
frames = [frames, 1].max
|
||||
@move_x_rate = [(@screen_x - @destination_x).abs / frames, 2].max
|
||||
@move_y_rate = [(@screen_y - @destination_y).abs / frames, 2].max
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# update_move_to
|
||||
#--------------------------------------------------------------------------
|
||||
def update_move_to
|
||||
@move_x_rate = 0 if @screen_x == @destination_x || @move_x_rate.nil?
|
||||
@move_y_rate = 0 if @screen_y == @destination_y || @move_y_rate.nil?
|
||||
value = [(@screen_x - @destination_x).abs, @move_x_rate].min
|
||||
@screen_x += (@destination_x > @screen_x) ? value : -value
|
||||
value = [(@screen_y - @destination_y).abs, @move_y_rate].min
|
||||
@screen_y += (@destination_y > @screen_y) ? value : -value
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# move_forward
|
||||
#--------------------------------------------------------------------------
|
||||
def move_forward(distance = 24, frames = 12)
|
||||
direction = forward_direction
|
||||
move_direction(direction, distance, frames)
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# move_backward
|
||||
#--------------------------------------------------------------------------
|
||||
def move_backward(distance = 24, frames = 12)
|
||||
direction = Direction.opposite(forward_direction)
|
||||
move_direction(direction, distance, frames)
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# move_direction
|
||||
#--------------------------------------------------------------------------
|
||||
def move_direction(direction, distance = 24, frames = 12)
|
||||
case direction
|
||||
when 1; move_x = distance / -2; move_y = distance / 2
|
||||
when 2; move_x = distance * 0; move_y = distance * 1
|
||||
when 3; move_x = distance / -2; move_y = distance / 2
|
||||
when 4; move_x = distance * -1; move_y = distance * 0
|
||||
when 6; move_x = distance * 1; move_y = distance * 0
|
||||
when 7; move_x = distance / -2; move_y = distance / -2
|
||||
when 8; move_x = distance * 0; move_y = distance * -1
|
||||
when 9; move_x = distance / 2; move_y = distance / -2
|
||||
else; return
|
||||
end
|
||||
destination_x = @screen_x + move_x
|
||||
destination_y = @screen_y + move_y
|
||||
create_move_to(destination_x, destination_y, frames)
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# forward_direction
|
||||
#--------------------------------------------------------------------------
|
||||
def forward_direction
|
||||
return ($game_system.party_direction ||
|
||||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION)
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# move_origin
|
||||
#--------------------------------------------------------------------------
|
||||
def move_origin
|
||||
create_move_to(@origin_x, @origin_y)
|
||||
face_coordinate(@origin_x, @origin_y)
|
||||
@moved_back = false
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# moving?
|
||||
#--------------------------------------------------------------------------
|
||||
def moving?
|
||||
return false if dead? || !exist?
|
||||
return @move_x_rate != 0 || @move_y_rate != 0
|
||||
end
|
||||
|
||||
end # Game_Battler
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_Actor
|
||||
#==============================================================================
|
||||
|
||||
class Game_Actor < Game_Battler
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# overwrite method: use_sprite?
|
||||
#--------------------------------------------------------------------------
|
||||
def use_sprite?
|
||||
return true
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: screen_x
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_x
|
||||
return @screen_x rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: screen_y
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_y
|
||||
return @screen_y rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: screen_z
|
||||
#--------------------------------------------------------------------------
|
||||
def screen_z
|
||||
return 100
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: sprite
|
||||
#--------------------------------------------------------------------------
|
||||
def sprite
|
||||
index = $game_party.battle_members.index(self)
|
||||
return SceneManager.scene.spriteset.actor_sprites[index]
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: character
|
||||
#--------------------------------------------------------------------------
|
||||
def character
|
||||
return sprite.character_base
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# face_opposing_party
|
||||
#--------------------------------------------------------------------------
|
||||
def face_opposing_party
|
||||
dr = $game_system.party_direction || YEA::VISUAL_BATTLERS::PARTY_DIRECTION
|
||||
direction = Direction.opposite(dr)
|
||||
character.set_direction(Direction.correct(direction)) rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# forward_direction
|
||||
#--------------------------------------------------------------------------
|
||||
def forward_direction
|
||||
return Direction.opposite(($game_system.party_direction ||
|
||||
YEA::VISUAL_BATTLERS::PARTY_DIRECTION))
|
||||
end
|
||||
|
||||
end # Game_Actor
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_Enemy
|
||||
#==============================================================================
|
||||
|
||||
class Game_Enemy < Game_Battler
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: sprite
|
||||
#--------------------------------------------------------------------------
|
||||
def sprite
|
||||
return SceneManager.scene.spriteset.enemy_sprites.reverse[self.index]
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: character
|
||||
#--------------------------------------------------------------------------
|
||||
def character
|
||||
return sprite
|
||||
end
|
||||
|
||||
end # Game_Enemy
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Game_Troop
|
||||
#==============================================================================
|
||||
|
||||
class Game_Troop < Game_Unit
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: setup
|
||||
#--------------------------------------------------------------------------
|
||||
alias game_troop_setup_vb setup
|
||||
def setup(troop_id)
|
||||
game_troop_setup_vb(troop_id)
|
||||
set_coordinates
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: set_coordinates
|
||||
#--------------------------------------------------------------------------
|
||||
def set_coordinates
|
||||
for member in members
|
||||
member.origin_x = member.screen_x
|
||||
member.origin_y = member.screen_y
|
||||
member.create_move_to(member.screen_x, member.screen_y, 1)
|
||||
end
|
||||
end
|
||||
|
||||
end # Game_Troop
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Sprite_Battler
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_Battler < Sprite_Base
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# public instance_variable
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :character_base
|
||||
attr_accessor :character_sprite
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: dispose
|
||||
#--------------------------------------------------------------------------
|
||||
alias sprite_battler_dispose_vb dispose
|
||||
def dispose
|
||||
dispose_character_sprite
|
||||
sprite_battler_dispose_vb
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: dispose_character_sprite
|
||||
#--------------------------------------------------------------------------
|
||||
def dispose_character_sprite
|
||||
@character_sprite.dispose unless @character_sprite.nil?
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: update
|
||||
#--------------------------------------------------------------------------
|
||||
alias sprite_battler_update_vb update
|
||||
def update
|
||||
sprite_battler_update_vb
|
||||
return if @battler.nil?
|
||||
update_move_to
|
||||
update_character_base
|
||||
update_character_sprite
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: update_character_base
|
||||
#--------------------------------------------------------------------------
|
||||
def update_character_base
|
||||
return if @character_base.nil?
|
||||
@character_base.update
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: update_character_sprite
|
||||
#--------------------------------------------------------------------------
|
||||
def update_character_sprite
|
||||
return if @character_sprite.nil?
|
||||
@character_sprite.update
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: update_move_to
|
||||
#--------------------------------------------------------------------------
|
||||
def update_move_to
|
||||
@battler.update_move_to
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: moving?
|
||||
#--------------------------------------------------------------------------
|
||||
def moving?
|
||||
return false if @battler.nil?
|
||||
return @battler.moving?
|
||||
end
|
||||
|
||||
end # Sprite_Battler
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Sprite_BattleCharacter
|
||||
#==============================================================================
|
||||
|
||||
class Sprite_BattleCharacter < Sprite_Character
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# initialize
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize(viewport, character = nil)
|
||||
super(viewport, character)
|
||||
character.sprite = self
|
||||
end
|
||||
|
||||
end # Sprite_BattleCharacter
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Spriteset_Battle
|
||||
#==============================================================================
|
||||
|
||||
class Spriteset_Battle
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# public instance_variable
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :actor_sprites
|
||||
attr_accessor :enemy_sprites
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# overwrite method: create_actors
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actors
|
||||
total = $game_party.max_battle_members
|
||||
@current_party = $game_party.battle_members.clone
|
||||
@actor_sprites = Array.new(total) { Sprite_Battler.new(@viewport1) }
|
||||
for actor in $game_party.battle_members
|
||||
@actor_sprites[actor.index].battler = actor
|
||||
create_actor_sprite(actor)
|
||||
end
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: create_actor_sprite
|
||||
#--------------------------------------------------------------------------
|
||||
def create_actor_sprite(actor)
|
||||
character = Game_BattleCharacter.new(actor)
|
||||
character_sprite = Sprite_BattleCharacter.new(@viewport1, character)
|
||||
@actor_sprites[actor.index].character_base = character
|
||||
@actor_sprites[actor.index].character_sprite = character_sprite
|
||||
actor.face_opposing_party
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: update_actors
|
||||
#--------------------------------------------------------------------------
|
||||
alias spriteset_battle_update_actors_vb update_actors
|
||||
def update_actors
|
||||
if @current_party != $game_party.battle_members
|
||||
dispose_actors
|
||||
create_actors
|
||||
end
|
||||
spriteset_battle_update_actors_vb
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: moving?
|
||||
#--------------------------------------------------------------------------
|
||||
def moving?
|
||||
return battler_sprites.any? {|sprite| sprite.moving? }
|
||||
end
|
||||
|
||||
end # Spriteset_Battle
|
||||
|
||||
#==============================================================================
|
||||
# ? <20><> Scene_Battle
|
||||
#==============================================================================
|
||||
|
||||
class Scene_Battle < Scene_Base
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# public instance variables
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :spriteset
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: process_action_end
|
||||
#--------------------------------------------------------------------------
|
||||
alias scene_battle_process_action_end_vb process_action_end
|
||||
def process_action_end
|
||||
start_battler_move_origin
|
||||
scene_battle_process_action_end_vb
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# alias method: execute_action
|
||||
#--------------------------------------------------------------------------
|
||||
alias scene_battle_execute_action_vb execute_action
|
||||
def execute_action
|
||||
start_battler_move_forward
|
||||
scene_battle_execute_action_vb
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: start_battler_move_forward
|
||||
#--------------------------------------------------------------------------
|
||||
def start_battler_move_forward
|
||||
return if @subject.started_turn
|
||||
@subject.started_turn = true
|
||||
@subject.move_forward
|
||||
wait_for_moving
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: start_battler_move_origin
|
||||
#--------------------------------------------------------------------------
|
||||
def start_battler_move_origin
|
||||
@subject.started_turn = nil
|
||||
move_battlers_origin
|
||||
wait_for_moving
|
||||
@subject.face_opposing_party rescue 0
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: move_battlers_origin
|
||||
#--------------------------------------------------------------------------
|
||||
def move_battlers_origin
|
||||
for member in all_battle_members
|
||||
next if member.dead?
|
||||
next unless member.exist?
|
||||
member.move_origin
|
||||
end
|
||||
end
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# new method: wait_for_moving
|
||||
#--------------------------------------------------------------------------
|
||||
def wait_for_moving
|
||||
update_for_wait
|
||||
update_for_wait while @spriteset.moving?
|
||||
end
|
||||
|
||||
end # Scene_Battle
|
||||
|
||||
#==============================================================================
|
||||
#
|
||||
# <20><> End of File
|
||||
#
|
||||
#==============================================================================
|
||||
@@ -1 +0,0 @@
|
||||
DROP ALL TABLES
|
||||
@@ -1 +0,0 @@
|
||||
{"foo": "bar"}
|
||||
25
samples/WebIDL/AnimationEvent.webidl
Normal file
25
samples/WebIDL/AnimationEvent.webidl
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://www.w3.org/TR/css3-animations/#animation-events-
|
||||
* http://dev.w3.org/csswg/css3-animations/#animation-events-
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Constructor(DOMString type, optional AnimationEventInit eventInitDict)]
|
||||
interface AnimationEvent : Event {
|
||||
readonly attribute DOMString animationName;
|
||||
readonly attribute float elapsedTime;
|
||||
readonly attribute DOMString pseudoElement;
|
||||
};
|
||||
|
||||
dictionary AnimationEventInit : EventInit {
|
||||
DOMString animationName = "";
|
||||
float elapsedTime = 0;
|
||||
DOMString pseudoElement = "";
|
||||
};
|
||||
35
samples/WebIDL/Fetch.webidl
Normal file
35
samples/WebIDL/Fetch.webidl
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://fetch.spec.whatwg.org/
|
||||
*/
|
||||
|
||||
typedef object JSON;
|
||||
// FIXME(nsm): Bug 739173: FormData is not available in workers.
|
||||
// typedef (ArrayBuffer or ArrayBufferView or Blob or FormData or USVString or URLSearchParams) BodyInit;
|
||||
typedef (ArrayBuffer or ArrayBufferView or Blob or USVString or URLSearchParams) BodyInit;
|
||||
|
||||
[NoInterfaceObject, Exposed=(Window,Worker)]
|
||||
interface Body {
|
||||
readonly attribute boolean bodyUsed;
|
||||
[Throws]
|
||||
Promise<ArrayBuffer> arrayBuffer();
|
||||
[Throws]
|
||||
Promise<Blob> blob();
|
||||
// FIXME(nsm): Bug 739173 FormData is not supported in workers.
|
||||
// Promise<FormData> formData();
|
||||
[Throws]
|
||||
Promise<JSON> json();
|
||||
[Throws]
|
||||
Promise<USVString> text();
|
||||
};
|
||||
|
||||
[NoInterfaceObject, Exposed=(Window,Worker)]
|
||||
interface GlobalFetch {
|
||||
[Throws, Func="mozilla::dom::Headers::PrefEnabled"]
|
||||
Promise<Response> fetch(RequestInfo input, optional RequestInit init);
|
||||
};
|
||||
|
||||
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
1
test/fixtures/Data/bootstrap.css.map
vendored
Normal file
1
test/fixtures/Data/bootstrap.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
0
samples/Text/md → test/fixtures/Data/md
vendored
0
samples/Text/md → test/fixtures/Data/md
vendored
@@ -18,56 +18,65 @@ class TestBlob < Test::Unit::TestCase
|
||||
File.expand_path("../../samples", __FILE__)
|
||||
end
|
||||
|
||||
def blob(name)
|
||||
def fixtures_path
|
||||
File.expand_path("../fixtures", __FILE__)
|
||||
end
|
||||
|
||||
def sample_blob(name)
|
||||
name = File.join(samples_path, name) unless name =~ /^\//
|
||||
FileBlob.new(name, samples_path)
|
||||
end
|
||||
|
||||
def fixture_blob(name)
|
||||
name = File.join(fixtures_path, name) unless name =~ /^\//
|
||||
FileBlob.new(name, fixtures_path)
|
||||
end
|
||||
|
||||
def script_blob(name)
|
||||
blob = blob(name)
|
||||
blob = sample_blob(name)
|
||||
blob.instance_variable_set(:@name, 'script')
|
||||
blob
|
||||
end
|
||||
|
||||
def test_name
|
||||
assert_equal "foo.rb", blob("foo.rb").name
|
||||
assert_equal "foo.rb", sample_blob("foo.rb").name
|
||||
end
|
||||
|
||||
def test_mime_type
|
||||
assert_equal "application/postscript", blob("Binary/octocat.ai").mime_type
|
||||
assert_equal "application/x-ruby", blob("Ruby/grit.rb").mime_type
|
||||
assert_equal "application/x-sh", blob("Shell/script.sh").mime_type
|
||||
assert_equal "application/xml", blob("XML/bar.xml").mime_type
|
||||
assert_equal "audio/ogg", blob("Binary/foo.ogg").mime_type
|
||||
assert_equal "text/plain", blob("Text/README").mime_type
|
||||
assert_equal "application/postscript", fixture_blob("Binary/octocat.ai").mime_type
|
||||
assert_equal "application/x-ruby", sample_blob("Ruby/grit.rb").mime_type
|
||||
assert_equal "application/x-sh", sample_blob("Shell/script.sh").mime_type
|
||||
assert_equal "application/xml", sample_blob("XML/bar.xml").mime_type
|
||||
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").mime_type
|
||||
assert_equal "text/plain", fixture_blob("Data/README").mime_type
|
||||
end
|
||||
|
||||
def test_content_type
|
||||
assert_equal "application/pdf", blob("Binary/foo.pdf").content_type
|
||||
assert_equal "audio/ogg", blob("Binary/foo.ogg").content_type
|
||||
assert_equal "image/png", blob("Binary/foo.png").content_type
|
||||
assert_equal "text/plain; charset=iso-8859-2", blob("Text/README").content_type
|
||||
assert_equal "application/pdf", fixture_blob("Binary/foo.pdf").content_type
|
||||
assert_equal "audio/ogg", fixture_blob("Binary/foo.ogg").content_type
|
||||
assert_equal "image/png", fixture_blob("Binary/foo.png").content_type
|
||||
assert_equal "text/plain; charset=iso-8859-2", fixture_blob("Data/README").content_type
|
||||
end
|
||||
|
||||
def test_disposition
|
||||
assert_equal "attachment; filename=foo+bar.jar", blob("Binary/foo bar.jar").disposition
|
||||
assert_equal "attachment; filename=foo.bin", blob("Binary/foo.bin").disposition
|
||||
assert_equal "attachment; filename=linguist.gem", blob("Binary/linguist.gem").disposition
|
||||
assert_equal "attachment; filename=octocat.ai", blob("Binary/octocat.ai").disposition
|
||||
assert_equal "inline", blob("Text/README").disposition
|
||||
assert_equal "inline", blob("Text/foo.txt").disposition
|
||||
assert_equal "inline", blob("Ruby/grit.rb").disposition
|
||||
assert_equal "inline", blob("Binary/octocat.png").disposition
|
||||
assert_equal "attachment; filename=foo+bar.jar", fixture_blob("Binary/foo bar.jar").disposition
|
||||
assert_equal "attachment; filename=foo.bin", fixture_blob("Binary/foo.bin").disposition
|
||||
assert_equal "attachment; filename=linguist.gem", fixture_blob("Binary/linguist.gem").disposition
|
||||
assert_equal "attachment; filename=octocat.ai", fixture_blob("Binary/octocat.ai").disposition
|
||||
assert_equal "inline", fixture_blob("Data/README").disposition
|
||||
assert_equal "inline", sample_blob("Text/foo.txt").disposition
|
||||
assert_equal "inline", sample_blob("Ruby/grit.rb").disposition
|
||||
assert_equal "inline", fixture_blob("Binary/octocat.png").disposition
|
||||
end
|
||||
|
||||
def test_data
|
||||
assert_equal "module Foo\nend\n", blob("Ruby/foo.rb").data
|
||||
assert_equal "module Foo\nend\n", sample_blob("Ruby/foo.rb").data
|
||||
end
|
||||
|
||||
def test_lines
|
||||
assert_equal ["module Foo", "end", ""], blob("Ruby/foo.rb").lines
|
||||
assert_equal ["line 1", "line 2", ""], blob("Text/mac.txt").lines
|
||||
assert_equal 475, blob("Emacs Lisp/ess-julia.el").lines.length
|
||||
assert_equal ["module Foo", "end", ""], sample_blob("Ruby/foo.rb").lines
|
||||
assert_equal ["line 1", "line 2", ""], sample_blob("Text/mac.txt").lines
|
||||
assert_equal 475, sample_blob("Emacs Lisp/ess-julia.el").lines.length
|
||||
end
|
||||
|
||||
def test_lines_maintains_original_encoding
|
||||
@@ -75,135 +84,126 @@ class TestBlob < Test::Unit::TestCase
|
||||
# earlier versions of the gem made implicit guarantees that the encoding of
|
||||
# each `line` is in the same encoding as the file was originally read (in
|
||||
# practice, UTF-8 or ASCII-8BIT)
|
||||
assert_equal Encoding.default_external, blob("Text/utf16le.txt").lines.first.encoding
|
||||
assert_equal Encoding.default_external, fixture_blob("Data/utf16le").lines.first.encoding
|
||||
end
|
||||
|
||||
def test_size
|
||||
assert_equal 15, blob("Ruby/foo.rb").size
|
||||
assert_equal 15, sample_blob("Ruby/foo.rb").size
|
||||
end
|
||||
|
||||
def test_loc
|
||||
assert_equal 3, blob("Ruby/foo.rb").loc
|
||||
assert_equal 3, sample_blob("Ruby/foo.rb").loc
|
||||
end
|
||||
|
||||
def test_sloc
|
||||
assert_equal 2, blob("Ruby/foo.rb").sloc
|
||||
assert_equal 3, blob("Text/utf16le-windows.txt").sloc
|
||||
assert_equal 1, blob("Text/iso8859-8-i.txt").sloc
|
||||
assert_equal 2, sample_blob("Ruby/foo.rb").sloc
|
||||
assert_equal 3, fixture_blob("Data/utf16le-windows").sloc
|
||||
assert_equal 1, fixture_blob("Data/iso8859-8-i").sloc
|
||||
end
|
||||
|
||||
def test_encoding
|
||||
assert_equal "ISO-8859-2", blob("Text/README").encoding
|
||||
assert_equal "ISO-8859-2", blob("Text/README").ruby_encoding
|
||||
assert_equal "ISO-8859-1", blob("Text/dump.sql").encoding
|
||||
assert_equal "ISO-8859-1", blob("Text/dump.sql").ruby_encoding
|
||||
assert_equal "UTF-8", blob("Text/foo.txt").encoding
|
||||
assert_equal "UTF-8", blob("Text/foo.txt").ruby_encoding
|
||||
assert_equal "UTF-16LE", blob("Text/utf16le.txt").encoding
|
||||
assert_equal "UTF-16LE", blob("Text/utf16le.txt").ruby_encoding
|
||||
assert_equal "UTF-16LE", blob("Text/utf16le-windows.txt").encoding
|
||||
assert_equal "UTF-16LE", blob("Text/utf16le-windows.txt").ruby_encoding
|
||||
assert_equal "ISO-2022-KR", blob("Text/ISO-2022-KR.txt").encoding
|
||||
assert_equal "binary", blob("Text/ISO-2022-KR.txt").ruby_encoding
|
||||
assert_nil blob("Binary/dog.o").encoding
|
||||
|
||||
assert_equal "windows-1252", blob("Text/Visual_Battlers.rb").encoding
|
||||
assert_equal "Windows-1252", blob("Text/Visual_Battlers.rb").ruby_encoding
|
||||
assert_equal "ISO-8859-2", fixture_blob("Data/README").encoding
|
||||
assert_equal "ISO-8859-2", fixture_blob("Data/README").ruby_encoding
|
||||
assert_equal "UTF-8", sample_blob("Text/foo.txt").encoding
|
||||
assert_equal "UTF-8", sample_blob("Text/foo.txt").ruby_encoding
|
||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").encoding
|
||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le").ruby_encoding
|
||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").encoding
|
||||
assert_equal "UTF-16LE", fixture_blob("Data/utf16le-windows").ruby_encoding
|
||||
assert_equal "ISO-2022-KR", sample_blob("Text/ISO-2022-KR.txt").encoding
|
||||
assert_equal "binary", sample_blob("Text/ISO-2022-KR.txt").ruby_encoding
|
||||
assert_nil fixture_blob("Binary/dog.o").encoding
|
||||
end
|
||||
|
||||
def test_binary
|
||||
# Large blobs aren't loaded
|
||||
large_blob = blob("git.exe")
|
||||
large_blob = sample_blob("git.exe")
|
||||
large_blob.instance_eval do
|
||||
def data; end
|
||||
end
|
||||
assert large_blob.binary?
|
||||
|
||||
assert blob("Binary/git.deb").binary?
|
||||
assert blob("Binary/git.exe").binary?
|
||||
assert blob("Binary/hello.pbc").binary?
|
||||
assert blob("Binary/linguist.gem").binary?
|
||||
assert blob("Binary/octocat.ai").binary?
|
||||
assert blob("Binary/octocat.png").binary?
|
||||
assert blob("Binary/zip").binary?
|
||||
assert !blob("Text/README").binary?
|
||||
assert !blob("Text/file.txt").binary?
|
||||
assert !blob("Ruby/foo.rb").binary?
|
||||
assert !blob("Perl/script.pl").binary?
|
||||
assert fixture_blob("Binary/git.deb").binary?
|
||||
assert fixture_blob("Binary/git.exe").binary?
|
||||
assert fixture_blob("Binary/hello.pbc").binary?
|
||||
assert fixture_blob("Binary/linguist.gem").binary?
|
||||
assert fixture_blob("Binary/octocat.ai").binary?
|
||||
assert fixture_blob("Binary/octocat.png").binary?
|
||||
assert fixture_blob("Binary/zip").binary?
|
||||
assert !fixture_blob("Data/README").binary?
|
||||
assert !sample_blob("Ruby/foo.rb").binary?
|
||||
assert !sample_blob("Perl/script.pl").binary?
|
||||
end
|
||||
|
||||
def test_all_binary
|
||||
Samples.each do |sample|
|
||||
blob = blob(sample[:path])
|
||||
blob = sample_blob(sample[:path])
|
||||
assert ! (blob.likely_binary? || blob.binary?), "#{sample[:path]} is a binary file"
|
||||
end
|
||||
end
|
||||
|
||||
def test_text
|
||||
assert blob("Text/README").text?
|
||||
assert blob("Text/dump.sql").text?
|
||||
assert blob("Text/file.json").text?
|
||||
assert blob("Text/file.txt").text?
|
||||
assert blob("Text/md").text?
|
||||
assert blob("Shell/script.sh").text?
|
||||
assert blob("Text/txt").text?
|
||||
assert fixture_blob("Data/README").text?
|
||||
assert fixture_blob("Data/md").text?
|
||||
assert sample_blob("Shell/script.sh").text?
|
||||
assert fixture_blob("Data/txt").text?
|
||||
end
|
||||
|
||||
def test_image
|
||||
assert blob("Binary/octocat.gif").image?
|
||||
assert blob("Binary/octocat.jpeg").image?
|
||||
assert blob("Binary/octocat.jpg").image?
|
||||
assert blob("Binary/octocat.png").image?
|
||||
assert !blob("Binary/octocat.ai").image?
|
||||
assert !blob("Binary/octocat.psd").image?
|
||||
assert fixture_blob("Binary/octocat.gif").image?
|
||||
assert fixture_blob("Binary/octocat.jpeg").image?
|
||||
assert fixture_blob("Binary/octocat.jpg").image?
|
||||
assert fixture_blob("Binary/octocat.png").image?
|
||||
assert !fixture_blob("Binary/octocat.ai").image?
|
||||
assert !fixture_blob("Binary/octocat.psd").image?
|
||||
end
|
||||
|
||||
def test_solid
|
||||
assert blob("Binary/cube.stl").solid?
|
||||
assert blob("Text/cube.stl").solid?
|
||||
assert fixture_blob("Binary/cube.stl").solid?
|
||||
assert fixture_blob("Data/cube.stl").solid?
|
||||
end
|
||||
|
||||
def test_csv
|
||||
assert blob("Text/cars.csv").csv?
|
||||
assert fixture_blob("Data/cars.csv").csv?
|
||||
end
|
||||
|
||||
def test_pdf
|
||||
assert blob("Binary/foo.pdf").pdf?
|
||||
assert fixture_blob("Binary/foo.pdf").pdf?
|
||||
end
|
||||
|
||||
def test_viewable
|
||||
assert blob("Text/README").viewable?
|
||||
assert blob("Ruby/foo.rb").viewable?
|
||||
assert blob("Perl/script.pl").viewable?
|
||||
assert !blob("Binary/linguist.gem").viewable?
|
||||
assert !blob("Binary/octocat.ai").viewable?
|
||||
assert !blob("Binary/octocat.png").viewable?
|
||||
assert fixture_blob("Data/README").viewable?
|
||||
assert sample_blob("Ruby/foo.rb").viewable?
|
||||
assert sample_blob("Perl/script.pl").viewable?
|
||||
assert !fixture_blob("Binary/linguist.gem").viewable?
|
||||
assert !fixture_blob("Binary/octocat.ai").viewable?
|
||||
assert !fixture_blob("Binary/octocat.png").viewable?
|
||||
end
|
||||
|
||||
def test_generated
|
||||
assert !blob("Text/README").generated?
|
||||
assert !fixture_blob("Data/README").generated?
|
||||
|
||||
# Xcode project files
|
||||
assert !blob("XML/MainMenu.xib").generated?
|
||||
assert blob("Binary/MainMenu.nib").generated?
|
||||
assert !blob("XML/project.pbxproj").generated?
|
||||
assert !sample_blob("XML/MainMenu.xib").generated?
|
||||
assert fixture_blob("Binary/MainMenu.nib").generated?
|
||||
assert !sample_blob("XML/project.pbxproj").generated?
|
||||
|
||||
# Gemfile.lock is NOT generated
|
||||
assert !blob("Gemfile.lock").generated?
|
||||
assert !sample_blob("Gemfile.lock").generated?
|
||||
|
||||
# Generated .NET Docfiles
|
||||
assert blob("XML/net_docfile.xml").generated?
|
||||
assert sample_blob("XML/net_docfile.xml").generated?
|
||||
|
||||
# Long line
|
||||
assert !blob("JavaScript/uglify.js").generated?
|
||||
assert !sample_blob("JavaScript/uglify.js").generated?
|
||||
|
||||
# Inlined JS, but mostly code
|
||||
assert !blob("JavaScript/json2_backbone.js").generated?
|
||||
assert !sample_blob("JavaScript/json2_backbone.js").generated?
|
||||
|
||||
# Minified JS
|
||||
assert !blob("JavaScript/jquery-1.6.1.js").generated?
|
||||
assert blob("JavaScript/jquery-1.6.1.min.js").generated?
|
||||
assert blob("JavaScript/jquery-1.4.2.min.js").generated?
|
||||
assert !sample_blob("JavaScript/jquery-1.6.1.js").generated?
|
||||
assert sample_blob("JavaScript/jquery-1.6.1.min.js").generated?
|
||||
assert sample_blob("JavaScript/jquery-1.4.2.min.js").generated?
|
||||
|
||||
# CoffeeScript-generated JS
|
||||
# TODO
|
||||
@@ -212,256 +212,256 @@ class TestBlob < Test::Unit::TestCase
|
||||
# TODO
|
||||
|
||||
# Composer generated composer.lock file
|
||||
assert blob("JSON/composer.lock").generated?
|
||||
assert sample_blob("JSON/composer.lock").generated?
|
||||
|
||||
# PEG.js-generated parsers
|
||||
assert blob("JavaScript/parser.js").generated?
|
||||
assert sample_blob("JavaScript/parser.js").generated?
|
||||
|
||||
# Generated PostScript
|
||||
assert !blob("PostScript/sierpinski.ps").generated?
|
||||
assert !sample_blob("PostScript/sierpinski.ps").generated?
|
||||
|
||||
# These examples are too basic to tell
|
||||
assert !blob("JavaScript/hello.js").generated?
|
||||
assert !sample_blob("JavaScript/hello.js").generated?
|
||||
|
||||
assert blob("JavaScript/intro-old.js").generated?
|
||||
assert blob("JavaScript/classes-old.js").generated?
|
||||
assert sample_blob("JavaScript/intro-old.js").generated?
|
||||
assert sample_blob("JavaScript/classes-old.js").generated?
|
||||
|
||||
assert blob("JavaScript/intro.js").generated?
|
||||
assert blob("JavaScript/classes.js").generated?
|
||||
assert sample_blob("JavaScript/intro.js").generated?
|
||||
assert sample_blob("JavaScript/classes.js").generated?
|
||||
|
||||
# Protocol Buffer generated code
|
||||
assert blob("C++/protocol-buffer.pb.h").generated?
|
||||
assert blob("C++/protocol-buffer.pb.cc").generated?
|
||||
assert blob("Java/ProtocolBuffer.java").generated?
|
||||
assert blob("Python/protocol_buffer_pb2.py").generated?
|
||||
assert sample_blob("C++/protocol-buffer.pb.h").generated?
|
||||
assert sample_blob("C++/protocol-buffer.pb.cc").generated?
|
||||
assert sample_blob("Java/ProtocolBuffer.java").generated?
|
||||
assert sample_blob("Python/protocol_buffer_pb2.py").generated?
|
||||
|
||||
# Generated JNI
|
||||
assert blob("C/jni_layer.h").generated?
|
||||
assert sample_blob("C/jni_layer.h").generated?
|
||||
|
||||
# Minified CSS
|
||||
assert !blob("CSS/bootstrap.css").generated?
|
||||
assert blob("CSS/bootstrap.min.css").generated?
|
||||
assert !sample_blob("CSS/bootstrap.css").generated?
|
||||
assert sample_blob("CSS/bootstrap.min.css").generated?
|
||||
|
||||
# Generated VCR
|
||||
assert blob("YAML/vcr_cassette.yml").generated?
|
||||
assert sample_blob("YAML/vcr_cassette.yml").generated?
|
||||
|
||||
# Generated by Zephir
|
||||
assert blob("Zephir/filenames/exception.zep.c").generated?
|
||||
assert blob("Zephir/filenames/exception.zep.h").generated?
|
||||
assert blob("Zephir/filenames/exception.zep.php").generated?
|
||||
assert !blob("Zephir/Router.zep").generated?
|
||||
assert sample_blob("Zephir/filenames/exception.zep.c").generated?
|
||||
assert sample_blob("Zephir/filenames/exception.zep.h").generated?
|
||||
assert sample_blob("Zephir/filenames/exception.zep.php").generated?
|
||||
assert !sample_blob("Zephir/Router.zep").generated?
|
||||
|
||||
|
||||
assert Linguist::Generated.generated?("node_modules/grunt/lib/grunt.js", nil)
|
||||
|
||||
# Godep saved dependencies
|
||||
assert blob("Godeps/Godeps.json").generated?
|
||||
assert blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
||||
assert sample_blob("Godeps/Godeps.json").generated?
|
||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").generated?
|
||||
end
|
||||
|
||||
def test_vendored
|
||||
assert !blob("Text/README").vendored?
|
||||
assert !blob("ext/extconf.rb").vendored?
|
||||
assert !fixture_blob("Data/README").vendored?
|
||||
assert !sample_blob("ext/extconf.rb").vendored?
|
||||
|
||||
# Dependencies
|
||||
assert blob("dependencies/windows/headers/GL/glext.h").vendored?
|
||||
assert sample_blob("dependencies/windows/headers/GL/glext.h").vendored?
|
||||
|
||||
# Node dependencies
|
||||
assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored?
|
||||
assert sample_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?
|
||||
assert sample_blob("bower_components/custom/custom.js").vendored?
|
||||
assert sample_blob("app/bower_components/custom/custom.js").vendored?
|
||||
assert sample_blob("vendor/assets/bower_components/custom/custom.js").vendored?
|
||||
|
||||
# Go dependencies
|
||||
assert !blob("Godeps/Godeps.json").vendored?
|
||||
assert blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored?
|
||||
assert !sample_blob("Godeps/Godeps.json").vendored?
|
||||
assert sample_blob("Godeps/_workspace/src/github.com/kr/s3/sign.go").vendored?
|
||||
|
||||
# Rails vendor/
|
||||
assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
||||
assert sample_blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
||||
|
||||
# 'thirdparty' directory
|
||||
assert blob("thirdparty/lib/main.c").vendored?
|
||||
assert sample_blob("thirdparty/lib/main.c").vendored?
|
||||
|
||||
# 'extern(al)' directory
|
||||
assert blob("extern/util/__init__.py").vendored?
|
||||
assert blob("external/jquery.min.js").vendored?
|
||||
assert sample_blob("extern/util/__init__.py").vendored?
|
||||
assert sample_blob("external/jquery.min.js").vendored?
|
||||
|
||||
# C deps
|
||||
assert blob("deps/http_parser/http_parser.c").vendored?
|
||||
assert blob("deps/v8/src/v8.h").vendored?
|
||||
assert sample_blob("deps/http_parser/http_parser.c").vendored?
|
||||
assert sample_blob("deps/v8/src/v8.h").vendored?
|
||||
|
||||
# Chart.js
|
||||
assert blob("some/vendored/path/Chart.js").vendored?
|
||||
assert !blob("some/vendored/path/chart.js").vendored?
|
||||
assert sample_blob("some/vendored/path/Chart.js").vendored?
|
||||
assert !sample_blob("some/vendored/path/chart.js").vendored?
|
||||
|
||||
# Codemirror deps
|
||||
assert blob("codemirror/mode/blah.js").vendored?
|
||||
assert sample_blob("codemirror/mode/blah.js").vendored?
|
||||
|
||||
# Debian packaging
|
||||
assert blob("debian/cron.d").vendored?
|
||||
assert sample_blob("debian/cron.d").vendored?
|
||||
|
||||
# Minified JavaScript and CSS
|
||||
assert blob("foo.min.js").vendored?
|
||||
assert blob("foo.min.css").vendored?
|
||||
assert blob("foo-min.js").vendored?
|
||||
assert blob("foo-min.css").vendored?
|
||||
assert !blob("foomin.css").vendored?
|
||||
assert !blob("foo.min.txt").vendored?
|
||||
assert sample_blob("foo.min.js").vendored?
|
||||
assert sample_blob("foo.min.css").vendored?
|
||||
assert sample_blob("foo-min.js").vendored?
|
||||
assert sample_blob("foo-min.css").vendored?
|
||||
assert !sample_blob("foomin.css").vendored?
|
||||
assert !sample_blob("foo.min.txt").vendored?
|
||||
|
||||
# Prototype
|
||||
assert !blob("public/javascripts/application.js").vendored?
|
||||
assert blob("public/javascripts/prototype.js").vendored?
|
||||
assert blob("public/javascripts/effects.js").vendored?
|
||||
assert blob("public/javascripts/controls.js").vendored?
|
||||
assert blob("public/javascripts/dragdrop.js").vendored?
|
||||
assert !sample_blob("public/javascripts/application.js").vendored?
|
||||
assert sample_blob("public/javascripts/prototype.js").vendored?
|
||||
assert sample_blob("public/javascripts/effects.js").vendored?
|
||||
assert sample_blob("public/javascripts/controls.js").vendored?
|
||||
assert sample_blob("public/javascripts/dragdrop.js").vendored?
|
||||
|
||||
# jQuery
|
||||
assert blob("jquery.js").vendored?
|
||||
assert blob("public/javascripts/jquery.js").vendored?
|
||||
assert blob("public/javascripts/jquery.min.js").vendored?
|
||||
assert blob("public/javascripts/jquery-1.7.js").vendored?
|
||||
assert blob("public/javascripts/jquery-1.7.min.js").vendored?
|
||||
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?
|
||||
assert sample_blob("jquery.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery.min.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.7.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.7.min.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.5.2.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.6.1.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.6.1.min.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.10.1.js").vendored?
|
||||
assert sample_blob("public/javascripts/jquery-1.10.1.min.js").vendored?
|
||||
assert !sample_blob("public/javascripts/jquery.github.menu.js").vendored?
|
||||
|
||||
# jQuery UI
|
||||
assert blob("themes/ui-lightness/jquery-ui.css").vendored?
|
||||
assert blob("themes/ui-lightness/jquery-ui-1.8.22.custom.css").vendored?
|
||||
assert blob("themes/ui-lightness/jquery.ui.accordion.css").vendored?
|
||||
assert blob("ui/i18n/jquery.ui.datepicker-ar.js").vendored?
|
||||
assert blob("ui/i18n/jquery-ui-i18n.js").vendored?
|
||||
assert blob("ui/jquery.effects.blind.js").vendored?
|
||||
assert blob("ui/jquery-ui-1.8.22.custom.js").vendored?
|
||||
assert blob("ui/jquery-ui-1.8.22.custom.min.js").vendored?
|
||||
assert blob("ui/jquery-ui-1.8.22.js").vendored?
|
||||
assert blob("ui/jquery-ui-1.8.js").vendored?
|
||||
assert blob("ui/jquery-ui.min.js").vendored?
|
||||
assert blob("ui/jquery.ui.accordion.js").vendored?
|
||||
assert blob("ui/minified/jquery.effects.blind.min.js").vendored?
|
||||
assert blob("ui/minified/jquery.ui.accordion.min.js").vendored?
|
||||
assert sample_blob("themes/ui-lightness/jquery-ui.css").vendored?
|
||||
assert sample_blob("themes/ui-lightness/jquery-ui-1.8.22.custom.css").vendored?
|
||||
assert sample_blob("themes/ui-lightness/jquery.ui.accordion.css").vendored?
|
||||
assert sample_blob("ui/i18n/jquery.ui.datepicker-ar.js").vendored?
|
||||
assert sample_blob("ui/i18n/jquery-ui-i18n.js").vendored?
|
||||
assert sample_blob("ui/jquery.effects.blind.js").vendored?
|
||||
assert sample_blob("ui/jquery-ui-1.8.22.custom.js").vendored?
|
||||
assert sample_blob("ui/jquery-ui-1.8.22.custom.min.js").vendored?
|
||||
assert sample_blob("ui/jquery-ui-1.8.22.js").vendored?
|
||||
assert sample_blob("ui/jquery-ui-1.8.js").vendored?
|
||||
assert sample_blob("ui/jquery-ui.min.js").vendored?
|
||||
assert sample_blob("ui/jquery.ui.accordion.js").vendored?
|
||||
assert sample_blob("ui/minified/jquery.effects.blind.min.js").vendored?
|
||||
assert sample_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?
|
||||
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat.js").vendored?
|
||||
assert sample_blob("public/javascripts/mootools-core-1.3.2-full-compat-yc.js").vendored?
|
||||
|
||||
# Dojo
|
||||
assert blob("public/javascripts/dojo.js").vendored?
|
||||
assert sample_blob("public/javascripts/dojo.js").vendored?
|
||||
|
||||
# MochiKit
|
||||
assert blob("public/javascripts/MochiKit.js").vendored?
|
||||
assert sample_blob("public/javascripts/MochiKit.js").vendored?
|
||||
|
||||
# YUI
|
||||
assert blob("public/javascripts/yahoo-dom-event.js").vendored?
|
||||
assert blob("public/javascripts/yahoo-min.js").vendored?
|
||||
assert blob("public/javascripts/yuiloader-dom-event.js").vendored?
|
||||
assert sample_blob("public/javascripts/yahoo-dom-event.js").vendored?
|
||||
assert sample_blob("public/javascripts/yahoo-min.js").vendored?
|
||||
assert sample_blob("public/javascripts/yuiloader-dom-event.js").vendored?
|
||||
|
||||
# WYS editors
|
||||
assert blob("public/javascripts/ckeditor.js").vendored?
|
||||
assert blob("public/javascripts/tiny_mce.js").vendored?
|
||||
assert blob("public/javascripts/tiny_mce_popup.js").vendored?
|
||||
assert blob("public/javascripts/tiny_mce_src.js").vendored?
|
||||
assert sample_blob("public/javascripts/ckeditor.js").vendored?
|
||||
assert sample_blob("public/javascripts/tiny_mce.js").vendored?
|
||||
assert sample_blob("public/javascripts/tiny_mce_popup.js").vendored?
|
||||
assert sample_blob("public/javascripts/tiny_mce_src.js").vendored?
|
||||
|
||||
# AngularJS
|
||||
assert blob("public/javascripts/angular.js").vendored?
|
||||
assert blob("public/javascripts/angular.min.js").vendored?
|
||||
assert sample_blob("public/javascripts/angular.js").vendored?
|
||||
assert sample_blob("public/javascripts/angular.min.js").vendored?
|
||||
|
||||
# D3.js
|
||||
assert blob("public/javascripts/d3.v3.js").vendored?
|
||||
assert blob("public/javascripts/d3.v3.min.js").vendored?
|
||||
assert sample_blob("public/javascripts/d3.v3.js").vendored?
|
||||
assert sample_blob("public/javascripts/d3.v3.min.js").vendored?
|
||||
|
||||
# Modernizr
|
||||
assert blob("public/javascripts/modernizr-2.7.1.js").vendored?
|
||||
assert blob("public/javascripts/modernizr.custom.01009.js").vendored?
|
||||
assert sample_blob("public/javascripts/modernizr-2.7.1.js").vendored?
|
||||
assert sample_blob("public/javascripts/modernizr.custom.01009.js").vendored?
|
||||
|
||||
# Fabric
|
||||
assert blob("fabfile.py").vendored?
|
||||
assert sample_blob("fabfile.py").vendored?
|
||||
|
||||
# WAF
|
||||
assert blob("waf").vendored?
|
||||
assert sample_blob("waf").vendored?
|
||||
|
||||
# Visual Studio IntelliSense
|
||||
assert blob("Scripts/jquery-1.7-vsdoc.js").vendored?
|
||||
assert sample_blob("Scripts/jquery-1.7-vsdoc.js").vendored?
|
||||
|
||||
# Microsoft Ajax
|
||||
assert blob("Scripts/MicrosoftAjax.debug.js").vendored?
|
||||
assert blob("Scripts/MicrosoftAjax.js").vendored?
|
||||
assert blob("Scripts/MicrosoftMvcAjax.debug.js").vendored?
|
||||
assert blob("Scripts/MicrosoftMvcAjax.js").vendored?
|
||||
assert blob("Scripts/MicrosoftMvcValidation.debug.js").vendored?
|
||||
assert blob("Scripts/MicrosoftMvcValidation.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftAjax.debug.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftAjax.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftMvcAjax.debug.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftMvcAjax.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftMvcValidation.debug.js").vendored?
|
||||
assert sample_blob("Scripts/MicrosoftMvcValidation.js").vendored?
|
||||
|
||||
# jQuery validation plugin (MS bundles this with asp.net mvc)
|
||||
assert blob("Scripts/jquery.validate.js").vendored?
|
||||
assert blob("Scripts/jquery.validate.min.js").vendored?
|
||||
assert blob("Scripts/jquery.validate.unobtrusive.js").vendored?
|
||||
assert blob("Scripts/jquery.validate.unobtrusive.min.js").vendored?
|
||||
assert blob("Scripts/jquery.unobtrusive-ajax.js").vendored?
|
||||
assert blob("Scripts/jquery.unobtrusive-ajax.min.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.validate.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.validate.min.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.validate.unobtrusive.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.validate.unobtrusive.min.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.unobtrusive-ajax.js").vendored?
|
||||
assert sample_blob("Scripts/jquery.unobtrusive-ajax.min.js").vendored?
|
||||
|
||||
# NuGet Packages
|
||||
assert blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
|
||||
assert sample_blob("packages/Modernizr.2.0.6/Content/Scripts/modernizr-2.0.6-development-only.js").vendored?
|
||||
|
||||
# Font Awesome
|
||||
assert blob("some/asset/path/font-awesome.min.css").vendored?
|
||||
assert blob("some/asset/path/font-awesome.css").vendored?
|
||||
assert sample_blob("some/asset/path/font-awesome.min.css").vendored?
|
||||
assert sample_blob("some/asset/path/font-awesome.css").vendored?
|
||||
|
||||
# Normalize
|
||||
assert blob("some/asset/path/normalize.css").vendored?
|
||||
assert sample_blob("some/asset/path/normalize.css").vendored?
|
||||
|
||||
# Cocoapods
|
||||
assert blob('Pods/blah').vendored?
|
||||
assert sample_blob('Pods/blah').vendored?
|
||||
|
||||
# Html5shiv
|
||||
assert blob("Scripts/html5shiv.js").vendored?
|
||||
assert blob("Scripts/html5shiv.min.js").vendored?
|
||||
assert sample_blob("Scripts/html5shiv.js").vendored?
|
||||
assert sample_blob("Scripts/html5shiv.min.js").vendored?
|
||||
|
||||
# Test fixtures
|
||||
assert blob("test/fixtures/random.rkt").vendored?
|
||||
assert blob("Test/fixtures/random.rkt").vendored?
|
||||
assert sample_blob("test/fixtures/random.rkt").vendored?
|
||||
assert sample_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?
|
||||
assert sample_blob("cordova.js").vendored?
|
||||
assert sample_blob("cordova.min.js").vendored?
|
||||
assert sample_blob("cordova-2.1.0.js").vendored?
|
||||
assert sample_blob("cordova-2.1.0.min.js").vendored?
|
||||
|
||||
# Foundation js
|
||||
assert blob("foundation.js").vendored?
|
||||
assert blob("foundation.min.js").vendored?
|
||||
assert blob("foundation.abide.js").vendored?
|
||||
assert sample_blob("foundation.js").vendored?
|
||||
assert sample_blob("foundation.min.js").vendored?
|
||||
assert sample_blob("foundation.abide.js").vendored?
|
||||
|
||||
# Vagrant
|
||||
assert blob("Vagrantfile").vendored?
|
||||
assert sample_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?
|
||||
assert sample_blob("gradlew").vendored?
|
||||
assert sample_blob("gradlew.bat").vendored?
|
||||
assert sample_blob("gradle/wrapper/gradle-wrapper.properties").vendored?
|
||||
assert sample_blob("subproject/gradlew").vendored?
|
||||
assert sample_blob("subproject/gradlew.bat").vendored?
|
||||
assert sample_blob("subproject/gradle/wrapper/gradle-wrapper.properties").vendored?
|
||||
|
||||
# Octicons
|
||||
assert blob("octicons.css").vendored?
|
||||
assert blob("public/octicons.min.css").vendored?
|
||||
assert blob("public/octicons/sprockets-octicons.scss").vendored?
|
||||
assert sample_blob("octicons.css").vendored?
|
||||
assert sample_blob("public/octicons.min.css").vendored?
|
||||
assert sample_blob("public/octicons/sprockets-octicons.scss").vendored?
|
||||
|
||||
# Typesafe Activator
|
||||
assert blob("activator").vendored?
|
||||
assert blob("activator.bat").vendored?
|
||||
assert blob("subproject/activator").vendored?
|
||||
assert blob("subproject/activator.bat").vendored?
|
||||
assert sample_blob("activator").vendored?
|
||||
assert sample_blob("activator.bat").vendored?
|
||||
assert sample_blob("subproject/activator").vendored?
|
||||
assert sample_blob("subproject/activator.bat").vendored?
|
||||
end
|
||||
|
||||
def test_language
|
||||
Samples.each do |sample|
|
||||
blob = blob(sample[:path])
|
||||
blob = sample_blob(sample[:path])
|
||||
assert blob.language, "No language for #{sample[:path]}"
|
||||
assert_equal sample[:language], blob.language.name, blob.name
|
||||
end
|
||||
@@ -469,7 +469,8 @@ class TestBlob < Test::Unit::TestCase
|
||||
# Test language detection for files which shouldn't be used as samples
|
||||
root = File.expand_path('../fixtures', __FILE__)
|
||||
Dir.entries(root).each do |language|
|
||||
next if language == '.' || language == '..' || File.basename(language) == 'ace_modes.json'
|
||||
next if language == '.' || language == '..' || language == 'Binary' ||
|
||||
File.basename(language) == 'ace_modes.json'
|
||||
|
||||
# Each directory contains test files of a language
|
||||
dirname = File.join(root, language)
|
||||
@@ -479,15 +480,19 @@ class TestBlob < Test::Unit::TestCase
|
||||
filepath = File.join(dirname, filename)
|
||||
next unless File.file?(filepath)
|
||||
|
||||
blob = blob(filepath)
|
||||
blob = fixture_blob(filepath)
|
||||
if language == 'Data'
|
||||
assert blob.language.nil?, "A language was found for #{filepath}"
|
||||
else
|
||||
assert blob.language, "No language for #{filepath}"
|
||||
assert_equal language, blob.language.name, blob.name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_minified_files_not_safe_to_highlight
|
||||
assert !blob("JavaScript/jquery-1.6.1.min.js").safe_to_colorize?
|
||||
assert !sample_blob("JavaScript/jquery-1.6.1.min.js").safe_to_colorize?
|
||||
end
|
||||
|
||||
def test_empty
|
||||
|
||||
@@ -122,7 +122,14 @@ class TestHeuristcs < Test::Unit::TestCase
|
||||
assert_heuristics({
|
||||
"Frege" => all_fixtures("Frege"),
|
||||
"Forth" => all_fixtures("Forth"),
|
||||
"text" => all_fixtures("text")
|
||||
"Text" => all_fixtures("Text")
|
||||
})
|
||||
end
|
||||
|
||||
def test_bb_by_heuristics
|
||||
assert_heuristics({
|
||||
"BitBake" => all_fixtures("BitBake"),
|
||||
"BlitzBasic" => all_fixtures("BlitzBasic")
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
@@ -308,11 +308,12 @@ class TestLanguage < Test::Unit::TestCase
|
||||
assert_equal 'css', Language['CSS'].ace_mode
|
||||
assert_equal 'lsl', Language['LSL'].ace_mode
|
||||
assert_equal 'javascript', Language['JavaScript'].ace_mode
|
||||
assert_equal 'none', Language['FORTRAN'].ace_mode
|
||||
assert_equal 'text', Language['FORTRAN'].ace_mode
|
||||
end
|
||||
|
||||
def test_ace_modes
|
||||
assert Language.ace_modes.include?(Language['Ruby'])
|
||||
assert Language.ace_modes.include?(Language['FORTRAN'])
|
||||
end
|
||||
|
||||
def test_wrap
|
||||
@@ -366,12 +367,21 @@ class TestLanguage < Test::Unit::TestCase
|
||||
File.basename(ace_github_mode["name"], ".js") if ace_github_mode["name"] !~ /_highlight_rules|_test|_worker/
|
||||
end.compact.uniq.sort.map(&:downcase)
|
||||
|
||||
missing = Language.all.reject { |language| language.ace_mode == "none" || existing_ace_modes.include?(language.ace_mode) }
|
||||
missing = Language.all.reject { |language| language.ace_mode == "text" || existing_ace_modes.include?(language.ace_mode) }
|
||||
message = "The following languages do not have an Ace mode listed in languages.yml. Please add an Ace mode for all new languages.\n"
|
||||
message << "If no Ace mode exists for a language, mark the language with `ace_mode: none` in lib/linguist/languages.yml.\n"
|
||||
message << "If no Ace mode exists for a language, mark the language with `ace_mode: text` in lib/linguist/languages.yml.\n"
|
||||
|
||||
width = missing.map { |language| language.name.length }.max
|
||||
message << missing.map { |language| sprintf("%-#{width}s %s", language.name, language.ace_mode) }.sort.join("\n")
|
||||
assert missing.empty?, message
|
||||
end
|
||||
|
||||
def test_all_popular_languages_exist
|
||||
popular = YAML.load(File.read(File.expand_path("../../lib/linguist/popular.yml", __FILE__)))
|
||||
|
||||
missing = popular - Language.all.map(&:name)
|
||||
message = "The following languages are listed in lib/linguist/popular.yml but not in lib/linguist/languages.yml.\n"
|
||||
message << missing.sort.join("\n")
|
||||
assert missing.empty?, message
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,8 @@ class TestShebang < Test::Unit::TestCase
|
||||
assert_interpreter nil, " #!/usr/sbin/ruby"
|
||||
assert_interpreter nil, "\n#!/usr/sbin/ruby"
|
||||
assert_interpreter nil, "#!"
|
||||
assert_interpreter nil, "#! "
|
||||
assert_interpreter nil, "#!/usr/bin/env"
|
||||
|
||||
assert_interpreter "ruby", "#!/usr/sbin/ruby\n# bar"
|
||||
assert_interpreter "ruby", "#!/usr/bin/ruby\n# foo"
|
||||
@@ -34,6 +36,8 @@ class TestShebang < Test::Unit::TestCase
|
||||
assert_interpreter "python3", "#!/usr/bin/python3\n\n\n\n"
|
||||
assert_interpreter "sbcl", "#!/usr/bin/sbcl --script\n\n"
|
||||
assert_interpreter "perl", "#! perl"
|
||||
|
||||
assert_interpreter "ruby", "#!/bin/sh\n\n\nexec ruby $0 $@"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user