Skip to content

Commit

Permalink
sokol.utils added (non auto-generated)
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Jan 6, 2024
1 parent 1b0c50b commit 0684058
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 49 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
- name: Build
run: |
zig build debugtext_print -DZigCC --summary all
zig build clear -DZigCC --summary all
zig build sgl_context -DZigCC --summary all
zig build debugtext_print -DZigCC -DBetterC --summary all
zig build clear -DZigCC -DBetterC --summary all
zig build sgl_context -DBetterC -DZigCC --summary all
zig build cube -DZigCC --summary all
zig build blend -DZigCC --summary all
3 changes: 2 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn build(b: *Builder) !void {

// ldc2 w/ druntime + phobos2 works on MSVC
if (builtin.os.tag == .windows and target.query.isNative())
target.query.abi = .msvc;
target.result.abi = .msvc;

const optimize = b.standardOptimizeOption(.{});
const sokol = buildSokol(b, target, optimize, config, "");
Expand Down Expand Up @@ -397,6 +397,7 @@ fn buildLDC(b: *Builder, lib: *CompileStep, config: ldcConfig) !*RunStep {
"shape",
"time",
"debugtext",
"utils",
};
try cmds.append("-i");
inline for (srcs) |src| {
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

module sokol.app;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

enum max_touchpoints = 8;
enum max_mousebuttons = 3;
enum max_keycodes = 512;
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/audio.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

module sokol.audio;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

enum LogItem {
Ok,
Malloc_failed,
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/debugtext.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module sokol.debugtext;
import sg = sokol.gfx;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;


// WIP: helper function to convert "anything" to a Range struct
Range asRange(T)(T val) @trusted {
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/gfx.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

module sokol.gfx;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;


// WIP: helper function to convert "anything" to a Range struct
Range asRange(T)(T val) @trusted {
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/gl.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module sokol.gl;
import sg = sokol.gfx;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

enum LogItem {
Ok,
Malloc_failed,
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/glue.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module sokol.glue;
import sg = sokol.gfx;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

extern(C) sg.ContextDesc sapp_sgcontext() @system @nogc nothrow;
sg.ContextDesc context() @trusted nothrow {
return sapp_sgcontext();
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/log.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

module sokol.log;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

extern(C) void slog_func(scope const(char)*, uint, uint, scope const(char)*, uint, scope const(char)*, void*) @system @nogc nothrow;
alias func = slog_func;
8 changes: 3 additions & 5 deletions src/sokol/shape.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module sokol.shape;
import sg = sokol.gfx;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;


// WIP: helper function to convert "anything" to a Range struct
Range asRange(T)(T val) @trusted {
Expand Down
8 changes: 3 additions & 5 deletions src/sokol/time.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

module sokol.time;

// helper function to convert a C string to a D string
string cStrTod(T)(scope T c_str) nothrow {
import std.conv: to;
return c_str.to!string;
}
// helper functions
import sokol.utils: cStrTod;

extern(C) void stm_setup() @system @nogc nothrow;
void setup() @trusted nothrow {
stm_setup();
Expand Down
9 changes: 9 additions & 0 deletions src/sokol/utils.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module sokol.utils;

// helper function to convert a C string to a D string
string cStrTod(inout(char)* c_str) nothrow {
auto start = c_str;
auto end = cast(char*) c_str;
for (; *end; end++){}
return cast(string) c_str[0 .. end - start];
}

0 comments on commit 0684058

Please sign in to comment.