Skip to content

Instantly share code, notes, and snippets.

View kassane's full-sized avatar
🏠
Working from home

Matheus C. França kassane

🏠
Working from home
View GitHub Profile
@kassane
kassane / gdextension_interface.zig
Last active December 29, 2023 17:13
Godot 4 - GDExtension for zig bindings
// GDExtension - zig (v0.11.0 or master) binding
// cmd: godot --dump-gdextension-interface -q --headless
// based on: https://github.com/godot-dlang/godot-dlang/blob/master/gdextension_interface.h
const std = @import("std");
pub const GDExtensionVariantType = enum(c_uint) {
GDEXTENSION_VARIANT_TYPE_NIL = 0,
GDEXTENSION_VARIANT_TYPE_BOOL = 1,
GDEXTENSION_VARIANT_TYPE_INT = 2,
GDEXTENSION_VARIANT_TYPE_FLOAT = 3,
module intrusive_mpsc_queue;
import core.atomic;
// An intrusive MPSC queue in D.
struct IntrusiveQueue(T)
{
private T* head;
private T* tail;
private T stub;

Named arguments in D language

DIP1030

Named/labeled/keyword arguments are useful in Python and OCaml, but in the D language they were proposed by DIP1030 and adopted three years ago.

Currently, templates are not supported, but recent DMDs -preview allow you to try out these features without any flags. The verification environment this time is DMD2.106.0.

@kassane
kassane / dlang_UEFI_Boot.md
Last active December 7, 2023 12:55
Running D language with Zephyr

Development environment

  • LDC
  • lld
  • qemu
  • ovmf(Open Virtual Machine Firmware)

Also, although it is not required, I use just as the command runner, just like the reference source. Make is fine, but I felt like I could understand the FAQ's philosophy, so I tried using it.

UEFI target

@kassane
kassane / sleepsort-asio.cpp
Last active November 19, 2023 14:23
slsort C++
#include <iostream>
#include <chrono>
#include <array>
#include <thread>
#include <asio/thread_pool.hpp>
#include <asio/post.hpp>
void sleepSort(const std::array<int,8>& numbers) {
asio::thread_pool pool(numbers.size());
for (const auto& num : numbers) {
@kassane
kassane / ldc2_zig_cc.sh
Last active November 4, 2023 15:10
LDC2 cross-compiling using zig toolchain - D language
#!/usr/bin/env bash
# Based on: https://github.com/kassane/xwin-zig-test/
# download and unpack WinSDK and MSCRT libs
# manifest 16 == VS2019
# xwin --manifest-version 16 --accept-license splat --output $PWD/.xwin --include-debug-symbols --preserve-ms-arch-notation --include-debug-libs
# "$HOME/ldc-xcross/lib64" - need prebuilded libs
# curl -LO https://github.com/ldc-developers/ldc/releases/download/v1.35.0/ldc2-1.35.0-windows-multilib.7z
@kassane
kassane / tb_client.d
Last active October 29, 2023 16:40
[Draft] TigerBeetle Client - Pascal binding
@nogc nothrow:
extern(C): __gshared:
//////////////////////////////////////////////////////////
// This file was auto-generated by tb_client_header.zig //
// Do not manually modify. //
//////////////////////////////////////////////////////////
import core.stdc.stdint;
import core.int128;
@kassane
kassane / output.log
Last active October 28, 2023 13:34
Hello Linux on Mipsel - Zig version
root@OpenWrt:~# /tmp/hello-zig
Zig Info:
Version: 0.12.0-dev.1297+a9e66ed73
Stage: stage2_llvm
Let's have a look at your shiny MIPS - mips32 system! :)
cpuinfo:
@kassane
kassane / Dockerfile
Created October 27, 2023 20:20
Dlang - LDC latest version on Debian
FROM debian:latest
ENV LDC_PATH /usr/local/ldc
RUN apt-get update && \
apt-get install -y --no-install-recommends curl wget gcc ca-certificates xz-utils libxml2 && \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
RUN set -ex && \
LDC_VERSION=$(curl -sL https://ldc-developers.github.io/LATEST)
@kassane
kassane / zig_cpp-modules.md
Last active October 6, 2023 19:41
Zig/clang++ (C++20) modules
// main.cpp

import moduleTest;

#include <cstdio>

auto main() -> int
{