Stub out core:os/os2 for js_wasm

This commit is contained in:
Jeroen van Rijn
2025-10-27 23:08:56 +01:00
parent 0ea165e5ed
commit fbc7e72e53
11 changed files with 410 additions and 1 deletions

24
core/os/os2/dir_js.odin Normal file
View File

@@ -0,0 +1,24 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:intrinsics"
Read_Directory_Iterator_Impl :: struct {
fullpath: [dynamic]byte,
buf: []byte,
off: int,
}
@(require_results)
_read_directory_iterator :: proc(it: ^Read_Directory_Iterator) -> (fi: File_Info, index: int, ok: bool) {
return {}, -1, false
}
_read_directory_iterator_init :: proc(it: ^Read_Directory_Iterator, f: ^File) {
}
_read_directory_iterator_destroy :: proc(it: ^Read_Directory_Iterator) {
}

42
core/os/os2/env_js.odin Normal file
View File

@@ -0,0 +1,42 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
build_env :: proc() -> (err: Error) {
return
}
// delete_string_if_not_original :: proc(str: string) {
// }
@(require_results)
_lookup_env_alloc :: proc(key: string, allocator: runtime.Allocator) -> (value: string, found: bool) {
return
}
_lookup_env_buf :: proc(buf: []u8, key: string) -> (value: string, error: Error) {
return "", .Unsupported
}
_lookup_env :: proc{_lookup_env_alloc, _lookup_env_buf}
@(require_results)
_set_env :: proc(key, value: string) -> (err: Error) {
return .Unsupported
}
@(require_results)
_unset_env :: proc(key: string) -> bool {
return true
}
_clear_env :: proc() {
}
@(require_results)
_environ :: proc(allocator: runtime.Allocator) -> (environ: []string, err: Error) {
return {}, .Unsupported
}

View File

@@ -0,0 +1,13 @@
#+build js wasm32, js wasm64p32
#+private
package os2
_Platform_Error :: enum i32 {}
_error_string :: proc(errno: i32) -> string {
return "<unknown platform error>"
}
_get_platform_error :: proc(errno: _Platform_Error) -> Error {
return Platform_Error(errno)
}

107
core/os/os2/file_js.odin Normal file
View File

@@ -0,0 +1,107 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
import "core:io"
import "core:time"
File_Impl :: distinct rawptr
_open :: proc(name: string, flags: File_Flags, perm: int) -> (f: ^File, err: Error) {
return nil, .Unsupported
}
_new_file :: proc(handle: uintptr, name: string, allocator: runtime.Allocator) -> (f: ^File, err: Error) {
return nil, .Unsupported
}
_clone :: proc(f: ^File) -> (clone: ^File, err: Error) {
return nil, .Unsupported
}
_close :: proc(f: ^File_Impl) -> (err: Error) {
return .Unsupported
}
_fd :: proc(f: ^File) -> uintptr {
return 0
}
_name :: proc(f: ^File) -> string {
return ""
}
_sync :: proc(f: ^File) -> Error {
return .Unsupported
}
_truncate :: proc(f: ^File, size: i64) -> Error {
return .Unsupported
}
_remove :: proc(name: string) -> Error {
return .Unsupported
}
_rename :: proc(old_path, new_path: string) -> Error {
return .Unsupported
}
_link :: proc(old_name, new_name: string) -> Error {
return .Unsupported
}
_symlink :: proc(old_name, new_name: string) -> Error {
return .Unsupported
}
_read_link :: proc(name: string, allocator: runtime.Allocator) -> (s: string, err: Error) {
return "", .Unsupported
}
_chdir :: proc(name: string) -> Error {
return .Unsupported
}
_fchdir :: proc(f: ^File) -> Error {
return .Unsupported
}
_fchmod :: proc(f: ^File, mode: int) -> Error {
return .Unsupported
}
_chmod :: proc(name: string, mode: int) -> Error {
return .Unsupported
}
_fchown :: proc(f: ^File, uid, gid: int) -> Error {
return .Unsupported
}
_chown :: proc(name: string, uid, gid: int) -> Error {
return .Unsupported
}
_lchown :: proc(name: string, uid, gid: int) -> Error {
return .Unsupported
}
_chtimes :: proc(name: string, atime, mtime: time.Time) -> Error {
return .Unsupported
}
_fchtimes :: proc(f: ^File, atime, mtime: time.Time) -> Error {
return .Unsupported
}
_exists :: proc(path: string) -> bool {
return false
}
_file_stream_proc :: proc(stream_data: rawptr, mode: io.Stream_Mode, p: []byte, offset: i64, whence: io.Seek_From) -> (n: i64, err: io.Error) {
return 0, .Empty
}

7
core/os/os2/heap_js.odin Normal file
View File

@@ -0,0 +1,7 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
_heap_allocator_proc :: runtime.wasm_allocator_proc

85
core/os/os2/path_js.odin Normal file
View File

