mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Merge pull request #2397 from DragosPopse/master
Made most libraries panic on js targets instead of not compiling
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
//+build js
|
||||||
|
//+private
|
||||||
|
package dynlib
|
||||||
|
|
||||||
|
_load_library :: proc(path: string, global_symbols := false) -> (Library, bool) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_unload_library :: proc(library: Library) -> bool {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_symbol_address :: proc(library: Library, symbol: string) -> (ptr: rawptr, found: bool) {
|
||||||
|
return
|
||||||
|
}
|
||||||
+275
-2
@@ -1,4 +1,277 @@
|
|||||||
|
//+build js
|
||||||
package os
|
package os
|
||||||
// +build js
|
|
||||||
|
|
||||||
#panic("package os does not support a js target")
|
import "core:intrinsics"
|
||||||
|
import "core:runtime"
|
||||||
|
import "core:unicode/utf16"
|
||||||
|
|
||||||
|
is_path_separator :: proc(c: byte) -> bool {
|
||||||
|
return c == '/' || c == '\\'
|
||||||
|
}
|
||||||
|
|
||||||
|
open :: proc(path: string, mode: int = O_RDONLY, perm: int = 0) -> (Handle, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
close :: proc(fd: Handle) -> Errno {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
flush :: proc(fd: Handle) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
@(private="file")
|
||||||
|
read_console :: proc(handle: Handle, b: []byte) -> (n: int, err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
read :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
seek :: proc(fd: Handle, offset: i64, whence: int) -> (i64, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
file_size :: proc(fd: Handle) -> (i64, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@(private)
|
||||||
|
MAX_RW :: 1<<30
|
||||||
|
|
||||||
|
@(private)
|
||||||
|
pread :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
@(private)
|
||||||
|
pwrite :: proc(fd: Handle, data: []byte, offset: i64) -> (int, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
read_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
write_at :: proc(fd: Handle, data: []byte, offset: i64) -> (n: int, err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE(bill): Uses startup to initialize it
|
||||||
|
//stdin := get_std_handle(uint(win32.STD_INPUT_HANDLE))
|
||||||
|
//stdout := get_std_handle(uint(win32.STD_OUTPUT_HANDLE))
|
||||||
|
//stderr := get_std_handle(uint(win32.STD_ERROR_HANDLE))
|
||||||
|
|
||||||
|
|
||||||
|
get_std_handle :: proc "contextless" (h: uint) -> Handle {
|
||||||
|
context = runtime.default_context()
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exists :: proc(path: string) -> bool {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
is_file :: proc(path: string) -> bool {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
is_dir :: proc(path: string) -> bool {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE(tetra): GetCurrentDirectory is not thread safe with SetCurrentDirectory and GetFullPathName
|
||||||
|
//@private cwd_lock := win32.SRWLOCK{} // zero is initialized
|
||||||
|
|
||||||
|
get_current_directory :: proc(allocator := context.allocator) -> string {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
set_current_directory :: proc(path: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
change_directory :: proc(path: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
remove_directory :: proc(path: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@(private)
|
||||||
|
is_abs :: proc(path: string) -> bool {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
@(private)
|
||||||
|
fix_long_path :: proc(path: string) -> string {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
link :: proc(old_name, new_name: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink :: proc(path: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rename :: proc(old_path, new_path: string) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ftruncate :: proc(fd: Handle, length: i64) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
truncate :: proc(path: string, length: i64) -> (err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
remove :: proc(name: string) -> Errno {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pipe :: proc() -> (r, w: Handle, err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
read_dir :: proc(fd: Handle, n: int, allocator := context.allocator) -> (fi: []File_Info, err: Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle :: distinct uintptr
|
||||||
|
File_Time :: distinct u64
|
||||||
|
Errno :: distinct int
|
||||||
|
|
||||||
|
|
||||||
|
INVALID_HANDLE :: ~Handle(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
O_RDONLY :: 0x00000
|
||||||
|
O_WRONLY :: 0x00001
|
||||||
|
O_RDWR :: 0x00002
|
||||||
|
O_CREATE :: 0x00040
|
||||||
|
O_EXCL :: 0x00080
|
||||||
|
O_NOCTTY :: 0x00100
|
||||||
|
O_TRUNC :: 0x00200
|
||||||
|
O_NONBLOCK :: 0x00800
|
||||||
|
O_APPEND :: 0x00400
|
||||||
|
O_SYNC :: 0x01000
|
||||||
|
O_ASYNC :: 0x02000
|
||||||
|
O_CLOEXEC :: 0x80000
|
||||||
|
|
||||||
|
|
||||||
|
ERROR_NONE: Errno : 0
|
||||||
|
ERROR_FILE_NOT_FOUND: Errno : 2
|
||||||
|
ERROR_PATH_NOT_FOUND: Errno : 3
|
||||||
|
ERROR_ACCESS_DENIED: Errno : 5
|
||||||
|
ERROR_INVALID_HANDLE: Errno : 6
|
||||||
|
ERROR_NOT_ENOUGH_MEMORY: Errno : 8
|
||||||
|
ERROR_NO_MORE_FILES: Errno : 18
|
||||||
|
ERROR_HANDLE_EOF: Errno : 38
|
||||||
|
ERROR_NETNAME_DELETED: Errno : 64
|
||||||
|
ERROR_FILE_EXISTS: Errno : 80
|
||||||
|
ERROR_INVALID_PARAMETER: Errno : 87
|
||||||
|
ERROR_BROKEN_PIPE: Errno : 109
|
||||||
|
ERROR_BUFFER_OVERFLOW: Errno : 111
|
||||||
|
ERROR_INSUFFICIENT_BUFFER: Errno : 122
|
||||||
|
ERROR_MOD_NOT_FOUND: Errno : 126
|
||||||
|
ERROR_PROC_NOT_FOUND: Errno : 127
|
||||||
|
ERROR_DIR_NOT_EMPTY: Errno : 145
|
||||||
|
ERROR_ALREADY_EXISTS: Errno : 183
|
||||||
|
ERROR_ENVVAR_NOT_FOUND: Errno : 203
|
||||||
|
ERROR_MORE_DATA: Errno : 234
|
||||||
|
ERROR_OPERATION_ABORTED: Errno : 995
|
||||||
|
ERROR_IO_PENDING: Errno : 997
|
||||||
|
ERROR_NOT_FOUND: Errno : 1168
|
||||||
|
ERROR_PRIVILEGE_NOT_HELD: Errno : 1314
|
||||||
|
WSAEACCES: Errno : 10013
|
||||||
|
WSAECONNRESET: Errno : 10054
|
||||||
|
|
||||||
|
// Windows reserves errors >= 1<<29 for application use
|
||||||
|
ERROR_FILE_IS_PIPE: Errno : 1<<29 + 0
|
||||||
|
ERROR_FILE_IS_NOT_DIR: Errno : 1<<29 + 1
|
||||||
|
ERROR_NEGATIVE_OFFSET: Errno : 1<<29 + 2
|
||||||
|
|
||||||
|
// "Argv" arguments converted to Odin strings
|
||||||
|
args := _alloc_command_line_arguments()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
last_write_time :: proc(fd: Handle) -> (File_Time, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
last_write_time_by_name :: proc(name: string) -> (File_Time, Errno) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
heap_free :: proc(ptr: rawptr) {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
get_page_size :: proc() -> int {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
@(private)
|
||||||
|
_processor_core_count :: proc() -> int {
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
exit :: proc "contextless" (code: int) -> ! {
|
||||||
|
context = runtime.default_context()
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
current_thread_id :: proc "contextless" () -> int {
|
||||||
|
context = runtime.default_context()
|
||||||
|
unimplemented("core:os procedure not supported on JS target")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_alloc_command_line_arguments :: proc() -> []string {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
//+build js
|
||||||
|
package thread
|
||||||
|
|
||||||
|
import "core:intrinsics"
|
||||||
|
import "core:sync"
|
||||||
|
import "core:mem"
|
||||||
|
|
||||||
|
Thread_State :: enum u8 {
|
||||||
|
Started,
|
||||||
|
Joined,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread_Os_Specific :: struct {
|
||||||
|
flags: bit_set[Thread_State; u8],
|
||||||
|
}
|
||||||
|
|
||||||
|
_thread_priority_map := [Thread_Priority]i32{
|
||||||
|
.Normal = 0,
|
||||||
|
.Low = -2,
|
||||||
|
.High = +2,
|
||||||
|
}
|
||||||
|
|
||||||
|
_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_start :: proc(t: ^Thread) {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_is_done :: proc(t: ^Thread) -> bool {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_join :: proc(t: ^Thread) {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_join_multiple :: proc(threads: ..^Thread) {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_destroy :: proc(thread: ^Thread) {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_terminate :: proc(using thread : ^Thread, exit_code: int) {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
|
_yield :: proc() {
|
||||||
|
unimplemented("core:thread procedure not supported on js target")
|
||||||
|
}
|
||||||
|
|
||||||
Vendored
+36
@@ -0,0 +1,36 @@
|
|||||||
|
//+build !js
|
||||||
|
package wasm_js_interface
|
||||||
|
|
||||||
|
import "core:runtime"
|
||||||
|
|
||||||
|
|
||||||
|
get_element_value_string :: proc "contextless" (id: string, buf: []byte) -> string {
|
||||||
|
context = runtime.default_context()
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get_element_min_max :: proc "contextless" (id: string) -> (min, max: f64) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rect :: struct {
|
||||||
|
x, y, width, height: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
get_bounding_client_rect :: proc "contextless" (id: string) -> (rect: Rect) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
window_get_rect :: proc "contextless" () -> (rect: Rect) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
window_get_scroll :: proc "contextless" () -> (x, y: f64) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
+288
@@ -0,0 +1,288 @@
|
|||||||
|
//+build !js
|
||||||
|
package wasm_js_interface
|
||||||
|
|
||||||
|
|
||||||
|
Event_Kind :: enum u32 {
|
||||||
|
Invalid,
|
||||||
|
|
||||||
|
Load,
|
||||||
|
Unload,
|
||||||
|
Error,
|
||||||
|
Resize,
|
||||||
|
Visibility_Change,
|
||||||
|
Fullscreen_Change,
|
||||||
|
Fullscreen_Error,
|
||||||
|
|
||||||
|
Click,
|
||||||
|
Double_Click,
|
||||||
|
Mouse_Move,
|
||||||
|
Mouse_Over,
|
||||||
|
Mouse_Out,
|
||||||
|
Mouse_Up,
|
||||||
|
Mouse_Down,
|
||||||
|
|
||||||
|
Key_Up,
|
||||||
|
Key_Down,
|
||||||
|
Key_Press,
|
||||||
|
|
||||||
|
Scroll,
|
||||||
|
Wheel,
|
||||||
|
|
||||||
|
Focus,
|
||||||
|
Submit,
|
||||||
|
Blur,
|
||||||
|
Change,
|
||||||
|
Select,
|
||||||
|
|
||||||
|
Animation_Start,
|
||||||
|
Animation_End,
|
||||||
|
Animation_Iteration,
|
||||||
|
Animation_Cancel,
|
||||||
|
|
||||||
|
Copy,
|
||||||
|
Cut,
|
||||||
|
Paste,
|
||||||
|
|
||||||
|
// Drag,
|
||||||
|
// Drag_Start,
|
||||||
|
// Drag_End,
|
||||||
|
// Drag_Enter,
|
||||||
|
// Drag_Leave,
|
||||||
|
// Drag_Over,
|
||||||
|
// Drop,
|
||||||
|
|
||||||
|
Pointer_Cancel,
|
||||||
|
Pointer_Down,
|
||||||
|
Pointer_Enter,
|
||||||
|
Pointer_Leave,
|
||||||
|
Pointer_Move,
|
||||||
|
Pointer_Over,
|
||||||
|
Pointer_Up,
|
||||||
|
Got_Pointer_Capture,
|
||||||
|
Lost_Pointer_Capture,
|
||||||
|
Pointer_Lock_Change,
|
||||||
|
Pointer_Lock_Error,
|
||||||
|
|
||||||
|
Selection_Change,
|
||||||
|
Selection_Start,
|
||||||
|
|
||||||
|
Touch_Cancel,
|
||||||
|
Touch_End,
|
||||||
|
Touch_Move,
|
||||||
|
Touch_Start,
|
||||||
|
|
||||||
|
Transition_Start,
|
||||||
|
Transition_End,
|
||||||
|
Transition_Run,
|
||||||
|
Transition_Cancel,
|
||||||
|
|
||||||
|
Context_Menu,
|
||||||
|
|
||||||
|
Custom,
|
||||||
|
|
||||||
|
}
|
||||||
|
event_kind_string := [Event_Kind]string{
|
||||||
|
.Invalid = "",
|
||||||
|
|
||||||
|
.Load = "load",
|
||||||
|
.Unload = "unload",
|
||||||
|
.Error = "error",
|
||||||
|
.Resize = "resize",
|
||||||
|
.Visibility_Change = "visibilitychange",
|
||||||
|
.Fullscreen_Change = "fullscreenchange",
|
||||||
|
.Fullscreen_Error = "fullscreenerror",
|
||||||
|
|
||||||
|
.Click = "click",
|
||||||
|
.Double_Click = "dblclick",
|
||||||
|
.Mouse_Move = "mousemove",
|
||||||
|
.Mouse_Over = "mouseover",
|
||||||
|
.Mouse_Out = "mouseout",
|
||||||
|
.Mouse_Up = "mouseup",
|
||||||
|
.Mouse_Down = "mousedown",
|
||||||
|
|
||||||
|
.Key_Up = "keyup",
|
||||||
|
.Key_Down = "keydown",
|
||||||
|
.Key_Press = "keypress",
|
||||||
|
|
||||||
|
.Scroll = "scroll",
|
||||||
|
.Wheel = "wheel",
|
||||||
|
|
||||||
|
.Focus = "focus",
|
||||||
|
.Submit = "submit",
|
||||||
|
.Blur = "blur",
|
||||||
|
.Change = "change",
|
||||||
|
.Select = "select",
|
||||||
|
|
||||||
|
.Animation_Start = "animationstart",
|
||||||
|
.Animation_End = "animationend",
|
||||||
|
.Animation_Iteration = "animationiteration",
|
||||||
|
.Animation_Cancel = "animationcancel",
|
||||||
|
|
||||||
|
.Copy = "copy",
|
||||||
|
.Cut = "cut",
|
||||||
|
.Paste = "paste",
|
||||||
|
|
||||||
|
// .Drag, = "drag",
|
||||||
|
// .Drag_Start, = "dragstart",
|
||||||
|
// .Drag_End, = "dragend",
|
||||||
|
// .Drag_Enter, = "dragenter",
|
||||||
|
// .Drag_Leave, = "dragleave",
|
||||||
|
// .Drag_Over, = "dragover",
|
||||||
|
// .Drop, = "drop",
|
||||||
|
|
||||||
|
.Pointer_Cancel = "pointercancel",
|
||||||
|
.Pointer_Down = "pointerdown",
|
||||||
|
.Pointer_Enter = "pointerenter",
|
||||||
|
.Pointer_Leave = "pointerleave",
|
||||||
|
.Pointer_Move = "pointermove",
|
||||||
|
.Pointer_Over = "pointerover",
|
||||||
|
.Pointer_Up = "pointerup",
|
||||||
|
.Got_Pointer_Capture = "gotpointercapture",
|
||||||
|
.Lost_Pointer_Capture = "lostpointercapture",
|
||||||
|
.Pointer_Lock_Change = "pointerlockchange",
|
||||||
|
.Pointer_Lock_Error = "pointerlockerror",
|
||||||
|
|
||||||
|
.Selection_Change = "selectionchange",
|
||||||
|
.Selection_Start = "selectionstart",
|
||||||
|
|
||||||
|
.Transition_Start = "transitionstart",
|
||||||
|
.Transition_End = "transitionend",
|
||||||
|
.Transition_Run = "transitionrun",
|
||||||
|
.Transition_Cancel = "transitioncancel",
|
||||||
|
|
||||||
|
.Touch_Cancel = "touchcancel",
|
||||||
|
.Touch_End = "touchend",
|
||||||
|
.Touch_Move = "touchmove",
|
||||||
|
.Touch_Start = "touchstart",
|
||||||
|
|
||||||
|
.Context_Menu = "contextmenu",
|
||||||
|
|
||||||
|
.Custom = "?custom?",
|
||||||
|
}
|
||||||
|
|
||||||
|
Delta_Mode :: enum u32 {
|
||||||
|
Pixel = 0,
|
||||||
|
Line = 1,
|
||||||
|
Page = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
Key_Location :: enum u8 {
|
||||||
|
Standard = 0,
|
||||||
|
Left = 1,
|
||||||
|
Right = 2,
|
||||||
|
Numpad = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
KEYBOARD_MAX_KEY_SIZE :: 16
|
||||||
|
KEYBOARD_MAX_CODE_SIZE :: 16
|
||||||
|
|
||||||
|
Event_Target_Kind :: enum u32 {
|
||||||
|
Element = 0,
|
||||||
|
Document = 1,
|
||||||
|
Window = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
Event_Phase :: enum u8 {
|
||||||
|
None = 0,
|
||||||
|
Capturing_Phase = 1,
|
||||||
|
At_Target = 2,
|
||||||
|
Bubbling_Phase = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
Event_Option :: enum u8 {
|
||||||
|
Bubbles = 0,
|
||||||
|
Cancelable = 1,
|
||||||
|
Composed = 2,
|
||||||
|
}
|
||||||
|
Event_Options :: distinct bit_set[Event_Option; u8]
|
||||||
|
|
||||||
|
Event :: struct {
|
||||||
|
kind: Event_Kind,
|
||||||
|
target_kind: Event_Target_Kind,
|
||||||
|
current_target_kind: Event_Target_Kind,
|
||||||
|
id: string,
|
||||||
|
timestamp: f64,
|
||||||
|
|
||||||
|
phase: Event_Phase,
|
||||||
|
options: Event_Options,
|
||||||
|
is_composing: bool,
|
||||||
|
is_trusted: bool,
|
||||||
|
|
||||||
|
using data: struct #raw_union #align 8 {
|
||||||
|
scroll: struct {
|
||||||
|
delta: [2]f64,
|
||||||
|
},
|
||||||
|
visibility_change: struct {
|
||||||
|
is_visible: bool,
|
||||||
|
},
|
||||||
|
wheel: struct {
|
||||||
|
delta: [3]f64,
|
||||||
|
delta_mode: Delta_Mode,
|
||||||
|
},
|
||||||
|
|
||||||
|
key: struct {
|
||||||
|
key: string,
|
||||||
|
code: string,
|
||||||
|
location: Key_Location,
|
||||||
|
|
||||||
|
ctrl: bool,
|
||||||
|
shift: bool,
|
||||||
|
alt: bool,
|
||||||
|
meta: bool,
|
||||||
|
|
||||||
|
repeat: bool,
|
||||||
|
|
||||||
|
_key_buf: [KEYBOARD_MAX_KEY_SIZE]byte,
|
||||||
|
_code_buf: [KEYBOARD_MAX_KEY_SIZE]byte,
|
||||||
|
},
|
||||||
|
|
||||||
|
mouse: struct {
|
||||||
|
screen: [2]i64,
|
||||||
|
client: [2]i64,
|
||||||
|
offset: [2]i64,
|
||||||
|
page: [2]i64,
|
||||||
|
movement: [2]i64,
|
||||||
|
|
||||||
|
ctrl: bool,
|
||||||
|
shift: bool,
|
||||||
|
alt: bool,
|
||||||
|
meta: bool,
|
||||||
|
|
||||||
|
button: i16,
|
||||||
|
buttons: bit_set[0..<16; u16],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
user_data: rawptr,
|
||||||
|
callback: proc(e: Event),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
add_event_listener :: proc(id: string, kind: Event_Kind, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_event_listener :: proc(id: string, kind: Event_Kind, user_data: rawptr, callback: proc(e: Event)) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
add_window_event_listener :: proc(kind: Event_Kind, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_window_event_listener :: proc(kind: Event_Kind, user_data: rawptr, callback: proc(e: Event)) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_event_listener_from_event :: proc(e: Event) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
add_custom_event_listener :: proc(id: string, name: string, user_data: rawptr, callback: proc(e: Event), use_capture := false) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
remove_custom_event_listener :: proc(id: string, name: string, user_data: rawptr, callback: proc(e: Event)) -> bool {
|
||||||
|
panic("vendor:wasm/js not supported on non JS targets")
|
||||||
|
}
|
||||||
|
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
//+build !js
|
||||||
|
package wasm_js_interface
|
||||||
|
|
||||||
|
import "core:mem"
|
||||||
|
|
||||||
|
PAGE_SIZE :: 64 * 1024
|
||||||
|
page_alloc :: proc(page_count: int) -> (data: []byte, err: mem.Allocator_Error) {
|
||||||
|
panic("vendor:wasm/js not supported on non-js targets")
|
||||||
|
}
|
||||||
|
|
||||||
|
page_allocator :: proc() -> mem.Allocator {
|
||||||
|
panic("vendor:wasm/js not supported on non-js targets")
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user