Skip to content

Instantly share code, notes, and snippets.

View laytan's full-sized avatar

Laytan laytan

View GitHub Profile
@laytan
laytan / odin.py
Created April 25, 2024 17:40
LLDB script to visualise Odin slices, maps, and strings
import lldb
def is_slice_type(t, internal_dict):
return t.name.startswith("[]") or t.name.startswith("[dynamic]")
class SliceChildProvider:
def __init__(self, val, dict):
self.val = val
def num_children(self):
@laytan
laytan / main.odin
Last active April 23, 2024 11:57
Graphviz Odin dependencies
package main
import "core:fmt"
import "core:io"
import "core:odin/ast"
import "core:odin/parser"
import "core:os"
import "core:path/filepath"
import "core:slice"
import "core:strings"
@laytan
laytan / main.odin
Created April 10, 2024 22:57
Stack traces using Odin instrumentation features
package main
import "core:runtime"
main :: proc() {
context.assertion_failure_proc = print_call_frames
foo()
}
@laytan
laytan / main.odin
Created March 18, 2024 21:44
Odin GLFW 3.4 Hello World
package main
import "core:log"
import "core:mem"
import "core:runtime"
import "vendor:glfw"
import gl "vendor:OpenGL"
main :: proc() {
@laytan
laytan / compile.sh
Last active March 22, 2024 22:52
Odin, GLFW & Vulkan boilerplate for Drawing a Triangle on https://vulkan-tutorial.com
#!/usr/bin/env sh
glslc shader.vert -o vert.spv
glslc shader.frag -o frag.spv
@laytan
laytan / minicoro.asm
Last active February 27, 2024 12:04
Odin minicoro source port (only darwin support for now)
/*
vim: syntax=armasm nospell
Some of the following assembly code is taken from LuaCoco by Mike Pall.
See https://coco.luajit.org/index.html
MIT license
Copyright (C) 2004-2016 Mike Pall. All rights reserved.
@laytan
laytan / lsp.odin
Last active January 18, 2024 03:19
Incomplete LSP example Odin
package lsp
import "core:bufio"
import "core:encoding/json"
import "core:io"
import "core:log"
Null :: distinct struct{}
Initialize_Error :: Response_Error(Initialize_Error_Data)
@laytan
laytan / generated.odin
Last active December 19, 2023 00:00
Odin test runner
package generated_tests
import test_gen "core:testing/generator"
import "core:os"
import "core:testing"
import test_core_crypto "../../../tests/core/crypto"
main :: proc() {
tests := []testing.Internal_Test{
@laytan
laytan / main.odin
Last active April 19, 2024 08:53
Raylib logging callback to Odin logger
logger: log.Logger
rl_log_buf: []byte
rl_log :: proc "c" (logLevel: rl.TraceLogLevel, text: cstring, args: libc.va_list) {
context = runtime.default_context()
context.logger = logger
level: log.Level
switch logLevel {
case .TRACE, .DEBUG: level = .Debug
case .ALL, .NONE, .INFO: level = .Info
@laytan
laytan / build.bat
Last active November 14, 2023 22:15
Orca in Odin
@echo off
setlocal enabledelayedexpansion
set ORCA_DIR=..\..\third-party\orca
set STDLIB_DIR=%ORCA_DIR%\src\libc-shim
:: common flags to build wasm modules
set wasmFlags=--target=wasm32^
--no-standard-libraries ^
-mbulk-memory ^