Skip to content

Instantly share code, notes, and snippets.

View kevinw's full-sized avatar

Kevin Watters kevinw

View GitHub Profile
@kevinw
kevinw / guard_allocator.odin
Last active June 26, 2021 04:04
guard_allocator.odin
// public domain, use at your own risk
package debug_alloc
import "core:mem"
import "core:os"
import "core:fmt"
import "core:sys/win32"
import "../stacktrace"
D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL:u32: 0xffffffff;
D3D11_KEEP_UNORDERED_ACCESS_VIEWS :u32: 0xffffffff;
ID3D11Device1 :: struct {
using vtable: *ID3D11Device1_VTable;
uuid :: "a04bfb29-08ef-43d6-a49c-a9bdbdcbe686";
}
ID3D11Device1_VTable :: struct {

run instructions

jai build.jai && module_test.exe

output

mod_a func (do_thing=false) is at procedure 0x7ff671b2f290
@kevinw
kevinw / print_locals.jai
Created September 2, 2020 14:15
trying out a jai macro for printing locals
#import "Basic";
#import "Compiler";
main :: () {
foo := 42;
bar := "meep";
baz := false;
print_locals(#code (foo, bar, baz));
@kevinw
kevinw / .vimrc
Created November 12, 2019 13:38
ALE linter for odin
let g:ale_odin_compiler = "c:\\Users\\Lyra\\src\\odin\\odin.exe"
let g:ale_linters = {
\ 'odin': ['odin']
\}
@kevinw
kevinw / guard_allocator.odin
Last active April 16, 2020 20:08
a guard page allocator for odin
package debug_alloc
import "core:mem"
import "core:os"
import "core:sys/win32"
guard_allocator := mem.Allocator {
procedure = guard_allocator_proc,
data = nil,
};
/*
The MIT License
Copyright (c) 2019 Aleksander B. Birkeland
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@kevinw
kevinw / editor.odin
Last active November 12, 2019 22:47
@tweak odin attribute
// An example file using the @tweak attribute.
package main
using import "core:math/linalg"
@tweak
editor_settings : struct {
grid_offset: Vector3,
test_string: string,
test_int: int,
@kevinw
kevinw / _README for Odin Vim ALE Linting.md
Last active September 18, 2019 02:06
run `odin check -vet` as a Vim ALE linter (async code checking as you write)

Until I get odin support in ALE's tree proper, here's how you register an odin check -vet linter with ALE so your edit->compile->fix loop is shorter!

An animated gif of vim's odin ALE support

@kevinw
kevinw / zig.vim
Created September 8, 2019 19:23
ALE linter for zig
" Author: Kevin Watters <kevinwatters@gmail.com>
" Description: This file adds support for checking zig code.
function! ale_linters#zig#zig#GetExecutable(buffer) abort
return g:ale_zig_compiler
endfunction
function! s:find_build_dir(direc, count) abort
let l:path = a:direc . "/build.zig"
if filereadable(l:path)