mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 21:31:01 +00:00
Merge branch 'master' into data-fixture-folder
This commit is contained in:
@@ -420,3 +420,5 @@ https://github.com/wmertens/sublime-nix:
|
|||||||
- source.nix
|
- source.nix
|
||||||
https://raw.githubusercontent.com/eregon/oz-tmbundle/master/Syntaxes/Oz.tmLanguage:
|
https://raw.githubusercontent.com/eregon/oz-tmbundle/master/Syntaxes/Oz.tmLanguage:
|
||||||
- source.oz
|
- source.oz
|
||||||
|
https://raw.githubusercontent.com/tenbits/sublime-mask/release/Syntaxes/mask.tmLanguage:
|
||||||
|
- source.mask
|
||||||
@@ -129,7 +129,7 @@ module Linguist
|
|||||||
disambiguate "FORTRAN", "Forth" do |data|
|
disambiguate "FORTRAN", "Forth" do |data|
|
||||||
if /^: /.match(data)
|
if /^: /.match(data)
|
||||||
Language["Forth"]
|
Language["Forth"]
|
||||||
elsif /^([c*][^a-z]| subroutine\s)/i.match(data)
|
elsif /^([c*][^a-z]| (subroutine|program)\s|!)/i.match(data)
|
||||||
Language["FORTRAN"]
|
Language["FORTRAN"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -156,5 +156,22 @@ module Linguist
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
disambiguate "TypeScript", "XML" do |data|
|
||||||
|
if data.include?("<TS ")
|
||||||
|
Language["XML"]
|
||||||
|
else
|
||||||
|
Language["TypeScript"]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -269,8 +269,12 @@ module Linguist
|
|||||||
|
|
||||||
# Public: A List of languages compatible with Ace.
|
# 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.
|
# Returns an Array of Languages.
|
||||||
def self.ace_modes
|
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 }
|
@ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
# Erlang bundles
|
# Erlang bundles
|
||||||
- ^rebar$
|
- ^rebar$
|
||||||
|
- erlang.mk
|
||||||
|
|
||||||
# Go dependencies
|
# Go dependencies
|
||||||
- Godeps/_workspace/
|
- Godeps/_workspace/
|
||||||
|
|||||||
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
|
||||||
12
samples/CMake/filenames/CMakeLists.txt
Normal file
12
samples/CMake/filenames/CMakeLists.txt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
|
project(Foo)
|
||||||
|
|
||||||
|
set(CMAKE_SKIP_RPATH TRUE)
|
||||||
|
set(CMAKE_INSTALL_PREFIX "/usr/local")
|
||||||
|
|
||||||
|
add_subdirectory(bar)
|
||||||
|
|
||||||
|
add_executable(foo foo.c)
|
||||||
|
target_link_libraries(foo pthread)
|
||||||
|
install(TARGETS foo DESTINATION bin)
|
||||||
244
samples/Forth/asm.fr
Normal file
244
samples/Forth/asm.fr
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
\ Copyright 2013-2014 Lars Brinkhoff
|
||||||
|
|
||||||
|
\ Assembler for x86.
|
||||||
|
|
||||||
|
\ Adds to FORTH vocabulary: ASSEMBLER CODE ;CODE.
|
||||||
|
\ Creates ASSEMBLER vocabulary with: END-CODE and x86 opcodes.
|
||||||
|
|
||||||
|
\ Conventional prefix syntax: "<source> <destination> <opcode>,".
|
||||||
|
\ Addressing modes:
|
||||||
|
\ - immediate: "n #"
|
||||||
|
\ - direct: n
|
||||||
|
\ - register: <reg>
|
||||||
|
\ - indirect: "<reg> )"
|
||||||
|
\ - indirect with displacement: "n <reg> )#"
|
||||||
|
\ - indexed: not supported yet
|
||||||
|
|
||||||
|
require lib/common.fth
|
||||||
|
require search.fth
|
||||||
|
|
||||||
|
vocabulary assembler
|
||||||
|
also assembler definitions
|
||||||
|
|
||||||
|
\ Access to the target image.
|
||||||
|
' header, defer header, is header,
|
||||||
|
' cell defer cell is cell
|
||||||
|
' dp defer dp is dp
|
||||||
|
0 value delta
|
||||||
|
|
||||||
|
: aligned cell + 1 - cell negate nand invert ;
|
||||||
|
: align dp @ aligned dp ! ;
|
||||||
|
: allot dp +! ;
|
||||||
|
: here dp @ ;
|
||||||
|
: cells cell * ;
|
||||||
|
: c! delta + c! ;
|
||||||
|
: c, here c! 1 allot ;
|
||||||
|
: h, dup c, 8 rshift c, ;
|
||||||
|
: , dup h, 16 rshift h, ;
|
||||||
|
|
||||||
|
base @ hex
|
||||||
|
|
||||||
|
\ This constant signals that an operand is not a direct address.
|
||||||
|
deadbeef constant -addr
|
||||||
|
|
||||||
|
\ Assembler state.
|
||||||
|
variable opcode
|
||||||
|
variable d
|
||||||
|
variable s
|
||||||
|
variable dir?
|
||||||
|
variable mrrm defer ?mrrm,
|
||||||
|
variable sib defer ?sib,
|
||||||
|
variable disp defer ?disp,
|
||||||
|
variable imm defer ?imm,
|
||||||
|
defer imm,
|
||||||
|
defer immediate-opcode
|
||||||
|
defer reg
|
||||||
|
defer ?opsize
|
||||||
|
|
||||||
|
\ Set opcode. And destination: register or memory.
|
||||||
|
: opcode! 3@ is immediate-opcode >r opcode ! ;
|
||||||
|
: !reg dir? @ if 2 d ! then dir? off ;
|
||||||
|
: !mem dir? off ;
|
||||||
|
|
||||||
|
\ Set bits in mod/reg/rm byte.
|
||||||
|
: -mrrm ['] nop is ?mrrm, ;
|
||||||
|
: mod! mrrm c0 !bits ;
|
||||||
|
: reg@ mrrm 38 @bits ;
|
||||||
|
: reg! mrrm 38 !bits ;
|
||||||
|
: rm@ mrrm 7 @bits ;
|
||||||
|
: rm! rm@ 3 lshift reg! mrrm 7 !bits ;
|
||||||
|
: reg>opcode rm@ opcode 07 !bits ;
|
||||||
|
: opcode>reg opcode @ dup 3 rshift rm! 8 rshift opcode ! ;
|
||||||
|
|
||||||
|
\ Write parts of instruction to memory.
|
||||||
|
: ds d @ s @ + ;
|
||||||
|
: ?twobyte dup FF > if dup 8 rshift c, then ;
|
||||||
|
: opcode, opcode @ ?twobyte ds + c, ;
|
||||||
|
: mrrm, mrrm @ c, ;
|
||||||
|
: sib, sib @ c, ;
|
||||||
|
: imm8, imm @ c, ;
|
||||||
|
: imm16, imm @ h, ;
|
||||||
|
: imm32, imm @ , ;
|
||||||
|
: disp8, disp @ c, ;
|
||||||
|
: disp32, disp @ , ;
|
||||||
|
|
||||||
|
\ Set operand size.
|
||||||
|
: -opsize 2drop r> drop ;
|
||||||
|
: opsize! is imm, s ! ['] -opsize is ?opsize ;
|
||||||
|
: !op8 0 ['] imm8, ?opsize ;
|
||||||
|
: !op32 1 ['] imm32, ?opsize ;
|
||||||
|
: !op16 1 ['] imm16, ?opsize 66 c, ;
|
||||||
|
|
||||||
|
\ Set SIB byte.
|
||||||
|
: !sib ['] sib, is ?sib, ;
|
||||||
|
: sib! 3 lshift + sib ! !sib ;
|
||||||
|
|
||||||
|
\ Set displacement.
|
||||||
|
: byte? -80 80 within ;
|
||||||
|
: disp! is ?disp, disp ! ;
|
||||||
|
: !disp8 ['] disp8, disp! ;
|
||||||
|
: !disp32 ['] disp32, disp! ;
|
||||||
|
: !disp ( a -- u ) dup byte? if !disp8 40 else !disp32 80 then ;
|
||||||
|
: -pc here 5 + negate ;
|
||||||
|
: relative -pc disp +! ;
|
||||||
|
|
||||||
|
\ Set immediate operand.
|
||||||
|
: imm! imm ! ['] imm, is ?imm, ;
|
||||||
|
|
||||||
|
\ Implements addressing modes: register, indirect, indexed, and direct.
|
||||||
|
: reg1 rm! !reg ;
|
||||||
|
: reg2 3 lshift reg! ;
|
||||||
|
: !reg2 ['] reg2 is reg ;
|
||||||
|
: ind dup mod! rm! !mem !reg2 ;
|
||||||
|
: ind# swap !disp + ind ;
|
||||||
|
: idx 04 ind sib! ;
|
||||||
|
: idx# rot !disp 04 + ind sib! ;
|
||||||
|
: addr !disp32 05 ind ;
|
||||||
|
|
||||||
|
\ Reset assembler state.
|
||||||
|
: 0opsize ['] opsize! is ?opsize ;
|
||||||
|
: 0ds d off s off ;
|
||||||
|
: 0reg ['] reg1 is reg ;
|
||||||
|
: 0mrrm c0 mrrm ! ['] mrrm, is ?mrrm, ;
|
||||||
|
: 0sib ['] nop is ?sib, ;
|
||||||
|
: 0disp ['] nop is ?disp, ;
|
||||||
|
: 0imm imm off ['] nop is ?imm, 0 is imm, ;
|
||||||
|
: 0asm 0imm 0disp 0reg 0ds 0mrrm 0sib 0opsize dir? on ;
|
||||||
|
|
||||||
|
\ Enter and exit assembler mode.
|
||||||
|
: start-code also assembler 0asm ;
|
||||||
|
: end-code align previous ;
|
||||||
|
|
||||||
|
\ Implements addressing mode: immediate.
|
||||||
|
: imm8? imm @ byte? ;
|
||||||
|
: ?sign-extend d off imm8? if 2 d ! ['] imm8, is ?imm, then ;
|
||||||
|
: alu# opcode @ reg! 80 opcode ! ?sign-extend ;
|
||||||
|
: mov# B0 s @ 3 lshift + rm@ + opcode ! 0ds -mrrm ;
|
||||||
|
: push# imm8? if ['] imm8, 6A else ['] imm32, 68 then dup opcode ! rm! is ?imm, ;
|
||||||
|
: test# F6 opcode ! ;
|
||||||
|
: imm-op imm! immediate-opcode ;
|
||||||
|
|
||||||
|
\ Process one operand. All operands except a direct address
|
||||||
|
\ have the stack picture ( n*x xt -addr ).
|
||||||
|
: addr? dup -addr <> ;
|
||||||
|
: op addr? if addr else drop execute then ;
|
||||||
|
|
||||||
|
\ Define instruction formats.
|
||||||
|
: instruction, opcode! opcode, ?mrrm, ?sib, ?disp, ?imm, 0asm ;
|
||||||
|
: mnemonic ( u a "name" -- ) create ['] nop 3, does> instruction, ;
|
||||||
|
: format: create ] !csp does> mnemonic ;
|
||||||
|
: immediate: ' latestxt >body ! ;
|
||||||
|
|
||||||
|
\ Instruction formats.
|
||||||
|
format: 0op -mrrm ;
|
||||||
|
format: 1reg op reg>opcode 0ds -mrrm ;
|
||||||
|
format: 1op opcode>reg op d off ;
|
||||||
|
format: 2op op op ;
|
||||||
|
format: 2op-d op op d off ;
|
||||||
|
format: 2op-ds op op 0ds ;
|
||||||
|
format: 1addr op relative -mrrm ;
|
||||||
|
format: 1imm8 !op8 op -mrrm ;
|
||||||
|
|
||||||
|
\ Instruction mnemonics.
|
||||||
|
00 2op add, immediate: alu#
|
||||||
|
08 2op or, immediate: alu#
|
||||||
|
0F44 2op-ds cmove, \ Todo: other condition codes.
|
||||||
|
0FB6 2op-ds movzx,
|
||||||
|
0FBE 2op-ds movsx,
|
||||||
|
10 2op adc, immediate: alu#
|
||||||
|
18 2op sbb, immediate: alu#
|
||||||
|
20 2op and, immediate: alu#
|
||||||
|
26 0op es,
|
||||||
|
28 2op sub, immediate: alu#
|
||||||
|
2E 0op cs,
|
||||||
|
30 2op xor, immediate: alu#
|
||||||
|
36 0op ss,
|
||||||
|
38 2op cmp, immediate: alu#
|
||||||
|
3E 0op ds,
|
||||||
|
50 1reg push, immediate: push#
|
||||||
|
58 1reg pop,
|
||||||
|
64 0op fs,
|
||||||
|
65 0op gs,
|
||||||
|
\ 70 jcc
|
||||||
|
84 2op-d test, immediate: test#
|
||||||
|
86 2op-d xchg,
|
||||||
|
88 2op mov, immediate: mov#
|
||||||
|
8D 2op-ds lea,
|
||||||
|
\ 8F/0 pop, rm
|
||||||
|
90 0op nop,
|
||||||
|
C3 0op ret,
|
||||||
|
\ C6/0 immediate mov to r/m
|
||||||
|
\ C7/0 immediate mov to r/m
|
||||||
|
CD 1imm8 int,
|
||||||
|
E8 1addr call,
|
||||||
|
E9 1addr jmp,
|
||||||
|
\ EB jmp rel8
|
||||||
|
F0 0op lock,
|
||||||
|
F2 0op rep,
|
||||||
|
F3 0op repz,
|
||||||
|
F4 0op hlt,
|
||||||
|
F5 0op cmc,
|
||||||
|
F610 1op not,
|
||||||
|
F618 1op neg,
|
||||||
|
F8 0op clc,
|
||||||
|
F9 0op stc,
|
||||||
|
FA 0op cli,
|
||||||
|
FB 0op sti,
|
||||||
|
FC 0op cld,
|
||||||
|
FD 0op std,
|
||||||
|
\ FE 0 inc rm
|
||||||
|
\ FF 1 dec rm
|
||||||
|
\ FF 2 call rm
|
||||||
|
\ FF 4 jmp rm
|
||||||
|
\ FF 6 push rm
|
||||||
|
|
||||||
|
: sp? dup 4 = ;
|
||||||
|
|
||||||
|
\ Addressing mode syntax: immediate, indirect, and displaced indirect.
|
||||||
|
: # ['] imm-op -addr ;
|
||||||
|
: ) 2drop sp? if 4 ['] idx else ['] ind then -addr 0reg 0opsize ;
|
||||||
|
: )# 2drop sp? if 4 ['] idx# else ['] ind# then -addr 0reg 0opsize ;
|
||||||
|
|
||||||
|
\ Define registers.
|
||||||
|
: reg8 create , does> @ ['] reg -addr !op8 ;
|
||||||
|
: reg16 create , does> @ ['] reg -addr !op16 ;
|
||||||
|
: reg32 create , does> @ ['] reg -addr !op32 ;
|
||||||
|
: reg: dup reg8 dup reg16 dup reg32 1+ ;
|
||||||
|
|
||||||
|
\ Register names.
|
||||||
|
0
|
||||||
|
reg: al ax eax reg: cl cx ecx reg: dl dx edx reg: bl bx ebx
|
||||||
|
reg: ah sp esp reg: ch bp ebp reg: dh si esi reg: bh di edi
|
||||||
|
drop
|
||||||
|
|
||||||
|
\ Runtime for ;CODE. CODE! is defined elsewhere.
|
||||||
|
: (;code) r> code! ;
|
||||||
|
|
||||||
|
base ! only forth definitions also assembler
|
||||||
|
|
||||||
|
\ Standard assembler entry points.
|
||||||
|
: code parse-name header, ?code, start-code ;
|
||||||
|
: ;code postpone (;code) reveal postpone [ ?csp start-code ; immediate
|
||||||
|
|
||||||
|
0asm
|
||||||
|
previous
|
||||||
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
|
||||||
|
|
||||||
|
mQINBFJJNS0BEADE9QkGDstkCAbUWIMnyzfYb+Z7KdF1vFR2WLe4yov9lwQ1gfjy
|
||||||
|
3lV5AZfEmNe+AGTRney/jpp9It0wyVQWvKM7N9yvFkWRVHq/thz8oDz/SknBoD1F
|
||||||
|
jACJgPXGlK3+YiXa03e3XM1JZxBgvHEH4MQTnNHQ2N7ey2J3oZ6NtOkZdu1xHKZS
|
||||||
|
hn1WUR9zRMa1XK1yLAowlKThnPk+jQVrMrwLtjoJ4wyWHGz+sZJw0IkV/7YJa2it
|
||||||
|
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OT2r+OzyCDI3isza2Xqzy6doC2/QGPMG3GMgc1aolToPznSTWX
|
||||||
|
KIlOuEpvGvZICprlb4fOVAa6nGF5WFi+kyF4UpkxOniaVW6fAfezlBEiQKlJe2Rh
|
||||||
|
SsDBbS2DmRw/6TEWzd2DVobfWfK+wWDLqm6L+zS3StkMCm3A6UKkoHZzWAAbKqta
|
||||||
|
sbQPFFfJnKyWXi0kjiAHlycdMouSgk1JY72fCxHUMxYRLKHGvpX1o2MlqUkjn5Yv
|
||||||
|
OVD9U8w4BUnv/iXd0Txdp1nkz/NLM174HCrQKSfubKNL1K53K0+iFNo4Ow2RJodR
|
||||||
|
71SGZgfkBxjD4bkJhaLB9xUmBkz6PaQl7pRVBtS7INbEbiyR2QvMYwsn7XwY92iI
|
||||||
|
WQ1yopiNGIub7pvrhs/qpzmftb/r9OaiGUoXB0FeQnDHo7x0vulX+0nU9crPcVCe
|
||||||
|
h/qQe/KCbs6ZuUkKKG9Y4XreJ8S1s3iGsVefwHQ/mjRB1b857of+61K4pquQ4u9J
|
||||||
|
svBlAR7nTIPqbZDw1lf5V2UrsyXQ2xBpCp5WGlRZ+SGvB0zvlzU=
|
||||||
|
=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-----
|
||||||
47
samples/XML/pt_BR.ts
Normal file
47
samples/XML/pt_BR.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.0" language="pt_BR">
|
||||||
|
<context>
|
||||||
|
<name>MainWindow</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../forms/mainwindow.ui" line="22"/>
|
||||||
|
<source>United Kingdom</source>
|
||||||
|
<translation>Reino Unido</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../forms/mainwindow.ui" line="38"/>
|
||||||
|
<source>God save the Queen</source>
|
||||||
|
<translation>Deus salve a Rainha</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="46"/>
|
||||||
|
<source>England</source>
|
||||||
|
<translation>Inglaterra</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="47"/>
|
||||||
|
<source>Wales</source>
|
||||||
|
<translation>Gales</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="48"/>
|
||||||
|
<source>Scotland</source>
|
||||||
|
<translation>Escócia</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="49"/>
|
||||||
|
<source>Northern Ireland</source>
|
||||||
|
<translation>Irlanda Norte</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="51"/>
|
||||||
|
<source>Portuguese</source>
|
||||||
|
<translation>Português</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../mainwindow.cpp" line="52"/>
|
||||||
|
<source>English</source>
|
||||||
|
<translation>Inglês</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
||||||
1
samples/text/messages.fr
Normal file
1
samples/text/messages.fr
Normal file
@@ -0,0 +1 @@
|
|||||||
|
the green potato=la pomme de terre verte
|
||||||
1
samples/text/readme.txt
Normal file
1
samples/text/readme.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Read me now!
|
||||||
@@ -118,6 +118,14 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_fr_by_heuristics
|
||||||
|
assert_heuristics({
|
||||||
|
"Frege" => all_fixtures("Frege"),
|
||||||
|
"Forth" => all_fixtures("Forth"),
|
||||||
|
"text" => all_fixtures("text")
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
def assert_heuristics(hash)
|
def assert_heuristics(hash)
|
||||||
candidates = hash.keys.map { |l| Language[l] }
|
candidates = hash.keys.map { |l| Language[l] }
|
||||||
|
|
||||||
@@ -135,4 +143,11 @@ class TestHeuristcs < Test::Unit::TestCase
|
|||||||
"LoomScript" => "LoomScript/HelloWorld.ls"
|
"LoomScript" => "LoomScript/HelloWorld.ls"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_ts_by_heuristics
|
||||||
|
assert_heuristics({
|
||||||
|
"TypeScript" => all_fixtures("TypeScript", "*.ts"),
|
||||||
|
"XML" => all_fixtures("XML", "*.ts")
|
||||||
|
})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -308,11 +308,12 @@ class TestLanguage < Test::Unit::TestCase
|
|||||||
assert_equal 'css', Language['CSS'].ace_mode
|
assert_equal 'css', Language['CSS'].ace_mode
|
||||||
assert_equal 'lsl', Language['LSL'].ace_mode
|
assert_equal 'lsl', Language['LSL'].ace_mode
|
||||||
assert_equal 'javascript', Language['JavaScript'].ace_mode
|
assert_equal 'javascript', Language['JavaScript'].ace_mode
|
||||||
assert_equal 'none', Language['FORTRAN'].ace_mode
|
assert_equal 'text', Language['FORTRAN'].ace_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ace_modes
|
def test_ace_modes
|
||||||
assert Language.ace_modes.include?(Language['Ruby'])
|
assert Language.ace_modes.include?(Language['Ruby'])
|
||||||
|
assert Language.ace_modes.include?(Language['FORTRAN'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_wrap
|
def test_wrap
|
||||||
@@ -366,9 +367,9 @@ class TestLanguage < Test::Unit::TestCase
|
|||||||
File.basename(ace_github_mode["name"], ".js") if ace_github_mode["name"] !~ /_highlight_rules|_test|_worker/
|
File.basename(ace_github_mode["name"], ".js") if ace_github_mode["name"] !~ /_highlight_rules|_test|_worker/
|
||||||
end.compact.uniq.sort.map(&:downcase)
|
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 = "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
|
width = missing.map { |language| language.name.length }.max
|
||||||
message << missing.map { |language| sprintf("%-#{width}s %s", language.name, language.ace_mode) }.sort.join("\n")
|
message << missing.map { |language| sprintf("%-#{width}s %s", language.name, language.ace_mode) }.sort.join("\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user