Skip to content

Commit

Permalink
Merge branch 'XAMPPRocky:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
meenzen authored May 3, 2023
2 parents 1023d33 + a99eb5f commit e2a2321
Show file tree
Hide file tree
Showing 7 changed files with 212 additions and 46 deletions.
131 changes: 93 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ num-format = "0.4.0"
once_cell = "1.9"
regex = "1.5"
serde_json = "1"
dirs = "4"
etcetera = "0.8"

[dependencies.env_logger]
features = []
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ Isabelle
Jai
Java
JavaScript
Jq
Json
Jsx
Julia
Expand Down
19 changes: 19 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@
"quotes": [["\\\"", "\\\""]],
"extensions": ["s"]
},
"Astro": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"], ["<!--", "-->"]],
"extensions": ["astro"]
},
"Ats": {
"name": "ATS",
"line_comment": ["//"],
Expand Down Expand Up @@ -716,6 +721,12 @@
"extensions": ["j2"],
"multi_line_comments": [["{#", "#}"]]
},
"Jq": {
"name": "jq",
"line_comment": ["#"],
"quotes": [["\\\"", "\\\""]],
"extensions": ["jq"]
},
"Json": {
"name": "JSON",
"blank": true,
Expand Down Expand Up @@ -1196,6 +1207,14 @@
"verbatim_quotes": [["@\\\"", "\\\""]],
"extensions": ["cshtml", "razor"]
},
"Redscript": {
"name": "Redscript",
"line_comment": ["//", "///"],
"multi_line_comments": [["/*", "*/"]],
"quotes": [["\\\"", "\\\""]],
"nested": true,
"extensions": ["reds"]
},
"Renpy": {
"name": "Ren'Py",
"line_comment": ["#"],
Expand Down
19 changes: 12 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::{env, fs, path::PathBuf};

use etcetera::BaseStrategy;

use crate::language::LanguageType;
use crate::sort::Sort;
use crate::stats::Report;
Expand Down Expand Up @@ -74,11 +76,11 @@ impl Config {
/// The current directory's configuration will take priority over the configuration
/// directory.
///
/// |Platform | Value | Example |
/// | ------- | ----- | ------- |
/// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
/// | macOS | `$HOME`/Library/Application Support | /Users/Alice/Library/Application Support |
/// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
/// |Platform | Value | Example |
/// | ------- | ------------------------------------- | ------------------------------ |
/// | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/alice/.config |
/// | macOS | `$XDG_CONFIG_HOME` or `$HOME`/.config | /Users/alice/.config |
/// | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
///
/// # Example
/// ```toml
Expand All @@ -90,11 +92,14 @@ impl Config {
// /// extensions = ["py3"]
/// ```
pub fn from_config_files() -> Self {
let conf_dir = dirs::config_dir()
let conf_dir = etcetera::choose_base_strategy()
.ok()
.map(|basedirs| basedirs.config_dir())
.and_then(Self::get_config)
.unwrap_or_default();

let home_dir = dirs::home_dir()
let home_dir = etcetera::home_dir()
.ok()
.and_then(Self::get_config)
.unwrap_or_default();

Expand Down
11 changes: 11 additions & 0 deletions tests/data/jq.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 11 lines 3 code 5 comments 3 blanks

# A function to perform arithmetic
def add_mul(adder; multiplier):
# comment chararacter in quotes
"# Result: " + ((. + adder) * multiplier | tostring);

# and demonstrate it
10 | add_mul(5; 4) # => "# Result: 60"

# end of file
75 changes: 75 additions & 0 deletions tests/data/redscript.reds
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// 75 lines 47 code 20 comments 8 blanks

// redscript allows line comments
/* as well as block comments */

// it supports global functions
func add2(x: Int32, y: Int32) -> Int32 {
return x + y;
}

// functions without a type annotation default to Void return type
func tutorial() {
let x: Int32 = 10;
// compiler can infer types for local variables, y will be Int32
let y = 20;
// it supports arithmetic
let sum = x + y + 13;
// as well as mutation
let mutable = 0;
mutable += 10;
// numbers with decimal points default to type Float
let num = 10.0;
// you can cast between some types
let uint: Uint8 = Cast(10);
// array literals
let arr = [1, 2, 3];
// array iteration
for item in arr {
// logging and string operations
Log("at " + ToString(item));
}
}

// you can define your own classes
public class IntTuple {
let fst: Int32;
let snd: Int32;
// you can define static member functions
public static func Create(fst: Int32, snd: Int32) -> ref<IntTuple> {
let tuple = new IntTuple();
tuple.fst = fst;
tuple.snd = snd;
return tuple;
}
public func Swap() {
let tmp = this.fst;
this.fst = this.snd;
this.snd = tmp;
}
}

// you can replace existing in-game methods by specifying the class they belong to
@replaceMethod(CraftingSystem)
private final func ProcessCraftSkill(xpAmount: Int32, craftedItem: StatsObjectID) {
// instantiate a class using the new operator
let xpEvent = new ExperiencePointsEvent();
xpEvent.amount = xpAmount * 100;
xpEvent.type = gamedataProficiencyType.Crafting;
GetPlayer(this.GetGameInstance()).QueueEvent(xpEvent);
}

// you can add new methods to existing classes as well
// they are visible to other code using the class
@addMethod(BackpackMainGameController)
private final func DisassembleAllJunkItems() -> Void {
let items = this.m_InventoryManager.GetPlayerItemsByType(gamedataItemType.Gen_Junk);
let i = 0;
for item in items {
ItemActionsHelper.DisassembleItem(this.m_player, InventoryItemData.GetID(item));
};
// some methods require CName literals, they need to be prefixed with the n letter
this.PlaySound(n"Item", n"OnBuy");
}

0 comments on commit e2a2321

Please sign in to comment.