Compare commits
3 commits
71964e8aea
...
b06efe88a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b06efe88a2 | ||
|
|
bcaa847501 | ||
|
|
72a24efd32 |
2 changed files with 35 additions and 16 deletions
42
STYLEGUIDE
42
STYLEGUIDE
|
|
@ -130,21 +130,23 @@ When authoring a new module, use this as a base plate:
|
|||
}
|
||||
|
||||
|
||||
Bindings
|
||||
--------
|
||||
Memory Management
|
||||
-----------------
|
||||
|
||||
Binding modules should default to static linking and take
|
||||
an optional '#module_parameter' to link dynamically.
|
||||
Libraries should be pinned to a specific version, and all
|
||||
binaries (.dll, .dylib, etc.) *must* be checked into
|
||||
source control. If possible, use the release build of the
|
||||
library that includes debug information.
|
||||
If a custom type needs memory to function, it should
|
||||
always assume the memory it requested came from an arena
|
||||
allocator. This means it is the responsibility of the
|
||||
arena to free the memory, not the custom data type.
|
||||
|
||||
Bindings should stay as close as possible to the original
|
||||
library. To jai-ify the bindings, create a submodule
|
||||
called 'wrapper' that import and wraps the api.
|
||||
In other words:
|
||||
|
||||
See: 'thirdparty/raylib' for example bindings.
|
||||
Do *not* add procedures that 'free' or 'delete' the memory
|
||||
allocated by the data type.
|
||||
|
||||
Instead, add procedures that 'reset' the data type,
|
||||
allowing the already allocated memory to be reused. For
|
||||
examples, see the 'reset' procedures in 'jc/kv'
|
||||
or 'jc/array'.
|
||||
|
||||
|
||||
OS-Specific Code
|
||||
|
|
@ -177,3 +179,19 @@ When writing code for a specific architecture, use
|
|||
the 'jc/arch' module. NEVER create a new file unless
|
||||
absolutely needed.
|
||||
|
||||
|
||||
Bindings
|
||||
--------
|
||||
|
||||
Binding modules should default to static linking and take
|
||||
an optional '#module_parameter' to link dynamically.
|
||||
Libraries should be pinned to a specific version, and all
|
||||
binaries (.dll, .dylib, etc.) *must* be checked into
|
||||
source control. If possible, use the release build of the
|
||||
library that includes debug information.
|
||||
|
||||
Bindings should stay as close as possible to the original
|
||||
library. To jai-ify the bindings, create a submodule
|
||||
called 'wrapper' that import and wraps the api.
|
||||
|
||||
See: 'thirdparty/raylib' for example bindings.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
// @todo(judah): replace array_add
|
||||
|
||||
init :: inline (arr: *[..]$T, allocator: Allocator) {
|
||||
arr.allocator = allocator;
|
||||
}
|
||||
|
||||
append :: inline (arr: *[..]$T, value: T) -> *T {
|
||||
ptr := basic.array_add(arr,, allocator = arr.allocator);
|
||||
ptr.* = value;
|
||||
|
|
@ -21,11 +25,8 @@ resize :: inline (arr: *[..]$T, new_size: int) {
|
|||
basic.array_reserve(arr, new_size,, allocator = arr.allocator);
|
||||
}
|
||||
|
||||
reset :: inline (arr: *[..]$T, $keep_memory := true) {
|
||||
reset :: inline (arr: *[..]$T) {
|
||||
arr.count = 0;
|
||||
#if !keep_memory {
|
||||
mem.release_memory(arr.data,, allocator = arr.allocator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue