aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-03-18 22:47:57 +0000
committergingerBill <bill@gingerbill.org>2024-03-18 22:47:57 +0000
commitcc62773a05cb6c7a00cfcb916da1b6fdde7de3e8 (patch)
treee2c4910d5f8791c5852dd0ecf175cf04fc999518
parent75f40b4078b840277d502e618cba1627b69e5c43 (diff)
Attempt at getting orca working somehow with the `@(link_suffix)`
-rw-r--r--base/runtime/procs.odin11
-rw-r--r--core/sys/orca/graphics.odin25
-rw-r--r--core/sys/orca/orca.odin2
-rw-r--r--core/sys/orca/util.odin71
4 files changed, 45 insertions, 64 deletions
diff --git a/base/runtime/procs.odin b/base/runtime/procs.odin
index d9422b6a2..454574c35 100644
--- a/base/runtime/procs.odin
+++ b/base/runtime/procs.odin
@@ -25,17 +25,6 @@ when ODIN_NO_CRT && ODIN_OS == .Windows {
RtlMoveMemory(dst, src, len)
return dst
}
-} else when ODIN_OS == .Orca {
- memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
- if ptr != nil && len != 0 {
- b := byte(val)
- p := ([^]byte)(ptr)
- for i := 0; i < len; i += 1 {
- p[i] = b
- }
- }
- return ptr
- }
} else when ODIN_NO_CRT || (ODIN_ARCH == .wasm32 || ODIN_ARCH == .wasm64p32) {
@(link_name="memset", linkage="strong", require)
memset :: proc "c" (ptr: rawptr, val: i32, len: int) -> rawptr {
diff --git a/core/sys/orca/graphics.odin b/core/sys/orca/graphics.odin
index b2cfb7980..1a1f22b96 100644
--- a/core/sys/orca/graphics.odin
+++ b/core/sys/orca/graphics.odin
@@ -7,10 +7,10 @@ color :: distinct [4]f32
utf32 :: rune
// handles
-surface :: distinct u64
-font :: distinct u64
-image :: distinct u64
-canvas :: distinct u64
+surface :: distinct u32
+font :: distinct u32
+image :: distinct u32
+canvas :: distinct u32
joint_type :: enum c.int {
MITER,
@@ -58,22 +58,23 @@ image_region :: struct {
//------------------------------------------------------------------------------------------
// graphics surface
//------------------------------------------------------------------------------------------
-@(default_calling_convention="c", link_prefix="oc_")
+@(default_calling_convention="c", link_prefix="oc_", link_suffix="_argptr_stub")
foreign {
surface_nil :: proc() -> surface ---
surface_is_nil :: proc() -> c.bool ---
- surface_canvas :: proc() -> surface ---
- surface_gles :: proc() -> surface ---
+ surface_canvas :: proc(s: ^surface) ---
surface_destroy :: proc(surface: surface) ---
-
- surface_select :: proc(surface: surface) ---
- surface_deselect :: proc() ---
- surface_present :: proc(surface: surface) ---
-
+
surface_get_size :: proc(surface: surface) -> vec2 ---
surface_contents_scaling :: proc(surface: surface) -> vec2 ---
surface_bring_to_front :: proc(surface: surface) ---
surface_send_to_back :: proc(surface: surface) ---
+
+ surface_gles :: proc(surface: ^surface) ---
+ surface_select :: proc(surface: surface) ---
+
+ surface_deselect :: proc() ---
+ surface_present :: proc(surface: surface) ---
}
//------------------------------------------------------------------------------------------
diff --git a/core/sys/orca/orca.odin b/core/sys/orca/orca.odin
index dfbf1a798..4c5d886dc 100644
--- a/core/sys/orca/orca.odin
+++ b/core/sys/orca/orca.odin
@@ -13,7 +13,7 @@ rect :: [4]f32
//------------------------------------------------------------------------------------------
// window
//------------------------------------------------------------------------------------------
-@(default_calling_convention="c", link_prefix="oc_")
+@(default_calling_convention="c", link_prefix="oc_", link_suffix="_argptr_stub")
foreign {
window_set_title :: proc(title: str8) ---
window_set_size :: proc(size: vec2) ---
diff --git a/core/sys/orca/util.odin b/core/sys/orca/util.odin
index f818e2c2f..c1ec9a765 100644
--- a/core/sys/orca/util.odin
+++ b/core/sys/orca/util.odin
@@ -219,57 +219,48 @@ log_level :: enum c.int {
foreign {
bridge_log :: proc(
level: log_level,
- functionLen: i32,
- function: cstring,
- fileLen: i32,
- file: cstring,
- line: i32,
- msgLen: i32,
+ functionLen: c.int,
+ function: [^]byte,
+ fileLen: c.int,
+ file: [^]byte,
+ line: c.int,
+ msgLen: c.int,
msg: [^]byte,
) ---
-
- log_ext :: proc(
- level: log_level,
- function: cstring,
- file: cstring,
- line: c.int,
- fmt: cstring,
- #c_vararg args: ..any,
- ) ---
}
-log_proc: [1028]u8
-log_file: [1028]u8
+@(private)
+log_position :: proc "contextless" (loc: runtime.Source_Code_Location) -> (functionLen: c.int, function: [^]byte,
+ fileLen: c.int, file: [^]byte,
+ line: c.int) {
+ functionLen = c.int(len(loc.procedure))
+ function = raw_data(loc.procedure)
-log_temp :: proc "c" (loc: runtime.Source_Code_Location) -> (function, file: cstring) {
- copy(log_proc[:], loc.procedure)
- log_proc[len(loc.procedure)] = 0
- function = cstring(&log_proc[0])
-
- copy(log_file[:], loc.file_path)
- log_file[len(loc.file_path)] = 0
- file = cstring(&log_file[0])
+ fileLen = c.int(len(loc.file_path))
+ file = raw_data(loc.file_path)
+ line = c.int(loc.line)
return
}
-log_info :: proc "c" (format: cstring, args: ..any, loc := #caller_location) {
- function, file := log_temp(loc)
- // final := fmt.ctprintf(format, ..args)
- // log_ext(.INFO, function, file, loc.line, final, {})
- log_ext(.INFO, function, file, loc.line, format, {})
+log_ext :: proc "contextless" (level: log_level, format: string, args: ..any, loc := #caller_location) {
+ @(thread_local) buffer: [256]byte
+
+ context = runtime.default_context()
+
+ s := fmt.bprintf(buffer[:], format, ..args)
+
+ bridge_log(level, log_position(loc), c.int(len(s)), raw_data(s))
+}
+
+log_info :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
+ log_ext(.INFO, format, ..args, loc=loc)
}
-log_warning :: proc "c" (format: cstring, args: ..any, loc := #caller_location) {
- function, file := log_temp(loc)
- // final := fmt.ctprintf(format, ..args)
- // log_ext(.WARNING, function, file, loc.line, final, {})
- log_ext(.WARNING, function, file, loc.line, format, {})
+log_warning :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
+ log_ext(.WARNING, format, ..args, loc=loc)
}
-log_error :: proc "c" (format: cstring, args: ..any, loc := #caller_location) {
- function, file := log_temp(loc)
- // final := fmt.ctprintf(format, ..args)
- // log_ext(.ERROR, function, file, loc.line, final, {})
- log_ext(.ERROR, function, file, loc.line, format, {})
+log_error :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
+ log_ext(.ERROR, format, ..args, loc=loc)
}