Mercurial > games > semicongine
view src/semicongine/vulkan/utils.nim @ 588:008592db0442
did: big refactoring
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 12 Apr 2023 01:20:53 +0700 |
parents | bbeec60e25ca |
children |
line wrap: on
line source
import std/typetraits import std/strutils import std/strformat func cleanString*(str: openArray[char]): string = for i in 0 ..< len(str): if str[i] == char(0): result = join(str[0 ..< i]) break func toCPointer*[T](list: var seq[T]): ptr T = if list.len > 0: addr list[0] else: nil proc staticExecChecked*(command: string, input = ""): string {.compileTime.} = let (output, exitcode) = gorgeEx( command = command, input = input) if exitcode != 0: raise newException(Exception, &"Running '{command}' produced exit code: {exitcode}" & output) return output func size*[T: seq](list: T): uint64 = uint64(list.len * sizeof(get(genericParams(typeof(list)), 0)))