Skip to content

Commit

Permalink
merge main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
StunxFS committed Nov 30, 2023
2 parents 8874b39 + 5361b0e commit 30c1fd2
Show file tree
Hide file tree
Showing 132 changed files with 1,506 additions and 1,511 deletions.
2 changes: 1 addition & 1 deletion cmd/src/tools/cmd_fmt.ri
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import rivet/report;
var fmtDescription := "Formats the given Rivet source files or recursively formats all files in the
directory, then prints their formatted source to stdout.";

public func cmd_fmt(args: []string) -> ! {
pub func cmd_fmt(args: []string) -> ! {
mut fp := flag.FlagParser.new(args);
fp.set_application_name("rivet fmt");
fp.set_arguments_description("[FILES|DIRECTORIES]");
Expand Down
2 changes: 1 addition & 1 deletion cmd/src/tools/cmd_new.ri
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var availableTemplates := "Available templates:
bin A simple binary project (default).
lib A simple library project.";

public func cmd_new(args: []string, is_init: bool) -> ! {
pub func cmd_new(args: []string, is_init: bool) -> ! {
mut template := "";
mut fp := flag.FlagParser.new(args);
if is_init {
Expand Down
10 changes: 5 additions & 5 deletions cmd/src/tools/templates/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

public var mainFile := "import std/console;
pub var mainFile := "import std/console;
func main() {
console.writeln(\"Hello World!\");
}
";

public var libFile := "public func add(a: int32, b: int32) -> int32 {
pub var libFile := "pub func add(a: int32, b: int32) -> int32 {
return a + b;
}
Expand All @@ -18,7 +18,7 @@ test \"test `add` function\" {
}
";

public var gitignoreFile := "# Binaries for programs and plugins
pub var gitignoreFile := "# Binaries for programs and plugins
{}
*.exe
*.exe~
Expand All @@ -39,12 +39,12 @@ bin/
.env
";

public var gitattributesFile := "* text=auto eol=lf
pub var gitattributesFile := "* text=auto eol=lf
*.bat eol=crlf
*.ri linguist-language=Rivet text=auto eol=lf
";

public var editorConfigFile := "[*]
pub var editorConfigFile := "[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
Expand Down
2 changes: 1 addition & 1 deletion cmd/src/tools/utils.ri
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import std/console;
import std/console/styles;

#[inline]
public func readln(prompt: string) -> ?string {
pub func readln(prompt: string) -> ?string {
prefix := styles.bold(styles.green("> "));
return if prompt.is_empty() {
console.readln(prefix)
Expand Down
72 changes: 36 additions & 36 deletions lib/c/src/ctypes/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

public alias char := uint8;
public alias schar := int8;
public alias uchar := uint8;

public alias short := int16;
public alias ushort := uint16;

public alias int := int32;
public alias uint := uint32;

public alias long := int64;
public alias longlong := int64;

public alias ulong := uint64;
public alias ulonglong := uint64;

public alias float := float32;
public alias double := float64;

public alias wchar_t := uint32;
public alias intmax_t := int64;
public alias uintmax_t := uint64;

public alias size_t := uint;
public alias ptrdiff_t := int;
public alias intptr_t := int;
public alias uintptr_t := uint;
public alias ssize_t := int;

public alias pid_t := int32;
public alias off_t := int64;
public alias ino_t := uint64;
public alias dev_t := uint64;
public alias uid_t := uint32;
public alias gid_t := uint32;
public alias mode_t := uint;
pub alias char := uint8;
pub alias schar := int8;
pub alias uchar := uint8;

pub alias short := int16;
pub alias ushort := uint16;

pub alias int := int32;
pub alias uint := uint32;

pub alias long := int64;
pub alias longlong := int64;

pub alias ulong := uint64;
pub alias ulonglong := uint64;

pub alias float := float32;
pub alias double := float64;

pub alias wchar_t := uint32;
pub alias intmax_t := int64;
pub alias uintmax_t := uint64;

pub alias size_t := uint;
pub alias ptrdiff_t := int;
pub alias intptr_t := int;
pub alias uintptr_t := uint;
pub alias ssize_t := int;

pub alias pid_t := int32;
pub alias off_t := int64;
pub alias ino_t := uint64;
pub alias dev_t := uint64;
pub alias uid_t := uint32;
pub alias gid_t := uint32;
pub alias mode_t := uint;
14 changes: 7 additions & 7 deletions lib/c/src/errno.ri
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
import c/libc;

#[boxed]
public struct ErrnoError < Throwable {
public msg: string;
public code: int32;
pub struct ErrnoError < Throwable {
pub msg: string;
pub code: int32;

public func to_string(self) -> string {
pub func to_string(self) -> string {
return "errno: {} (code: {})".fmt(self.msg, self.code);
}
}

#[inline]
public func errno() -> int32 {
pub func errno() -> int32 {
return unsafe {
#if _LINUX_
libc.__errno_location()?.*
Expand All @@ -26,7 +26,7 @@ public func errno() -> int32 {
}

#[inline]
public func errno_msg(code: int32 := errno()) -> string {
pub func errno_msg(code: int32 := errno()) -> string {
unsafe {
return if s := libc.strerror(code) {
string.from_raw(s)
Expand All @@ -37,6 +37,6 @@ public func errno_msg(code: int32 := errno()) -> string {
}

#[inline]
public func last_errno_error() -> ErrnoError {
pub func last_errno_error() -> ErrnoError {
return ErrnoError(errno_msg(), errno());
}
18 changes: 9 additions & 9 deletions lib/c/src/libc/dirent.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

public struct dirent {
public d_ino: uint;
public d_off: uint;
public d_reclen: uint16;
public d_type: uint8;
public d_name: [256]uint8;
pub struct dirent {
pub d_ino: uint;
pub d_off: uint;
pub d_reclen: uint16;
pub d_type: uint8;
pub d_name: [256]uint8;
}

extern (C) {
public func opendir(d: [&]uint8) -> ?&dirent;
public func readdir(d: &dirent) -> ?&dirent;
public func closedir(d: &dirent) -> int32;
pub func opendir(d: [&]uint8) -> ?&dirent;
pub func readdir(d: &dirent) -> ?&dirent;
pub func closedir(d: &dirent) -> int32;
}
16 changes: 8 additions & 8 deletions lib/c/src/libc/dlfcn.ri
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Use of this source code is governed by an MIT license that can
// be found in the LICENSE file.

public const RTLD_LAZY := 0x001;
public const RTLD_NOW := 0x002;
public const RTLD_BINDING_MASK := 0x3;
public const RTLD_GLOBAL := 0x100;
pub const RTLD_LAZY := 0x001;
pub const RTLD_NOW := 0x002;
pub const RTLD_BINDING_MASK := 0x3;
pub const RTLD_GLOBAL := 0x100;

extern (C) {
public func dlopen(__file: [&]uint8, __mode: int32) -> ?rawptr;
public func dlclose(__handle: rawptr) -> int32;
public func dlsym(__handle: rawptr, __name: [&]uint8) -> ?rawptr;
public func dlerror() -> ?[&]uint8;
pub func dlopen(__file: [&]uint8, __mode: int32) -> ?rawptr;
pub func dlclose(__handle: rawptr) -> int32;
pub func dlsym(__handle: rawptr, __name: [&]uint8) -> ?rawptr;
pub func dlerror() -> ?[&]uint8;
}
16 changes: 8 additions & 8 deletions lib/c/src/libc/errno.ri
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

#if _LINUX_
extern (C) {
public func __errno_location() -> ?&mut int32;
pub func __errno_location() -> ?&mut int32;
}

public const EDOM := 33;
public const EILSEQ := 84;
public const ERANGE := 34;
pub const EDOM := 33;
pub const EILSEQ := 84;
pub const ERANGE := 34;
#endif

#if _WINDOWS_
extern (C) {
[dllimport]
public func _errno() &mut int32;
pub func _errno() &mut int32;
}

public const EDOM := 33;
public const EILSEQ := 42;
public const ERANGE := 34;
pub const EDOM := 33;
pub const EILSEQ := 42;
pub const ERANGE := 34;
#endif
2 changes: 1 addition & 1 deletion lib/c/src/libc/mod.ri
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// be found in the LICENSE file.

extern (C) {
public var environ: [&][&]uint8;
pub var environ: [&][&]uint8;
}
Loading

0 comments on commit 30c1fd2

Please sign in to comment.