Skip to content

Instantly share code, notes, and snippets.

@jovial
jovial / gist:588a336c9d2b52992e38
Created August 13, 2014 15:31
SIGSEGV with nimrod finializers and echo
type
AObj = object
b : BRef
BObj = object
i : int
ARef = ref AObj
BRef = ref BObj
proc finalize(a : ARef) =
echo "A has gone"
@jovial
jovial / gist:00fdcae18ac9bfa1a6af
Last active August 29, 2015 14:08
static call method hack
import macros
macro genStaticGetter(a: expr): stmt =
## generates a getter which returns a pointer to a method with
## a particular type signature.
##
## The getter has the form methodname(typ: type(param1), typ2: type(param2), ...),
## where methodname is the name of the method passed to this macro, and param#
## corresponds to the the param in position # of the method signature. # is a integer
## representing the position of the parameter.
@jovial
jovial / gist:9b8efa0fed114c7b5f9b
Created October 31, 2014 13:01
staticCall with some issues
import macros
macro genStaticGetter(a: expr): stmt =
## generates a getter which returns a pointer to a method with
## a particular type signature.
##
## The getter has the form methodname(typ: type(param1), typ2: type(param2), ...),
## where methodname is the name of the method passed to this macro, and param#
## corresponds to the the param in position # of the method signature. # is a integer
## representing the position of the parameter.
import tables
import typetraits
import macros
proc newTemplate*(name = newEmptyNode(); params: openArray[PNimrodNode] = [newEmptyNode()];
body: PNimrodNode = newStmtList()): PNimrodNode {.compileTime.} =
## shortcut for creating a new template
##
## The ``params`` array must start with the return type of the template,
## followed by a list of IdentDefs which specify the params.
@jovial
jovial / gist:f99380b6e975b2b60f27
Last active August 29, 2015 14:12
Non working Qt macro
import NimQml
import macros
import typeinfo
import strutils
import typetraits
import tables
static:
let nimFromQtVariant = {
@jovial
jovial / supertype.nim
Last active August 29, 2015 14:12
supertype for generics
import tables
import typetraits
import macros
import strutils
import parseutils
import sequtils
type QObject* = ref object of RootObj
name*: string
data*: pointer
@jovial
jovial / baremetal
Last active October 7, 2022 13:24
Tempest test lists
tempest.api.compute.servers.test_create_server.ServersTestJSON.test_host_name_is_same_as_server_name[id-ac1ad47f-984b-4441-9274-c9079b7a0666]