Attempt at getting orca working somehow with the @(link_suffix)

This commit is contained in:
gingerBill
2024-03-18 22:47:57 +00:00
parent 75f40b4078
commit cc62773a05
4 changed files with 45 additions and 64 deletions

View File

@@ -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 {

View File

@@ -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) ---
}
//------------------------------------------------------------------------------------------

View File

@@ -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) ---

View File

@@ -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_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_info :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
log_ext(.INFO, 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_warning :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
log_ext(.WARNING, format, ..args, loc=loc)
}
log_error :: proc "contextless" (format: string, args: ..any, loc := #caller_location) {
log_ext(.ERROR, format, ..args, loc=loc)
}