@@ -0,0 +1,85 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
_Path_Separator :: '/'
_Path_Separator_String :: "/"
_Path_List_Separator :: ':'
_is_path_separator :: proc(c: byte) -> (ok: bool) {
return c == _Path_Separator
}
_mkdir :: proc(name: string, perm: int) -> (err: Error) {
return .Unsupported
}
_mkdir_all :: proc(path: string, perm: int) -> (err: Error) {
return .Unsupported
}
_remove_all :: proc(path: string) -> (err: Error) {
return .Unsupported
}
_get_working_directory :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) {
return "", .Unsupported
}
_set_working_directory :: proc(dir: string) -> (err: Error) {
return .Unsupported
}
_get_executable_path :: proc(allocator: runtime.Allocator) -> (path: string, err: Error) {
return "", .Unsupported
}
_are_paths_identical :: proc(a, b: string) -> bool {
return false
}
_clean_path_handle_start :: proc(path: string, buffer: []u8) -> (rooted: bool, start: int) {
return
}
_is_absolute_path :: proc(path: string) -> bool {
return false
}
_get_absolute_path :: proc(path: string, allocator: runtime.Allocator) -> (absolute_path: string, err: Error) {
return "", .Unsupported
}
_get_relative_path_handle_start :: proc(base, target: string) -> bool {
return false
}
_get_common_path_len :: proc(base, target: string) -> int {
i := 0
end := min(len(base), len(target))
for j in 0..=end {
if j == end || _is_path_separator(base[j]) {
if base[i:j] == target[i:j] {
i = j
} else {
break
}
}
}
return i
}
_split_path :: proc(path: string) -> (dir, file: string) {
i := len(path) - 1
for i >= 0 && !_is_path_separator(path[i]) {
i -= 1
}
if i == 0 {
return path[:i+1], path[i+1:]
} else if i > 0 {
return path[:i], path[i+1:]
}
return "", path
}

14
core/os/os2/pipe_js.odin Normal file
View File

@@ -0,0 +1,14 @@
#+build js wasm32, js wasm64p32
#+private
package os2
_pipe :: proc() -> (r, w: ^File, err: Error) {
err = .Unsupported
return
}
@(require_results)
_pipe_has_data :: proc(r: ^File) -> (ok: bool, err: Error) {
err = .Unsupported
return
}

View File

@@ -0,0 +1,87 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
import "core:time"
_exit :: proc "contextless" (code: int) -> ! {
runtime.panic_contextless("exit")
}
_get_uid :: proc() -> int {
return 0
}
_get_euid :: proc() -> int {
return 0
}
_get_gid :: proc() -> int {
return 0
}
_get_egid :: proc() -> int {
return 0
}
_get_pid :: proc() -> int {
return 0
}
_get_ppid :: proc() -> int {
return 0
}
_process_info_by_handle :: proc(process: Process, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
err = .Unsupported
return
}
_current_process_info :: proc(selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
err = .Unsupported
return
}
_process_start :: proc(desc: Process_Desc) -> (process: Process, err: Error) {
err = .Unsupported
return
}
_process_wait :: proc(process: Process, timeout: time.Duration) -> (process_state: Process_State, err: Error) {
err = .Unsupported
return
}
_process_close :: proc(process: Process) -> Error {
return .Unsupported
}
_process_kill :: proc(process: Process) -> (err: Error) {
return .Unsupported
}
_process_info_by_pid :: proc(pid: int, selection: Process_Info_Fields, allocator: runtime.Allocator) -> (info: Process_Info, err: Error) {
err = .Unsupported
return
}
_process_list :: proc(allocator: runtime.Allocator) -> (list: []int, err: Error) {
err = .Unsupported
return
}
_process_open :: proc(pid: int, flags: Process_Open_Flags) -> (process: Process, err: Error) {
process.pid = pid
err = .Unsupported
return
}
_process_handle_still_valid :: proc(p: Process) -> Error {
return nil
}
_process_state_update_times :: proc(p: Process, state: ^Process_State) {
return
}

21
core/os/os2/stat_js.odin Normal file
View File

@@ -0,0 +1,21 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
_fstat :: proc(f: ^File, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
return {}, .Unsupported
}
_stat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
return {}, .Unsupported
}
_lstat :: proc(name: string, allocator: runtime.Allocator) -> (fi: File_Info, err: Error) {
return {}, .Unsupported
}
_same_file :: proc(fi1, fi2: File_Info) -> bool {
return fi1.fullpath == fi2.fullpath
}

View File

@@ -0,0 +1,9 @@
#+build js wasm32, js wasm64p32
#+private
package os2
import "base:runtime"
_temp_dir :: proc(allocator: runtime.Allocator) -> (string, runtime.Allocator_Error) {
return "", .Mode_Not_Implemented
}

View File

@@ -15,7 +15,7 @@ foreign dom_lib {
get_element_value_string_length :: proc(id: string) -> int ---
set_element_key_string :: proc(id: string, key: string, value: string) ---
get_element_key_string_length :: proc(id: string, key: string, ) -> int ---
get_element_key_string_length :: proc(id: string, key: string) -> int ---
device_pixel_ratio :: proc() -> f64 ---